core: make the COMBOOT API available to in-kernel PM code
authorH. Peter Anvin <hpa@zytor.com>
Fri, 15 May 2009 03:17:43 +0000 (20:17 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 15 May 2009 03:17:43 +0000 (20:17 -0700)
Make it possible to call the COMBOOT API from in-kernel PM code,
simply by setting up the COMBOOT API earlier and only tearing it down
during final shutdown.

WARNING: the COMBOOT API is quite possibly probably not reentrant; I
haven't checked it...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core/cleanup.inc
core/comboot.inc
core/hello.c
core/init.inc

index 9166f01..7db5593 100644 (file)
@@ -50,5 +50,7 @@ cleanup_hardware:
 .no_vmware:
 %endif
 
+               call comboot_cleanup_api
+
                popad
                ret
index 7d9efba..b1048bb 100644 (file)
@@ -148,8 +148,8 @@ comboot_return:     cli                     ; Don't trust anyone
                jmp comboot_exit
 
 ;
-; Set up the COMBOOT API interrupt vectors.  This is also used
-; by the COM32 code.
+; Set up the COMBOOT API interrupt vectors.  This is now done at
+; initialization time.
 ;
 comboot_setup_api:
                mov di,DOSErrTramp      ; Error trampolines
@@ -178,6 +178,18 @@ comboot_setup_api:
                loop .loop2
                ret
 
+;
+; Restore the original state of the COMBOOT API vectors
+;
+comboot_cleanup_api:
+               pusha
+               mov si,DOSSaveVectors
+               mov di,4*20h
+               mov cx,20h
+               rep movsd               ; Restore DOS-range vectors
+               popa
+               ret
+
                section .bss16
                alignb 4
 DOSSaveVectors resd 32
@@ -296,12 +308,6 @@ comboot_exit_msg:
                pop bx                  ; Return address
                RESET_STACK_AND_SEGS SI ; Contains cld
                call adjust_screen      ; The COMBOOT program might have changed the screen
-               pusha
-               mov si,DOSSaveVectors
-               mov di,4*20h
-               mov cx,20h
-               rep movsd               ; Restore DOS-range vectors
-               popa
                jcxz .nomsg
                mov si,KernelCName
                call writestr
index c4b2803..6c12c73 100644 (file)
@@ -3,18 +3,14 @@
 
 void myputchar(int c)
 {
-#if 1
   static com32sys_t ireg;
+  static uint16_t *vram = 0xb8000;
 
-  ireg.eax.b[1] = 0x0e;
-  ireg.eax.b[0] = c;
-  ireg.ebx.w[0] = 0x0007;
-  core_intcall(0x10, &ireg, NULL);
-#else
-  static uint16_t *vram = (void *)0xb8000;
+  ireg.eax.b[1] = 0x02;
+  ireg.edx.b[0] = c;
+  core_intcall(0x21, &ireg, NULL);
 
-  *vram++ = (uint8_t)c + 0x1f00;
-#endif
+  *vram++ = c + 0x1f00;
 }
 
 void myputs(const char *str)
index 90c607e..7f65ffa 100644 (file)
@@ -43,9 +43,6 @@ common_init:
                mov cx,__uibss_dwords
                rep stosd
 
-               ; Now set up screen parameters
-               call adjust_screen
-
 ;
 ; Initialize configuration information
 ;
@@ -63,4 +60,13 @@ common_init:
                add ax,PKTBUF_SIZE
                loop .setbufptr
 %endif
-               section .text16                 ; This is an inline file...
+
+;
+; Set up the COMBOOT APIs
+;
+               call comboot_setup_api
+
+;
+; Now set up screen parameters
+;
+               call adjust_screen