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>
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,
;
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
uint32_t sssp;
uint32_t csip;
};
-
struct setup_header *shdr;
/* Structure passed in from the real-mode code */
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 */
__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;
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;
* this module must be linked first
*/
-#define ARGS 4 /* Number of real-mode arguments */
-
.section ".init", "ax"
.globl _start
_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:
.long idt
.word 0
- .section ".bss","aw"
- .globl rm_args
-rm_args:
- .space (ARGS+1)*4
-
.section ".bss.large","aw"
.balign 2048
idt: