summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2001-12-15 06:38:03 +0000
committerhpa <hpa>2001-12-15 06:38:03 +0000
commit624495b348f4c32a81d47b3d7597a619fe7ca2f3 (patch)
tree4637143336a62c0e71bfa5ac4eb84bfbed072a8a
parentaafb7e7c5c9372b6e6d929affa953438b083dbaf (diff)
downloadsyslinux-624495b348f4c32a81d47b3d7597a619fe7ca2f3.tar.gz
Minor cleanups
-rw-r--r--memdisk/memdisk.asm37
-rw-r--r--memdisk/setup.c74
2 files changed, 75 insertions, 36 deletions
diff --git a/memdisk/memdisk.asm b/memdisk/memdisk.asm
index 11234501..c18545a5 100644
--- a/memdisk/memdisk.asm
+++ b/memdisk/memdisk.asm
@@ -87,6 +87,7 @@ Int13Start:
jmp far [cs:OldInt13]
.our_drive:
+ ; Swap stack
mov [cs:Stack],esp
mov [cs:SavedAX],ax
mov ax,ss
@@ -99,6 +100,7 @@ Int13Start:
mov ds,ax
mov es,ax
mov ax,[SavedAX]
+
pushad
mov bp,sp ; Point BP to the entry stack frame
TRACER 'F'
@@ -151,18 +153,17 @@ Invalid_jump:
jmp short Done
GetDriveType:
- mov ah,[DriveNo]
- shr ah,7
- pushf
- or ah,02h
- mov P_AH,ah
- popf
+ test byte [DriveNo],80h
+ mov bl,02h ; Type 02h = floppy with changeline
jz .floppy
- mov ax,[DiskSize] ; For hard disk return the size
- mov P_DX,ax
- mov ax,[DiskSize+2]
- mov P_CX,ax
+ ; Hard disks only...
+ inc bx ; Type = 03h
+ mov dx,[DiskSize] ; Return the disk size in sectors
+ mov P_DX,dx
+ mov cx,[DiskSize+2]
+ mov P_CX,cx
.floppy:
+ mov P_AH,bl ; 02h floppy, 03h hard disk
pop ax ; Drop return address
xor ax,ax ; Success...
jmp short DoneWeird ; But don't stick it into P_AX
@@ -186,10 +187,6 @@ Write:
xchg esi,edi ; Opposite direction of a Read!
jmp short do_copy
- ; These verify one sector only
-Seek:
- mov P_AL,1
-
; Verify integrity; just bounds-check
Verify:
call setup_regs ; Returns error if appropriate
@@ -199,6 +196,7 @@ CheckIfReady: ; These are always-successful noop functions
Recalibrate:
InitWithParms:
DetectChange:
+Seek:
success:
xor ax,ax ; Always successful
ret
@@ -209,9 +207,8 @@ GetParms:
mov P_DL,dl
test byte [DriveNo],80h
jnz .hd
- mov di,[BPT]
- mov P_DI,di
- mov ax,[BPT+2]
+ mov P_DI,DPT
+ mov ax,cs
mov P_ES,ax
mov bl,[DriveType]
mov P_BL,bl
@@ -481,16 +478,16 @@ DriveType db 0 ; Our drive type (floppies)
DriveCnt db 0 ; Drive count (from the BIOS)
db 0 ; Pad
-BPT dd 0 ; BIOS parameter table pointer (floppies)
-
MyStack dw 0 ; Offset of stack
+StatusPtr dw 0 ; Where to save status (zeroseg ptr)
+
+DPT times 16 db 0 ; BIOS parameter table pointer (floppies)
; End patch area
Stack dd 0 ; Saved SS:ESP on invocation
dw 0
SavedAX dw 0 ; AX saved on invocation
-StatusPtr dw 0 ; Where to save status (zeroseg ptr)
alignb 4, db 0 ; We *MUST* end on a dword boundary
diff --git a/memdisk/setup.c b/memdisk/setup.c
index f8fbdf6f..e75bcb40 100644
--- a/memdisk/setup.c
+++ b/memdisk/setup.c
@@ -27,14 +27,34 @@ struct memdisk_header {
uint16_t total_size;
};
-/* The Disk Parameter Table is required on hard disks */
-struct dpt {
- uint16_t max_cyl; /* Max cylinder */
- uint8_t max_head; /* Max head */
- uint8_t junk1[5]; /* Obsolete junk, leave at zero */
- uint8_t ctrl; /* Control byte */
- uint8_t junk2[7]; /* More obsolete junk */
-};
+/* The Disk Parameter Table may be required */
+typedef union {
+ struct hd_dpt {
+ uint16_t max_cyl; /* Max cylinder */
+ uint8_t max_head; /* Max head */
+ uint8_t junk1[5]; /* Obsolete junk, leave at zero */
+ uint8_t ctrl; /* Control byte */
+ uint8_t junk2[7]; /* More obsolete junk */
+ } hd;
+ struct fd_dpt {
+ uint8_t specify1; /* "First specify byte" */
+ uint8_t specify2; /* "Second specify byte" */
+ uint8_t delay; /* Delay until motor turn off */
+ uint8_t sectors; /* Sectors/track */
+
+ uint8_t bps; /* Bytes/sector (02h = 512) */
+ uint8_t isgap; /* Length of intersector gap */
+ uint8_t dlen; /* Data length (0FFh) */
+ uint8_t fgap; /* Formatting gap */
+
+ uint8_t ffill; /* Format fill byte */
+ uint8_t settle; /* Head settle time (ms) */
+ uint8_t mstart; /* Motor start time */
+ uint8_t _pad1; /* Padding */
+
+ uint32_t old_fd_dpt; /* Extension: pointer to old INT 1Eh */
+ } fd;
+} dpt_t;
struct patch_area {
uint16_t cylinders;
@@ -57,10 +77,10 @@ struct patch_area {
uint8_t drivecnt;
uint8_t _pad1;
- uint16_t bpt_offs, bpt_seg;
+ uint16_t mystack;
uint16_t statusptr;
- uint16_t mystack;
+ dpt_t dpt;
};
/* This is the header in the boot sector/setup area */
@@ -198,6 +218,7 @@ rdz_32(uint32_t addr)
/* Addresses in the zero page */
#define BIOS_INT13 (0x13*4) /* INT 13h vector */
#define BIOS_INT15 (0x15*4) /* INT 15h vector */
+#define BIOS_INT1E (0x1E*4) /* INT 1Eh vector */
#define BIOS_INT40 (0x40*4) /* INT 13h vector */
#define BIOS_INT41 (0x41*4) /* INT 41h vector */
#define BIOS_INT46 (0x46*4) /* INT 46h vector */
@@ -462,6 +483,30 @@ uint32_t setup(void)
pptr->diskbuf = shdr->ramdisk_image;
pptr->statusptr = (geometry->driveno & 0x80) ? 0x474 : 0x441;
+ /* Set up a drive parameter table */
+ if ( geometry->driveno & 0x80 ) {
+ /* Hard disk */
+ pptr->dpt.hd.max_cyl = geometry->c-1;
+ pptr->dpt.hd.max_head = geometry->h-1;
+ pptr->dpt.hd.ctrl = (geometry->h > 8) ? 0x08: 0;
+ } else {
+ /* Floppy - most of these fields are bogus and mimic
+ a 1.44 MB floppy drive */
+ pptr->dpt.fd.specify1 = 0xdf;
+ pptr->dpt.fd.specify2 = 0x02;
+ pptr->dpt.fd.delay = 0x25;
+ pptr->dpt.fd.sectors = geometry->s;
+ pptr->dpt.fd.bps = 0x02;
+ pptr->dpt.fd.isgap = 0x12;
+ pptr->dpt.fd.dlen = 0xff;
+ pptr->dpt.fd.fgap = 0x6c;
+ pptr->dpt.fd.ffill = 0xf6;
+ pptr->dpt.fd.settle = 0x0f;
+ pptr->dpt.fd.mstart = 0x05;
+
+ pptr->dpt.fd.old_fd_dpt = rdz_32(BIOS_INT1E);
+ }
+
/* The size is given by hptr->total_size plus the size of the
E820 map -- 12 bytes per range; we may need as many as
2 additional ranges plus the terminating range, over what
@@ -538,13 +583,10 @@ uint32_t setup(void)
if ( cf ) {
printf("INT 13 08: Failure\n");
pptr->drivecnt = 1;
- pptr->bpt_offs = pptr->bpt_seg = 0;
} else {
printf("INT 13 08: Success, count = %u, BPT = %04x:%04x\n",
dl, bpt_es, bpt_di);
pptr->drivecnt = dl+1;
- pptr->bpt_offs = bpt_di;
- pptr->bpt_seg = bpt_es;
}
}
@@ -583,9 +625,9 @@ uint32_t setup(void)
/* Update BIOS hard disk count */
wrz_8(BIOS_HD_COUNT, rdz_8(BIOS_HD_COUNT)+1);
} else {
-#if 0 /* Apparently this is NOT wanted... */
+#if 1 /* Apparently this is NOT wanted... */
/* Update BIOS floppy disk count */
- uint16_t equip = rdz_16(BIOS_EQUIP);
+ uint8_t equip = rdz_8(BIOS_EQUIP);
if ( equip & 1 ) {
if ( (equip & (3 << 6)) != (3 << 6) ) {
equip += (1 << 6);
@@ -594,7 +636,7 @@ uint32_t setup(void)
equip |= 1;
equip &= ~(3 << 6);
}
- wrz_16(BIOS_EQUIP, equip);
+ wrz_8(BIOS_EQUIP, equip);
#endif
}