From: H. Peter Anvin Date: Mon, 8 Jun 2009 00:13:58 +0000 (-0700) Subject: memdisk: move rm_args initialization to C code; export rm_size X-Git-Tag: syslinux-3.83-pre2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=788de9d8dc339c5fe99029131eb6e2c152181c6a;p=platform%2Fupstream%2Fsyslinux.git memdisk: move rm_args initialization to C code; export rm_size Move the rm_args initialization (and the associated sti) to C code. Export the total size of the real-mode code to the protected-mode code. Signed-off-by: H. Peter Anvin --- diff --git a/memdisk/memdisk.h b/memdisk/memdisk.h index cf4a1e9..41ce13b 100644 --- a/memdisk/memdisk.h +++ b/memdisk/memdisk.h @@ -72,6 +72,16 @@ static inline int memcmp(const void *__a, const void *__b, unsigned int __n) return 0; } +static inline void sti(void) +{ + asm volatile("sti"); +} + +static inline void cli(void) +{ + asm volatile("cli"); +} + /* Decompression */ extern int check_zip(void *indata, uint32_t size, uint32_t * zbytes_p, uint32_t * dbytes_p, uint32_t * orig_crc, diff --git a/memdisk/memdisk16.asm b/memdisk/memdisk16.asm index e8e5d78..2568eed 100644 --- a/memdisk/memdisk16.asm +++ b/memdisk/memdisk16.asm @@ -596,10 +596,8 @@ call32_call_start: ; mov esp, (BOUNCE_SEG << 4) + 0x10000 - ; Arguments for start32.S only + push dword stack_end ; RM size push dword call32_handle_interrupt+CS_BASE - - ; Arguments for setup() push dword CS_BASE ; Segment base push dword (BOUNCE_SEG << 4) ; Bounce buffer address push dword call32_syscall+CS_BASE ; Syscall entry point diff --git a/memdisk/setup.c b/memdisk/setup.c index c4fc7e2..f9b9ed1 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -154,7 +154,6 @@ struct setup_header { uint32_t sssp; uint32_t csip; }; - struct setup_header *shdr; /* Structure passed in from the real-mode code */ @@ -164,8 +163,9 @@ struct real_mode_args { uint32_t rm_bounce; uint32_t rm_base; uint32_t rm_handle_interrupt; + uint32_t rm_size; }; -extern struct real_mode_args rm_args; +struct real_mode_args rm_args; /* Access to high memory */ @@ -713,7 +713,7 @@ static uint32_t pnp_install_check(void) __cdecl syscall_t syscall; void *sys_bounce; -void setup(void) +void setup(const struct real_mode_args *rm_args_ptr) { unsigned int bin_size; char *memdisk_hook; @@ -731,6 +731,10 @@ void setup(void) int do_edd = 1; /* 0 = no, 1 = yes, default is yes */ int no_bpt; /* No valid BPT presented */ + /* We need to copy the rm_args into their proper place */ + memcpy(&rm_args, rm_args_ptr, sizeof rm_args); + sti(); /* ... then interrupts are safe */ + /* Set up global variables */ syscall = (__cdecl syscall_t) rm_args.rm_syscall; sys_bounce = (void *)rm_args.rm_bounce; diff --git a/memdisk/start32.S b/memdisk/start32.S index d631875..8fcebcc 100644 --- a/memdisk/start32.S +++ b/memdisk/start32.S @@ -16,8 +16,6 @@ * this module must be linked first */ -#define ARGS 4 /* Number of real-mode arguments */ - .section ".init", "ax" .globl _start _start: @@ -67,19 +65,15 @@ _start: lidtl idt_ptr /* Save arguments, switch stacks */ - movl %esp, %esi + movl %esp, %eax /* Pointer to arguments */ movl $__stack_end, %esp - movl $rm_args, %edi - movl $(ARGS+1), %ecx - rep; movsl - sti /* Ready for interrupts now */ call setup - jmp *(rm_args) /* First argument is return */ + jmp *(rm_args) /* First argument is return */ .section ".text","ax" handle_interrupt: - jmp *(rm_args+4*4) /* Interrupt pointer is argument 4 */ + jmp *(rm_args+4*4) /* Interrupt pointer is argument 4 */ .section ".rodata","a" idt_ptr: @@ -87,11 +81,6 @@ idt_ptr: .long idt .word 0 - .section ".bss","aw" - .globl rm_args -rm_args: - .space (ARGS+1)*4 - .section ".bss.large","aw" .balign 2048 idt: