aboutsummaryrefslogtreecommitdiffstats
path: root/memdisk
diff options
context:
space:
mode:
Diffstat (limited to 'memdisk')
-rw-r--r--memdisk/Makefile14
-rw-r--r--memdisk/memdisk.inc (renamed from memdisk/memdisk.asm)18
-rw-r--r--memdisk/memdisk_chs.asm2
-rw-r--r--memdisk/memdisk_edd.asm2
-rw-r--r--memdisk/setup.c37
5 files changed, 36 insertions, 37 deletions
diff --git a/memdisk/Makefile b/memdisk/Makefile
index 93575c30..d9c16206 100644
--- a/memdisk/Makefile
+++ b/memdisk/Makefile
@@ -20,7 +20,7 @@ LDFLAGS = $(GCCOPT) -g
INCLUDE = -I$(topdir)/com32/include
NASM = nasm
NASMOPT = -O9999
-NFLAGS = -dDATE='"$(DATE)"' -dWITH_EDD
+NFLAGS = -dDATE='"$(DATE)"'
NINCLUDE =
SRCS = $(wildcard *.asm *.c *.h)
@@ -38,11 +38,11 @@ endif
# Important: init.o16 must be first!!
OBJS16 = init.o16 init32.o
OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \
- unzip.o memdisk.o
+ unzip.o memdisk_chs.o memdisk_edd.o
CSRC = setup.c msetup.c e820func.c conio.c unzip.c
SSRC = start32.S memcpy.S memset.S
-NASMSRC = memdisk.asm memdisk16.asm
+NASMSRC = memdisk_chs.asm memdisk_edd.asm memdisk16.asm
all: memdisk # e820test
@@ -56,7 +56,7 @@ clean: tidy
spotless: clean
rm -f memdisk .depend
-%.o: %.asm
+memdisk16.o: memdisk16.asm
$(NASM) $(NASMOPT) $(NFLAGS) $(NINCLUDE) -f elf -l $*.lst -o $@ $<
%.o: %.s
@@ -92,6 +92,9 @@ spotless: clean
%.bin: %.asm
$(NASM) -f bin $(NASMOPT) $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
+memdisk_%.o: memdisk_%.bin
+ $(LD) -r -b binary -o $@ $<
+
memdisk16.elf: $(OBJS16)
$(LD) -Ttext 0 -o $@ $^
@@ -107,9 +110,6 @@ memdisk: memdisk16.bin memdisk32.bin postprocess.pl
e820test: e820test.c e820func.c msetup.c
$(CC) -m32 -g -W -Wall -DTEST -o $@ $^
-memdisk.o: memdisk.bin
- $(LD) -r -b binary -o $@ $<
-
.depend:
rm -f .depend
for csrc in *.c ; do $(CC) $(INCLUDE) $(CFLAGS) -MM $$csrc >> .depend ; done ; true
diff --git a/memdisk/memdisk.asm b/memdisk/memdisk.inc
index 0d489614..1e2076bd 100644
--- a/memdisk/memdisk.asm
+++ b/memdisk/memdisk.inc
@@ -1,12 +1,12 @@
; -*- fundamental -*- (asm-mode sucks)
; ****************************************************************************
;
-; memdisk.asm
+; memdisk.inc
;
; A program to emulate an INT 13h disk BIOS from a "disk" in extended
; memory.
;
-; Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
+; Copyright 2001-2009 H. Peter Anvin - All Rights Reserved
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
@@ -22,12 +22,6 @@
; %define DEBUG_TRACERS ; Uncomment to get debugging tracers
-%ifdef WITH_EDD
-%define EDD 1
-%else
-%define EDD 0
-%endif
-
%ifdef DEBUG_TRACERS
%macro TRACER 1
@@ -154,7 +148,7 @@ Int13Start:
mov bp,sp ; Point BP to the entry stack frame
TRACER 'F'
; Note: AH == P_AH here
- cmp ah,[Int13MaxFunc]
+ cmp ah,[Int13FuncsCnt-1]
ja Invalid_jump
xor al,al ; AL = 0 is standard entry condition
mov di,ax
@@ -884,7 +878,7 @@ Int13FuncsCnt equ (Int13FuncsEnd-Int13Funcs) >> 1
alignb 8, db 0
-Shaker dw ShakerEnd-$
+Shaker dw ShakerEnd-$-1 ; Descriptor table limit
dd 0 ; Pointer to self
dw 0
@@ -935,10 +929,6 @@ DPT_ptr dw 0 ; If nonzero, pointer to DPT
MDI_Len equ $-MemDisk_Info
; ---- MDI structure ends here ---
-Int13MaxFunc db Int13FuncsCnt-1 ; Max INT 13h function (to disable EDD)
- db 0 ; pad
-
- dw 0 ; pad
MemInt1588 dw 0 ; 1MB-65MB memory amount (1K)
Cylinders dw 0 ; Cylinder count
diff --git a/memdisk/memdisk_chs.asm b/memdisk/memdisk_chs.asm
new file mode 100644
index 00000000..4b06a856
--- /dev/null
+++ b/memdisk/memdisk_chs.asm
@@ -0,0 +1,2 @@
+%define EDD 0
+%include "memdisk.inc"
diff --git a/memdisk/memdisk_edd.asm b/memdisk/memdisk_edd.asm
new file mode 100644
index 00000000..d2e7b1cf
--- /dev/null
+++ b/memdisk/memdisk_edd.asm
@@ -0,0 +1,2 @@
+%define EDD 1
+%include "memdisk.inc"
diff --git a/memdisk/setup.c b/memdisk/setup.c
index db644ae2..b492b0d2 100644
--- a/memdisk/setup.c
+++ b/memdisk/setup.c
@@ -22,8 +22,12 @@ const char memdisk_version[] =
const char copyright[] =
"Copyright " FIRSTYEAR "-" YEAR_STR " H. Peter Anvin";
-extern const char _binary_memdisk_bin_start[], _binary_memdisk_bin_end[];
-extern const char _binary_memdisk_bin_size[]; /* Weird, I know */
+extern const char _binary_memdisk_chs_bin_start[];
+extern const char _binary_memdisk_chs_bin_end[];
+extern const char _binary_memdisk_chs_bin_size[];
+extern const char _binary_memdisk_edd_bin_start[];
+extern const char _binary_memdisk_edd_bin_end[];
+extern const char _binary_memdisk_edd_bin_size[];
struct memdisk_header {
uint16_t int13_offs;
@@ -92,11 +96,6 @@ struct patch_area {
uint16_t dpt_ptr;
/* End of the official MemDisk_Info */
- uint8_t maxint13func;
-#define MAXINT13_NOEDD 0x16
- uint8_t _pad2;
-
- uint16_t _pad3;
uint16_t memint1588;
uint16_t cylinders;
@@ -672,7 +671,8 @@ void *sys_bounce;
__cdecl void setup(__cdecl syscall_t cs_syscall, void *cs_bounce)
{
- unsigned int bin_size = (int) &_binary_memdisk_bin_size;
+ unsigned int bin_size;
+ char *memdisk_hook;
struct memdisk_header *hptr;
struct patch_area *pptr;
uint16_t driverseg;
@@ -684,7 +684,7 @@ __cdecl void setup(__cdecl syscall_t cs_syscall, void *cs_bounce)
com32sys_t regs;
uint32_t ramdisk_image, ramdisk_size;
int bios_drives;
- int do_edd = -1; /* -1 = default, 0 = no, 1 = yes */
+ int do_edd = 1; /* 0 = no, 1 = yes, default is yes */
int no_bpt; /* No valid BPT presented */
/* Set up global variables */
@@ -723,13 +723,22 @@ __cdecl void setup(__cdecl syscall_t cs_syscall, void *cs_bounce)
else
do_edd = (geometry->driveno & 0x80) ? 1 : 0;
+ /* Choose the appropriate installable memdisk hook */
+ if (do_edd) {
+ bin_size = (int) &_binary_memdisk_edd_bin_size;
+ memdisk_hook = (char *) &_binary_memdisk_edd_bin_start;
+ } else {
+ bin_size = (int) &_binary_memdisk_chs_bin_size;
+ memdisk_hook = (char *) &_binary_memdisk_chs_bin_start;
+ }
+
/* Reserve the ramdisk memory */
insertrange(ramdisk_image, ramdisk_size, 2, 1);
parse_mem(); /* Recompute variables */
/* Figure out where it needs to go */
- hptr = (struct memdisk_header *) &_binary_memdisk_bin_start;
- pptr = (struct patch_area *)(_binary_memdisk_bin_start + hptr->patch_offs);
+ hptr = (struct memdisk_header *) memdisk_hook;
+ pptr = (struct patch_area *)(memdisk_hook + hptr->patch_offs);
dosmem_k = rdz_16(BIOS_BASEMEM);
pptr->olddosmem = dosmem_k;
@@ -800,10 +809,6 @@ __cdecl void setup(__cdecl syscall_t cs_syscall, void *cs_bounce)
}
puts(" access to high memory\n");
- /* pptr->maxint13func defaults to EDD enabled, if compiled in */
- if (!do_edd)
- pptr->maxint13func = MAXINT13_NOEDD;
-
/* Set up a drive parameter table */
if ( geometry->driveno & 0x80 ) {
/* Hard disk */
@@ -972,7 +977,7 @@ __cdecl void setup(__cdecl syscall_t cs_syscall, void *cs_bounce)
hptr = (struct memdisk_header *)dpp;
/* Actually copy to low memory */
- dpp = mempcpy(dpp, &_binary_memdisk_bin_start, bin_size);
+ dpp = mempcpy(dpp, memdisk_hook, bin_size);
dpp = mempcpy(dpp, ranges, (nranges+1)*sizeof(ranges[0]));
dpp = mempcpy(dpp, shdr->cmdline, cmdlinelen+1);
}