diff options
author | Robert de Bath <rdebath@poboxes.com> | 2002-07-22 23:35:31 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:48:47 +0200 |
commit | 673f690a37f6673a3262e933709c79de8a66f48c (patch) | |
tree | 3acd007863bf23ce8549f9edb5e51d23a3bc6078 /bootblocks | |
parent | 352e3b3230dfc6746be6d53325ffe1e33efc5289 (diff) | |
download | dev86-673f690a37f6673a3262e933709c79de8a66f48c.tar.gz |
Import Dev86src-0.16.4.tar.gzv0.16.4
Diffstat (limited to 'bootblocks')
-rw-r--r-- | bootblocks/Makefile | 25 | ||||
-rw-r--r-- | bootblocks/bb_init1.s | 25 | ||||
-rw-r--r-- | bootblocks/bb_init2.s | 17 | ||||
-rw-r--r-- | bootblocks/bb_linux.s | 22 | ||||
-rw-r--r-- | bootblocks/boot_fpy.s | 6 | ||||
-rw-r--r-- | bootblocks/buffer.c | 142 | ||||
-rw-r--r-- | bootblocks/bzimage.c | 21 | ||||
-rw-r--r-- | bootblocks/com_bcc.s | 65 | ||||
-rw-r--r-- | bootblocks/crc.c | 216 | ||||
-rw-r--r-- | bootblocks/elf_info.c | 189 | ||||
-rw-r--r-- | bootblocks/elf_info.h | 282 | ||||
-rw-r--r-- | bootblocks/i86_funcs.c | 94 | ||||
-rw-r--r-- | bootblocks/i86_funcs.h | 4 | ||||
-rw-r--r-- | bootblocks/li86.s | 47 | ||||
-rw-r--r-- | bootblocks/makeboot.c | 4 | ||||
-rw-r--r-- | bootblocks/mbr.s | 3 | ||||
-rw-r--r-- | bootblocks/min_buf.c | 119 | ||||
-rw-r--r-- | bootblocks/monitor.c | 17 | ||||
-rw-r--r-- | bootblocks/monitor.h | 15 | ||||
-rw-r--r-- | bootblocks/standalone.c | 310 | ||||
-rw-r--r-- | bootblocks/tich.s | 39 | ||||
-rw-r--r-- | bootblocks/trk_buf.c | 390 |
22 files changed, 259 insertions, 1793 deletions
diff --git a/bootblocks/Makefile b/bootblocks/Makefile index 40e7817..d7ec4fa 100644 --- a/bootblocks/Makefile +++ b/bootblocks/Makefile @@ -16,26 +16,25 @@ default: makeboot makeboot.com monitor.out minix_elks.bin lsys.com all: bootbin bootsys default tgz -bootsys: bootfile.sys boottar.sys bootminix.sys +bootsys: bootfile.sys boottar.sys bootminix.sys monitor.sys CSRC=minix.c -SSRC=sysboot.s tarboot.s skip.s com_bcc.s tich.s mbr.s msdos.s noboot.s \ - boot_fpy.s killhd.s +SSRC=sysboot.s tarboot.s skip.s mbr.s msdos.s noboot.s \ + boot_fpy.s killhd.s bb_linux.s bb_init1.s bb_init2.s encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v msdos16.v bootbin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin msdos16.bin minix_elks.bin MOBJ=monitor.o commands.o i86_funcs.o relocate.o help.o bzimage.o \ - trk_buf.o min_buf.o unix.o fs.o fs_tar.o fs_min.o fs_dos.o + buffer.o unix.o fs.o fs_tar.o fs_min.o fs_dos.o MSRC=monitor.c commands.c i86_funcs.c relocate.c help.c bzimage.c \ - trk_buf.c min_buf.c unix.c fs.c fs_tar.c fs_min.c fs_dos.c + buffer.c unix.c fs.c fs_tar.c fs_min.c fs_dos.c MINC=i86_funcs.h readfs.h monitor.h BOOTBLOCKS=sysboot.v noboot.v skip.v msdos.v msdos16.v \ - tarboot.v minix.v minixhd.v mbr.v + tarboot.v minix.v minixhd.v mbr.v killhd.v -EXTRAS=minix.h elf_info.c elf_info.h standalone.c li86.s \ - zimage.s minix_elks.c crc.c lsys.c +EXTRAS=minix.h zimage.s minix_elks.c lsys.c install: @@ -60,12 +59,18 @@ boottar.sys: $(MSRC) $(MINC) tarboot.bin mv monitor.out boottar.sys @rm -f $(MOBJ) -bootminix.sys: $(MSRC) $(MINC) tarboot.bin +bootminix.sys: $(MSRC) $(MINC) minix.bin @rm -f $(MOBJ) make 'CFLAGS=$(CFLAGS) -DMINFLOPPY -i' monitor.out mv monitor.out bootminix.sys @rm -f $(MOBJ) +monitor.sys: $(MSRC) $(MINC) + @rm -f $(MOBJ) + make 'CFLAGS=$(CFLAGS) -DNOMONITOR -i' monitor.out + mv monitor.out monitor.sys + @rm -f $(MOBJ) + monitor: $(MSRC) $(MINC) @rm -f $(MOBJ) make 'CFLAGS=-ansi -H0x8000' monitor.out @@ -96,7 +101,7 @@ lsys.com: lsys.c msdos.v msdos16.v $(CC) -Md -O -o lsys.com lsys.c clean realclean: - rm -f bootfile.sys boottar.sys bootminix.sys + rm -f bootfile.sys boottar.sys bootminix.sys monitor.sys rm -f monitor makeboot bootblocks.tar.gz rm -f minix.s minixhd.s minix_elks.s msdos16.s rm -f *.com *.o *.bin *.out *.lst *.sym *.v *.tmp diff --git a/bootblocks/bb_init1.s b/bootblocks/bb_init1.s new file mode 100644 index 0000000..b7e6a6d --- /dev/null +++ b/bootblocks/bb_init1.s @@ -0,0 +1,25 @@ +ORGADDR=0x0600 + +.org ORGADDR +entry start +public start +start: + xor ax,ax + mov si,#$7C00 + mov di,#ORGADDR + + mov ss,ax + mov sp,di ! Or ax or si + + push ax + pop ds + push ax + pop es + + mov cx,#256 + cld + rep + movsw + jmpi go,#0 +go: + diff --git a/bootblocks/bb_init2.s b/bootblocks/bb_init2.s new file mode 100644 index 0000000..b27b8aa --- /dev/null +++ b/bootblocks/bb_init2.s @@ -0,0 +1,17 @@ +ORGADDR=$0500 + +org ORGADDR + cld + mov bx,#$7C00 ! Pointer to start of BB. + xor ax,ax ! Segs all to zero + mov ds,ax + mov es,ax + mov ss,ax + mov sp,bx ! SP Just below BB + mov cx,#$100 ! Move 256 words + mov si,bx ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + jmpi cont,#0 ! Set CS:IP correct. +cont: diff --git a/bootblocks/bb_linux.s b/bootblocks/bb_linux.s new file mode 100644 index 0000000..6bad72b --- /dev/null +++ b/bootblocks/bb_linux.s @@ -0,0 +1,22 @@ + +INITSEG = $9000 + +org 0 +mov ax,#$07c0 +mov ds,ax +mov ax,#INITSEG +mov es,ax +mov cx,#256 +sub si,si +sub di,di +cld +rep + movsw +jmpi go,INITSEG +go: + +mov di,#0x4000-12 +mov ds,ax +mov ss,ax ! put stack at INITSEG:0x4000-12. +mov sp,di + diff --git a/bootblocks/boot_fpy.s b/bootblocks/boot_fpy.s index a40d0fa..ced54c7 100644 --- a/bootblocks/boot_fpy.s +++ b/bootblocks/boot_fpy.s @@ -169,6 +169,12 @@ load_track: jnz inc_trk all_loaded: + ! Now it's loaded turn off the floppy motor. + mov dx,#0x3f2 + xor al, al + outb + + ! And start up the program. xor dx,dx ! DX=0 => floppy drive push dx ! CX=0 => partition offset = 0 diff --git a/bootblocks/buffer.c b/bootblocks/buffer.c new file mode 100644 index 0000000..d0a90bd --- /dev/null +++ b/bootblocks/buffer.c @@ -0,0 +1,142 @@ + +#include "monitor.h" + +#ifndef MAXTRK +#define MAXTRK 18 +#endif + +int disk_drive = 0; +int disk_spt = 7; +int disk_heads = 0; +int disk_cyls = 0; +long disk_partition_offset = 0; + +static long bad_start = -1; +static long buf_start = -1; +static int buf_sec = 0; +static int buf_len = 0; +static char buffer[MAXTRK*512]; /* WARNING: This must be DMAable */ + +void reset_disk() +{ + disk_spt = 7; /* Defaults for reading floppy boot area. */ + disk_heads = 0; + disk_cyls = 0; + bad_start = -1; + disk_partition_offset = 0; + +#ifdef __STANDALONE__ + if( disk_drive == __argr.h.dl && __argr.x.si >= 9 && __argr.x.si <= 63 ) + { + disk_spt = __argr.x.si; + disk_heads = 2; + disk_cyls = 80; + } + if( disk_drive & 0x80 ) + { + /* Hard disk, get parameters from bios */ + long dpt; + int v; + + if( disk_drive == __argr.h.dl ) + disk_partition_offset = __argr.x.cx + ((long)__argr.h.dh<<16); + + dpt = _bios_get_dpt(disk_drive); + v = ((dpt>>16) & 0xFF); + if( v != 0xFF && v > (disk_drive&0x7F) ) + { + disk_spt = (dpt & 0x3F); /* Max sector number 1-63 */ + if( disk_spt == 0 ) disk_spt = 64; /* 1-64 ? */ + disk_heads = ((dpt>>24) & 0xFF) + 1; /* Head count 1-256 */ + disk_cyls = ((dpt>>8) & 0xFF) + ((dpt<<2) & 0x300) + 1; + + /* Cyls count, unchecked, only needs != 0, if AMI 386 bios can be + * upto 4096 cylinder, otherwise BIOS limit is 1024 cyl. + */ + } + } +#endif +} + +char * read_lsector(sectno) +long sectno; +{ + int tries; + int rv = 0; + + int phy_s = 1; + int phy_h = 0; + int phy_c = 0; + + long bstart; + + if( sectno == 0 || disk_heads == 0 ) reset_disk(); + if( disk_partition_offset > 0 ) sectno += disk_partition_offset; + + if( disk_spt < 1 || disk_heads < 1 ) + phy_s = sectno; + else + { + phy_s = sectno%disk_spt; + phy_h = sectno/disk_spt%disk_heads; + phy_c = sectno/disk_spt/disk_heads; + + bstart = (long)phy_c*disk_heads+phy_h; + if (disk_spt > MAXTRK) { + bstart = bstart * (disk_spt+MAXTRK-1)/MAXTRK; + buf_sec = phy_s/MAXTRK; + bstart = bstart + buf_sec; + buf_sec *= MAXTRK; + + if (disk_spt > buf_sec+MAXTRK) buf_len = MAXTRK; + else buf_len = disk_spt-buf_sec; + } else { + buf_sec = 0; + buf_len = disk_spt; + } + + if( bstart != buf_start && bstart != bad_start && buf_len > 1 ) + { + rv = _bios_disk_read(disk_drive,phy_c,phy_h,buf_sec+1,buf_len,buffer); + if( rv == 0 ) + buf_start = bstart; + else { + bad_start = bstart; + buf_start = -1; + } +#ifdef DEBUG + printf("Track read %d,%d,%d,%d,%d,%d -> %d\n", + disk_drive,phy_c,phy_h,buf_sec+1,buf_len,buffer, rv); +#endif + } + + if( bstart == buf_start ) + return buffer + (phy_s-buf_sec) * 512; + } + + tries = 6; + do + { + if( rv && tries<0) { + int v; + printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n", + rv, disk_drive, phy_c, phy_h, phy_s+1, 1, buffer); + printf("Retry ?"); v = (getch()&0x7F); printf("\n"); + if (v == 3 || v == 27 || v == 'n' || v == 'N') + return 0; + tries = 6; + } + + if (tries == 3) _bios_disk_reset(disk_drive); + + rv = _bios_disk_read(disk_drive, phy_c, phy_h, phy_s+1, 1, buffer); + tries--; + } + while(rv); +#ifdef DEBUG + printf("Sector read %d,%d,%d,%d,%d,%d -> %d\n", + disk_drive,phy_c,phy_h,phy_s+1,1,buffer, rv); +#endif + + if(rv) return 0; else return buffer; +} diff --git a/bootblocks/bzimage.c b/bootblocks/bzimage.c index 8540cd6..d9d92bc 100644 --- a/bootblocks/bzimage.c +++ b/bootblocks/bzimage.c @@ -106,10 +106,6 @@ char * command_line; } if( main_mem_top < 3072 ) printf("RTFM warning: Linux needs at least 4MB of memory.\n"); - - len = (len+1023)/1024+1; /* Where to load the RD image (Mb) */ - if (len<6) len=6; /* Default to 6Mb mark */ - initrd_start = len * 4096; /* 256 bytes pages. */ #endif low_sects = buffer[497] + 1; /* setup sects + boot sector */ @@ -214,6 +210,7 @@ char * command_line; if( check_crc() < 0 && !keep_going() ) return -1; #endif +#ifndef NOMONITOR if( x86 < 3 || x86_emu ) { if( x86 < 3 ) @@ -222,6 +219,7 @@ char * command_line; printf("RTFM error: Linux-i386 cannot be run in an emulator.\n"); if( !keep_going() ) return -1; } +#endif printf("linux "); if( linux_command_line ) @@ -229,19 +227,6 @@ char * command_line; printf("\n"); fflush(stdout); - if( a20_closed() ) open_a20(); - if( a20_closed() ) - { - printf("Normal routine for opening A20 Gate failed, Trying PS/2 Bios\n"); - bios_open_a20(); - } - if( a20_closed() ) - { - printf("All routines for opening A20 Gate failed, if I can't open it\n"); - printf("then Linux probably can't either!\n"); - if( !keep_going() ) return -1; - } - __set_es(0x9000); /* Save pointer to command line */ @@ -690,8 +675,6 @@ unsigned int k_top; rd_start = address - rd_len*4; rd_start &= -16; /* Page boundry */ - if (initrd_start && initrd_start<rd_start) - rd_start = initrd_start; address = rd_start; printf("Loading %s at 0x%x00\n", fname, rd_start); diff --git a/bootblocks/com_bcc.s b/bootblocks/com_bcc.s deleted file mode 100644 index 061575f..0000000 --- a/bootblocks/com_bcc.s +++ /dev/null @@ -1,65 +0,0 @@ - -! This header assumes only that we're loaded at a 16 byte boundry - -ENDOFF=4 ! If you add code adjust this till it stops failing. - -org 0 -entry start -public start -start: - call chk ! This chunk allows this code to exist at _any_ click -chk: - pop ax - mov cl,#4 - shr ax,cl - mov bx,cs - add ax,bx - push ax - mov bx,#going - push bx - retf -going: - mov ds,ax - - add ax,#ENDOFF+2 ! New CS - mov bx,ax ! Saved - mov dx,[a_entry] ! Save the entry - zero - mov ax,[btype] - and ax,#$20 ! Split I/D ? - jz impure - mov cl,#4 - mov ax,[a_text] - shr ax,cl -impure: ! ax is now offset 'tween CS&DS - add ax,bx ! ax = DS - mov ss,ax - mov sp,[a_total] ! SS:SP is now ready for prog. - mov ds,ax - xor cx,cx ! argc, argv and envp = 0 - push cx - push cx - push cx - push bx ! CS - push dx ! Entry address - retf ! Gone. - -! Check for overlap -end_of_code: - if end_of_code>hitme - fail! At end_of_code - endif - -.org ((ENDOFF)<<4)-1 -hitme: -.byte 0xFF ! Marker - -magic: .space 2 ! A.out header -btype: .space 2 -headerlen: .space 4 -a_text: .space 4 -a_data: .space 4 -a_bss: .space 4 -a_entry: .space 4 -a_total: .space 4 -a_syms: .space 4 -.org (ENDOFF+2)<<4 ! Code start. diff --git a/bootblocks/crc.c b/bootblocks/crc.c deleted file mode 100644 index 88c43a5..0000000 --- a/bootblocks/crc.c +++ /dev/null @@ -1,216 +0,0 @@ - -#include <stdio.h> - -/* crctab calculated by Mark G. Mendel, Network Systems Corporation */ -static unsigned short crctab[256] = { - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, - 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, - 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, - 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, - 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, - 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, - 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, - 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, - 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, - 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, - 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, - 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, - 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, - 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, - 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, - 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, - 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, - 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, - 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, - 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, - 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, - 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, - 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 -}; - -/* - * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. - * NOTE: First srgument must be in range 0 to 255. - * Second argument is referenced twice. - * - * Programmers may incorporate any or all code into their programs, - * giving proper credit within the source. Publication of the - * source routines is permitted so long as proper credit is given - * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, - * Omen Technology. - */ - -#define updcrc(cp, crc) ( crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp) - -/* - * Copyright (C) 1986 Gary S. Brown. You may use this program, or - * code or tables extracted from it, as desired without restriction. - */ - -/* First, the polynomial itself and its table of feedback terms. The */ -/* polynomial is */ -/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ -/* Note that we take it "backwards" and put the highest-order term in */ -/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */ -/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */ -/* the MSB being 1. */ - -/* Note that the usual hardware shift register implementation, which */ -/* is what we're using (we're merely optimizing it by doing eight-bit */ -/* chunks at a time) shifts bits into the lowest-order term. In our */ -/* implementation, that means shifting towards the right. Why do we */ -/* do it this way? Because the calculated CRC must be transmitted in */ -/* order from highest-order term to lowest-order term. UARTs transmit */ -/* characters in order from LSB to MSB. By storing the CRC this way, */ -/* we hand it to the UART in the order low-byte to high-byte; the UART */ -/* sends each low-bit to hight-bit; and the result is transmission bit */ -/* by bit from highest- to lowest-order term without requiring any bit */ -/* shuffling on our part. Reception works similarly. */ - -/* The feedback terms table consists of 256, 32-bit entries. Notes: */ -/* */ -/* The table can be generated at runtime if desired; code to do so */ -/* is shown later. It might not be obvious, but the feedback */ -/* terms simply represent the results of eight shift/xor opera- */ -/* tions for all combinations of data and CRC register values. */ -/* */ -/* The values must be right-shifted by eight bits by the "updcrc" */ -/* logic; the shift must be unsigned (bring in zeroes). On some */ -/* hardware you could probably optimize the shift in assembler by */ -/* using byte-swap instructions. */ - -static long cr3tab[] = { /* CRC polynomial 0xedb88320 */ -0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, -0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, -0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, -0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, -0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, -0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, -0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, -0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, -0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, -0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, -0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, -0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, -0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, -0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, -0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, -0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, -0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, -0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, -0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, -0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, -0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, -0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, -0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, -0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, -0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, -0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, -0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, -0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, -0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, -0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, -0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, -0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -#define UPDC32(b, c) (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF)) - -int skip = 0; -int do_16 = 0; -int do_hex = 0; - -main(argc, argv) -int argc; -char ** argv; -{ - int ar; - int done = 0; - for(ar=1; ar<argc; ar++) if( argv[ar][0] == '-' ) - { - switch(argv[ar][1]) - { - case 's': do_16 = 1; break; - case 't': do_16 = 0; break; - case 'h': do_hex = 1; break; - default: - fprintf(stderr, "Usage: %s -sth +skip files\n", argv[0]); - exit(1); - } - } - else if( argv[ar][0] == '+' ) - { - skip = atoi(argv[ar]+1); - } - else - { - do_crc(argv[ar]); - done++; - } - if( done == 0 ) - { - fprintf(stderr, "Usage: %s -sth +skip files\n", argv[0]); - exit(1); - } - exit(0); -} - -do_crc(fname) -char * fname; -{ - FILE * fd; - unsigned short crc = 0; - long crc32 = -1; - int ch; - long count = 0; - - fd = fopen(fname, "r"); - if( fd == 0 ) - { - printf("%s:\tCannot open\n", fname); - exit(1); - } - - while((ch=getc(fd)) != EOF) - { - if( count >= skip ) - { - crc = updcrc(ch, crc); - crc32 = UPDC32(ch, crc32); - } - count++; - } - fclose(fd); - crc32 ^= 0xFFFFFFFF; - - printf("%-14s: %6ld CRC32=0x%08lx (%10lu)", fname, count, crc32, crc32); - printf(" CRC16=0x%04lx (%5u)\n", crc, crc); - -/* - if(do_hex) - { - if(do_16) - printf("%-14s:\t%6ld %04x\n", fname, count, crc); - else - printf("%-14s:\t%6ld %08lx\n", fname, count, crc32); - } - else - { - if(do_16) - printf("%-14s:\t%6ld %5u\n", fname, count, crc); - else - printf("%-14s:\t%6ld %10lu\n", fname, count, crc32); - } -*/ - fflush(stdout); -} - diff --git a/bootblocks/elf_info.c b/bootblocks/elf_info.c deleted file mode 100644 index 86fa392..0000000 --- a/bootblocks/elf_info.c +++ /dev/null @@ -1,189 +0,0 @@ - -#include <stdio.h> -#include "elf_info.h" - -Elf32_Ehdr elf_head; -Elf32_Phdr *elf_prog; - -#ifdef TEST -FILE *ifd; - -main(argc, argv) -int argc; -char **argv; -{ - ifd = fopen(argv[1], "r"); - if (ifd == 0) - exit(1); - - read_elfprog(); - write_ram("", -1L, 0); - - fclose(ifd); -} - -read_file(buf, offset, len) -void *buf; -long offset; -int len; -{ - fseek(ifd, offset, 0); - return fread(buf, 1, len, ifd); -} - -write_ram(buf, linear, len) -char *buf; -long linear; -int len; -{ -static long llen = 0; -static long lastlin= -1; - - if( llen > 0 && lastlin + llen != linear ) - { - printf("for %8ld bytes\n", llen); - lastlin= -1; - } - if( lastlin == -1 ) - { - lastlin = linear; - llen = 0; - - if( linear != -1 ) - printf("Write %08lx ", linear); - } - llen += len; - return len; -} - -error(str) -char *str; -{ - printf("Error: %s\n", str); - return -1; -} -#endif - -info_elf() -{ - int i; - - printf("ELF-386 executable, entry = 0x%08lx\n", elf_head.e_entry); - printf("\t\toffset paddr vaddr filesz memsz align\n"); - for (i = 0; i < elf_head.e_phnum; i++) - { - printf(" %d: ", i); - switch ((int) elf_prog[i].p_type) - { - case PT_NULL: - printf("PT_NULL"); - break; - case PT_LOAD: - printf("PT_LOAD"); - break; - case PT_DYNAMIC: - printf("PT_DYNAMIC"); - break; - case PT_INTERP: - printf("PT_INTERP"); - break; - case PT_NOTE: - printf("PT_NOTE"); - break; - case PT_SHLIB: - printf("PT_SHLIB"); - break; - case PT_PHDR: - printf("PT_PHDR"); - break; - default: - printf("PT_(%d)", elf_prog[i].p_type); - break; - } - printf("\t%08lx %08lx %08lx %08lx %08lx %08lx", - elf_prog[i].p_offset, - elf_prog[i].p_paddr, - elf_prog[i].p_vaddr, - elf_prog[i].p_filesz, - elf_prog[i].p_memsz, - elf_prog[i].p_align - ); - printf("\n"); - } -} - -read_elfprog() -{ - static unsigned char elf_ok[] = - {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ELFCLASS32, ELFDATA2LSB, EV_CURRENT}; - - int i; - char page_buf[4096]; - - if (read_file(&elf_head, 0L, sizeof(elf_head)) != sizeof(elf_head)) - return error("Can't read ELF header"); - - if (memcmp(elf_head.e_ident, elf_ok, 7) != 0 || - elf_head.e_type != ET_EXEC || - elf_head.e_machine != EM_386 || - elf_head.e_phnum <= 0 || - elf_head.e_phentsize != sizeof(Elf32_Phdr) - ) - return error("Not a 386 executable ELF program"); - - elf_prog = malloc(i = sizeof(Elf32_Phdr) * elf_head.e_phnum); - if (elf_prog == 0) - return error("Out of memory"); - - if (read_file(elf_prog, elf_head.e_phoff, i) != i) - return error("Can't read ELF program header"); - - info_elf(); - - for (i = 0; i < elf_head.e_phnum; i++) - { - long from, to, length, copied; - int chunk; - - switch ((int) elf_prog[i].p_type) - { - case PT_NULL: - case PT_NOTE: - continue; - default: - return error("ELF: Unusable program segment (Must be static)"); - case PT_LOAD: - break; - } - from=elf_prog[i].p_offset; - to=elf_prog[i].p_vaddr; - length=elf_prog[i].p_filesz; - - for(copied=0; copied<length; ) - { - if(length>copied+sizeof(page_buf)) chunk=sizeof(page_buf); - else chunk=length-copied; - - if( (chunk=read_file(page_buf, from, chunk)) <= 0 ) - return error("ELF Cannot read executable"); - if( write_ram(page_buf, to, chunk) < 0 ) - return error("Memory save failed"); - copied+=chunk; from+=chunk; to+=chunk; - } - length=elf_prog[i].p_memsz; - if( length > copied ) - { - write_ram("", -1L, 0); - memset(page_buf, '\0', sizeof(page_buf)); - for(; copied<length; ) - { - if(length>copied+sizeof(page_buf)) chunk=sizeof(page_buf); - else chunk=length-copied; - - if( write_ram(page_buf, to, chunk) < 0 ) - return error("Memory zap failed"); - copied+=chunk; to+=chunk; - } - } - } -} diff --git a/bootblocks/elf_info.h b/bootblocks/elf_info.h deleted file mode 100644 index a011d97..0000000 --- a/bootblocks/elf_info.h +++ /dev/null @@ -1,282 +0,0 @@ - -/* ELF layout information */ - -/* NOTE: I'm copying the file format information here because the _format_ - * is standard, but the Linux header files are not and may depend on - * headers not available when compiling Linux-86 code. - */ - -#ifndef _LINUX_ELF_H -#define _LINUX_ELF_H - -typedef unsigned long Elf32_Addr; -typedef unsigned short Elf32_Half; -typedef unsigned long Elf32_Off; -typedef long Elf32_Sword; -typedef unsigned long Elf32_Word; - -/* These constants are for the segment types stored in the image headers */ -#define PT_NULL 0 -#define PT_LOAD 1 -#define PT_DYNAMIC 2 -#define PT_INTERP 3 -#define PT_NOTE 4 -#define PT_SHLIB 5 -#define PT_PHDR 6 -#define PT_LOPROC 0x70000000L -#define PT_HIPROC 0x7fffffffL - -/* These constants define the different elf file types */ -#define ET_NONE 0 -#define ET_REL 1 -#define ET_EXEC 2 -#define ET_DYN 3 -#define ET_CORE 4 -#define ET_LOPROC 5 -#define ET_HIPROC 6 - -/* These constants define the various ELF target machines */ -#define EM_NONE 0 -#define EM_M32 1 -#define EM_SPARC 2 -#define EM_386 3 -#define EM_68K 4 -#define EM_88K 5 -#define EM_486 6 /* Perhaps disused */ -#define EM_860 7 - -/* This is the info that is needed to parse the dynamic section of the file */ -#define DT_NULL 0 -#define DT_NEEDED 1 -#define DT_PLTRELSZ 2 -#define DT_PLTGOT 3 -#define DT_HASH 4 -#define DT_STRTAB 5 -#define DT_SYMTAB 6 -#define DT_RELA 7 -#define DT_RELASZ 8 -#define DT_RELAENT 9 -#define DT_STRSZ 10 -#define DT_SYMENT 11 -#define DT_INIT 12 -#define DT_FINI 13 -#define DT_SONAME 14 -#define DT_RPATH 15 -#define DT_SYMBOLIC 16 -#define DT_REL 17 -#define DT_RELSZ 18 -#define DT_RELENT 19 -#define DT_PLTREL 20 -#define DT_DEBUG 21 -#define DT_TEXTREL 22 -#define DT_JMPREL 23 -#define DT_LOPROC 0x70000000L -#define DT_HIPROC 0x7fffffffL - -/* This info is needed when parsing the symbol table */ -#define STB_LOCAL 0 -#define STB_GLOBAL 1 -#define STB_WEAK 2 - -#define STT_NOTYPE 0 -#define STT_OBJECT 1 -#define STT_FUNC 2 -#define STT_SECTION 3 -#define STT_FILE 4 - -#define ELF32_ST_BIND(x) ((x) >> 4) -#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) - -/* Symbolic values for the entries in the auxiliary table - put on the initial stack */ -#define AT_NULL 0 /* end of vector */ -#define AT_IGNORE 1 /* entry should be ignored */ -#define AT_EXECFD 2 /* file descriptor of program */ -#define AT_PHDR 3 /* program headers for program */ -#define AT_PHENT 4 /* size of program header entry */ -#define AT_PHNUM 5 /* number of program headers */ -#define AT_PAGESZ 6 /* system page size */ -#define AT_BASE 7 /* base address of interpreter */ -#define AT_FLAGS 8 /* flags */ -#define AT_ENTRY 9 /* entry point of program */ -#define AT_NOTELF 10 /* program is not ELF */ -#define AT_UID 11 /* real uid */ -#define AT_EUID 12 /* effective uid */ -#define AT_GID 13 /* real gid */ -#define AT_EGID 14 /* effective gid */ - - -typedef struct dynamic{ - Elf32_Sword d_tag; - union{ - Elf32_Sword d_val; - Elf32_Addr d_ptr; - } d_un; -} Elf32_Dyn; - -extern Elf32_Dyn _DYNAMIC []; - -/* The following are used with relocations */ -#define ELF32_R_SYM(x) ((x) >> 8) -#define ELF32_R_TYPE(x) ((x) & 0xff) - -#define R_386_NONE 0 -#define R_386_32 1 -#define R_386_PC32 2 -#define R_386_GOT32 3 -#define R_386_PLT32 4 -#define R_386_COPY 5 -#define R_386_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_386_RELATIVE 8 -#define R_386_GOTOFF 9 -#define R_386_GOTPC 10 -#define R_386_NUM 11 - -typedef struct elf32_rel { - Elf32_Addr r_offset; - Elf32_Word r_info; -} Elf32_Rel; - -typedef struct elf32_rela{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} Elf32_Rela; - -typedef struct elf32_sym{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - unsigned char st_info; - unsigned char st_other; - Elf32_Half st_shndx; -} Elf32_Sym; - - -#define EI_NIDENT 16 - -typedef struct elfhdr{ - unsigned char e_ident[EI_NIDENT]; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; /* Entry point */ - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} Elf32_Ehdr; - -/* These constants define the permissions on sections in the program - header, p_flags. */ -#define PF_R 0x4 -#define PF_W 0x2 -#define PF_X 0x1 - -typedef struct elf_phdr{ - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; -} Elf32_Phdr; - -/* sh_type */ -#define SHT_NULL 0 -#define SHT_PROGBITS 1 -#define SHT_SYMTAB 2 -#define SHT_STRTAB 3 -#define SHT_RELA 4 -#define SHT_HASH 5 -#define SHT_DYNAMIC 6 -#define SHT_NOTE 7 -#define SHT_NOBITS 8 -#define SHT_REL 9 -#define SHT_SHLIB 10 -#define SHT_DYNSYM 11 -#define SHT_NUM 12 -#define SHT_LOPROC 0x70000000L -#define SHT_HIPROC 0x7fffffffL -#define SHT_LOUSER 0x80000000L -#define SHT_HIUSER 0xffffffffL - -/* sh_flags */ -#define SHF_WRITE 0x1 -#define SHF_ALLOC 0x2 -#define SHF_EXECINSTR 0x4 -#define SHF_MASKPROC 0xf0000000L - -/* special section indexes */ -#define SHN_UNDEF 0 -#define SHN_LORESERVE 0xff00L -#define SHN_LOPROC 0xff00L -#define SHN_HIPROC 0xff1fL -#define SHN_ABS 0xfff1L -#define SHN_COMMON 0xfff2L -#define SHN_HIRESERVE 0xffffL - -typedef struct { - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} Elf32_Shdr; - -#define EI_MAG0 0 /* e_ident[] indexes */ -#define EI_MAG1 1 -#define EI_MAG2 2 -#define EI_MAG3 3 -#define EI_CLASS 4 -#define EI_DATA 5 -#define EI_VERSION 6 -#define EI_PAD 7 - -#define ELFMAG0 0x7f /* EI_MAG */ -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -#define ELFCLASSNONE 0 /* EI_CLASS */ -#define ELFCLASS32 1 -#define ELFCLASS64 2 -#define ELFCLASSNUM 3 - -#define ELFDATANONE 0 /* e_ident[EI_DATA] */ -#define ELFDATA2LSB 1 -#define ELFDATA2MSB 2 - -#define EV_NONE 0 /* e_version, EI_VERSION */ -#define EV_CURRENT 1 -#define EV_NUM 2 - -/* Notes used in ET_CORE */ -#define NT_PRSTATUS 1 -#define NT_PRFPREG 2 -#define NT_PRPSINFO 3 -#define NT_TASKSTRUCT 4 - -/* Note header in a PT_NOTE section */ -typedef struct elf_note { - Elf32_Word n_namesz; /* Name size */ - Elf32_Word n_descsz; /* Content size */ - Elf32_Word n_type; /* Content type */ -} Elf32_Nhdr; - -#endif /* _LINUX_ELF_H */ diff --git a/bootblocks/i86_funcs.c b/bootblocks/i86_funcs.c index 2112141..7d010f5 100644 --- a/bootblocks/i86_funcs.c +++ b/bootblocks/i86_funcs.c @@ -1,77 +1,21 @@ #include "monitor.h" -int x86 = 0; /* CPU major number */ +#ifndef NOMONITOR +int x86 = 3; /* CPU major number */ char *x86_name = ""; /* and it's name */ int x86_emu = 0; /* Is this a PC emulator ? */ -int x86_a20_closed = 1; /* Is the A20 gate closed ? */ int x86_fpu = 0; +#endif int x86_test = 0; /* In test mode */ unsigned boot_mem_top = 0x2000; /* Default 128k, the minimum */ long main_mem_top = 0; /* K of extended memory */ -int a20_closed() -{ - register int v, rv = 0; - if (x86_test) return 1; /* If not standalone don't try */ - - __set_es(0); - v = __peek_es(512); - __set_es(0xFFFF); - if (v == __peek_es(512+16)) - { - __set_es(0); - __poke_es(512, v+1); - __set_es(0xFFFF); - if (v+1 == __peek_es(512+16)) - rv = 1; - __set_es(0); - __poke_es(512, v); - } - return x86_a20_closed = rv; -} - -static void asm_open_a20() -{ -#asm - call empty_8042 - mov al,#0xD1 ! command write - out #0x64,al - call empty_8042 - mov al,#0xDF ! A20 on - out #0x60,al -empty_8042: - .word 0x00eb,0x00eb - in al,#0x64 ! 8042 status port - test al,#2 ! is input buffer full? - jnz empty_8042 ! yes - loop, with no timeout! -#endasm -} - -void open_a20() { if(!x86_test) asm_open_a20(); } - -/* This calls the BIOS to open the A20 gate, officially this is only supported - on PS/2s but if the normal routine fails we may as well try this. - */ -void asm_bios_open_a20() -{ -#asm - mov ax,#$2401 - int $15 - jc bios_failed_a20 - xor ax,ax -bios_failed_a20: - mov al,ah - xor ah,ah -#endasm -} - -void bios_open_a20() { if(!x86_test) asm_bios_open_a20(); } - void cpu_check() { +#ifndef NOMONITOR static char *name_808x[] = { "8088", "8086", "80C88", "80C86", "NEC V20", "NEC V30", "808x Clone" @@ -107,8 +51,12 @@ void cpu_check() if (c & 0x01) x86_emu = 1; /* Already in protected mode !!! */ } -#ifdef __STANDALONE__ x86_test = x86_emu; + if (x86<3) + x86_test = 1; +#endif + +#ifdef __STANDALONE__ if (__argr.x.cflag) x86_test = 1; #else @@ -118,35 +66,27 @@ void cpu_check() void mem_check() { -#ifndef __STANDALONE__ - main_mem_top = 16384; - return; /* If not standalone don't try */ -#else + if (x86_test) { + main_mem_top = 0; + return; + } + #asm int 0x12 ! Amount of boot memory mov cl,#6 sal ax,cl ! In segments mov [_boot_mem_top],ax - ! Next check for extended - mov al,[_x86] ! If we ain't got a 286+ we can't access it anyway - cmp al,#2 - jl is_xt - - mov ah,#0x88 ! + mov ah,#0x88 ! Next check for extended int 0x15 - jnc got_ext ! Error!? This should _not_ happen ... but ... + jnc got_ext ! Error! is_xt: xor ax,ax got_ext: mov word ptr [_main_mem_top+2],#0 mov [_main_mem_top],ax - #endasm - /* Rest are big memory for 80386+ */ - if( x86 < 3 ) return; - /* Try int $15 EAX=$E820 */ { struct e820_dat { @@ -202,8 +142,6 @@ got_e820: no_e801: #endasm } - -#endif } #define RIGHTS (0x93000000L) diff --git a/bootblocks/i86_funcs.h b/bootblocks/i86_funcs.h index 2fdb860..798b827 100644 --- a/bootblocks/i86_funcs.h +++ b/bootblocks/i86_funcs.h @@ -5,16 +5,12 @@ extern int x86; /* CPU major number (0-3) */ extern char *x86_name; /* and it's name */ extern int x86_emu; /* Is this a PC emulator ? */ -extern int x86_a20_closed; /* Is the A20 gate closed ? */ extern int x86_fpu; extern int x86_test; /* Running in test mode ? */ extern unsigned boot_mem_top; /* Top of RAM below 1M */ extern long main_mem_top; /* Top of RAM above 1M */ -int a20_closed(); -void open_a20(); -void bios_open_a20(); void cpu_check(); void mem_check(); int ext_put(); diff --git a/bootblocks/li86.s b/bootblocks/li86.s deleted file mode 100644 index cabbc15..0000000 --- a/bootblocks/li86.s +++ /dev/null @@ -1,47 +0,0 @@ -!---------------------------------------------------------------------------- -! -! This is a skeleton for creating an impure Linux-8086 executable without -! using the linker. The .text and .data areas are correctly positioned. -! -! This file needs to be compiled using the 3 pass mode (-O) -! eg: as86 -O li86.s -s li86.sym -b li86.bin -! -!---------------------------------------------------------------------------- -.text -org -32 -.word 0x0301 ! Magic -.word 0x0410 ! Btype -.long 0x20 ! header length -.long _etext ! a_text -.long _edata-_etext ! a_data -.long 0 ! a_bss -.long 0 ! a_entry -.long STACK_SIZE ! a_total -.long 0 ! a_syms -.data -.blkb _etext -.even -.text -!---------------------------------------------------------------------------- - -STACK_SIZE = 0x10000 - -.data -var: -.word $1234 - -.text - int $20 - mov ax,var - mov bx,_edata - push ax - ret - -!---------------------------------------------------------------------------- -! This trailer must be at the end of the file. -.text -_etext: -.data -_edata: -END - diff --git a/bootblocks/makeboot.c b/bootblocks/makeboot.c index 77403c3..a7a02ac 100644 --- a/bootblocks/makeboot.c +++ b/bootblocks/makeboot.c @@ -9,6 +9,7 @@ #include "msdos.v" #include "msdos16.v" #include "skip.v" +#include "killhd.v" #include "tarboot.v" #include "minix.v" #include "minixhd.v" @@ -58,6 +59,9 @@ struct bblist { { "hdmin","Minix Hard disk FS booter", minixhd_data, minixhd_size, 2, minixhd_bootfile-minixhd_start, FS_ZERO}, +{ "killhd", "Deletes MBR from hard disk when booted", + killhd_data, killhd_size, + 0, 0, FS_ADOS}, #ifdef mbr_Banner { "mbr", "Master boot record for HD (with optional message)", mbr_data,mbr_size, diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s index a5e4585..a5a3923 100644 --- a/bootblocks/mbr.s +++ b/bootblocks/mbr.s @@ -394,7 +394,8 @@ diskman_magic: org ORGADDR+0x180 .asciz "ELKS MBR " .asciz "Robert de Bath," -.asciz "Copyright 1996-2000." +.asciz "Copyright " +.asciz "1996-2002. " org partition_start-1 .byte 0xFF endif diff --git a/bootblocks/min_buf.c b/bootblocks/min_buf.c deleted file mode 100644 index 75d2043..0000000 --- a/bootblocks/min_buf.c +++ /dev/null @@ -1,119 +0,0 @@ - -#include "monitor.h" - -#ifdef MINI_BUF -#ifndef MAXTRK -#define MAXTRK 21 -#endif - -int disk_drive = 0; -int disk_spt = 7; -int disk_heads = 0; -int disk_cyls = 0; -int bad_track = -1; - -static int track_no = -1; -static int buf_len = 0; -static char buffer[MAXTRK*512]; /* WARNING: This must be DMAable */ - -void reset_disk() -{ - disk_spt = 7; - disk_heads = 0; - disk_cyls = 0; - bad_track = -1; - -#ifdef __STANDALONE__ - if( disk_drive == __argr.h.dl && __argr.x.si >= 9 && __argr.x.si <= 63 ) - { - disk_spt = __argr.x.si; - disk_heads = 2; - disk_cyls = 80; - } -#endif -} - -char * read_lsector(sectno) -long sectno; -{ - int tries = 5; - int rv = 0; - - int phy_s = 1; - int phy_h = 0; - int phy_c = 0; - int ltrack; - - if( sectno == 0 || disk_heads == 0 ) reset_disk(); - if( buf_len != disk_spt ) track_no = -1; - - if( disk_spt < 1 || disk_heads < 1 ) - phy_s = sectno; - else - { - phy_s = sectno%disk_spt; - phy_h = sectno/disk_spt%disk_heads; - phy_c = sectno/disk_spt/disk_heads; - } - -#ifdef DEBUG - fprintf(stderr, "read_sector(%ld = %d,%d,%d)\n", sectno, phy_c, phy_h, phy_s); -#endif - - ltrack = phy_c*disk_heads+phy_h; - if( disk_spt > 1 && disk_spt <= MAXTRK - && track_no != ltrack && ltrack != bad_track) - { - rv = phy_read(disk_drive, phy_c, phy_h, 1, disk_spt, buffer); - if( rv == 0 ) - { - track_no = ltrack; - buf_len = disk_spt; - } - else - bad_track = ltrack; - } - if( track_no == ltrack ) - return buffer + phy_s * 512; - - do - { - rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, buffer); - tries--; - } - while(rv && tries > 0); - if( rv ) printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n", - rv, disk_drive, phy_c, phy_h, phy_s+1, 1, buffer); - - if(rv) return 0; else return buffer; -} - -#if defined(__MSDOS__) || defined(__STANDALONE__) -phy_read(drive, cyl, head, sect, length, buffer) -{ -#asm - push bp - mov bp,sp - - push ds - pop es - - mov dl,[bp+2+_phy_read.drive] - mov ch,[bp+2+_phy_read.cyl] - mov dh,[bp+2+_phy_read.head] - mov cl,[bp+2+_phy_read.sect] - mov al,[bp+2+_phy_read.length] - mov bx,[bp+2+_phy_read.buffer] - - mov ah,#$02 - int $13 - jc read_err - mov ax,#0 -read_err: - - pop bp -#endasm -} -#endif - -#endif diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c index ed823a6..acdd168 100644 --- a/bootblocks/monitor.c +++ b/bootblocks/monitor.c @@ -27,7 +27,7 @@ static char minibuf[2] = " "; struct t_cmd_list * cptr; #ifdef __STANDALONE__ - printf("\r"); + printf("\r\n"); #endif init_prog(); @@ -151,23 +151,12 @@ void init_prog() cpu_check(); mem_check(); +#ifndef NOMONITOR printf("Processor: %s", x86_name); if(x86_fpu) printf(" with FPU"); if(x86_emu) printf(" in protected mode"); - if(x86 > 1) - { - printf(", A20 gate "); - if( a20_closed() ) - { - open_a20(); - if( a20_closed() ) - printf("won't open!!"); - else - printf("is now open"); - } - else printf("is already open."); - } printf("\n"); +#endif printf("There is %u bytes available", offt-sbrk(0)); printf(", %dk of boot memory", boot_mem_top/64); diff --git a/bootblocks/monitor.h b/bootblocks/monitor.h index 9d66f95..4e499f0 100644 --- a/bootblocks/monitor.h +++ b/bootblocks/monitor.h @@ -19,9 +19,6 @@ extern union REGS __argr; #ifdef TARFLOPPY #define SINGLEFS -#define NOMONITOR -#define NOCOMMAND -#define MINI_BUF #define open_file tar_open_file #define rewind_file tar_rewind_file @@ -32,9 +29,6 @@ extern union REGS __argr; #ifdef MINFLOPPY #define SINGLEFS -#define NOMONITOR -#define NOCOMMAND -#define MINI_BUF #define open_file min_open_file #define rewind_file min_rewind_file @@ -45,10 +39,6 @@ extern union REGS __argr; #ifdef DOSFLOPPY #define SINGLEFS -#define NOMONITOR -#define NOCOMMAND -#define MINI_BUF -#define MAXTRK 24 #define open_file dos_open_file #define rewind_file dos_rewind_file @@ -57,6 +47,11 @@ extern union REGS __argr; #define read_block dos_read_block #endif +#ifdef SINGLEFS +/* #define NOCOMMAND */ +#define NOMONITOR +#endif + #ifdef __STANDALONE__ #undef putchar #define putchar putch diff --git a/bootblocks/standalone.c b/bootblocks/standalone.c deleted file mode 100644 index 8344c64..0000000 --- a/bootblocks/standalone.c +++ /dev/null @@ -1,310 +0,0 @@ - -#include <bios.h> -#include <errno.h> -#asm -entry _int_80 ! Tell ld86 we really do need this file. - ! then call the init stuff before main. - - loc 1 ! Make sure the pointer is in the correct segment -auto_func: ! Label for bcc -M to work. - .word _pre_main ! Pointer to the autorun function - .word no_op ! Space filler cause segs are padded to 4 bytes. - .text ! So the function after is also in the correct seg. -#endasm - -void int_80(); - -static void pre_main() -{ - /* Set the int 0x80 pointer to here */ - __set_es(0); - __doke_es(0x80*4+0, int_80); - __doke_es(0x80*4+2, __get_cs()); - bios_coninit(); -} - -void int_80() -{ -#asm -SYS_EXIT=1 -SYS_FORK=2 -SYS_READ=3 -SYS_WRITE=4 -SYS_OPEN=5 -SYS_CLOSE=6 -SYS_CHDIR=12 -SYS_LSEEK=19 -ENOSYS=38 - - push es - push si - push di - push dx - push cx - push bx - cmp ax,#SYS_READ - jne L1 - call _func_read - jmp L0 -L1: - cmp ax,#SYS_WRITE - jne L2 - call _func_write - jmp L0 -L2: - cmp ax,#SYS_LSEEK - jne L3 - call _func_lseek - jmp L0 -L3: - cmp ax,#SYS_EXIT - jne L4 - call _func_exit - jmp L0 -L4: - mov ax,#-ENOSYS -L0: - pop bx - pop cx - pop dx - pop di - pop si - pop es - iret -#endasm -} - -func_lseek() { return -38; } - -func_write(bx,cx,dx,di,si,es) -int bx,dx; -char * cx; -{ - register int v, c; - if(bx == 1 || bx == 2) - { - for(v=dx; v>0; v--) - { - c= *cx++; - if( c == '\n') bios_putc('\r'); - bios_putc(c); - } - return dx; - } - return -EBADF; -} - -func_read(bx,cx,dx,di,si,es) -int bx,dx; -char * cx; -{ - if(bx == 0) return read_line(cx, dx); - return -EBADF; -} - -read_line(buf, len) -char * buf; -int len; -{ - int ch; - int pos=0; - - if( len == 1 ) - { - buf[0]=((ch=bios_getc())&0xFF?ch&0xFF:((ch>>8)&0xFF|0x80)); - return 1; - } - - for(ch=0;;) - { - if(ch != '\003') - { - ch = bios_getc(); - if( pos == 0 && (ch&0xFF) == 0 ) - { - buf[0] = ((ch>>8)|0x80); - return 1; - } - ch &= 0x7F; - } - if( ch == '\r' ) - { - bios_putc('\r'); bios_putc('\n'); - buf[pos++] = '\n'; - return pos; - } - if( ch >= ' ' && ch != 0x7F && pos < len-1) - bios_putc(buf[pos++] = ch); - else if( (ch == '\003' || ch == '\b') && pos > 0 ) - { - bios_putc('\b'); bios_putc(' '); bios_putc('\b'); - pos--; - } - else if( ch == '\003' ) - return 0; - else - bios_putc('\007'); - } -} - -#define CTRL(x) ((x)&0x1F) -static int last_attr = 0x07; -static int con_mode; -static int con_size = 0x184F; -static int con_colour = 0; - -bios_coninit() -{ -#asm - mov ax,#$0F00 - int $10 - mov _con_mode,ax -#endasm - if( (con_mode &0xFF) > 39 ) con_size = (con_size&0xFF00) + (con_mode&0xFF); - if( (con_mode&0xFF00) != 0x700) - con_colour = 1; -} - -bios_putc(c) -int c; -{ -static char tbuf[3]; -static int tcnt=0; - if(tcnt) - { - tbuf[tcnt++] = c; - if( tcnt < 3 && (tbuf[0] != CTRL(']') || tbuf[1] < '`' || tbuf[1] > 'p')) - return; - if( tbuf[0] == CTRL('P') ) - { - if( tbuf[1] >= 32 && tbuf[1] <= 56 - && tbuf[2] >= 32 && tbuf[2] <= 111 ) - asm_cpos((tbuf[1]-32), (tbuf[2]-32)); - } - else - { - if( tbuf[1] >= '`' ) - last_attr = ( (tbuf[1]&0xF) | (last_attr&0xF0)); - else - last_attr = ( (tbuf[2]&0xF) | ((tbuf[1]&0xF)<<4)); - - if( !con_colour ) - last_attr = (last_attr&0x88) + ((last_attr&7)?0x07:0x70); - } - tcnt=0; - return; - } - if( c & 0xE0 ) { asm_colour(last_attr) ; asm_putc(c); } - else switch(c) - { - case CTRL('L'): - asm_cpos(0,0); - asm_cls(); - break; - case CTRL('P'): - case CTRL(']'): - tbuf[tcnt++] = c; - break; - default: - asm_putc(c); - break; - } - return; -} - -static asm_putc(c) -{ -#asm -#if !__FIRST_ARG_IN_AX__ - mov bx,sp - mov ax,[bx+2] -#endif - mov ah,#$0E - mov bx,#7 - int $10 -#endasm -} - -static asm_colour(c) -{ -#asm -#if __FIRST_ARG_IN_AX__ - mov bx,ax -#else - mov bx,sp - mov bx,[bx+2] -#endif - mov ah,#$08 - int $10 - mov ah,#$09 - mov cx,#1 - int $10 -#endasm -} - -static asm_cls() -{ -#asm - push bp ! Bug in some old BIOS's - !mov ax,#$0500 - !int $10 - mov ax,#$0600 - mov bh,_last_attr - mov cx,#$0000 - mov dx,_con_size - int $10 - pop bp -#endasm -} - -static asm_cpos(r,c) -{ -#asm -#if __FIRST_ARG_IN_AX__ - mov bx,sp - mov dh,al - mov ax,[bx+2] - mov dl,al -#else - mov bx,sp - mov ax,[bx+2] - mov dh,al - mov ax,[bx+4] - mov dl,al -#endif - mov ah,#$02 - mov bx,#7 - int $10 -#endasm -} - -bios_getc() -{ -#asm - xor ax,ax - int $16 -#endasm -} - -static void be_safe() -{ -#asm - iret -#endasm -} - -func_exit(bx,cx,dx,di,si,es) /* AKA reboot! */ -{ - __set_es(0); - __doke_es(0xE6*4+2,__get_cs()); - __doke_es(0xE6*4+0,be_safe); -#asm - mov ax,#$FFFF - int $E6 ! Try to exit DOSEMU - mov ax,#$0040 ! If we get here we're not in dosemu. - mov es,ax - seg es - mov [$72],#$1234 ! Warm reboot. - jmpi $0000,$FFFF -#endasm -} diff --git a/bootblocks/tich.s b/bootblocks/tich.s deleted file mode 100644 index ce21e4a..0000000 --- a/bootblocks/tich.s +++ /dev/null @@ -1,39 +0,0 @@ -! - -org 0 - call chk !This chunk allows this code to exist at _any_ click -chk: - pop ax - mov cl,#4 - shr ax,cl - mov bx,cs - add ax,bx - push ax - mov bx,#going - push bx - retf -going: - mov ds,ax - mov es,ax - -! Print 'mesg' - mov ah,#0x03 ! read cursor pos - xor bh,bh - int 0x10 - - mov cx,#(emesg-mesg) - mov bp,#mesg - mov bx,#$7 ! page 0, attribute 7 (normal) - mov ax,#$1301 ! write string, move cursor - int $10 - -nogood: - j nogood - -mesg: -.ascii "Hello world" -emesg: - -! Floppies aren't supposed to need this, oh well. -org 510 - .word $AA55 diff --git a/bootblocks/trk_buf.c b/bootblocks/trk_buf.c deleted file mode 100644 index cfa1e93..0000000 --- a/bootblocks/trk_buf.c +++ /dev/null @@ -1,390 +0,0 @@ - -#include "monitor.h" - -#ifndef MINI_BUF - -/* #define DEBUG 1 /**/ - -int disk_drive = 0; -int disk_spt = 7; -int disk_heads = 0; -int disk_cyls = 0; -long disk_partition_offset = 0; - -int check_motor = 1; - -static int last_drive = -1; -static int data_len = 0; -static long data_trk1 = 0; -static char * data_buf1 = 0; -static long data_trk2 = 0; -static char * data_buf2 = 0; - -static long bad_track = -1; /* Track number of last unsuccesful read */ - -static long get_dpt(); - -void reset_disk() -{ -#ifdef DEBUG - fprintf(stderr, "Reset Disk: "); -#endif - if( data_buf1 ) free(data_buf1); - if( data_buf2 ) free(data_buf2); - data_buf1 = data_buf2 = 0; - last_drive = disk_drive; - bad_track = -1; - - disk_spt = 7; /* Defaults for reading floppy boot area. */ - disk_heads = 0; - disk_cyls = 0; - - if( !(disk_drive & 0x80 ) ) - { -#ifdef __STANDALONE__ - if( disk_drive == __argr.h.dl && __argr.x.si >= 9 && __argr.x.si <= 63 ) - { - disk_spt = __argr.x.si; - disk_heads = 2; - disk_cyls = 80; - } -#endif - - /* Floppy -> no partitions */ - /* Even if there were we couldn't deal with it anyway! */ - disk_partition_offset = 0; - } -#if defined(__MSDOS__) || defined(__STANDALONE__) - else - { - /* Hard disk, get parameters from bios */ - long dpt; - int v; - -#ifdef __STANDALONE__ - if( disk_partition_offset == 0 && disk_drive == __argr.h.dl ) - { - disk_partition_offset = __argr.x.cx + ((long)__argr.h.dh<<16); - } -#endif - - dpt = get_dpt(disk_drive); - v = ((dpt>>16) & 0xFF); - if( v != 0xFF && v > (disk_drive&0x7F) ) - { - disk_spt = (dpt & 0x3F); /* Max sector number 1-63 */ - if( disk_spt == 0 ) disk_spt = 64; /* 1-64 ? */ - disk_heads = ((dpt>>24) & 0xFF) + 1; /* Head count 1-256 */ - disk_cyls = ((dpt>>8) & 0xFF) + ((dpt<<2) & 0x300) + 1; - - /* Cyls count, unchecked, only needs != 0, if AMI 386 bios can be - * upto 4096 cylinder, otherwise BIOS limit is 1024 cyl. - */ - } - } -#endif - -#ifdef DEBUG - fprintf(stderr, "%d/%d/%d\n", disk_spt, disk_heads, disk_cyls); -#endif -} - -char * read_lsector(sectno) -long sectno; -{ - int rv; - - int phy_s = 1; - int phy_h = 0; - int phy_c = 0; - - rv = 0; - if( disk_drive != last_drive ) rv = 1; - else if( check_motor ) rv = ( motor_running() == 0 ); - else if( sectno == 0 ) rv = 1; - if( rv ) reset_disk(); - - if( disk_partition_offset > 0 ) - sectno += disk_partition_offset; - - if( disk_spt < 0 || disk_spt > 63 || disk_heads < 1 ) - { - phy_s = sectno; -#if DEBUG > 1 - fprintf(stderr, "read_sector(%ld = %d,%d,%d)\n", - sectno, phy_c, phy_h, phy_s+1); -#endif - } - else - { - phy_s = sectno%disk_spt; - phy_h = sectno/disk_spt%disk_heads; - phy_c = sectno/disk_spt/disk_heads; - -#if DEBUG > 1 - fprintf(stderr, "read_sector(%ld = %d,%d,%d)\n", - sectno, phy_c, phy_h, phy_s+1); -#endif - - if( fetch_track_buf(phy_c, phy_h, phy_s) >= 0 ) - return data_buf1 + (phy_s % data_len) * 512; - } - - data_len = -1; /* Zap the cache */ - if( data_buf1 == 0 ) - data_buf1 = malloc(512); - if( data_buf1 == 0 ) - { - printf("Cannot allocate memory for disk read!!!\n"); - return 0; - } - -#ifdef DEBUG - fprintf(stderr, "phy_read(%d,%d,%d,%d,%d,0x%x)\n", - disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1); -#endif - - do - { - int v,tries = 6; - do - { - rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1); - tries--; - } - while(rv && tries > 0); - if( rv ) - { - printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\nRetry:", - rv, disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1); - fflush(stdout); - - v = phy_reset(disk_drive); - v = (getch()&0x7F); - printf("\n"); - if( v == 3 || v == 27 ) break; - } - } - while(rv); - - check_motor = motor_running(); - - if(rv) return 0; else return data_buf1; -} - -fetch_track_buf(phy_c, phy_h, phy_s) -int phy_c, phy_h, phy_s; -{ - long trk_no, t; - char * p; - int tries = 6; - int rv, nlen; - - /* Big tracks get us short of memory so limit it. */ - nlen = (disk_spt-1)/24; - nlen = (disk_spt+nlen)/(nlen+1); - /* - trk_no = (long)phy_c*disk_heads*4+phy_h*4+phy_s/nlen+1; - */ - - trk_no = (long)(phy_c*disk_heads+phy_h)*((disk_spt+4)/nlen)+phy_s/nlen+1; - -#if DEBUG > 2 - fprintf(stderr, "Info len=%d,%d trk=%ld,%ld,%ld\n", - data_len,nlen, trk_no,data_trk1,data_trk2); -#endif - - if( data_len != nlen ) - { - if( data_buf1 ) free(data_buf1); - if( data_buf2 ) free(data_buf2); - data_buf1 = data_buf2 = 0; - data_len = nlen; - } - if( trk_no == bad_track ) return -1; - - if( data_buf1 && trk_no == data_trk1 ) return 0; - - /* Two cases: - * 1) buffer2 has the one we want, need to swap to make it most recent - * 2) Neither has it, need to swap to overwrite least recent. - */ - - /* But sequential reads may spoil this so don't swap if we are shifting - * to the next track. - */ - - if( trk_no == data_trk2 || trk_no != data_trk1 + 1 ) - { - p = data_buf1; data_buf1 = data_buf2; data_buf2 = p; - t = data_trk1; data_trk1 = data_trk2; data_trk2 = t; - } - - /* The other one right ? */ - if( data_buf1 && trk_no == data_trk1 ) return 0; - - /* If we get here we have to do a physical read ... */ - /* into data_buf1. */ - - if( data_buf1 == 0 ) - { - data_buf1 = malloc(disk_spt*512); - -#ifdef DEBUG - if( data_buf1 ) - fprintf(stderr, "Allocated buffer to %d\n", data_buf1); - else - fprintf(stderr, "Failed to allocated buffer.\n"); -#endif - } - if( data_buf1 == 0 ) - { - /* Is buf2 allocated ? Yes take it! */ - data_buf1 = data_buf2; data_buf2 = 0; data_trk2 = -1; - } - - data_trk1 = -1; - - /* Not enough memory for track read. */ - if( data_buf1 == 0 ) return -1; - -#ifdef DEBUG - fprintf(stderr, "phy_read(%d,%d,%d,%d,%d,0x%x)\n", - disk_drive, phy_c, phy_h, phy_s/data_len*data_len+1, data_len, data_buf1); -#endif - - do /* the physical read */ - { - rv = phy_read(disk_drive, phy_c, phy_h, phy_s/data_len*data_len+1, data_len, - data_buf1); - tries--; - } - while(rv && tries > 0); - if( rv ) printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n", - rv, disk_drive, phy_c, phy_h, phy_s/data_len+1, data_len, data_buf1); - - check_motor = motor_running(); - - /* Disk error, it'll try one at a time, _very_ slowly! */ - if(rv) - { - bad_track = trk_no; - return -1; - } - - /* Yes! */ - data_trk1 = trk_no; - return 0; -} - -#if defined(__MSDOS__) || defined(__STANDALONE__) -phy_read(drive, cyl, head, sect, length, buffer) -{ -#asm - push bp - mov bp,sp - - push es - push ds - pop es - - mov dl,[bp+2+_phy_read.drive] - mov ch,[bp+2+_phy_read.cyl] - mov dh,[bp+2+_phy_read.head] - mov bx,[bp+2+_phy_read.buffer] - - mov ax,[bp+2+_phy_read.cyl] ! Bits 10-11 of cylinder, AMI BIOS. - mov cl,#4 - sar ax,cl - and al,#$C0 - xor dh,al - - mov cl,[bp+2+_phy_read.sect] - and cl,#$3F - mov ax,[bp+2+_phy_read.cyl] ! Bits 8-9 of cylinder. - sar ax,#1 - sar ax,#1 - and al,#$C0 - or cl,al - - mov al,[bp+2+_phy_read.length] - mov ah,#$02 - int $13 - jc read_err - mov ax,#0 -read_err: - xchg ah,al - xor ah,ah - - pop es - pop bp -#endasm -} - -long -get_dpt(drive) -{ -#asm - push bp - mov bp,sp - - push di - push es - - mov dl,[bp+2+_get_dpt.drive] - - mov ah,#$08 - int $13 - jnc func_ok - mov cx,ax - mov dx,#-1 -func_ok: - mov ax,cx - - pop es - pop di - pop bp -#endasm -} - -phy_reset(drive) -{ -#asm - push bp - mov bp,sp - - push di - push es - - mov dl,[bp+2+_phy_reset.drive] - - mov ah,#$08 - int $13 - jnc reset_ok - mov cx,ax - mov dx,#-1 -reset_ok: - mov ax,cx - - pop es - pop di - pop bp -#endasm -} - -motor_running() -{ -#asm - push es - mov ax,#$40 - mov es,ax - seg es - mov al,[$3f] - xor ah,ah - and al,#$0F - pop es -#endasm -} -#endif - -#endif |