1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
4 ;; Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
6 ;; This program is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ;; Boston MA 02111-1307, USA; either version 2 of the License, or
10 ;; (at your option) any later version; incorporated herein by reference.
12 ;; -----------------------------------------------------------------------
17 ;; Common code for running a COM32 image
23 ; Load a COM32 image. A COM32 image is the 32-bit analogue to a DOS
24 ; .com file. A COM32 image is loaded at address 0x101000, with %esp
25 ; set to the high end of usable memory.
27 ; A COM32 image should begin with the magic bytes:
28 ; B8 FF 4C CD 21, which is "mov eax,0x21cd4cff" in 32-bit mode and
29 ; "mov ax,0x4cff; int 0x21" in 16-bit mode. This will abort the
30 ; program with an error if run in 16-bit mode.
32 com32_entry equ free_high_memory
36 push si ; Save file handle
37 push eax ; Save file length
39 call make_plain_cmdline
40 ; Copy the command line into the low cmdline buffer
46 inc cx ; Include final null
54 call comboot_setup_api ; Set up the COMBOOT-style API
56 mov edi,com32_entry ; Load address
59 xor dx,dx ; No padding
60 mov bx,abort_check ; Don't print dots, but allow abort
67 cmp dword [trackbuf],0xcd4cfeb8
69 cmp byte [trackbuf+4],0x21
74 ; Point the stack to the end of (permitted) high memory
77 xor ax,ax ; Align to a 64K boundary
79 mov ebx,.pm ; Where to go in PM
83 ; This is invoked right before the actually starting the COM32
84 ; progam, in 32-bit mode...
89 ; Set up the calling stack frame
91 push dword pm_api_vector
92 push dword Com32Name ; Module filename
93 push dword [HighMemSize] ; Memory managed by Syslinux
94 push dword core_cfarcall ; Cfarcall entry point
95 push dword core_farcall ; Farcall entry point
96 push dword (1 << 16) ; 64K bounce buffer
97 push dword core_real_mode ; Bounce buffer address
98 push dword core_intcall ; Intcall entry point
99 push dword command_line ; Command line pointer
100 push dword 9 ; Argument count
101 sti ; Interrupts OK now
102 call com32_entry ; Run the program...
103 ; ... on return, fall through to com32_exit ...
105 mov bx,comboot_return
113 mov si,not_com32r_msg
118 not_com32r_msg db ': not a COM32R image', CR, LF, 0
120 ; Ersatz com32 invocation structure, to make libcom32
121 ; code run the same if linked to the core. This is in
122 ; the .data16 segment so HighMemSize can live here.
124 ; Danger, Will Robinson: it's not clear the use of
125 ; core_xfer_buf is safe here.
126 global __entry_esp, __com32
129 dd 0 ; Dummy to avoid _exit issues
131 dd 9 ; Argument count
132 dd 0 ; No command line
133 dd core_intcall ; Intcall entry point
134 dd 0 ; Bounce buffer address
135 dd 0 ; 64K bounce buffer
136 dd core_farcall ; Farcall entry point
137 dd core_cfarcall ; Cfarcall entry point
138 HighMemSize dd 0 ; End of memory pointer (bytes)
139 dd 0 ; No module name
140 dd pm_api_vector ; Protected mode functions
143 Com32Name resb FILENAME_MAX