aboutsummaryrefslogtreecommitdiffstats
path: root/memdisk
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-06-07 17:13:58 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-06-07 17:13:58 -0700
commit788de9d8dc339c5fe99029131eb6e2c152181c6a (patch)
tree7336843641cd4b1f8ec314ec865ccb4516b0c426 /memdisk
parent0a4a533cc1c0e0c7e526f454d29b416bb580df0f (diff)
downloadsyslinux.git-788de9d8dc339c5fe99029131eb6e2c152181c6a.tar.gz
syslinux.git-788de9d8dc339c5fe99029131eb6e2c152181c6a.tar.xz
syslinux.git-788de9d8dc339c5fe99029131eb6e2c152181c6a.zip
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 <hpa@zytor.com>
Diffstat (limited to 'memdisk')
-rw-r--r--memdisk/memdisk.h10
-rw-r--r--memdisk/memdisk16.asm4
-rw-r--r--memdisk/setup.c10
-rw-r--r--memdisk/start32.S17
4 files changed, 21 insertions, 20 deletions
diff --git a/memdisk/memdisk.h b/memdisk/memdisk.h
index cf4a1e99..41ce13b1 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 e8e5d78d..2568eed4 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 c4fc7e23..f9b9ed1f 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 d631875d..8fcebcc6 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: