summaryrefslogtreecommitdiff
path: root/memdisk
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-10-17 15:04:39 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-10-17 15:04:39 -0700
commitc0480f52bec399fc81bd9104c88de30cfdd32276 (patch)
tree54eaf4e116f2bdbe9f968673eacf06a60d2afc49 /memdisk
parentaf9cc4b2abe87db7ef0680e52393a24d550cc31d (diff)
downloadsyslinux-c0480f52bec399fc81bd9104c88de30cfdd32276.tar.gz
[memdisk] Saner handling of the values returned to the real-mode code.
Diffstat (limited to 'memdisk')
-rw-r--r--memdisk/memdisk16.asm18
-rw-r--r--memdisk/setup.c17
2 files changed, 18 insertions, 17 deletions
diff --git a/memdisk/memdisk16.asm b/memdisk/memdisk16.asm
index ebcfe7e8..87c088fd 100644
--- a/memdisk/memdisk16.asm
+++ b/memdisk/memdisk16.asm
@@ -70,6 +70,13 @@ pad1 dw 0
cmd_line_ptr dd 0 ; Command line
ramdisk_max dd 0xffffffff ; Highest allowed ramdisk address
+;
+; These fields aren't real setup fields, they're poked in by the
+; 32-bit code.
+;
+b_esdi dd 0 ; ES:DI for boot sector invocation
+b_edx dd 0 ; EDX for boot sector invocation
+
section .rodata
memdisk_version:
db "MEMDISK ", VERSION, " ", DATE, 0
@@ -131,14 +138,13 @@ copy_cmdline:
call init32
;
; When init32 returns, we have been set up, the new boot sector loaded,
-; and we should go and and run the newly loaded boot sector
+; and we should go and and run the newly loaded boot sector.
;
-; The setup function returns (in DX) the drive number, and
-; the value for ES:DI in AX
+; The setup function will have poked values into the setup area.
;
- movzx edi,ax
- shr eax,16
- mov es,ax
+ movzx edi,word [cs:b_esdi]
+ mov es,word [cs:b_esdi+2]
+ mov edx,[cs:b_edx]
cli
xor esi,esi ; No partition table involved
diff --git a/memdisk/setup.c b/memdisk/setup.c
index fe8023b1..745cfe4a 100644
--- a/memdisk/setup.c
+++ b/memdisk/setup.c
@@ -123,9 +123,11 @@ struct setup_header {
uint16_t pad1;
uint32_t cmd_line_ptr;
uint32_t initrd_addr_max;
+ uint32_t esdi;
+ uint32_t edx;
};
-const struct setup_header * const shdr = (struct setup_header *)(LOW_SEG << 4);
+struct setup_header * const shdr = (struct setup_header *)(LOW_SEG << 4);
/* Access to high memory */
@@ -535,12 +537,7 @@ static uint32_t pnp_install_check(void)
syscall_t syscall;
void *sys_bounce;
-struct setup_return {
- uint32_t es; /* ES:DI -> $PnP structure */
- uint32_t dx; /* DL -> boot device */
-};
-
-struct setup_return setup(syscall_t cs_syscall, void *cs_bounce)
+void setup(syscall_t cs_syscall, void *cs_bounce)
{
unsigned int bin_size = (int) &_binary_memdisk_bin_size;
struct memdisk_header *hptr;
@@ -553,7 +550,6 @@ struct setup_return setup(syscall_t cs_syscall, void *cs_bounce)
int total_size, cmdlinelen;
com32sys_t regs;
uint32_t ramdisk_image, ramdisk_size;
- struct setup_return sr;
/* Set up global variables */
syscall = cs_syscall;
@@ -809,7 +805,6 @@ struct setup_return setup(syscall_t cs_syscall, void *cs_bounce)
puts("booting...\n");
/* On return the assembly code will jump to the boot vector */
- sr.esdi = pnp_install_check();
- sr.dx = geometry->driveno;
- return sr;
+ shdr->esdi = pnp_install_check();
+ shdr->edx = geometry->driveno;
}