Bug fixes; get mouse working.

Fix bug in post causing PIC2 to not be initialized properly.
Only run ata_detect if CONFIG_ATA enabled.
Improve debugging aids - introduce debug_isr(); move DEBUGF to each file.
Enable mouse by default.
Fix bug in floppy causing extra test of PORT_FD_STATUS on recalibrate.
Always disable/enable kbd in handle_09 event.
This commit is contained in:
Kevin O'Connor 2008-03-02 13:58:23 -05:00
parent 44c631dfd2
commit c65a3804a9
12 changed files with 40 additions and 24 deletions

View File

@ -926,5 +926,4 @@ ata_detect()
// FIXME : should use bios=cmos|auto|disable bits
// FIXME : should know about translation bits
// FIXME : move hard_drive_post here
}

View File

@ -183,7 +183,8 @@ handle_19()
void VISIBLE
begin_boot()
{
ata_detect();
if (CONFIG_ATA)
ata_detect();
irq_enable();
struct bregs br;
memset(&br, 0, sizeof(br));

View File

@ -10,6 +10,9 @@
#include "disk.h" // floppy_tick
#include "cmos.h" // inb_cmos
#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args)
#define DEBUGF(fmt, args...)
static void
init_rtc()
{
@ -257,7 +260,7 @@ handle_1c(struct bregs *regs)
void VISIBLE
handle_08(struct bregs *regs)
{
// debug_enter(regs);
// debug_isr(regs);
floppy_tick();
@ -338,7 +341,7 @@ handle_1583(struct bregs *regs)
void VISIBLE
handle_70(struct bregs *regs)
{
debug_enter(regs);
debug_isr(regs);
// Check which modes are enabled and have occurred.
u8 registerB = inb_cmos(CMOS_STATUS_B);

View File

@ -3,10 +3,11 @@
// Configuration definitions.
#define CONFIG_FLOPPY_SUPPORT 1
#define CONFIG_PS2_MOUSE 0
#define CONFIG_PS2_MOUSE 1
#define CONFIG_ATA 1
#define CONFIG_KBD_CALL_INT15_4F 1
#define CONFIG_ELTORITO_BOOT 0
#define CONFIG_MAX_ATA_INTERFACES 4
#define CONFIG_MAX_ATA_DEVICES (CONFIG_MAX_ATA_INTERFACES*2)

View File

@ -651,7 +651,7 @@ handle_13(struct bregs *regs)
void VISIBLE
handle_76(struct bregs *regs)
{
debug_enter(regs);
debug_isr(regs);
SET_BDA(floppy_harddisk_info, 0xff);
eoi_both_pics();
}

View File

@ -12,6 +12,9 @@
#include "util.h" // irq_disable
#include "cmos.h" // inb_cmos
#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
@ -149,9 +152,6 @@ floppy_pio(u8 *cmd, u8 cmdlen)
v &= ~FRS_TIMEOUT;
SET_BDA(floppy_recalibration_status, v);
if ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0)
BX_PANIC("int13_diskette: ctrl not ready\n");
return 0;
}
@ -201,6 +201,10 @@ floppy_cmd(struct bregs *regs, u16 count, u8 *cmd, u8 cmdlen)
if (ret)
return ret;
// check port 3f4 for accessibility to status bytes
if ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0)
BX_PANIC("int13_diskette: ctrl not ready\n");
// read 7 return status bytes from controller
u8 i;
for (i=0; i<7; i++) {
@ -347,6 +351,7 @@ check_drive(struct bregs *regs, u8 drive)
{
// see if drive exists
if (drive > 1 || !get_drive_type(drive)) {
// XXX - return type doesn't match
floppy_fail(regs, DISK_RET_ETIMEOUT);
return 1;
}
@ -712,7 +717,7 @@ floppy_13(struct bregs *regs, u8 drive)
void VISIBLE
handle_0e(struct bregs *regs)
{
//debug_enter(regs);
//debug_isr(regs);
if ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0) {
outb(0x08, PORT_FD_DATA); // sense interrupt status
while ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0)

View File

@ -544,15 +544,15 @@ process_key(u8 scancode)
void VISIBLE
handle_09(struct bregs *regs)
{
// debug_enter(regs);
outb(0x0b, PORT_PIC1);
if ((inb(PORT_PIC1) & 0x02) == 0)
return;
//debug_isr(regs);
// disable keyboard
outb(0xad, PORT_PS2_STATUS);
outb(0x0b, PORT_PIC1);
if ((inb(PORT_PIC1) & 0x02) == 0)
goto done;
// read key from keyboard controller
u8 key = inb(PORT_PS2_DATA);
irq_enable();
@ -564,7 +564,7 @@ handle_09(struct bregs *regs)
tr.ah = 0x4f;
tr.flags = F_CF;
call16_int(0x15, &tr);
if (!tr.flags & F_CF)
if (!(tr.flags & F_CF))
goto done;
key = tr.al;
}

View File

@ -191,7 +191,6 @@ mouse_15c203(struct bregs *regs)
// 1 = 50 dpi, 2 counts per millimeter
// 2 = 100 dpi, 4 counts per millimeter
// 3 = 200 dpi, 8 counts per millimeter
bprintf(0, "ebda_seg=%x\n", GET_BDA(ebda_seg));
u8 comm_byte = inhibit_mouse_int_and_events(); // disable IRQ12 and packets
if (regs->bh >= 4) {
handle_ret(regs, RET_EUNSUPPORTED);
@ -235,7 +234,6 @@ mouse_15c205(struct bregs *regs)
handle_ret(regs, RET_EINTERFACE);
return;
}
bprintf(0, "ebda_seg=%x\n", GET_BDA(ebda_seg));
SET_EBDA(mouse_flag1, 0x00);
SET_EBDA(mouse_flag2, regs->bh);
@ -340,7 +338,7 @@ mouse_15c2XX(struct bregs *regs)
void
handle_15c2(struct bregs *regs)
{
debug_stub(regs);
//debug_stub(regs);
if (! CONFIG_PS2_MOUSE) {
handle_ret(regs, RET_EUNSUPPORTED);
@ -417,7 +415,7 @@ int74_function()
void VISIBLE
handle_74(struct bregs *regs)
{
debug_enter(regs);
//debug_isr(regs);
irq_enable();
int74_function();

View File

@ -167,6 +167,13 @@ dump_regs(const char *fname, const char *type, struct bregs *regs)
, regs->ip, regs->cs, regs->flags);
}
void
__debug_isr(const char *fname, struct bregs *regs)
{
puts_cs(0, fname);
putc(0, '\n');
}
// Function called on handler startup.
void
__debug_enter(const char *fname, struct bregs *regs)

View File

@ -317,7 +317,7 @@ static void
pic_setup()
{
outb(0x11, PORT_PIC1);
outb(0x11, PORT_PIC2_DATA);
outb(0x11, PORT_PIC2);
outb(0x08, PORT_PIC1_DATA);
outb(0x70, PORT_PIC2_DATA);
outb(0x04, PORT_PIC1_DATA);

View File

@ -471,7 +471,7 @@ handle_10(struct bregs *regs)
void VISIBLE
handle_nmi(struct bregs *regs)
{
debug_enter(regs);
debug_isr(regs);
// XXX
}
@ -479,7 +479,7 @@ handle_nmi(struct bregs *regs)
void VISIBLE
handle_75(struct bregs *regs)
{
debug_enter(regs);
debug_isr(regs);
// clear irq13
outb(0, PORT_MATH_CLEAR);

View File

@ -37,7 +37,6 @@ static inline void nop(void)
asm volatile("nop");
}
#define DEBUGF(fmt, args...) bprintf(0, fmt , ##args)
#define BX_PANIC(fmt, args...) bprintf(0, fmt , ##args)
#define BX_INFO(fmt, args...) bprintf(0, fmt , ##args)
@ -104,12 +103,15 @@ void bprintf(u16 action, const char *fmt, ...)
void __debug_enter(const char *fname, struct bregs *regs);
void __debug_exit(const char *fname, struct bregs *regs);
void __debug_stub(const char *fname, struct bregs *regs);
void __debug_isr(const char *fname, struct bregs *regs);
#define debug_enter(regs) \
__debug_enter(__func__, regs)
#define debug_exit(regs) \
__debug_exit(__func__, regs)
#define debug_stub(regs) \
__debug_stub(__func__, regs)
#define debug_isr(regs) \
__debug_isr(__func__, regs)
#define printf(fmt, args...) \
bprintf(1, fmt , ##args )