From ef71989a37a54a04dc2b83651c8dc78df2004fdc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 26 Nov 2012 11:14:00 -0500 Subject: [PATCH] floppy: Minor cleanup - reduce some cut-and-paste code. The diskette_param_table is a copy of diskette_param_table2 - just memcpy it at runtime instead of duplicating the configuration in the code. Also, setup the floppy interrupt vector in the floppy.c code instead of the post.c code. Signed-off-by: Kevin O'Connor --- src/floppy.c | 22 ++++++---------------- src/post.c | 2 -- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/floppy.c b/src/floppy.c index ce54d0c..3c8ae5a 100644 --- a/src/floppy.c +++ b/src/floppy.c @@ -47,22 +47,7 @@ struct floppy_ext_dbt_s diskette_param_table2 VAR16VISIBLE = { .drive_type = 4, // drive type in cmos }; -// Since no provisions are made for multiple drive types, most -// values in this table are ignored. I set parameters for 1.44M -// floppy here -struct floppy_dbt_s diskette_param_table VAR16FIXED(0xefc7) = { - .specify1 = 0xAF, - .specify2 = 0x02, - .shutoff_ticks = FLOPPY_MOTOR_TICKS, - .bps_code = FLOPPY_SIZE_CODE, - .sectors = 18, - .interblock_len = FLOPPY_GAPLEN, - .data_len = FLOPPY_DATALEN, - .gap_len = FLOPPY_FORMAT_GAPLEN, - .fill_byte = FLOPPY_FILLBYTE, - .settle_time = 0x0F, - .startup_time = 0x08, -}; +struct floppy_dbt_s diskette_param_table VAR16FIXED(0xefc7); struct floppyinfo_s { struct chs_s chs; @@ -131,6 +116,11 @@ addFloppy(int floppyid, int ftype) void floppy_setup(void) { + memcpy(&diskette_param_table, &diskette_param_table2 + , sizeof(diskette_param_table)); + SET_IVT(0x1E, SEGOFF(SEG_BIOS + , (u32)&diskette_param_table2 - BUILD_BIOS_ADDR)); + if (! CONFIG_FLOPPY) return; dprintf(3, "init floppy drives\n"); diff --git a/src/post.c b/src/post.c index 0133f75..9a6dd3f 100644 --- a/src/post.c +++ b/src/post.c @@ -73,8 +73,6 @@ init_ivt(void) // set vector 0x79 to zero // this is used by 'gardian angel' protection system SET_IVT(0x79, SEGOFF(0, 0)); - - SET_IVT(0x1E, SEGOFF(SEG_BIOS, (u32)&diskette_param_table2 - BUILD_BIOS_ADDR)); } static void -- 2.39.5