X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fapm.c;h=c497dbecd8306b514d1d07e9baf2dac889b1f50b;hb=refs%2Fheads%2Fcoreboot;hp=1d8ceef0c99017179cd1b1cc7ff6e50b2583756a;hpb=2ad37441d313110d3a206f87a9ce9609dcaa8eb0;p=seabios.git diff --git a/src/apm.c b/src/apm.c index 1d8ceef..c497dbe 100644 --- a/src/apm.c +++ b/src/apm.c @@ -4,19 +4,26 @@ // Copyright (C) 2005 Struan Bartlett // Copyright (C) 2004 Fabrice Bellard // -// This file may be distributed under the terms of the GNU GPLv3 license. +// This file may be distributed under the terms of the GNU LGPLv3 license. #include "farptr.h" // GET_VAR -#include "biosvar.h" // struct bregs +#include "bregs.h" // struct bregs #include "ioport.h" // outb -#include "util.h" // irq_enable +#include "util.h" // wait_irq +#include "config.h" // CONFIG_* +#include "biosvar.h" // GET_GLOBAL static void out_str(const char *str_cs) { + if (CONFIG_COREBOOT) { + dprintf(1, "APM request '%s'\n", str_cs); + return; + } + u8 *s = (u8*)str_cs; for (;;) { - u8 c = GET_VAR(CS, *s); + u8 c = GET_GLOBAL(*s); if (!c) break; outb(c, PORT_BIOS_APM); @@ -46,14 +53,14 @@ handle_155301(struct bregs *regs) } // Assembler entry points defined in romlayout.S -extern void apm16protected_entry(); -extern void apm32protected_entry(); +extern void entry_apm16(void); +extern void entry_apm32(void); // APM 16 bit protected mode interface connect static void handle_155302(struct bregs *regs) { - regs->bx = (u32)apm16protected_entry; + regs->bx = (u32)entry_apm16; regs->ax = SEG_BIOS; // 16 bit code segment base regs->si = 0xfff0; // 16 bit code segment size regs->cx = SEG_BIOS; // data segment address @@ -66,7 +73,7 @@ static void handle_155303(struct bregs *regs) { regs->ax = SEG_BIOS; // 32 bit code segment base - regs->ebx = (u32)apm32protected_entry; + regs->ebx = (u32)entry_apm32; regs->cx = SEG_BIOS; // 16 bit code segment base // 32 bit code segment size (low 16 bits) // 16 bit code segment size (high 16 bits) @@ -87,11 +94,26 @@ handle_155304(struct bregs *regs) static void handle_155305(struct bregs *regs) { - irq_enable(); - hlt(); + wait_irq(); + set_success(regs); +} + +// APM cpu busy +static void +handle_155306(struct bregs *regs) +{ set_success(regs); } +void +apm_shutdown(void) +{ + irq_disable(); + out_str("Shutdown"); + for (;;) + hlt(); +} + // APM Set Power State static void handle_155307(struct bregs *regs) @@ -108,10 +130,7 @@ handle_155307(struct bregs *regs) out_str("Suspend"); break; case 3: - irq_disable(); - out_str("Shutdown"); - for (;;) - hlt(); + apm_shutdown(); break; } set_success(regs); @@ -136,12 +155,13 @@ handle_15530a(struct bregs *regs) set_success(regs); } +#define RET_ENOEVENT 0x80 + // Get PM Event static void handle_15530b(struct bregs *regs) { - set_fail(regs); - regs->ah = 0x80; // no event pending + set_code_invalid_silent(regs, RET_ENOEVENT); } // APM Driver Version @@ -172,12 +192,17 @@ handle_155310(struct bregs *regs) static void handle_1553XX(struct bregs *regs) { - set_fail(regs); + set_unimplemented(regs); } -void VISIBLE16 +void handle_1553(struct bregs *regs) { + if (! CONFIG_APMBIOS) { + set_code_invalid(regs, RET_EUNSUPPORTED); + return; + } + //debug_stub(regs); switch (regs->al) { case 0x00: handle_155300(regs); break; @@ -186,6 +211,7 @@ handle_1553(struct bregs *regs) case 0x03: handle_155303(regs); break; case 0x04: handle_155304(regs); break; case 0x05: handle_155305(regs); break; + case 0x06: handle_155306(regs); break; case 0x07: handle_155307(regs); break; case 0x08: handle_155308(regs); break; case 0x0a: handle_15530a(regs); break; @@ -196,3 +222,17 @@ handle_1553(struct bregs *regs) default: handle_1553XX(regs); break; } } + +void VISIBLE16 +handle_apm16(struct bregs *regs) +{ + debug_enter(regs, DEBUG_HDL_apm); + handle_1553(regs); +} + +void VISIBLE32SEG +handle_apm32(struct bregs *regs) +{ + debug_enter(regs, DEBUG_HDL_apm); + handle_1553(regs); +}