diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2008-06-28 12:15:57 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2008-06-28 12:15:57 -0400 |
commit | a05223c876ea62952a2e07910d6e6a4dacee3a2f (patch) | |
tree | 78835fa53e48320e5b0667b03ca9c19dfdade7c6 | |
parent | e10e6f849d328a47ca878b8d4428751f25508341 (diff) | |
download | seabios-a05223c876ea62952a2e07910d6e6a4dacee3a2f.tar.gz |
Improve some debugging output.
Replace DEBUGF calls with dprintf calls.
Make ata calls consistently use 'int' return codes.
Make each error return code in ata.c use a unique negative number.
-rw-r--r-- | src/ata.c | 67 | ||||
-rw-r--r-- | src/boot.c | 2 | ||||
-rw-r--r-- | src/cdrom.c | 29 | ||||
-rw-r--r-- | src/clock.c | 3 | ||||
-rw-r--r-- | src/disk.c | 3 | ||||
-rw-r--r-- | src/disk.h | 2 | ||||
-rw-r--r-- | src/floppy.c | 10 | ||||
-rw-r--r-- | src/mouse.c | 3 |
8 files changed, 50 insertions, 69 deletions
@@ -24,9 +24,6 @@ #define IDE_TIMEOUT 32000u //32 seconds max for IDE ops -#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args) -#define DEBUGF(fmt, args...) - /**************************************************************** * Helper functions @@ -57,21 +54,21 @@ await_ide(u8 when_done, u16 base, u16 timeout) // mod 2048 each 16 ms if (time>>16 != last) { last = time >>16; - DEBUGF("await_ide: (TIMEOUT,BSY,!BSY,!BSY_DRQ,!BSY_!DRQ,!BSY_RDY)" - " %d time= %d timeout= %d\n" - , when_done, time>>11, timeout); + dprintf(6, "await_ide: (TIMEOUT,BSY,!BSY,!BSY_DRQ" + ",!BSY_!DRQ,!BSY_RDY) %d time= %d timeout= %d\n" + , when_done, time>>11, timeout); } if (status & ATA_CB_STAT_ERR) { - DEBUGF("await_ide: ERROR (TIMEOUT,BSY,!BSY,!BSY_DRQ" - ",!BSY_!DRQ,!BSY_RDY) %d time= %d timeout= %d\n" - , when_done, time>>11, timeout); + dprintf(1, "await_ide: ERROR (TIMEOUT,BSY,!BSY,!BSY_DRQ" + ",!BSY_!DRQ,!BSY_RDY) %d status=%x time= %d timeout= %d\n" + , when_done, status, time>>11, timeout); return -1; } if (timeout == 0 || (time>>11) > timeout) break; } dprintf(1, "IDE time out\n"); - return -1; + return -2; } // Wait for ide state - pauses for one ata cycle first. @@ -188,7 +185,7 @@ send_cmd(int driveid, struct ata_pio_command *cmd) int status = inb(iobase1 + ATA_CB_STAT); if (status & ATA_CB_STAT_BSY) - return 1; + return -3; // Disable interrupts outb(ATA_CB_DC_HD15 | ATA_CB_DC_NIEN, iobase2 + ATA_CB_DC); @@ -196,7 +193,7 @@ send_cmd(int driveid, struct ata_pio_command *cmd) // Select device u8 device = inb(iobase1 + ATA_CB_DH); outb(cmd->device, iobase1 + ATA_CB_DH); - if ((device ^ cmd->device) & (1UL << 4)) + if ((device ^ cmd->device) & (1 << 4)) // Wait for device to become active. msleep(50); @@ -219,13 +216,13 @@ send_cmd(int driveid, struct ata_pio_command *cmd) return status; if (status & ATA_CB_STAT_ERR) { - DEBUGF("send_cmd : read error\n"); - return 2; + dprintf(6, "send_cmd : read error\n"); + return -4; } if (!(status & ATA_CB_STAT_DRQ)) { - DEBUGF("send_cmd : DRQ not set (status %02x)\n" - , (unsigned) status); - return 3; + dprintf(6, "send_cmd : DRQ not set (status %02x)\n" + , (unsigned) status); + return -5; } return 0; @@ -261,10 +258,10 @@ static __always_inline int ata_transfer(int driveid, int iswrite, int count, int blocksize , int skipfirst, int skiplast, void *far_buffer) { - DEBUGF("ata_transfer id=%d write=%d count=%d bs=%d" - " skipf=%d skipl=%d buf=%p\n" - , driveid, iswrite, count, blocksize - , skipfirst, skiplast, far_buffer); + dprintf(16, "ata_transfer id=%d write=%d count=%d bs=%d" + " skipf=%d skipl=%d buf=%p\n" + , driveid, iswrite, count, blocksize + , skipfirst, skiplast, far_buffer); // Reset count of transferred data SET_EBDA(ata.trsfsectors, 0); @@ -286,14 +283,14 @@ ata_transfer(int driveid, int iswrite, int count, int blocksize if (iswrite) { // Write data to controller - DEBUGF("Write sector id=%d dest=%p\n", driveid, far_buffer); + dprintf(16, "Write sector id=%d dest=%p\n", driveid, far_buffer); if (mode == ATA_MODE_PIO32) outsl_far(iobase1, far_buffer, bsize / 4); else outsw_far(iobase1, far_buffer, bsize / 2); } else { // Read data from controller - DEBUGF("Read sector id=%d dest=%p\n", driveid, far_buffer); + dprintf(16, "Read sector id=%d dest=%p\n", driveid, far_buffer); if (mode == ATA_MODE_PIO32) insl_far(iobase1, far_buffer, bsize / 4); else @@ -316,9 +313,9 @@ ata_transfer(int driveid, int iswrite, int count, int blocksize status &= (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR); if (status != (ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ)) { - DEBUGF("ata_transfer : more sectors left (status %02x)\n" - , (unsigned) status); - return 5; + dprintf(6, "ata_transfer : more sectors left (status %02x)\n" + , (unsigned) status); + return -6; } } @@ -327,9 +324,9 @@ ata_transfer(int driveid, int iswrite, int count, int blocksize if (!iswrite) status &= ~ATA_CB_STAT_DF; if (status != ATA_CB_STAT_RDY ) { - DEBUGF("ata_transfer : no sectors left (status %02x)\n" - , (unsigned) status); - return 4; + dprintf(6, "ata_transfer : no sectors left (status %02x)\n" + , (unsigned) status); + return -7; } // Enable interrupts @@ -510,10 +507,10 @@ cdrom_read_512(int driveid, u32 vlba, u32 vcount, void *far_buffer) op.count = count; op.far_buffer = far_buffer; - DEBUGF("cdrom_read_512: id=%d vlba=%d vcount=%d buf=%p lba=%d elba=%d" - " count=%d before=%d after=%d\n" - , driveid, vlba, vcount, far_buffer, lba, elba - , count, before, after); + dprintf(16, "cdrom_read_512: id=%d vlba=%d vcount=%d buf=%p lba=%d elba=%d" + " count=%d before=%d after=%d\n" + , driveid, vlba, vcount, far_buffer, lba, elba + , count, before, after); int ret = send_cmd_cdrom(&op); if (ret) @@ -813,9 +810,9 @@ init_drive_ata(int driveid) report_model(driveid, buffer); u8 version = get_ata_version(buffer); if (sizeinmb < (1 << 16)) - printf(" ATA-%d Hard-Disk (%u MBytes)\n", version, (u32)sizeinmb); + printf(" ATA-%d Hard-Disk (%u MiBytes)\n", version, (u32)sizeinmb); else - printf(" ATA-%d Hard-Disk (%u GBytes)\n", version + printf(" ATA-%d Hard-Disk (%u GiBytes)\n", version , (u32)(sizeinmb >> 10)); } @@ -147,7 +147,7 @@ try_boot(u16 seq_nr) /* CD-ROM */ if (! CONFIG_CDROM_BOOT) break; - u16 status = cdrom_boot(); + int status = cdrom_boot(); if (status) { printf("CDROM boot failure code : %04x\n", status); print_boot_failure(type, 1); diff --git a/src/cdrom.c b/src/cdrom.c index ef81bb37..adb2cfca 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -9,9 +9,6 @@ #include "util.h" // memset #include "ata.h" // ATA_CMD_READ_SECTORS -#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args) -#define DEBUGF(fmt, args...) - /**************************************************************** * CDROM functions @@ -302,7 +299,7 @@ cdemu_134b(struct bregs *regs) ****************************************************************/ // Request SENSE -static u16 +static int atapi_get_sense(u16 device, u8 *asc, u8 *ascq) { u8 buffer[18]; @@ -310,10 +307,10 @@ atapi_get_sense(u16 device, u8 *asc, u8 *ascq) memset(atacmd, 0, sizeof(atacmd)); atacmd[0] = ATA_CMD_REQUEST_SENSE; atacmd[4] = sizeof(buffer); - u16 ret = ata_cmd_packet(device, atacmd, sizeof(atacmd), sizeof(buffer) + int ret = ata_cmd_packet(device, atacmd, sizeof(atacmd), sizeof(buffer) , MAKE_FARPTR(GET_SEG(SS), (u32)buffer)); if (ret != 0) - return 0x0002; + return ret; *asc = buffer[12]; *ascq = buffer[13]; @@ -321,7 +318,7 @@ atapi_get_sense(u16 device, u8 *asc, u8 *ascq) return 0; } -static u16 +static int atapi_is_ready(u16 device) { if (GET_EBDA(ata.devices[device].type) != ATA_TYPE_ATAPI) { @@ -329,7 +326,7 @@ atapi_is_ready(u16 device) return -1; } - DEBUGF("ata_detect_medium: begin\n"); + dprintf(6, "ata_detect_medium: begin\n"); u8 packet[12]; memset(packet, 0, sizeof(packet)); packet[0] = 0x25; /* READ CAPACITY */ @@ -343,10 +340,10 @@ atapi_is_ready(u16 device) u8 in_progress = 0; for (;; time+=100) { if (time >= timeout) { - DEBUGF("read capacity failed\n"); + dprintf(1, "read capacity failed\n"); return -1; } - u16 ret = ata_cmd_packet(device, packet, sizeof(packet), sizeof(buf) + int ret = ata_cmd_packet(device, packet, sizeof(packet), sizeof(buf) , MAKE_FARPTR(GET_SEG(SS), (u32)buf)); if (ret == 0) break; @@ -357,7 +354,7 @@ atapi_is_ready(u16 device) continue; if (asc == 0x3a) { /* MEDIUM NOT PRESENT */ - DEBUGF("Device reports MEDIUM NOT PRESENT\n"); + dprintf(1, "Device reports MEDIUM NOT PRESENT\n"); return -1; } @@ -386,7 +383,7 @@ atapi_is_ready(u16 device) | (u32) buf[2] << 8 | (u32) buf[3] << 0; - DEBUGF("sectors=%u\n", sectors); + dprintf(6, "sectors=%u\n", sectors); if (block_len == 2048) sectors <<= 2; /* # of sectors in 512-byte "soft" sector */ if (sectors != GET_EBDA(ata.devices[device].sectors)) @@ -395,7 +392,7 @@ atapi_is_ready(u16 device) return 0; } -static u16 +static int atapi_is_cdrom(u8 device) { if (device >= CONFIG_MAX_ATA_DEVICES) @@ -425,7 +422,7 @@ streq_cs(u8 *s1, char *cs_s2) } } -u16 +int cdrom_boot() { // Find out the first cdrom @@ -434,7 +431,7 @@ cdrom_boot() if (atapi_is_cdrom(device)) break; - u16 ret = atapi_is_ready(device); + int ret = atapi_is_ready(device); if (ret) dprintf(1, "ata_is_ready returned %d\n", ret); @@ -557,7 +554,7 @@ cdrom_boot() // everything is ok, so from now on, the emulation is active SET_EBDA(cdemu.active, 0x01); - DEBUGF("cdemu media=%d\n", media); + dprintf(6, "cdemu media=%d\n", media); return 0; } diff --git a/src/clock.c b/src/clock.c index 605d4367..41625704 100644 --- a/src/clock.c +++ b/src/clock.c @@ -11,9 +11,6 @@ #include "cmos.h" // inb_cmos #include "pic.h" // unmask_pic1 -#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args) -#define DEBUGF(fmt, args...) - // RTC register flags #define RTC_A_UIP 0x80 #define RTC_B_SET 0x80 @@ -12,9 +12,6 @@ #include "ata.h" // ATA_* #include "pic.h" // eoi_pic2 -#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args) -#define DEBUGF(fmt, args...) - /**************************************************************** * Helper functions @@ -112,7 +112,7 @@ int cdrom_read_emu(u16 device, u32 lba, u32 count, void *far_buffer); void cdrom_13(struct bregs *regs, u8 device); void cdemu_13(struct bregs *regs); void cdemu_134b(struct bregs *regs); -u16 cdrom_boot(); +int cdrom_boot(); #endif // disk.h diff --git a/src/floppy.c b/src/floppy.c index efe9592f..afb87786 100644 --- a/src/floppy.c +++ b/src/floppy.c @@ -13,9 +13,6 @@ #include "cmos.h" // inb_cmos #include "pic.h" // unmask_pic1 -#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args) -#define DEBUGF(fmt, args...) - #define BX_FLOPPY_ON_CNT 37 /* 2 seconds */ // New diskette parameter table adding 3 parameters from IBM @@ -553,7 +550,7 @@ floppy_1304(struct bregs *regs, u8 drive) static void floppy_1305(struct bregs *regs, u8 drive) { - DEBUGF("floppy f05\n"); + dprintf(3, "floppy f05\n"); if (check_drive(regs, drive)) return; @@ -598,7 +595,7 @@ floppy_1305(struct bregs *regs, u8 drive) static void floppy_1308(struct bregs *regs, u8 drive) { - DEBUGF("floppy f08\n"); + dprintf(3, "floppy f08\n"); u8 drive_type = inb_cmos(CMOS_FLOPPY_DRIVE_TYPE); u8 num_floppies = 0; @@ -690,7 +687,7 @@ floppy_1308(struct bregs *regs, u8 drive) static void floppy_1315(struct bregs *regs, u8 drive) { - DEBUGF("floppy f15\n"); + dprintf(6, "floppy f15\n"); if (drive > 1) { set_fail(regs); regs->ah = 0; // only 2 drives supported @@ -707,7 +704,6 @@ floppy_1315(struct bregs *regs, u8 drive) static void floppy_1316(struct bregs *regs, u8 drive) { - DEBUGF("floppy f16\n"); if (drive > 1) { floppy_ret(regs, DISK_RET_EPARAM); return; diff --git a/src/mouse.c b/src/mouse.c index 8f6775f2..163d849d 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -9,9 +9,6 @@ #include "util.h" // debug_isr #include "pic.h" // unmask_pic2 -#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args) -#define DEBUGF(fmt, args...) - static char panic_msg_keyb_buffer_full[] = "%s: keyboard input buffer full\n"; void |