diff options
Diffstat (limited to 'sys/i386/boot')
27 files changed, 0 insertions, 6465 deletions
diff --git a/sys/i386/boot/README.386BSD b/sys/i386/boot/README.386BSD deleted file mode 100644 index cc5cb8fe2fbc..000000000000 --- a/sys/i386/boot/README.386BSD +++ /dev/null @@ -1,151 +0,0 @@ -This Boot code is different from the original boot code that came with -386BSD in that it uses the BIOS to load the kernel and to provide all i/o -services. The advantage ofthis is that the same boot code exactly, can run -on any device that is supported by the BIOS. (That's most of them) -This is important for the 'generic scsi' project because it means we can -write drivers for new scsi adapters without having to develop an new -set of boot blocks for each. - -At this point you should read the first part of README.MACH... come back here -when you have done that: - -In normal operation, when co-existing with other operating systems, the -following operations occur: - -1/ the BIOS loads the first block of the disk (called the Master Boot Record -or MBR) and if it has the correct magic numbers, jumps into it: - -2/ The MBR code, looks at the Partition table that is embedded within it, -to detirmine which is the partition to boot from. If you are using the os-bs -bootblocks (highly recommended) then it will give you a menu to choose from. - -3/ The MBR will load the first record of the selected partition and -if it has (the same) magic numbers, jumps into it. In 386bsd this is the -first stage boot, (or boot1) it is represented in /usr/mdec by -wdboot, asboot and sdboot. If the disk has been set up without DOS partitioning -then this block will be at block zero, and will have been loaded directly by -the BIOS. - -4/ Boot1 will look at block0 (which might be itself if there are no DOS -partitions) and will find the 386bsd partition, and using the information -regarding the start position of that partition, will load the next 13 sectors -or so, to around 90000 (640k - 64k). and will jump into it at the appropriate -entry point. Since boot1 and boot2 were compiled together as one file -and then split later, boot1 knows the exact position within boot2 of the -entry point. - -Boot 1 also contains a compiled in DOS partition table -(in case it is at block 0), which contains a 386bsd partition starting -at 0. This ensures that the same code can work whether or not -boot1 is at block 0. - -5/ Boot2 asks the user for a boot device, partition and filename, and then -loads the MBR of the selected device. This may or may not be the device -which was originally used to boot the first MBR. The partition table -of the new MBR is searched for a 386bsd partition, and if one is found, -that is then in turn searched for the disklabel. This could all be on the -second disk at this point, if the user selected it. - -6/On finding the disklabel, boot2 can find the correct unix partition -within the 386bsd partition, and using cutdown filesystem code, -look for the file to boot (e.g. 386bsd). - -7/ Boot2 loads this file starting at the location specified by the a.out header, -(see later) and leaps into it at the location specified in he header. - -if the file does not exist or cannot be loaded, boot2 goes back to step 5. - -386bsd is now running and will hopefully start vm etc. and get to multi-user -mode. - -########################################################################## -During all these steps, all i/o is performed using the BIOS. This has a number -of side effects: - -1/ Since BIOS disk calls are specified in terms of cylinder,head and sector, -and the BIOS read the disk information from either the CMOS or from some other -location which is un-available to us, we must use the cyl,head,sec information -that is given in the MBR, rather than the start address in the MBR, because -we cannot guarentee that we can corectly calculate C,H,S from the start address. - -Therefore, the C,H,S information in the MBR must be as correct for this boot -to work as it would be for DOS to boot. For example, adaptec BIOS routines -assume a layout of 64 heads and 32 sectors giving 1MB per ficticious cylinder. -You must use these figures to calculate the correct values. Luckily, the DOS -fdisk program will do all this for you if you tell it to give you a DOS -partition, and you can change it to a 386BSD partition later. If you use -no DOS partitioning, then the compiled in table in Boot1 will do just fine. - -If you want to do it by hand remember that BIOS counts sectors starting at 1. -(cylinders and heads start at 0 (??)) - -2/ you cannot overwrite the bottom 4k of ram until you have finished ALL -bios calls, as BIOS uses this area as scratch memory. - -3/ Since BIOS runs in REAL mode, and Boot2 runs in protected mode, -Boot 2 switches back to real mode just before each BIOS call and then -back to protected mode on each return. Touch this at your peril.! - -######################################################################### -In answering the prompt from Boot2: -you can, -1/ leave it alone.. it will boot the indicated file from the first -partition of the first drive seen by the BIOS (C:) - -2/ enter only "-s" to boot the default to single user mode - -3/ enter only a filename (optionally with -s) to boot that kernel, - -4/ enter a whole line of the form shown in the prompt. This allows you to -boot some other partition, possibly on the second drive, as root. - - -########################################################################## -In the case you have two drives the same type (both scsi or bith IDE/ESDI), -wd(0,a)xxx - will boot xxx from drive 0, a partition. -wd(1,a)xxx - will boot xxx from drive 1, a partition. - -similarly for sd. - -if you have one wd drive and one scsi drive, then you MUST -use device 'hd' - -otherwise the following will happen: - -with wd0 and sd0, you specify sd1 or wd1 to indicate the 2nd drive. -it boots the kernel correctly, then tells the kernel to use sd1 as root. -you however may not have an sd1, and problems arise. - -hd is special in that the kernel is always told to use unit 0, -The correct TYPE of device will be specified too, so the kernel -will be told either sd0 or wd0. - -Whether sd or wd is specified to the kernel is read from the disklabel, -so ensure that all SCSI disks have type SCSI in their disklabel or the -boot code will assume they are ESDI or IDE. (Remember, because it is -working through the BIOS it has ho idea what kind of disk it is. - -########################################################################## -Installing: -The makefile supplied has a target install which will create the -files wdboot,bootwd ,sdboot and bootsd in /usr/mdec. -BEWARE these will overwrite the existing wdboot and bootwd. (so back -them up) - -there are also targets wd and sd which wil only do one of them - -The commented out targets wd0 and sd0 are examples of how to -load the new bootblocks, however,make sure you change the -device type and label to suit your drive if you uncomment them. -(see 'man disklabel') - -If you already have made partitions using the old bootblocks -these should install painlessly. - -Before you do this ensure you have a booting floppy with correct -disktab and bootblock files on it so that if it doesn't work, you can -re-disklabel from the floppy. - -$Id$ diff --git a/sys/i386/boot/README.MACH b/sys/i386/boot/README.MACH deleted file mode 100644 index cb6232936e28..000000000000 --- a/sys/i386/boot/README.MACH +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:33:55 rpd - * $Id$ - */ - -********NOTE: This is not all relevant to the 386BSD version********** - - AT386 Protected Mode Bootstrap Loader - ===================================== - -1. Overview of Startup - ------------------- - - After the system is rebooted, the BIOS bootstrap routine reads Sector - 1, Track 0 into memory at location 0000:7C00H. If location 0000:7DFEH - (last two bytes of that sector) contains the value AA55H, the BIOS - bootstrap routine will transfer control to 0000:7C00H. Otherwise, the - boot code in that sector is bad and the boot routine stops. - - For DOS compatibility reason, one extra stage of boot is required if - the boot device is a hard disk. The first sector of the hard disk will - contain the MOS-DOS boot code and a boot record partition table. - When this sector is loaded into 0000:7C00H, it will relocate itself - to somewhere else and then load the first sector of the active - partition into 0000:7C00H. Both UNIX and DOS use the command "fdisk" -[ 386bsd does not have an 'fdisk' (yet) ] - to install this first sector into the hard disk and to manipulate - the hard disk partitions. - - - -2. The First Stage Bootstrap Loader - -------------------------------- - - After startup, the first stage boot is loaded at 0000:7C00H. This - first stage boot will load itself and the second stage boot into - memory at location 0000:1000H. For floppy disks, the first cylinder - is reserved as the boot cylinder, and the boot code (first and second) - will be loaded from there. Currently, only double sided, high density - (15 sectors per track) floppies are supported. For hard disks, the - first 29 sectors of the active partition is reserved for boot code - which will be loaded by the first stage boot. All the disk types - recognized by BIOS are supported by this bootstrap loader. -[for 386bsd we load the second stage booter to 9000:0] - - - -3. The Second Stage Bootstrap Loader - -------------------------------- - - After the boot code is loaded, the control is passed to the second - stage bootstrap loader "boot2()". In order to be able to load the - big kernel image (bigger than 512K or 640K, depends on the memory - configuration), the second stage boot loader will run on the protected - mode. This bootstarp loader does not have any stand alone device - drivers, all the I/O's are through the BIOS calls. Since the first - stage boot code will no longer be used at this moment, the memory - location of the first stage boot code (0000:1000H to 0000:1200H) will - be used as an internal buffer for BIOS calls. Immediately after this - internal buffer is the GDT table for the second stage boot loader. - Since this boot loader needs to switch back and forth between protected - and real mode in order to use BIOS calls, the limit of the boot code - and boot data segments must not be greater than 64K. - - The boot loader loads the kernel image at memory location above 1 MB - to skip the memory hole between 521K/640K and 1MB. After the kernel - is loaded, the boot loader stores the information in the stack and - then passes control to kernel. Currently, the three information passed - fromm the boot loader to the kernel are type of the boot device, size - of the base memory and size of the extended memory. - -[ 386bsd receives: howto, bootdev] - -[ 386bsd is loaded where-ever the "MByte" bits of the load address specify, -so if you link it for FE100000 it will load to 1MB, but if you link -it for FE000000 it will load ad 0MB] - -[for machines with only 512KB normal ram the kernel will need to be linked -for 1MB and the bootblocks modified to run below 512KB. (8000:0)] - - -4. The UNIX Startup - ---------------- - - Since the boot loader loads the kernel image at memory location above - 1MB, the kernel has to start as protected mode. In addition, the - link editor description file (vuifile) has to indicate that - the text and data segments start above 1MB. Also, the boot loader - passes the infomation to the kernel through the stack. - -[MOST of what is mentionned below is NOT relevant to 386bsd] - -5. Disk Layout and Bad Block Handling - --------------------------------- - - The System V/386 Release 3.2 (AT) disk layout will be used as the disk - layout for the MACH System on the AT platform. - - This disk layout is as follows: - - * Reserve the first sector of cylinder 0 for the DOS boot record which - contains the master boot code (446 bytes) and the partition table. - (Refer to DOS Technical Reference Manual page 9-6 to 9-10). - - * Reserve the first 29 sectors of the UNIX partition for the first - and the second stage bootstrap. - - * Reserve the 30th sector of the UNIX partition for the pdinfo and - the vtoc tables. - - * Reserve the 31st to the 34th sectors of the UNIX partition for the - bad track and the bad block mapping tables. - - * Reserve up to 253 consecutive tracks when required, beginning with - the 35th sector of the UNIX partition, for alternate tracks. - - * Reserve up to 253 consecutive blocks, beginning with the first - sector after the alternate tracks area, for alternate blocks. - - SEC - 1 - ---------------------------------------------------- - | X | | CYL 0, TRK 0 - ---------------- .......... -------------------- - | .......... | - ---------------- .......... -------------------- - | .......... | - =============================================================== - ^ | BOOTSTRAP | CYL N, TRK M - | ---------------------------------------------------- - | | |30 |31 |32 |33 |34 | - ---------------------------------------------------- --- - U | .......... | ^ - N ---------------- .......... --------------------- | - I | .......... | Alternate Tracks - X ---------------- .......... --------------------- | - | .......... | V - P ---------------------------------------------------- --- - A | .......... | ^ - R ---------------- .......... --------------------- | - T | .......... | Alternate Blocks - I ---------------- .......... -------------------- | - T | .......... | V - I ---------------------------------------------------- --- - O | Unix root partition starts from here | - N ---------------- ----------------- - | | - ---------------------------------------------------- - | | - ---------------------------------------------------- - | | - | --------------------------------------------------- - | | | - | ---------------------------------------------------- - V | | - =============================================================== - | ........ | - --------------- ........ -------------- - | ........ | - ---------------------------------------------------- - - - The bad block handling mechanism is as follows: - - * Use the alternate track in the alternate tracks area if the - track containing the target sector is bad. - - * Use the alternate block in the alternate blocks area if the - target sector is bad. - - - - -6. How to make: - ----------- - - Since the kernel image is loaded above 1 MB, the kernel must start - as protected mode. This means that this bootstrap loader will work - only when the corresponding changes on the kernel startup code are done. - - The make command to generate this bootstrap loader is: - - make -f boot.mk fdboot (floppy boot loader) - make -f boot.mk hdboot (wini boot loader) -[to make 386bsd bootblocks "make sd wd" (warning: they will be installed -in /dev/mdec.. take backups)] diff --git a/sys/i386/boot/asm.S b/sys/i386/boot/asm.S deleted file mode 100644 index 90f523f4425a..000000000000 --- a/sys/i386/boot/asm.S +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:13 rpd - * $Id: asm.S,v 1.4 1994/10/02 05:18:24 rgrimes Exp $ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "asm.s" - -#include "asm.h" - - -CR0_PE_ON = 0x1 -CR0_PE_OFF = 0xfffffffe - -.globl _ouraddr - .text - -/* - * - * real_to_prot() - * transfer from real mode to protected mode. - */ - -ENTRY(real_to_prot) - /* guarantee that interrupt is disabled when in prot mode */ - cli - - /* load the gdtr */ - addr32 - data32 - lgdt EXT(Gdtr) - - /* set the PE bit of CR0 */ - mov %cr0, %eax - - data32 - or $CR0_PE_ON, %eax - mov %eax, %cr0 - - /* - * make intrasegment jump to flush the processor pipeline and - * reload CS register - */ - data32 - ljmp $0x18, $xprot - -xprot: - /* - * we are in USE32 mode now - * set up the protected mode segment registers : DS, SS, ES - */ - mov $0x20, %eax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - -#ifdef BDE_DEBUGGER - /* load idtr so we can debug */ - lidt EXT(Idtr_prot) -#endif - - ret - -/* - * - * prot_to_real() - * transfer from protected mode to real mode - * - */ - -ENTRY(prot_to_real) - - /* set up a dummy stack frame for the second seg change. */ - movl _ouraddr, %eax - sarl $4, %eax - pushw %ax - movw $xreal, %ax /* gas botches pushw $xreal, extra bytes 0, 0 */ - pushw %ax /* decode to add %al, (%eax) (%al usually 0) */ - - /* Change to use16 mode. */ - ljmp $0x28, $x16 - -x16: - /* clear the PE bit of CR0 */ - mov %cr0, %eax - data32 - and $CR0_PE_OFF, %eax - mov %eax, %cr0 - - /* - * make intersegment jmp to flush the processor pipeline - * using the fake stack frame set up earlier - * and reload CS register - */ - lret - -xreal: - /* - * we are in real mode now - * set up the real mode segment registers : DS, SS, ES - */ - movw %cs, %ax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - -#ifdef BDE_DEBUGGER - /* load idtr so we can debug */ - addr32 - data32 - lidt EXT(Idtr_real) -#endif - - data32 - ret - -/* - * startprog(phyaddr) - * start the program on protected mode where phyaddr is the entry point - * - * XXX This whole mess should go away and we should run the boot code in - * flat 32 bit mode with it linked -T BOOTSEG. See the netboot code for - * how this is done. - */ - -ENTRY(startprog) - push %ebp - mov %esp, %ebp - movl %esp, %eax /* Use eax as the old stack pointer */ - - /* convert the current stack to a 32 bit flat model */ - mov $0x10, %ebx - movw %bx, %ss - addl $(BOOTSEG<<4),%esp - - /* copy the arguments from the old stack to the new stack */ - pushl 0x14(%eax) /* &bootinfo */ - pushl $0 /* was &nfsdiskless */ - pushl $0 /* was esym */ - pushl $0 /* was cyloffset */ - pushl 0x10(%eax) /* bootdev */ - pushl 0x0C(%eax) /* howto */ - movl $(ourreturn),%ebx - addl $(BOOTSEG<<4),%ebx /* Fix it up for flat segments */ - pushl %ebx /* our return address */ - - /* push on our entry address */ - pushl $0x08 /* segment selector */ - pushl 0x08(%eax) /* kernel entry address */ - - /* convert over the other data segs */ - mov $0x10, %ebx - movw %bx, %ds - movw %bx, %es - - /* convert the PC (and code seg) */ - lret -ourreturn: - /* For now there is not much we can do, just lock in a loop */ - jmp ourreturn - -/* - * - * pbzero( dst, cnt) - * where src is a virtual address and dst is a physical address - */ - -ENTRY(pbzero) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - /* set %es to point at the flat segment */ - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %edi /* destination */ - mov 0xc(%ebp), %ecx /* count */ - mov $0x0, %eax /* value */ - - rep - stosb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret -/* - * pcpy(src, dst, cnt) - * where src is a virtual address and dst is a physical address - */ - -ENTRY(pcpy) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - /* set %es to point at the flat segment */ - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %esi /* source */ - mov 0xc(%ebp), %edi /* destination */ - mov 0x10(%ebp), %ecx /* count */ - - rep - movsb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret - diff --git a/sys/i386/boot/asm.h b/sys/i386/boot/asm.h deleted file mode 100644 index 43242bdec0fa..000000000000 --- a/sys/i386/boot/asm.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.7 92/02/29 15:33:41 rpd - * $Id$ - */ - -#define S_ARG0 4(%esp) -#define S_ARG1 8(%esp) -#define S_ARG2 12(%esp) -#define S_ARG3 16(%esp) - -#define FRAME pushl %ebp; movl %esp, %ebp -#define EMARF leave - -#define B_ARG0 8(%ebp) -#define B_ARG1 12(%ebp) -#define B_ARG2 16(%ebp) -#define B_ARG3 20(%ebp) - -#ifdef wheeze - -#define ALIGN 4 -#define EXT(x) x -#define LEXT(x) x: -#define LCL(x) ./**/x - -#define LB(x,n) ./**/x -#define LBb(x,n) ./**/x -#define LBf(x,n) ./**/x - -#define SVC lcall $7,$0 - -#define String .string -#define Value .value -#define Times(a,b) [a\*b] -#define Divide(a,b) [a\\b] - -#define INB inb (%dx) -#define OUTB outb (%dx) -#define INL inl (%dx) -#define OUTL outl (%dx) - -#else wheeze -#define ALIGN -#define LCL(x) x - -#define LB(x,n) n -#ifdef __STDC__ -#define EXT(x) _ ## x -#define LEXT(x) _ ## x ## : - -#define LBb(x,n) n ## b -#define LBf(x,n) n ## f -#else __STDC__ -#define EXT(x) _/**/x -#define LEXT(x) _/**/x/**/: -#define LBb(x,n) n/**/b -#define LBf(x,n) n/**/f -#endif __STDC__ -#define SVC .byte 0x9a; .long 0; .word 0x7 - -#define String .ascii -#define Value .word -#define Times(a,b) (a*b) -#define Divide(a,b) (a/b) - -#define INB inb %dx, %al -#define OUTB outb %al, %dx -#define INL inl %dx, %eax -#define OUTL outl %eax, %dx - -#endif wheeze - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -#ifdef GPROF -#ifdef __STDC__ - -#define MCOUNT .data; LB(x, 9); .long 0; .text; lea LBb(x, 9),%edx; call mcount -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ASENTRY(x) .globl x; .align ALIGN; x ## : ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; - -#else __STDC__ - -#define MCOUNT .data; LB(x, 9): .long 0; .text; lea LBb(x, 9),%edx; call mcount -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x: ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; - -#endif __STDC__ -#else GPROF -#ifdef __STDC__ - -#define MCOUNT -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x ## : - -#else __STDC__ - -#define MCOUNT -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x: - -#endif __STDC__ -#endif GPROF - -#define Entry(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define DATA(x) .globl EXT(x); .align ALIGN; LEXT(x) diff --git a/sys/i386/boot/asm.s b/sys/i386/boot/asm.s deleted file mode 100644 index 8802b13f6d32..000000000000 --- a/sys/i386/boot/asm.s +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - * HISTORY - * $Log: asm.s,v $ - * Revision 2.2 92/04/04 11:34:13 rpd - * Fix Intel Copyright as per B. Davies authorization. - * [92/04/03 rvb] - * From 2.5 boot: pruned inb(), outb(), and pzero(). - * [92/03/30 rvb] - * - * Revision 2.2 91/04/02 14:35:10 mbj - * Added _sp() => where is the stack at. [kupfer] - * Add Intel copyright - * [90/02/09 rvb] - * - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "asm.s" - -#include "asm.h" - - -CR0_PE_ON = 0x1 -CR0_PE_OFF = 0xfffffffe - -.globl _ouraddr - .text - -/* -# -# real_to_prot() -# transfer from real mode to protected mode. -*/ - -ENTRY(real_to_prot) - # guarantee that interrupt is disabled when in prot mode - cli - - # load the gdtr - addr16 - data32 - lgdt EXT(Gdtr) - - # set the PE bit of CR0 - mov %cr0, %eax - - data32 - or $CR0_PE_ON, %eax - mov %eax, %cr0 - - # make intrasegment jump to flush the processor pipeline and - # reload CS register - data32 - ljmp $0x18, $xprot - -xprot: - # we are in USE32 mode now - # set up the protective mode segment registers : DS, SS, ES - mov $0x20, %eax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - - ret - -/* -# -# prot_to_real() -# transfer from protected mode to real mode -# -*/ - -ENTRY(prot_to_real) - - # set up a dummy stack frame for the second seg change. - movl _ouraddr, %eax - sarl $4, %eax - pushw %ax - pushw $xreal - - # Change to use16 mode. - ljmp $0x28, $x16 - -x16: - # clear the PE bit of CR0 - mov %cr0, %eax - data32 - and $CR0_PE_OFF, %eax - mov %eax, %cr0 - - - # make intersegment jmp to flush the processor pipeline - # using the fake stack frame set up earlier - # and reload CS register - lret - - -xreal: - # we are in real mode now - # set up the real mode segment registers : DS, SS, ES - movw %cs, %ax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - - data32 - ret - -/* -# -# startprog(phyaddr) -# start the program on protected mode where phyaddr is the entry point -# -*/ - -ENTRY(startprog) - push %ebp - mov %esp, %ebp - - - - # get things we need into registers - movl 0x8(%ebp), %ecx # entry offset - movl 0x0c(%ebp), %eax # &argv - - # make a new stack at 0:0xa0000 (big segs) - mov $0x10, %ebx - movw %bx, %ss - movl $0xa0000,%ebx - movl %ebx,%esp - - - # push some number of args onto the stack - pushl $0 # nominally a cyl offset in the boot. - pushl 0x8(%eax) # argv[2] = bootdev - pushl 0x4(%eax) # argv[1] = howto - pushl $0 # dummy 'return' address - - # push on our entry address - mov $0x08, %ebx # segment - pushl %ebx - pushl %ecx - - # convert over the other data segs - mov $0x10, %ebx - movw %bx, %ds - movw %bx, %es - - # convert the PC (and code seg) - lret -/* -# -# pbzero( dst, cnt) -# where src is a virtual address and dst is a physical address -*/ - -ENTRY(pbzero) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - # set %es to point at the flat segment - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %edi # destination - mov 0xc(%ebp), %ecx # count - mov $0x0,%eax # value - - rep - stosb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret -/* -# -# pcpy(src, dst, cnt) -# where src is a virtual address and dst is a physical address -# -*/ - -ENTRY(pcpy) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - # set %es to point at the flat segment - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %esi # source - mov 0xc(%ebp), %edi # destination - mov 0x10(%ebp), %ecx # count - - rep - movsb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret - diff --git a/sys/i386/boot/bios.S b/sys/i386/boot/bios.S deleted file mode 100644 index 16ded4dfc7db..000000000000 --- a/sys/i386/boot/bios.S +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id: bios.S,v 1.2 1993/10/16 19:11:30 rgrimes Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "bios.s" - -#include "asm.h" - .text - -/* - * biosread(dev, cyl, head, sec, nsec, offset) - * Read "nsec" sectors from disk to offset "offset" in boot segment - * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory - * Call with %ah = 0x2 - * %al = number of sectors - * %ch = cylinder - * %cl = sector - * %dh = head - * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) - * %es:%bx = segment:offset of buffer - * Return: - * %al = 0x0 on success; err code on failure - */ - -ENTRY(biosread) - push %ebp - mov %esp, %ebp - - push %ebx - push %ecx - push %edx - push %es - - movb 0x10(%ebp), %dh - movw 0x0c(%ebp), %cx - /* cylinder; the highest 2 bits of cyl is in %cl */ - xchgb %ch, %cl - rorb $2, %cl - movb 0x14(%ebp), %al - orb %al, %cl - incb %cl /* sector; sec starts from 1, not 0 */ - movb 0x8(%ebp), %dl /* device */ - movl 0x1c(%ebp), %ebx /* offset */ - - /* prot_to_real will set %es to BOOTSEG */ - call EXT(prot_to_real) /* enter real mode */ - movb $0x2, %ah /* subfunction */ - addr32 - movb 0x18(%ebp), %al /* number of sectors */ - - sti - int $0x13 - cli - - /* save return value (actually movw %ax, %bx) */ - mov %eax, %ebx - - data32 - call EXT(real_to_prot) /* back to protected mode */ - - xor %eax, %eax - movb %bh, %al /* return value in %ax */ - - pop %es - pop %edx - pop %ecx - pop %ebx - pop %ebp - - ret - - -/* - * putc(ch) - * BIOS call "INT 10H Function 0Eh" to write character to console - * Call with %ah = 0x0e - * %al = character - * %bh = page - * %bl = foreground color ( graphics modes) - */ - - -ENTRY(putc) - push %ebp - mov %esp, %ebp - push %ebx - push %ecx - - movb 0x8(%ebp), %cl - - call EXT(prot_to_real) - - data32 - mov $0x1, %ebx /* %bh=0, %bl=1 (blue) */ - movb $0xe, %ah - movb %cl, %al - sti - int $0x10 /* display a byte */ - cli - - data32 - call EXT(real_to_prot) - - pop %ecx - pop %ebx - pop %ebp - ret - - -/* - * getc() - * BIOS call "INT 16H Function 00H" to read character from keyboard - * Call with %ah = 0x0 - * Return: %ah = keyboard scan code - * %al = ASCII character - */ - -ENTRY(getc) - push %ebp - mov %esp, %ebp - push %ebx /* save %ebx */ - - call EXT(prot_to_real) - - movb $0x0, %ah - sti - int $0x16 - cli - - movb %al, %bl /* real_to_prot uses %eax */ - - data32 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret -/* - * ischar() - * if there is a character pending, return it; otherwise return 0 - * BIOS call "INT 16H Function 01H" to check whether a character is pending - * Call with %ah = 0x1 - * Return: - * If key waiting to be input: - * %ah = keyboard scan code - * %al = ASCII character - * Zero flag = clear - * else - * Zero flag = set - */ -ENTRY(ischar) - push %ebp - mov %esp, %ebp - push %ebx - - call EXT(prot_to_real) /* enter real mode */ - - xor %ebx, %ebx - movb $0x1, %ah - sti - int $0x16 - cli - data32 - jz nochar - movb %al, %bl - -nochar: - data32 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret - -/* - * - * get_diskinfo(): return a word that represents the - * max number of sectors and heads and drives for this device - * - */ - -ENTRY(get_diskinfo) - push %ebp - mov %esp, %ebp - push %es - push %ebx - push %ecx - push %edx - - movb 0x8(%ebp), %dl /* diskinfo(drive #) */ - call EXT(prot_to_real) /* enter real mode */ - - movb $0x8, %ah /* ask for disk info */ - - sti - int $0x13 - cli - - jnc ok - /* - * Urk. Call failed. It is not supported for floppies by old BIOS's. - * Guess it's a 15-sector floppy. Initialize all the registers for - * documentation, although we only need head and sector counts. - */ - subb %ah, %ah /* %ax = 0 */ - movb %al, %al - movb %ah, %bh /* %bh = 0 */ - movb $2, %bl /* %bl bits 0-3 = drive type, - bit 2 = 1.2M */ - movb $79, %ch /* max track */ - movb $15, %cl /* max sector */ - movb $1, %dh /* max head */ - movb $1, %dl /* # floppy drives installed */ - /* es:di = parameter table */ - /* carry = 0 */ -ok: - - data32 - call EXT(real_to_prot) /* back to protected mode */ - - xor %eax, %eax - - /* form a longword representing all this gunk */ - movb %dh, %ah /* max head */ - andb $0x3f, %cl /* mask of cylinder gunk */ - movb %cl, %al /* max sector (and # sectors) */ - - pop %edx - pop %ecx - pop %ebx - pop %es - pop %ebp - ret - -/* - * - * memsize(i) : return the memory size in KB. i == 0 for conventional memory, - * i == 1 for extended memory - * BIOS call "INT 12H" to get conventional memory size - * BIOS call "INT 15H, AH=88H" to get extended memory size - * Both have the return value in AX. - * - */ - -ENTRY(memsize) - push %ebp - mov %esp, %ebp - push %ebx - - mov 8(%ebp), %ebx - - call EXT(prot_to_real) /* enter real mode */ - - cmpb $0x1, %bl - data32 - je xext - - sti - int $0x12 - cli - data32 - jmp xdone - -xext: movb $0x88, %ah - sti - int $0x15 - cli - -xdone: - mov %eax, %ebx - - data32 - call EXT(real_to_prot) - - mov %ebx, %eax - pop %ebx - pop %ebp - ret diff --git a/sys/i386/boot/bios.s b/sys/i386/boot/bios.s deleted file mode 100644 index d1673a560042..000000000000 --- a/sys/i386/boot/bios.s +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - * HISTORY - * $Log: bios.s,v $ - * Revision 2.2 92/04/04 11:34:26 rpd - * Fix Intel Copyright as per B. Davies authorization. - * [92/04/03 rvb] - * From 2.5 version - * [92/03/30 mg32] - * - * Revision 2.2 91/04/02 14:35:21 mbj - * Add Intel copyright - * [90/02/09 rvb] - * - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "bios.s" - -#include "asm.h" - .text - -/* -# biosread(dev, cyl, head, sec) -# Read one sector from disk into the internal buffer "intbuf" which -# is the first 512 bytes of the boot loader. -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -ENTRY(biosread) - push %ebp - mov %esp, %ebp - - push %ebx - push %ecx - push %edx - push %es - - movb 0x10(%ebp), %dh - movw 0x0c(%ebp), %cx - xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl - rorb $2, %cl - movb 0x14(%ebp), %al - orb %al, %cl - incb %cl # sector; sec starts from 1, not 0 - movb 0x8(%ebp), %dl # device - xor %ebx, %ebx # offset -- 0 - # prot_to_real will set %es to BOOTSEG - - call EXT(prot_to_real) # enter real mode - movb $0x2, %ah # subfunction - movb $0x1, %al # number of sectors -- one - - sti - int $0x13 - cli - - mov %eax, %ebx # save return value - - data16 - call EXT(real_to_prot) # back to protected mode - - xor %eax, %eax - movb %bh, %al # return value in %ax - - pop %es - pop %edx - pop %ecx - pop %ebx - pop %ebp - - ret - - -/* -# putc(ch) -# BIOS call "INT 10H Function 0Eh" to write character to console -# Call with %ah = 0x0e -# %al = character -# %bh = page -# %bl = foreground color ( graphics modes) -*/ - - -ENTRY(putc) - push %ebp - mov %esp, %ebp - push %ebx - push %ecx - - movb 0x8(%ebp), %cl - - call EXT(prot_to_real) - - data16 - mov $0x1, %ebx # %bh=0, %bl=1 (blue) - movb $0xe, %ah - movb %cl, %al - sti - int $0x10 # display a byte - cli - - data16 - call EXT(real_to_prot) - - pop %ecx - pop %ebx - pop %ebp - ret - - -/* -# getc() -# BIOS call "INT 16H Function 00H" to read character from keyboard -# Call with %ah = 0x0 -# Return: %ah = keyboard scan code -# %al = ASCII character -*/ - -ENTRY(getc) - push %ebp - mov %esp, %ebp - push %ebx # save %ebx - - call EXT(prot_to_real) - - movb $0x0, %ah - sti - int $0x16 - cli - - movb %al, %bl # real_to_prot uses %eax - - data16 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret -/* -# ischar() -# if there is a character pending, return it; otherwise return 0 -# BIOS call "INT 16H Function 01H" to check whether a character is pending -# Call with %ah = 0x1 -# Return: -# If key waiting to be input: -# %ah = keyboard scan code -# %al = ASCII character -# Zero flag = clear -# else -# Zero flag = set -*/ -ENTRY(ischar) - push %ebp - mov %esp, %ebp - push %ebx - - call EXT(prot_to_real) # enter real mode - - xor %ebx, %ebx - movb $0x1, %ah - sti - int $0x16 - cli - data16 - jz nochar - movb %al, %bl - -nochar: - data16 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret - -/* -# -# get_diskinfo(): return a word that represents the -# max number of sectors and heads and drives for this device -# -*/ - -ENTRY(get_diskinfo) - push %ebp - mov %esp, %ebp - push %es - push %ebx - push %ecx - push %edx - - movb 0x8(%ebp), %dl # diskinfo(drive #) - call EXT(prot_to_real) # enter real mode - - movb $0x8, %ah # ask for disk info - - sti - int $0x13 - cli - - data16 - call EXT(real_to_prot) # back to protected mode - - xor %eax, %eax - - /*form a longword representing all this gunk*/ - movb %dh, %ah # # heads - andb $0x3f, %cl # mask of cylinder gunk - movb %cl, %al # # sectors - - pop %edx - pop %ecx - pop %ebx - pop %es - pop %ebp - ret - -/* -# -# memsize(i) : return the memory size in KB. i == 0 for conventional memory, -# i == 1 for extended memory -# BIOS call "INT 12H" to get conventional memory size -# BIOS call "INT 15H, AH=88H" to get extended memory size -# Both have the return value in AX. -# -*/ - -ENTRY(memsize) - push %ebp - mov %esp, %ebp - push %ebx - - mov 8(%ebp), %ebx - - call EXT(prot_to_real) # enter real mode - - cmpb $0x1, %bl - data16 - je xext - - sti - int $0x12 - cli - data16 - jmp xdone - -xext: movb $0x88, %ah - sti - int $0x15 - cli - -xdone: - mov %eax, %ebx - - data16 - call EXT(real_to_prot) - - mov %ebx, %eax - pop %ebx - pop %ebp - ret diff --git a/sys/i386/boot/boot.c b/sys/i386/boot/boot.c deleted file mode 100644 index a64ee21c62ca..000000000000 --- a/sys/i386/boot/boot.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, [92/04/03 16:51:14 rvb] - * $Id: boot.c,v 1.19 1994/10/26 20:22:10 jkh Exp $ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include <sys/param.h> -#include "boot.h" -#include <a.out.h> -#include <sys/reboot.h> -#include <machine/bootinfo.h> - -struct exec head; -struct bootinfo_t bootinfo; -char *name; -char *names[] = { - "/kernel" -}; -#define NUMNAMES (sizeof(names)/sizeof(char *)) - -extern int end; -boot(drive) -int drive; -{ - int loadflags, currname = 0; - char *t; - - printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n", - ouraddr, - memsize(0), - memsize(1)); - printf("use hd(1,a)/kernel to boot sd0 when wd0 is also installed\n"); - gateA20(); -loadstart: - /***************************************************************\ - * As a default set it to the first partition of the first * - * floppy or hard drive * - \***************************************************************/ - part = unit = 0; - maj = (drive&0x80 ? 0 : 2); /* a good first bet */ - name = names[currname++]; - - loadflags = 0; - if (currname == NUMNAMES) - currname = 0; - getbootdev(&loadflags); - if (openrd()) { - printf("Can't find %s\n", name); - goto loadstart; - } -/* if (inode.i_mode&IEXEC) - loadflags |= RB_KDB; -*/ - loadprog(loadflags); - goto loadstart; -} - -loadprog(howto) - int howto; -{ - long int startaddr; - long int addr; /* physical address.. not directly useable */ - long int bootdev; - long int total; - int i; - unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ - - read(&head, sizeof(head)); - if ( N_BADMAG(head)) { - printf("Invalid format!\n"); - return; - } - - poff = N_TXTOFF(head); - /*if(poff==0) - poff = 32;*/ - - startaddr = (int)head.a_entry & 0x00FFFFFF; /* some MEG boundary */ - addr = startaddr; - printf("Booting %s(%d,%c)%s @ 0x%x\n" - , devs[maj] - , unit - , 'a'+part - , name - , addr); - if(addr < ouraddr) - { - if((addr + head.a_text + head.a_data) > ouraddr) - { - printf("kernel overlaps loader\n"); - return; - } - if((addr + head.a_text + head.a_data + head.a_bss) > 0xa0000) - { - printf("bss exceeds 640k limit\n"); - return; - } - } - printf("text=0x%x ", head.a_text); - /********************************************************/ - /* LOAD THE TEXT SEGMENT */ - /* don't clobber the first 4k yet (BIOS NEEDS IT) */ - /********************************************************/ - read(tmpbuf,4096); - addr += 4096; - xread(addr, head.a_text - 4096); - addr += head.a_text - 4096; - - /********************************************************/ - /* Load the Initialised data after the text */ - /********************************************************/ - while (addr & CLOFSET) - *(char *)addr++ = 0; - - printf("data=0x%x ", head.a_data); - xread(addr, head.a_data); - addr += head.a_data; - - /********************************************************/ - /* Skip over the uninitialised data */ - /* (but clear it) */ - /********************************************************/ - printf("bss=0x%x ", head.a_bss); - if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr)) - { - pbzero(addr,ouraddr - (int)addr); - } - else - { - pbzero(addr,head.a_bss); - } - addr += head.a_bss; - -#ifdef LOADSYMS /* not yet, haven't worked this out yet */ - if (addr > 0x100000) - { - /********************************************************/ - /*copy in the symbol header */ - /********************************************************/ - pcpy(&head.a_syms, addr, sizeof(head.a_syms)); - addr += sizeof(head.a_syms); - - /********************************************************/ - /* READ in the symbol table */ - /********************************************************/ - printf("symbols=[+0x%x", head.a_syms); - xread(addr, head.a_syms); - addr += head.a_syms; - - /********************************************************/ - /* Followed by the next integer (another header) */ - /* more debug symbols? */ - /********************************************************/ - read(&i, sizeof(int)); - pcpy(&i, addr, sizeof(int)); - i -= sizeof(int); - addr += sizeof(int); - - - /********************************************************/ - /* and that many bytes of (debug symbols?) */ - /********************************************************/ - printf("+0x%x] ", i); - xread(addr, i); - addr += i; - } -#endif LOADSYMS - /********************************************************/ - /* and note the end address of all this */ - /********************************************************/ - - total = ((addr+sizeof(int)-1))&~(sizeof(int)-1); - printf("total=0x%x ", total); - bootdev = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ; - /****************************************************************/ - /* copy that first page and overwrite any BIOS variables */ - /****************************************************************/ - printf("entry point=0x%x\n" ,(int)startaddr); - /* Under no circumstances overwrite precious BIOS variables! */ - pcpy(tmpbuf, startaddr, 0x400); - pcpy(tmpbuf + 0x500, startaddr + 0x500, 4096 - 0x500); - bootinfo.version=1; - bootinfo.kernelname=(char *)((int)name + (BOOTSEG<<4)); - bootinfo.nfs_diskless=0; - startprog((int)startaddr, howto, bootdev, (int)&bootinfo+(BOOTSEG<<4)); - return; -} - -#define NAMEBUF_LEN 100 - -char namebuf[NAMEBUF_LEN]; -getbootdev(howto) - int *howto; -{ - char c, *ptr = namebuf; - printf("Boot: [[[%s(%d,%c)]%s][-s][-r][-a][-c][-d][-b]] :- " - , devs[maj] - , unit - , 'a'+part - , name); - if (gets(namebuf)) { - while (c=*ptr) { - while (c==' ') - c = *++ptr; - if (!c) - return; - if (c=='-') - while ((c = *++ptr) && c!=' ') - switch (c) { - case 'r': - *howto |= RB_DFLTROOT; continue; - case 'a': - *howto |= RB_ASKNAME; continue; - case 'c': - *howto |= RB_CONFIG; continue; - case 's': - *howto |= RB_SINGLE; continue; - case 'd': - *howto |= RB_KDB; continue; - case 'b': - *howto |= RB_HALT; continue; - } - else { - name = ptr; - while ((c = *++ptr) && c!=' '); - if (c) - *ptr++ = 0; - } - } - if (name[0] != '/') { - int i; - /* This is incredibly gross, but nonetheless compact */ - /* which is a good thing for a boot block to be */ - for (i = NAMEBUF_LEN - 1; i; i--) - name[i] = name[i - 1]; - name[0] = '/'; - } - } else - printf("\n"); -} - diff --git a/sys/i386/boot/boot.h b/sys/i386/boot/boot.h deleted file mode 100644 index 20469905fda2..000000000000 --- a/sys/i386/boot/boot.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:03 rpd - * $Id: boot.h,v 1.3 1993/10/16 19:11:32 rgrimes Exp $ - */ - -#include <sys/types.h> -#include <sys/param.h> -#include <sys/time.h> -#include <ufs/ufs/quota.h> -#include <ufs/ffs/fs.h> -#include <ufs/ufs/inode.h> - -extern char *devs[], *name, *iodest; -extern struct fs *fs; -extern struct inode inode; -extern int dosdev, unit, part, maj, boff, poff, bnum, cnt; -extern long int ouraddr; diff --git a/sys/i386/boot/boot.sed b/sys/i386/boot/boot.sed deleted file mode 100644 index c6b38eaac732..000000000000 --- a/sys/i386/boot/boot.sed +++ /dev/null @@ -1,3 +0,0 @@ -/^[ ]*.data/c\ - .text -/^[ ]*.ident/d diff --git a/sys/i386/boot/boot2.S b/sys/i386/boot/boot2.S deleted file mode 100644 index 5984f836590b..000000000000 --- a/sys/i386/boot/boot2.S +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:26 rpd - * $Id: boot2.S,v 1.4 1994/06/22 05:52:25 jkh Exp $ - */ - -#include "asm.h" - -/* Conventional GDT indexes. */ -#define BOOT_CS_INDEX 3 -#define BOOT_CS16_INDEX 5 -#define BOOT_DS_INDEX 4 - -#ifdef BDE_DEBUGGER -#define DB_CS_INDEX 14 -#define DB_CS16_INDEX 15 -#define DB_DS_INDEX 16 -#define GDT_INDEX 17 -#endif - -/* Vector numbers. */ -#define BREAKPOINT_VECTOR 3 -#define DEBUG_VECTOR 1 - -/* - * boot2() -- second stage boot - */ - -.globl EXT(ouraddr) - -ENTRY(boot2) - data32 - subl %eax, %eax - mov %cs, %ax - mov %ax, %ds - mov %ax, %es - data32 - shll $4, %eax - addr32 - data32 - movl %eax, EXT(ouraddr) - - /* fix up GDT entries for bootstrap */ -#define FIXUP(gdt_index) \ - addr32; \ - movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \ - addr32; \ - movb %bl, EXT(Gdt)+(8*gdt_index)+4 - - data32 - shld $16, %eax, %ebx - FIXUP(BOOT_CS_INDEX) - FIXUP(BOOT_CS16_INDEX) - FIXUP(BOOT_DS_INDEX) - - /* fix up GDT pointer */ - data32 - movl %eax, %ecx - data32 - addl $ EXT(Gdt), %eax - addr32 - data32 - movl %eax, EXT(Gdtr)+2 - -#ifdef BDE_DEBUGGER - /* fix up GDT entry for GDT */ - data32 - shld $16, %eax, %ebx - FIXUP(GDT_INDEX) - - /* fix up IDT pointer */ - data32 - addl $ EXT(Idt), %ecx - addr32 - data32 - movl %ecx, EXT(Idtr_prot)+2 - - /* %es = vector table segment for a while */ - push %es - data32 - subl %eax, %eax - mov %ax, %es - - /* fix up GDT entries for bdb */ - data32 - movl $4*DEBUG_VECTOR, %esi - addr32 - movl %es: 2(%esi), %eax /* actually movw to %ax */ - data32 - shll $4, %eax - data32 - shld $16, %eax, %ebx - FIXUP(DB_CS_INDEX) - FIXUP(DB_CS16_INDEX) - FIXUP(DB_DS_INDEX) - - /* Fetch entry points of bdb's protected mode trap handlers. These - * are stored at 2 before the corresponding entry points for real mode. - */ - data32 - subl %ebx, %ebx - addr32 - movl %es: (%esi), %ebx /* actually movw to %bx */ - data32 - subl %ecx, %ecx - addr32 - movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx - /* actually movw to %cx */ - - /* %es = bdb segment for a while */ - data32 - shrl $4, %eax - mov %ax, %es - - /* fix up IDT entries for bdb */ - data32 - subl $2, %ebx /* calculate EA to check it */ - jb 1f /* give up if it would trap */ - addr32 - movl %es: (%ebx), %eax /* actually movw to %ax */ - addr32 - movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */ -1: - data32 - subl $2, %ecx - jb 1f - addr32 - movl %es: (%ecx), %eax /* actually movw to %ax */ - addr32 - movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */ -1: - - /* finished with groping in real mode segments */ - pop %es -#endif /* BDE_DEBUGGER */ - - /* change to protected mode */ - data32 - call EXT(real_to_prot) - - /* clear the bss */ - movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */ - movl $ EXT(end), %ecx /* or EXT(_end) */ - subl %edi, %ecx - subb %al, %al - rep - stosb - - movzbl %dl, %edx /* discard head (%dh) and random high bits */ - pushl %edx - call EXT(boot) -oops: - hlt - jmp oops - - .data - .align 2 -#if 0 /* XXX this would give losing "_ouraddr :". Better declared in C */ -EXT(ouraddr): -#else -_ouraddr: -#endif - .long 0 diff --git a/sys/i386/boot/boot2.s b/sys/i386/boot/boot2.s deleted file mode 100644 index d319edf6d2d1..000000000000 --- a/sys/i386/boot/boot2.s +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - * HISTORY - * $Log: boot2.s,v $ - * Revision 2.2 92/04/04 11:35:26 rpd - * From 2.5 - * [92/03/30 rvb] - * - * Revision 2.2 91/04/02 14:39:21 mbj - * Put into rcs tree - * [90/02/09 rvb] - * - */ - -#include "asm.h" -#define LOADMSG 1 -/* - * boot2() -- second stage boot - */ - -.globl _ouraddr - -ENTRY(boot2) - movl %cs, %ax - movl %ax, %ds - movl %ax, %es - data32 - sall $4, %eax - data32 - movl %eax, _ouraddr - /* save the drive type and ID */ - data32 - pushl %edx - /* change to protected mode */ - data32 - call _real_to_prot - - call _boot - ret - - .data - .align 2 -_ouraddr: - .long 0 - - diff --git a/sys/i386/boot/disk.c b/sys/i386/boot/disk.c deleted file mode 100644 index a63ca5a73fe5..000000000000 --- a/sys/i386/boot/disk.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd - * $Id: disk.c,v 1.4 1994/02/22 22:59:40 rgrimes Exp $ - */ - -/* - * 93/10/08 bde - * If there is no 386BSD partition, initialize the label sector with - * LABELSECTOR instead of with garbage. - * - * 93/08/22 bde - * Fixed reading of bad sector table. It is at the end of the 'c' - * partition, which is not always at the end of the disk. - */ - -#include "boot.h" -#ifdef DO_BAD144 -#include <sys/dkbad.h> -#endif DO_BAD144 -#include <sys/disklabel.h> - -#define BIOS_DEV_FLOPPY 0x0 -#define BIOS_DEV_WIN 0x80 - -#define BPS 512 -#define SPT(di) ((di)&0xff) -#define HEADS(di) ((((di)>>8)&0xff)+1) - -char *devs[] = {"wd", "hd", "fd", "wt", "sd", 0}; - -#ifdef DO_BAD144 -struct dkbad dkb; -int do_bad144; -int bsize; -#endif DO_BAD144 - -int spt, spc; - -char *iodest; -struct fs *fs; -struct inode inode; -int dosdev, unit, part, maj, boff, poff, bnum, cnt; - -/*#define EMBEDDED_DISKLABEL 1*/ -extern struct disklabel disklabel; -/*struct disklabel disklabel;*/ - -devopen() -{ - struct dos_partition *dptr; - struct disklabel *dl; - int dosdev = inode.i_dev; - int i, sector, di; - - di = get_diskinfo(dosdev); - spc = (spt = SPT(di)) * HEADS(di); - if (dosdev == 2) - { - boff = 0; - part = (spt == 15 ? 3 : 1); - } - else - { -#ifdef EMBEDDED_DISKLABEL - dl = &disklabel; -#else EMBEDDED_DISKLABEL - Bread(dosdev, 0); - dptr = (struct dos_partition *)(((char *)0)+DOSPARTOFF); - sector = LABELSECTOR; - for (i = 0; i < NDOSPART; i++, dptr++) - if (dptr->dp_typ == DOSPTYP_386BSD) { - sector = dptr->dp_start + LABELSECTOR; - break; - } - Bread(dosdev, sector++); - dl=((struct disklabel *)0); - disklabel = *dl; /* structure copy (maybe useful later)*/ -#endif EMBEDDED_DISKLABEL - if (dl->d_magic != DISKMAGIC) { - printf("bad disklabel"); - return 1; - } - if( (maj == 4) || (maj == 0) || (maj == 1)) - { - if (dl->d_type == DTYPE_SCSI) - { - maj = 4; /* use scsi as boot dev */ - } - else - { - maj = 0; /* must be ESDI/IDE */ - } - } - boff = dl->d_partitions[part].p_offset; -#ifdef DO_BAD144 - bsize = dl->d_partitions[part].p_size; - do_bad144 = 0; - if (dl->d_flags & D_BADSECT) { - /* this disk uses bad144 */ - int i; - int dkbbnum; - struct dkbad *dkbptr; - - /* find the first readable bad sector table */ - /* some of this code is copied from ufs/ufs_disksubr.c */ - /* including the bugs :-( */ - /* read a bad sector table */ - -#define BAD144_PART 2 /* XXX scattered magic numbers */ -#define BSD_PART 0 /* XXX should be 2 but bad144.c uses 0 */ - if (dl->d_partitions[BSD_PART].p_offset != 0) - dkbbnum = dl->d_partitions[BAD144_PART].p_offset - + dl->d_partitions[BAD144_PART].p_size; - else - dkbbnum = dl->d_secperunit; - dkbbnum -= dl->d_nsectors; - - if (dl->d_secsize > DEV_BSIZE) - dkbbnum *= dl->d_secsize / DEV_BSIZE; - else - dkbbnum /= DEV_BSIZE / dl->d_secsize; - i = 0; - do_bad144 = 0; - do { - /* XXX: what if the "DOS sector" < 512 bytes ??? */ - Bread(dosdev, dkbbnum + i); - dkbptr = (struct dkbad *) 0; -/* XXX why is this not in <sys/dkbad.h> ??? */ -#define DKBAD_MAGIC 0x4321 - if (dkbptr->bt_mbz == 0 && - dkbptr->bt_flag == DKBAD_MAGIC) { - dkb = *dkbptr; /* structure copy */ - do_bad144 = 1; - break; - } - i += 2; - } while (i < 10 && i < dl->d_nsectors); - if (!do_bad144) - printf("Bad bad sector table\n"); - else - printf("Using bad sector table at %d\n", dkbbnum+i); - } -#endif DO_BAD144 - } - return 0; -} - -devread() -{ - int offset, sector = bnum; - int dosdev = inode.i_dev; - for (offset = 0; offset < cnt; offset += BPS) - { - Bread(dosdev, badsect(dosdev, sector++)); - bcopy(0, iodest+offset, BPS); - } -} - -#define I_ADDR ((void *) 0) /* XXX where all reads go */ - -/* Read ahead buffer large enough for one track on a 1440K floppy. For - * reading from floppies, the bootstrap has to be loaded on a 64K boundary - * to ensure that this buffer doesn't cross a 64K DMA boundary. - */ -#define RA_SECTORS 18 -static char ra_buf[RA_SECTORS * BPS]; -static int ra_dev; -static int ra_end; -static int ra_first; - -Bread(dosdev,sector) - int dosdev,sector; -{ - if (dosdev != ra_dev || sector < ra_first || sector >= ra_end) - { - int cyl, head, sec, nsec; - - cyl = sector/spc; - head = (sector % spc) / spt; - sec = sector % spt; - nsec = spt - sec; - if (nsec > RA_SECTORS) - nsec = RA_SECTORS; - twiddle(); - if (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) - { - nsec = 1; - twiddle(); - while (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) { - printf("Error: C:%d H:%d S:%d\n", cyl, head, sec); - twiddle(); - } - } - ra_dev = dosdev; - ra_first = sector; - ra_end = sector + nsec; - } - bcopy(ra_buf + (sector - ra_first) * BPS, I_ADDR, BPS); -} - -badsect(dosdev, sector) - int dosdev, sector; -{ - int i; -#ifdef DO_BAD144 - if (do_bad144) { - u_short cyl; - u_short head; - u_short sec; - int newsec; - struct disklabel *dl = &disklabel; - - /* XXX */ - /* from wd.c */ - /* bt_cyl = cylinder number in sorted order */ - /* bt_trksec is actually (head << 8) + sec */ - - /* only remap sectors in the partition */ - if (sector < boff || sector >= boff + bsize) { - goto no_remap; - } - - cyl = sector / dl->d_secpercyl; - head = (sector % dl->d_secpercyl) / dl->d_nsectors; - sec = sector % dl->d_nsectors; - sec = (head<<8) + sec; - - /* now, look in the table for a possible bad sector */ - for (i=0; i<126; i++) { - if (dkb.bt_bad[i].bt_cyl == cyl) { - /* found same cylinder */ - if (dkb.bt_bad[i].bt_trksec == sec) { - /* FOUND! */ - break; - } - } else if (dkb.bt_bad[i].bt_cyl > cyl) { - i = 126; - break; - } - } - if (i == 126) { - /* didn't find bad sector */ - goto no_remap; - } - /* otherwise find replacement sector */ - if (dl->d_partitions[BSD_PART].p_offset != 0) - newsec = dl->d_partitions[BAD144_PART].p_offset - + dl->d_partitions[BAD144_PART].p_size; - else - newsec = dl->d_secperunit; - newsec -= dl->d_nsectors + i + 1; - return newsec; - } -#endif DO_BAD144 - no_remap: - return sector; -} diff --git a/sys/i386/boot/io.c b/sys/i386/boot/io.c deleted file mode 100644 index ce2b1fe52bfb..000000000000 --- a/sys/i386/boot/io.c +++ /dev/null @@ -1,225 +0,0 @@ - -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:57 rpd - * $Id: io.c,v 1.8 1994/09/18 07:39:55 swallace Exp $ - */ - -#include <machine/cpufunc.h> - -#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */ -#define K_STATUS 0x64 /* keyboard status */ -#define K_CMD 0x64 /* keybd ctlr command (write-only) */ - -#define K_OBUF_FUL 0x01 /* output buffer full */ -#define K_IBUF_FUL 0x02 /* input buffer full */ - -#define KC_CMD_WIN 0xd0 /* read output port */ -#define KC_CMD_WOUT 0xd1 /* write output port */ -#define KB_A20 0xdf /* enable A20, - enable output buffer full interrupt - enable data line - enable clock line */ - -/* - * Gate A20 for high memory - */ -unsigned char x_20 = KB_A20; -gateA20() -{ -#ifdef IBM_L40 - outb(0x92, 0x2); -#else IBM_L40 - while (inb(K_STATUS) & K_IBUF_FUL); - while (inb(K_STATUS) & K_OBUF_FUL) - (void)inb(K_RDWR); - - outb(K_CMD, KC_CMD_WOUT); - while (inb(K_STATUS) & K_IBUF_FUL); - outb(K_RDWR, x_20); - while (inb(K_STATUS) & K_IBUF_FUL); -#endif IBM_L40 -} - -/* printf - only handles %d as decimal, %c as char, %s as string */ - -printf(format,data) - char *format; - int data; -{ - int *dataptr = &data; - char c; - - reset_twiddle(); - while (c = *format++) - if (c != '%') - putchar(c); - else - switch (c = *format++) { - case 'd': { - int num = *dataptr++; - char buf[10], *ptr = buf; - if (num<0) { - num = -num; - putchar('-'); - } - do - *ptr++ = '0'+num%10; - while (num /= 10); - do - putchar(*--ptr); - while (ptr != buf); - break; - } - case 'x': { - int num = *dataptr++, dig; - char buf[8], *ptr = buf; - do - *ptr++ = (dig=(num&0xf)) > 9? - 'a' + dig - 10 : - '0' + dig; - while (num >>= 4); - do - putchar(*--ptr); - while (ptr != buf); - break; - } - case 'c': putchar((*dataptr++)&0xff); break; - case 's': { - char *ptr = (char *)*dataptr++; - while (c = *ptr++) - putchar(c); - break; - } - } -} - -putchar(c) -{ - if (c == '\n') - putc('\r'); - putc(c); -} - -getchar() -{ - int c; - - if ((c=getc()) == '\r') - c = '\n'; - if (c == '\b') { - putchar('\b'); - putchar(' '); - } - putchar(c); - return(c); -} - -#if BOOTWAIT -/* - * This routine uses an inb to an unused port, the time to execute that - * inb is approximately 1.25uS. This value is pretty constant across - * all CPU's and all buses, with the exception of some PCI implentations - * that do not forward this I/O adress to the ISA bus as they know it - * is not a valid ISA bus address, those machines execute this inb in - * 60 nS :-(. - * - * XXX we need to use BIOS timer calls or something more reliable to - * produce timeouts in the boot code. - */ -delay1ms() -{ - int i = 800; - while (--i >= 0) - (void)inb(0x84); -} -#endif - -gets(buf) -char *buf; -{ - int i; - char *ptr=buf; - -#if BOOTWAIT - for (i = BOOTWAIT; i>0; delay1ms(),i--) -#endif - if (ischar()) - for (;;) - switch(*ptr = getchar() & 0xff) { - case '\n': - case '\r': - *ptr = '\0'; - return 1; - case '\b': - if (ptr > buf) ptr--; - continue; - default: - ptr++; - } - return 0; -} - -strcmp(s1, s2) -char *s1, *s2; -{ - while (*s1 == *s2) { - if (!*s1++) - return 0; - s2++; - } - return 1; -} - -bcopy(from, to, len) -char *from, *to; -int len; -{ - while (len-- > 0) - *to++ = *from++; -} - -static int tw_on; -static int tw_pos; -static char tw_chars[] = "|/-\\"; - -reset_twiddle() -{ - if (tw_on) - putchar('\b'); - tw_on = 0; - tw_pos = 0; -} - -twiddle() -{ - if (tw_on) - putchar('\b'); - else - tw_on = 1; - putchar(tw_chars[tw_pos++]); - tw_pos %= (sizeof(tw_chars) - 1); -} diff --git a/sys/i386/boot/netboot/509.doc b/sys/i386/boot/netboot/509.doc deleted file mode 100644 index 1908c64419a2..000000000000 --- a/sys/i386/boot/netboot/509.doc +++ /dev/null @@ -1,21 +0,0 @@ -During adding of 3C509 support I made following changes: - -1) File if_epreg.h added - it is slightly different from one in -/usr/src/sys/i386/isa ! - -2) Support of 3C509 added to ether.c - -3) Flag -DINCLUDE_3C509 added (to ether.h, ether.c, Makefile) - -4) Routine eth_fillname() added to ether.c because 3C509 has -different driver (ep0 instead of ed0). Main.c was changed -according to this. - -I had tested this version with 3C509 only, but I see no reasons -why it must not work with other cards. - -But don't try to link it for both 3C509 and 8390-based cards. In -this case object file grows behind 16K and everything fails -to work. I don't know how correct this trouble. - - Serge Babkin (babkin@hq.icb.chel.su) diff --git a/sys/i386/boot/netboot/ether.c b/sys/i386/boot/netboot/ether.c deleted file mode 100644 index 1077ab082436..000000000000 --- a/sys/i386/boot/netboot/ether.c +++ /dev/null @@ -1,1243 +0,0 @@ - -/************************************************************************** -NETBOOT - BOOTP/TFTP Bootstrap Program - -Author: Martin Renters. - Date: Mar 22 1995 - - This code is based heavily on David Greenman's if_ed.c driver and - Andres Vega Garcia's if_ep.c driver. - - Copyright (C) 1993-1994, David Greenman, Martin Renters. - Copyright (C) 1993-1995, Andres Vega Garcia. - Copyright (C) 1995, Serge Babkin. - This software may be used, modified, copied, distributed, and sold, in - both source and binary form provided that the above copyright and these - terms are retained. Under no circumstances are the authors responsible for - the proper functioning of this software, nor do the authors assume any - responsibility for damages incurred with its use. - -3c503 support added by Bill Paul (wpaul@ctr.columbia.edu) on 11/15/94 -SMC8416 support added by Bill Paul (wpaul@ctr.columbia.edu) on 12/25/94 -3c509 support added by Serge Babkin (babkin@hq.icb.chel.su) on 03/22/95 - -***************************************************************************/ - -/* #define EDEBUG */ - -#include "netboot.h" -#include "ether.h" - -#ifdef INCLUDE_3C509 -# include "if_epreg.h" -#endif - -extern short aui; -char bnc=0, utp=0; /* for 3C509 */ -unsigned short eth_nic_base; -unsigned short eth_asic_base; -unsigned short eth_base; -unsigned char eth_tx_start; -unsigned char eth_laar; -unsigned char eth_flags; -unsigned char eth_vendor; -unsigned char eth_memsize; -unsigned char *eth_bmem; -unsigned char *eth_rmem; -unsigned char *eth_node_addr; - -#ifdef INCLUDE_3C509 - -static send_ID_sequence(); -static get_eeprom_data(); -static get_e(); - -#endif - -/************************************************************************** -The following two variables are used externally -***************************************************************************/ -char packet[ETH_MAX_PACKET]; -int packetlen; - -/************************************************************************* -ETH_FILLNAME - Fill name of adapter in NFS structure -**************************************************************************/ - -eth_fillname(where) -char *where; -{ - switch(eth_vendor) { - case VENDOR_3C509: - where[0]='e'; where[1]='p'; where[2]='0'; where[3]=0; - break; - case VENDOR_WD: - case VENDOR_NOVELL: - case VENDOR_3COM: - where[0]='e'; where[1]='d'; where[2]='0'; where[3]=0; - break; - default: - where[0]='?'; where[1]='?'; where[2]='?'; where[3]=0; - break; - } -} - -/************************************************************************** -ETH_PROBE - Look for an adapter -***************************************************************************/ -eth_probe() -{ - /* common variables */ - int i; -#ifdef INCLUDE_3C509 - /* variables for 3C509 */ - int data, j, io_base, id_port = EP_ID_PORT; - int nisa = 0, neisa = 0; - u_short k; - int ep_current_tag = EP_LAST_TAG + 1; - short *p; -#endif -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - /* varaibles for 8390 */ - struct wd_board *brd; - char *name; - unsigned short chksum; - unsigned char c; -#endif - - eth_vendor = VENDOR_NONE; - -#ifdef INCLUDE_3C509 - - /********************************************************* - Search for 3Com 509 card - ***********************************************************/ - - /* Look for the EISA boards, leave them activated */ - /* search for the first card, ignore all others */ - for(j = 1; j < 16 && eth_vendor==VENDOR_NONE ; j++) { - io_base = (j * EP_EISA_START) | EP_EISA_W0; - if (inw(io_base + EP_W0_MFG_ID) != MFG_ID) - continue; - - /* we must found 0x1f if the board is EISA configurated */ - if ((inw(io_base + EP_W0_ADDRESS_CFG) & 0x1f) != 0x1f) - continue; - - /* Reset and Enable the card */ - outb(io_base + EP_W0_CONFIG_CTRL, W0_P4_CMD_RESET_ADAPTER); - DELAY(1000); /* we must wait at least 1 ms */ - outb(io_base + EP_W0_CONFIG_CTRL, W0_P4_CMD_ENABLE_ADAPTER); - - /* - * Once activated, all the registers are mapped in the range - * x000 - x00F, where x is the slot number. - */ - eth_base = j * EP_EISA_START; - eth_vendor = VENDOR_3C509; - } - ep_current_tag--; - - /* Look for the ISA boards. Init and leave them actived */ - /* search for the first card, ignore all others */ - outb(id_port, 0xc0); /* Global reset */ - DELAY(1000); - for (i = 0; i < EP_MAX_BOARDS && eth_vendor==VENDOR_NONE; i++) { - outb(id_port, 0); - outb(id_port, 0); - send_ID_sequence(id_port); - - data = get_eeprom_data(id_port, EEPROM_MFG_ID); - if (data != MFG_ID) - break; - - /* resolve contention using the Ethernet address */ - for (j = 0; j < 3; j++) - data = get_eeprom_data(id_port, j); - - eth_base = - (get_eeprom_data(id_port, EEPROM_ADDR_CFG) & 0x1f) * 0x10 + 0x200; - outb(id_port, ep_current_tag); /* tags board */ - outb(id_port, ACTIVATE_ADAPTER_TO_CONFIG); - eth_vendor = VENDOR_3C509; - ep_current_tag--; - } - - if(eth_vendor != VENDOR_3C509) - goto no3c509; - - /* - * The iobase was found and MFG_ID was 0x6d50. PROD_ID should be - * 0x9[0-f]50 - */ - GO_WINDOW(0); - k = get_e(EEPROM_PROD_ID); - if ((k & 0xf0ff) != (PROD_ID & 0xf0ff)) - goto no3c509; - - if(eth_base >= EP_EISA_START) { - printf("3C5x9 board on EISA at 0x%x - ",eth_base); - } else { - printf("3C5x9 board on ISA at 0x%x - ",eth_base); - } - - /* test for presence of connectors */ - i = inw(IS_BASE + EP_W0_CONFIG_CTRL); - j = inw(IS_BASE + EP_W0_ADDRESS_CFG) >> 14; - - switch(j) { - case 0: - if(i & IS_UTP) { - printf("10baseT\r\n"); - utp=1; - } - else { - printf("10baseT not present\r\n"); - eth_vendor=VENDOR_NONE; - goto no3c509; - } - - break; - case 1: - if(i & IS_AUI) - printf("10base5\r\n"); - else { - printf("10base5 not present\r\n"); - eth_vendor=VENDOR_NONE; - goto no3c509; - } - - break; - case 3: - if(i & IS_BNC) { - printf("10base2\r\n"); - bnc=1; - } - else { - printf("10base2 not present\r\n"); - eth_vendor=VENDOR_NONE; - goto no3c509; - } - - break; - default: - printf("unknown connector\r\n"); - eth_vendor=VENDOR_NONE; - goto no3c509; - } - /* - * Read the station address from the eeprom - */ - p = (u_short *) arptable[ARP_CLIENT].node; - for (i = 0; i < 3; i++) { - GO_WINDOW(0); - p[i] = htons(get_e(i)); - GO_WINDOW(2); - outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i])); - } - - printf("Ethernet address: "); - for(i=0; i<5; i++) { - printf("%b:",arptable[ARP_CLIENT].node[i]); - } - printf("%b\n",arptable[ARP_CLIENT].node[i]); - - eth_node_addr = arptable[ARP_CLIENT].node; - eth_reset(); - return eth_vendor; -no3c509: - eth_vendor = VENDOR_NONE; -#endif - -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) -#ifdef INCLUDE_WD - /****************************************************************** - Search for WD/SMC cards - *******************************************************************/ - for (eth_asic_base = WD_LOW_BASE; eth_asic_base <= WD_HIGH_BASE; - eth_asic_base += 0x20) { - chksum = 0; - for (i=8; i<16; i++) - chksum += inb(i+eth_asic_base); - if ((chksum & 0x00FF) == 0x00FF) - break; - } - if (eth_asic_base <= WD_HIGH_BASE) { /* We've found a board */ - eth_vendor = VENDOR_WD; - eth_nic_base = eth_asic_base + WD_NIC_ADDR; - c = inb(eth_asic_base+WD_BID); /* Get board id */ - for (brd = wd_boards; brd->name; brd++) - if (brd->id == c) break; - if (!brd->name) { - printf("\r\nUnknown Ethernet type %x\r\n", c); - return(0); /* Unknown type */ - } - eth_flags = brd->flags; - eth_memsize = brd->memsize; - eth_tx_start = 0; - if ((c == TYPE_WD8013EP) && - (inb(eth_asic_base + WD_ICR) & WD_ICR_16BIT)) { - eth_flags = FLAG_16BIT; - eth_memsize = MEM_16384; - } - if ((c & WD_SOFTCONFIG) && (!(eth_flags & FLAG_790))) { - eth_bmem = (char *)(0x80000 | - ((inb(eth_asic_base + WD_MSR) & 0x3F) << 13)); - } else - eth_bmem = (char *)WD_DEFAULT_MEM; - if (brd->id == TYPE_SMC8216T || brd->id == TYPE_SMC8216C) { - (unsigned int) *(eth_bmem + 8192) = (unsigned int)0; - if ((unsigned int) *(eth_bmem + 8192)) { - brd += 2; - eth_memsize = brd->memsize; - } - } - outb(eth_asic_base + WD_MSR, 0x80); /* Reset */ - printf("\r\n%s base 0x%x, memory 0x%X, addr ", - brd->name, eth_asic_base, eth_bmem); - for (i=0; i<6; i++) { - printf("%b",(int)(arptable[ARP_CLIENT].node[i] = - inb(i+eth_asic_base+WD_LAR))); - if (i < 5) printf (":"); - } - if (eth_flags & FLAG_790) { - outb(eth_asic_base+WD_MSR, WD_MSR_MENB); - outb(eth_asic_base+0x04, (inb(eth_asic_base+0x04) | - 0x80)); - outb(eth_asic_base+0x0B, - (((unsigned)eth_bmem >> 13) & 0x0F) | - (((unsigned)eth_bmem >> 11) & 0x40) | - (inb(eth_asic_base+0x0B) & 0xB0)); - outb(eth_asic_base+0x04, (inb(eth_asic_base+0x04) & - ~0x80)); - } else { - outb(eth_asic_base+WD_MSR, - (((unsigned)eth_bmem >> 13) & 0x3F) | 0x40); - } - if (eth_flags & FLAG_16BIT) { - if (eth_flags & FLAG_790) { - eth_laar = inb(eth_asic_base + WD_LAAR); - outb(eth_asic_base + WD_LAAR, WD_LAAR_M16EN); - inb(0x84); - } else { - outb(eth_asic_base + WD_LAAR, (eth_laar = - WD_LAAR_M16EN | WD_LAAR_L16EN | 1)); - } - } - printf("\r\n"); - - } -#endif -#ifdef INCLUDE_3COM - /****************************************************************** - Search for 3Com 3c503 if no WD/SMC cards - *******************************************************************/ - if (eth_vendor == VENDOR_NONE) { - eth_asic_base = _3COM_BASE + _3COM_ASIC_OFFSET; - eth_nic_base = _3COM_BASE; - eth_vendor = VENDOR_3COM; - /* - * Note that we use the same settings for both 8 and 16 bit cards: - * both have an 8K bank of memory at page 1 while only the 16 bit - * cards have a bank at page 0. - */ - eth_memsize = MEM_16384; - eth_tx_start = 32; - - /* Check our base address */ - - switch(inb(eth_asic_base + _3COM_BCFR)) { - case _3COM_BCFR_300: - if ((int)eth_nic_base != 0x300) - return(0); - break; - case _3COM_BCFR_310: - if ((int)eth_nic_base != 0x310) - return(0); - break; - case _3COM_BCFR_330: - if ((int)eth_nic_base != 0x330) - return(0); - break; - case _3COM_BCFR_350: - if ((int)eth_nic_base != 0x350) - return(0); - break; - case _3COM_BCFR_250: - if ((int)eth_nic_base != 0x250) - return(0); - break; - case _3COM_BCFR_280: - if ((int)eth_nic_base != 0x280) - return(0); - break; - case _3COM_BCFR_2A0: - if ((int)eth_nic_base != 0x2a0) - return(0); - break; - case _3COM_BCFR_2E0: - if ((int)eth_nic_base != 0x2e0) - return(0); - break; - default: - return (0); - } - - /* Now get the shared memory address */ - - switch (inb(eth_asic_base + _3COM_PCFR)) { - case _3COM_PCFR_DC000: - eth_bmem = (char *)0xdc000; - break; - case _3COM_PCFR_D8000: - eth_bmem = (char *)0xd8000; - break; - case _3COM_PCFR_CC000: - eth_bmem = (char *)0xcc000; - break; - case _3COM_PCFR_C8000: - eth_bmem = (char *)0xc8000; - break; - default: - return (0); - } - - /* Need this to make eth_poll() happy. */ - - eth_rmem = eth_bmem - 0x2000; - - /* Reset NIC and ASIC */ - - outb (eth_asic_base + _3COM_CR , _3COM_CR_RST | _3COM_CR_XSEL); - outb (eth_asic_base + _3COM_CR , _3COM_CR_XSEL); - - /* Get our ethernet address */ - - outb(eth_asic_base + _3COM_CR, _3COM_CR_EALO | _3COM_CR_XSEL); - printf("\r\n3Com 3c503 base 0x%x, memory 0x%X addr ", - eth_nic_base, eth_bmem); - for (i=0; i<6; i++) { - printf("%b",(int)(arptable[ARP_CLIENT].node[i] = - inb(eth_nic_base+i))); - if (i < 5) printf (":"); - } - outb(eth_asic_base + _3COM_CR, _3COM_CR_XSEL); - /* - * Initialize GA configuration register. Set bank and enable shared - * mem. We always use bank 1. - */ - outb(eth_asic_base + _3COM_GACFR, _3COM_GACFR_RSEL | - _3COM_GACFR_MBS0); - - outb(eth_asic_base + _3COM_VPTR2, 0xff); - outb(eth_asic_base + _3COM_VPTR1, 0xff); - outb(eth_asic_base + _3COM_VPTR0, 0x00); - /* - * Clear memory and verify that it worked (we use only 8K) - */ - bzero(eth_bmem, 0x2000); - for(i = 0; i < 0x2000; ++i) - if (*((eth_bmem)+i)) { - printf ("Failed to clear 3c503 shared mem.\r\n"); - return (0); - } - /* - * Initialize GA page/start/stop registers. - */ - outb(eth_asic_base + _3COM_PSTR, eth_tx_start); - outb(eth_asic_base + _3COM_PSPR, eth_memsize); - - printf ("\r\n"); - - } -#endif -#ifdef INCLUDE_NE - /****************************************************************** - Search for NE1000/2000 if no WD/SMC or 3com cards - *******************************************************************/ - if (eth_vendor == VENDOR_NONE) { - char romdata[16], testbuf[32]; - char test[] = "NE1000/2000 memory"; - eth_bmem = (char *)0; /* No shared memory */ - eth_asic_base = NE_BASE + NE_ASIC_OFFSET; - eth_nic_base = NE_BASE; - eth_vendor = VENDOR_NOVELL; - eth_flags = FLAG_PIO; - eth_memsize = MEM_16384; - eth_tx_start = 32; - c = inb(eth_asic_base + NE_RESET); - outb(eth_asic_base + NE_RESET, c); - inb(0x84); - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_STP | - D8390_COMMAND_RD2); - outb(eth_nic_base + D8390_P0_RCR, D8390_RCR_MON); - outb(eth_nic_base + D8390_P0_DCR, D8390_DCR_FT1 | D8390_DCR_LS); - outb(eth_nic_base + D8390_P0_PSTART, MEM_8192); - outb(eth_nic_base + D8390_P0_PSTOP, MEM_16384); - eth_pio_write(test, 8192, sizeof(test)); - eth_pio_read(8192, testbuf, sizeof(test)); - if (!bcompare(test, testbuf, sizeof(test))) { - eth_flags |= FLAG_16BIT; - eth_memsize = MEM_32768; - eth_tx_start = 64; - outb(eth_nic_base + D8390_P0_DCR, D8390_DCR_WTS | - D8390_DCR_FT1 | D8390_DCR_LS); - outb(eth_nic_base + D8390_P0_PSTART, MEM_16384); - outb(eth_nic_base + D8390_P0_PSTOP, MEM_32768); - eth_pio_write(test, 16384, sizeof(test)); - eth_pio_read(16384, testbuf, sizeof(test)); - if (!bcompare(testbuf, test, sizeof(test))) return (0); - } - eth_pio_read(0, romdata, 16); - printf("\r\nNE1000/NE2000 base 0x%x, addr ", eth_nic_base); - for (i=0; i<6; i++) { - printf("%b",(int)(arptable[ARP_CLIENT].node[i] = romdata[i - + ((eth_flags & FLAG_16BIT) ? i : 0)])); - if (i < 5) printf (":"); - } - printf("\r\n"); - } - if (eth_vendor == VENDOR_NONE) - goto no8390; - - if (eth_vendor != VENDOR_3COM) eth_rmem = eth_bmem; - eth_node_addr = arptable[ARP_CLIENT].node; - eth_reset(); - return(eth_vendor); -#endif /* NE */ -no8390: -#endif /*8390 */ - - return VENDOR_NONE; -} - -/************************************************************************** -ETH_RESET - Reset adapter -***************************************************************************/ -eth_reset() -{ - int s, i; - -#ifdef INCLUDE_3C509 - - /*********************************************************** - Reset 3Com 509 card - *************************************************************/ - - if(eth_vendor != VENDOR_3C509) - goto no3c509; - - /* stop card */ - outw(BASE + EP_COMMAND, RX_DISABLE); - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); - outw(BASE + EP_COMMAND, TX_DISABLE); - outw(BASE + EP_COMMAND, STOP_TRANSCEIVER); - outw(BASE + EP_COMMAND, RX_RESET); - outw(BASE + EP_COMMAND, TX_RESET); - outw(BASE + EP_COMMAND, C_INTR_LATCH); - outw(BASE + EP_COMMAND, SET_RD_0_MASK); - outw(BASE + EP_COMMAND, SET_INTR_MASK); - outw(BASE + EP_COMMAND, SET_RX_FILTER); - - /* - /* initialize card - */ - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); - - GO_WINDOW(0); - - /* Disable the card */ - outw(BASE + EP_W0_CONFIG_CTRL, 0); - - /* Configure IRQ to none */ - outw(BASE + EP_W0_RESOURCE_CFG, SET_IRQ(0)); - - /* Enable the card */ - outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ); - - GO_WINDOW(2); - - /* Reload the ether_addr. */ - for (i = 0; i < 6; i++) - outb(BASE + EP_W2_ADDR_0 + i, arptable[ARP_CLIENT].node[i]); - - outw(BASE + EP_COMMAND, RX_RESET); - outw(BASE + EP_COMMAND, TX_RESET); - - /* Window 1 is operating window */ - GO_WINDOW(1); - for (i = 0; i < 31; i++) - inb(BASE + EP_W1_TX_STATUS); - - /* get rid of stray intr's */ - outw(BASE + EP_COMMAND, ACK_INTR | 0xff); - - outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_5_INTS); - - outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS); - - outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | - FIL_BRDCST); - - /* configure BNC */ - if(bnc) { - outw(BASE + EP_COMMAND, START_TRANSCEIVER); - DELAY(1000); - } - /* configure UTP */ - if(utp) { - GO_WINDOW(4); - outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP); - GO_WINDOW(1); - } - - /* start tranciever and receiver */ - outw(BASE + EP_COMMAND, RX_ENABLE); - outw(BASE + EP_COMMAND, TX_ENABLE); - - /* set early threshold for minimal packet length */ - outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | 64); - - outw(BASE + EP_COMMAND, SET_TX_START_THRESH | 16); - - return 1; -no3c509: - -#endif - -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - - /************************************************************** - Reset cards based on 8390 chip - ****************************************************************/ - - if(eth_vendor!=VENDOR_WD && eth_vendor!=VENDOR_NOVELL - && eth_vendor!=VENDOR_3COM) - goto no8390; - - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, - D8390_COMMAND_PS0 | D8390_COMMAND_STP); - else - outb(eth_nic_base+D8390_P0_COMMAND, - D8390_COMMAND_PS0 | D8390_COMMAND_RD2 | - D8390_COMMAND_STP); - if (eth_flags & FLAG_16BIT) - outb(eth_nic_base+D8390_P0_DCR, 0x49); - else - outb(eth_nic_base+D8390_P0_DCR, 0x48); - outb(eth_nic_base+D8390_P0_RBCR0, 0); - outb(eth_nic_base+D8390_P0_RBCR1, 0); - outb(eth_nic_base+D8390_P0_RCR, 4); /* allow broadcast frames */ - outb(eth_nic_base+D8390_P0_TCR, 2); - outb(eth_nic_base+D8390_P0_TPSR, eth_tx_start); - outb(eth_nic_base+D8390_P0_PSTART, eth_tx_start + D8390_TXBUF_SIZE); - if (eth_flags & FLAG_790) outb(eth_nic_base + 0x09, 0); - outb(eth_nic_base+D8390_P0_PSTOP, eth_memsize); - outb(eth_nic_base+D8390_P0_BOUND, eth_tx_start + D8390_TXBUF_SIZE); - outb(eth_nic_base+D8390_P0_ISR, 0xFF); - outb(eth_nic_base+D8390_P0_IMR, 0); - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1 | - D8390_COMMAND_STP); - else - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1 | - D8390_COMMAND_RD2 | D8390_COMMAND_STP); - for (i=0; i<6; i++) - outb(eth_nic_base+D8390_P1_PAR0+i, eth_node_addr[i]); - for (i=0; i<6; i++) - outb(eth_nic_base+D8390_P1_MAR0+i, 0xFF); - outb(eth_nic_base+D8390_P1_CURR, eth_tx_start + D8390_TXBUF_SIZE+1); - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_STA); - else - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_RD2 | D8390_COMMAND_STA); - outb(eth_nic_base+D8390_P0_ISR, 0xFF); - outb(eth_nic_base+D8390_P0_TCR, 0); -#ifdef INCLUDE_3COM - if (eth_vendor == VENDOR_3COM) { - /* - * No way to tell whether or not we're supposed to use - * the 3Com's transceiver unless the user tells us. - * 'aui' should have some compile time default value - * which can be changed from the command menu. - */ - if (aui) - outb(eth_asic_base + _3COM_CR, 0); - else - outb(eth_asic_base + _3COM_CR, _3COM_CR_XSEL); - } -#endif - return(1); -no8390: -#endif /* 8390 */ -} - -/************************************************************************** -ETH_TRANSMIT - Transmit a frame -***************************************************************************/ -static const char padmap[] = { - 0, 3, 2, 1}; - -eth_transmit(d,t,s,p) -char *d; /* Destination */ -unsigned short t; /* Type */ -unsigned short s; /* size */ -char *p; /* Packet */ -{ - register u_int len; - int pad; - int status; - unsigned char c; - -#ifdef INCLUDE_3C509 - - if(eth_vendor != VENDOR_3C509) - goto no3c509; - -#ifdef EDEBUG - printf("{l=%d,t=%x}",s+14,t); -#endif - - /* swap bytes of type */ - t=(( t&0xFF )<<8) | ((t>>8) & 0xFF); - - len=s+14; /* actual length of packet */ - pad = padmap[len & 3]; - - /* - * The 3c509 automatically pads short packets to minimum ethernet length, - * but we drop packets that are too large. Perhaps we should truncate - * them instead? - */ - if (len + pad > ETHER_MAX_LEN) { - return 0; - } - - /* drop acknowledgements */ - while(( status=inb(BASE + EP_W1_TX_STATUS) )& TXS_COMPLETE ) { - if(status & (TXS_UNDERRUN|TXS_MAX_COLLISION|TXS_STATUS_OVERFLOW)) { - outw(BASE + EP_COMMAND, TX_RESET); - outw(BASE + EP_COMMAND, TX_ENABLE); - } - - outb(BASE + EP_W1_TX_STATUS, 0x0); - } - - while (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) { - /* no room in FIFO */ - } - - outw(BASE + EP_W1_TX_PIO_WR_1, len); - outw(BASE + EP_W1_TX_PIO_WR_1, 0x0); /* Second dword meaningless */ - - /* write packet */ - outsw(BASE + EP_W1_TX_PIO_WR_1, d, 3); - outsw(BASE + EP_W1_TX_PIO_WR_1, eth_node_addr, 3); - outw(BASE + EP_W1_TX_PIO_WR_1, t); - outsw(BASE + EP_W1_TX_PIO_WR_1, p, s / 2); - if (s & 1) - outb(BASE + EP_W1_TX_PIO_WR_1, *(p+s - 1)); - - while (pad--) - outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */ - - /* timeout after sending */ - DELAY(1000); - return 0; -no3c509: -#endif /* 3C509 */ - -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - - if(eth_vendor!=VENDOR_WD && eth_vendor!=VENDOR_NOVELL - && eth_vendor!=VENDOR_3COM) - goto no8390; - -#ifdef INCLUDE_3COM - if (eth_vendor == VENDOR_3COM) { - bcopy(d, eth_bmem, 6); /* dst */ - bcopy(eth_node_addr, eth_bmem+6, ETHER_ADDR_SIZE); /* src */ - *(eth_bmem+12) = t>>8; /* type */ - *(eth_bmem+13) = t; - bcopy(p, eth_bmem+14, s); - s += 14; - while (s < ETH_MIN_PACKET) *(eth_bmem+(s++)) = 0; - } -#endif -#ifdef INCLUDE_WD - if (eth_vendor == VENDOR_WD) { /* Memory interface */ - if (eth_flags & FLAG_16BIT) { - outb(eth_asic_base + WD_LAAR, eth_laar | WD_LAAR_M16EN); - inb(0x84); - } - if (eth_flags & FLAG_790) { - outb(eth_asic_base + WD_MSR, WD_MSR_MENB); - inb(0x84); - } - inb(0x84); - bcopy(d, eth_bmem, 6); /* dst */ - bcopy(eth_node_addr, eth_bmem+6, ETHER_ADDR_SIZE); /* src */ - *(eth_bmem+12) = t>>8; /* type */ - *(eth_bmem+13) = t; - bcopy(p, eth_bmem+14, s); - s += 14; - while (s < ETH_MIN_PACKET) *(eth_bmem+(s++)) = 0; - if (eth_flags & FLAG_790) { - outb(eth_asic_base + WD_MSR, 0); - inb(0x84); - } - if (eth_flags & FLAG_16BIT) { - outb(eth_asic_base + WD_LAAR, eth_laar & ~WD_LAAR_M16EN); - inb(0x84); - } - } -#endif -#ifdef INCLUDE_NE - if (eth_vendor == VENDOR_NOVELL) { /* Programmed I/O */ - unsigned short type; - type = (t >> 8) | (t << 8); - eth_pio_write(d, eth_tx_start<<8, 6); - eth_pio_write(eth_node_addr, (eth_tx_start<<8)+6, 6); - eth_pio_write(&type, (eth_tx_start<<8)+12, 2); - eth_pio_write(p, (eth_tx_start<<8)+14, s); - s += 14; - if (s < ETH_MIN_PACKET) s = ETH_MIN_PACKET; - } -#endif - twiddle(); - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_STA); - else - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_RD2 | D8390_COMMAND_STA); - outb(eth_nic_base+D8390_P0_TPSR, eth_tx_start); - outb(eth_nic_base+D8390_P0_TBCR0, s); - outb(eth_nic_base+D8390_P0_TBCR1, s>>8); - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_TXP | D8390_COMMAND_STA); - else - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_TXP | D8390_COMMAND_RD2 | - D8390_COMMAND_STA); - return(0); - -no8390: -#endif /* 8390 */ -} - -/************************************************************************** -ETH_POLL - Wait for a frame -***************************************************************************/ -eth_poll() -{ - /* common variables */ - unsigned short type = 0; - unsigned short len; - /* variables for 3C509 */ -#ifdef INCLUDE_3C509 - struct ether_header *eh; - int lenthisone; - short rx_fifo2, status, cst; - register short rx_fifo; -#endif - /* variables for 8390 */ -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - int ret = 0; - unsigned char bound,curr,rstat; - unsigned short pktoff; - unsigned char *p; - struct ringbuffer pkthdr; -#endif - -#ifdef INCLUDE_3C509 - - if(eth_vendor!=VENDOR_3C509) - goto no3c509; - - cst=inw(BASE + EP_STATUS); - -#ifdef EDEBUG - if(cst & 0x1FFF) - printf("-%x-",cst); -#endif - - if( (cst & (S_RX_COMPLETE|S_RX_EARLY) )==0 ) { - /* acknowledge everything */ - outw(BASE + EP_COMMAND, ACK_INTR| (cst & S_5_INTS)); - outw(BASE + EP_COMMAND, C_INTR_LATCH); - - return 0; - } - - status = inw(BASE + EP_W1_RX_STATUS); -#ifdef EDEBUG - printf("*%x*",status); -#endif - - if (status & ERR_RX) { - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - return 0; - } - - rx_fifo = status & RX_BYTES_MASK; - if (rx_fifo==0) - return 0; - - /* read packet */ -#ifdef EDEBUG - printf("[l=%d",rx_fifo); -#endif - insw(BASE + EP_W1_RX_PIO_RD_1, packet, rx_fifo / 2); - if(rx_fifo & 1) - packet[rx_fifo-1]=inb(BASE + EP_W1_RX_PIO_RD_1); - packetlen=rx_fifo; - - while(1) { - status = inw(BASE + EP_W1_RX_STATUS); -#ifdef EDEBUG - printf("*%x*",status); -#endif - rx_fifo = status & RX_BYTES_MASK; - - if(rx_fifo>0) { - insw(BASE + EP_W1_RX_PIO_RD_1, packet+packetlen, rx_fifo / 2); - if(rx_fifo & 1) - packet[packetlen+rx_fifo-1]=inb(BASE + EP_W1_RX_PIO_RD_1); - packetlen+=rx_fifo; -#ifdef EDEBUG - printf("+%d",rx_fifo); -#endif - } - - if(( status & RX_INCOMPLETE )==0) { -#ifdef EDEBUG - printf("=%d",packetlen); -#endif - break; - } - - DELAY(1000); - } - - /* acknowledge reception of packet */ - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); - - type = (packet[12]<<8) | packet[13]; - -#ifdef EDEBUG - if(packet[0]+packet[1]+packet[2]+packet[3]+packet[4]+ - packet[5] == 0xFF*6) - printf(",t=0x%x,b]",type); - else - printf(",t=0x%x]",type); -#endif - - - if (type == ARP) { - struct arprequest *arpreq; - unsigned long reqip; - - arpreq = (struct arprequest *)&packet[ETHER_HDR_SIZE]; - -#ifdef EDEBUG - printf("(ARP %I->%I)",ntohl(*(int*)arpreq->sipaddr), - ntohl(*(int*)arpreq->tipaddr)); -#endif - - convert_ipaddr(&reqip, arpreq->tipaddr); - if ((ntohs(arpreq->opcode) == ARP_REQUEST) && - (reqip == arptable[ARP_CLIENT].ipaddr)) { - arpreq->opcode = htons(ARP_REPLY); - bcopy(arpreq->sipaddr, arpreq->tipaddr, 4); - bcopy(arpreq->shwaddr, arpreq->thwaddr, 6); - bcopy(arptable[ARP_CLIENT].node, arpreq->shwaddr, 6); - convert_ipaddr(arpreq->sipaddr, &reqip); - eth_transmit(arpreq->thwaddr, ARP, sizeof(struct arprequest), - arpreq); - return(0); - } - } else if(type==IP) { - struct iphdr *iph; - - iph = (struct iphdr *)&packet[ETHER_HDR_SIZE]; -#ifdef EDEBUG - printf("(IP %I-%d->%I)",ntohl(*(int*)iph->src), - ntohs(iph->protocol),ntohl(*(int*)iph->dest)); -#endif - } - - return 1; - -no3c509: -#endif /* 3C509 */ -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - - if(eth_vendor!=VENDOR_WD && eth_vendor!=VENDOR_NOVELL - && eth_vendor!=VENDOR_3COM) - goto no8390; - - rstat = inb(eth_nic_base+D8390_P0_RSR); - if (rstat & D8390_RSTAT_OVER) { - eth_reset(); - return(0); - } - if (!(rstat & D8390_RSTAT_PRX)) return(0); - bound = inb(eth_nic_base+D8390_P0_BOUND)+1; - if (bound == eth_memsize) bound = eth_tx_start + D8390_TXBUF_SIZE; - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1); - curr = inb(eth_nic_base+D8390_P1_CURR); - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0); - if (curr == eth_memsize) curr=eth_tx_start + D8390_TXBUF_SIZE; - if (curr == bound) return(0); - if (eth_vendor == VENDOR_WD) { - if (eth_flags & FLAG_16BIT) { - outb(eth_asic_base + WD_LAAR, eth_laar | WD_LAAR_M16EN); - inb(0x84); - } - if (eth_flags & FLAG_790) { - outb(eth_asic_base + WD_MSR, WD_MSR_MENB); - inb(0x84); - } - inb(0x84); - } - pktoff = (bound << 8); - if (eth_flags & FLAG_PIO) - eth_pio_read(pktoff, &pkthdr, 4); - else - bcopy(eth_rmem + pktoff, &pkthdr, 4); - len = pkthdr.len - 4; /* sub CRC */ - pktoff += 4; - if (len > 1514) len = 1514; - bound = pkthdr.bound; /* New bound ptr */ - if ( (pkthdr.status & D8390_RSTAT_PRX) && (len > 14) && (len < 1518)) { - p = packet; - packetlen = len; - len = (eth_memsize << 8) - pktoff; - if (packetlen > len) { /* We have a wrap-around */ - if (eth_flags & FLAG_PIO) - eth_pio_read(pktoff, p, len); - else - bcopy(eth_rmem + pktoff, p, len); - pktoff = (eth_tx_start + D8390_TXBUF_SIZE) << 8; - p += len; - packetlen -= len; - } - if (eth_flags & FLAG_PIO) - eth_pio_read(pktoff, p, packetlen); - else - bcopy(eth_rmem + pktoff, p, packetlen); - - type = (packet[12]<<8) | packet[13]; - ret = 1; - } - if (eth_vendor == VENDOR_WD) { - if (eth_flags & FLAG_790) { - outb(eth_asic_base + WD_MSR, 0); - inb(0x84); - } - if (eth_flags & FLAG_16BIT) { - outb(eth_asic_base + WD_LAAR, eth_laar & - ~WD_LAAR_M16EN); - inb(0x84); - } - inb(0x84); - } - if (bound == (eth_tx_start + D8390_TXBUF_SIZE)) - bound = eth_memsize; - outb(eth_nic_base+D8390_P0_BOUND, bound-1); - if (ret && (type == ARP)) { - struct arprequest *arpreq; - unsigned long reqip; - arpreq = (struct arprequest *)&packet[ETHER_HDR_SIZE]; - convert_ipaddr(&reqip, arpreq->tipaddr); - if ((ntohs(arpreq->opcode) == ARP_REQUEST) && - (reqip == arptable[ARP_CLIENT].ipaddr)) { - arpreq->opcode = htons(ARP_REPLY); - bcopy(arpreq->sipaddr, arpreq->tipaddr, 4); - bcopy(arpreq->shwaddr, arpreq->thwaddr, 6); - bcopy(arptable[ARP_CLIENT].node, arpreq->shwaddr, 6); - convert_ipaddr(arpreq->sipaddr, &reqip); - eth_transmit(arpreq->thwaddr, ARP, sizeof(struct arprequest), - arpreq); - return(0); - } - } - return(ret); -no8390: -#endif /* 8390 */ -} - -#ifdef INCLUDE_NE -/************************************************************************** -NE1000/NE2000 Support Routines -***************************************************************************/ - -/* inw and outw are not needed more - standard version of them is used */ - -/************************************************************************** -ETH_PIO_READ - Read a frame via Programmed I/O -***************************************************************************/ -eth_pio_read(src, dst, cnt, init) -unsigned short src; -unsigned char *dst; -unsigned short cnt; -int init; -{ - if (cnt & 1) cnt++; - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD2 | - D8390_COMMAND_STA); - outb(eth_nic_base + D8390_P0_RBCR0, cnt); - outb(eth_nic_base + D8390_P0_RBCR1, cnt>>8); - outb(eth_nic_base + D8390_P0_RSAR0, src); - outb(eth_nic_base + D8390_P0_RSAR1, src>>8); - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD0 | - D8390_COMMAND_STA); - if (eth_flags & FLAG_16BIT) { - while (cnt) { - *((unsigned short *)dst) = inw(eth_asic_base + NE_DATA); - dst += 2; - cnt -= 2; - } - } - else { - while (cnt--) - *(dst++) = inb(eth_asic_base + NE_DATA); - } -} - -/************************************************************************** -ETH_PIO_WRITE - Write a frame via Programmed I/O -***************************************************************************/ -eth_pio_write(src, dst, cnt, init) -unsigned char *src; -unsigned short dst; -unsigned short cnt; -int init; -{ - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD2 | - D8390_COMMAND_STA); - outb(eth_nic_base + D8390_P0_ISR, D8390_ISR_RDC); - outb(eth_nic_base + D8390_P0_RBCR0, cnt); - outb(eth_nic_base + D8390_P0_RBCR1, cnt>>8); - outb(eth_nic_base + D8390_P0_RSAR0, dst); - outb(eth_nic_base + D8390_P0_RSAR1, dst>>8); - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD1 | - D8390_COMMAND_STA); - if (eth_flags & FLAG_16BIT) { - if (cnt & 1) cnt++; /* Round up */ - while (cnt) { - outw(eth_asic_base + NE_DATA, *((unsigned short *)src)); - src += 2; - cnt -= 2; - } - } - else { - while (cnt--) - outb(eth_asic_base + NE_DATA, *(src++)); - } - while((inb(eth_nic_base + D8390_P0_ISR) & D8390_ISR_RDC) - != D8390_ISR_RDC); -} -#else -/************************************************************************** -ETH_PIO_READ - Dummy routine when NE2000 not compiled in -***************************************************************************/ -eth_pio_read() { -} -#endif - -#ifdef INCLUDE_3C509 -/************************************************************************* - 3Com 509 - specific routines -**************************************************************************/ - -static int -eeprom_rdy() -{ - int i; - - for (i = 0; is_eeprom_busy(IS_BASE) && i < MAX_EEPROMBUSY; i++); - if (i >= MAX_EEPROMBUSY) { - printf("3c509: eeprom failed to come ready.\r\n"); - return (0); - } - return (1); -} - -/* - * get_e: gets a 16 bits word from the EEPROM. we must have set the window - * before - */ -static int -get_e(offset) -int offset; -{ - if (!eeprom_rdy()) - return (0xffff); - outw(IS_BASE + EP_W0_EEPROM_COMMAND, EEPROM_CMD_RD | offset); - if (!eeprom_rdy()) - return (0xffff); - return (inw(IS_BASE + EP_W0_EEPROM_DATA)); -} - -static int -send_ID_sequence(port) -int port; -{ - int cx, al; - - for (al = 0xff, cx = 0; cx < 255; cx++) { - outb(port, al); - al <<= 1; - if (al & 0x100) - al ^= 0xcf; - } - return (1); -} - - -/* - * We get eeprom data from the id_port given an offset into the eeprom. - * Basically; after the ID_sequence is sent to all of the cards; they enter - * the ID_CMD state where they will accept command requests. 0x80-0xbf loads - * the eeprom data. We then read the port 16 times and with every read; the - * cards check for contention (ie: if one card writes a 0 bit and another - * writes a 1 bit then the host sees a 0. At the end of the cycle; each card - * compares the data on the bus; if there is a difference then that card goes - * into ID_WAIT state again). In the meantime; one bit of data is returned in - * the AX register which is conveniently returned to us by inb(). Hence; we - * read 16 times getting one bit of data with each read. - */ -static int -get_eeprom_data(id_port, offset) -int id_port; -int offset; -{ - int i, data = 0; - outb(id_port, 0x80 + offset); - DELAY(1000); - for (i = 0; i < 16; i++) - data = (data << 1) | (inw(id_port) & 1); - return (data); -} - -/* a surrogate */ - -DELAY(val) -{ - int c; - - for(c=0; c<val; c+=20) { - twiddle(); - } -} - -#endif - diff --git a/sys/i386/boot/netboot/ether.h b/sys/i386/boot/netboot/ether.h deleted file mode 100644 index 8cd4df4870fe..000000000000 --- a/sys/i386/boot/netboot/ether.h +++ /dev/null @@ -1,262 +0,0 @@ -/************************************************************************** -NETBOOT - BOOTP/TFTP Bootstrap Program - -Author: Martin Renters - Date: Jun/94 - -**************************************************************************/ - -#define TRUE 1 -#define FALSE 0 - -#define ETH_MIN_PACKET 64 -#define ETH_MAX_PACKET 1518 - -#define VENDOR_NONE 0 -#define VENDOR_WD 1 -#define VENDOR_NOVELL 2 -#define VENDOR_3COM 3 -#define VENDOR_3C509 4 - -#define FLAG_PIO 0x01 -#define FLAG_16BIT 0x02 -#define FLAG_790 0x04 - -#define MEM_8192 32 -#define MEM_16384 64 -#define MEM_32768 128 - -/************************************************************************** -Western Digital/SMC Board Definitions -**************************************************************************/ -#define WD_LOW_BASE 0x200 -#define WD_HIGH_BASE 0x3e0 -#ifndef WD_DEFAULT_MEM -#define WD_DEFAULT_MEM 0xD0000 -#endif -#define WD_NIC_ADDR 0x10 - -/************************************************************************** -Western Digital/SMC ASIC Addresses -**************************************************************************/ -#define WD_MSR 0x00 -#define WD_ICR 0x01 -#define WD_IAR 0x02 -#define WD_BIO 0x03 -#define WD_IRR 0x04 -#define WD_LAAR 0x05 -#define WD_IJR 0x06 -#define WD_GP2 0x07 -#define WD_LAR 0x08 -#define WD_BID 0x0E - -#define WD_ICR_16BIT 0x01 - -#define WD_MSR_MENB 0x40 - -#define WD_LAAR_L16EN 0x40 -#define WD_LAAR_M16EN 0x80 - -#define WD_SOFTCONFIG 0x20 - -/************************************************************************** -Western Digital/SMC Board Types -**************************************************************************/ -#define TYPE_WD8003S 0x02 -#define TYPE_WD8003E 0x03 -#define TYPE_WD8013EBT 0x05 -#define TYPE_WD8003W 0x24 -#define TYPE_WD8003EB 0x25 -#define TYPE_WD8013W 0x26 -#define TYPE_WD8013EP 0x27 -#define TYPE_WD8013WC 0x28 -#define TYPE_WD8013EPC 0x29 -#define TYPE_SMC8216T 0x2a -#define TYPE_SMC8216C 0x2b -#define TYPE_SMC8416T 0x00 /* Bogus entries: the 8416 generates the */ -#define TYPE_SMC8416C 0x00 /* the same codes as the 8216. */ -#define TYPE_SMC8013EBP 0x2c - -#ifdef INCLUDE_WD -struct wd_board { - char *name; - char id; - char flags; - char memsize; -} wd_boards[] = { - {"WD8003S", TYPE_WD8003S, 0, MEM_8192}, - {"WD8003E", TYPE_WD8003E, 0, MEM_8192}, - {"WD8013EBT", TYPE_WD8013EBT, FLAG_16BIT, MEM_16384}, - {"WD8003W", TYPE_WD8003W, 0, MEM_8192}, - {"WD8003EB", TYPE_WD8003EB, 0, MEM_8192}, - {"WD8013W", TYPE_WD8013W, FLAG_16BIT, MEM_16384}, - {"WD8003EP/WD8013EP", - TYPE_WD8013EP, 0, MEM_8192}, - {"WD8013WC", TYPE_WD8013WC, FLAG_16BIT, MEM_16384}, - {"WD8013EPC", TYPE_WD8013EPC, FLAG_16BIT, MEM_16384}, - {"SMC8216T", TYPE_SMC8216T, FLAG_16BIT | FLAG_790, MEM_16384}, - {"SMC8216C", TYPE_SMC8216C, FLAG_16BIT | FLAG_790, MEM_16384}, - {"SMC8416T", TYPE_SMC8416T, FLAG_16BIT | FLAG_790, MEM_8192}, - {"SMC8416C/BT", TYPE_SMC8416C, FLAG_16BIT | FLAG_790, MEM_8192}, - {"SMC8013EBP", TYPE_SMC8013EBP,FLAG_16BIT, MEM_16384}, - {NULL, 0, 0} -}; -#endif -/************************************************************************** -3com 3c503 definitions -**************************************************************************/ - -#ifndef _3COM_BASE -#define _3COM_BASE 0x300 -#endif - -#define _3COM_TX_PAGE_OFFSET_8BIT 0x20 -#define _3COM_TX_PAGE_OFFSET_16BIT 0x0 -#define _3COM_RX_PAGE_OFFSET_16BIT 0x20 - -#define _3COM_ASIC_OFFSET 0x400 -#define _3COM_NIC_OFFSET 0x0 - -#define _3COM_PSTR 0 -#define _3COM_PSPR 1 - -#define _3COM_BCFR 3 -#define _3COM_BCFR_2E0 0x01 -#define _3COM_BCFR_2A0 0x02 -#define _3COM_BCFR_280 0x04 -#define _3COM_BCFR_250 0x08 -#define _3COM_BCFR_350 0x10 -#define _3COM_BCFR_330 0x20 -#define _3COM_BCFR_310 0x40 -#define _3COM_BCFR_300 0x80 -#define _3COM_PCFR 4 -#define _3COM_PCFR_C8000 0x10 -#define _3COM_PCFR_CC000 0x20 -#define _3COM_PCFR_D8000 0x40 -#define _3COM_PCFR_DC000 0x80 -#define _3COM_CR 6 -#define _3COM_CR_RST 0x01 /* Reset GA and NIC */ -#define _3COM_CR_XSEL 0x02 /* Transceiver select. BNC=1(def) AUI=0 */ -#define _3COM_CR_EALO 0x04 /* window EA PROM 0-15 to I/O base */ -#define _3COM_CR_EAHI 0x08 /* window EA PROM 16-31 to I/O base */ -#define _3COM_CR_SHARE 0x10 /* select interrupt sharing option */ -#define _3COM_CR_DBSEL 0x20 /* Double buffer select */ -#define _3COM_CR_DDIR 0x40 /* DMA direction select */ -#define _3COM_CR_START 0x80 /* Start DMA controller */ -#define _3COM_GACFR 5 -#define _3COM_GACFR_MBS0 0x01 -#define _3COM_GACFR_MBS1 0x02 -#define _3COM_GACFR_MBS2 0x04 -#define _3COM_GACFR_RSEL 0x08 /* enable shared memory */ -#define _3COM_GACFR_TEST 0x10 /* for GA testing */ -#define _3COM_GACFR_OWS 0x20 /* select 0WS access to GA */ -#define _3COM_GACFR_TCM 0x40 /* Mask DMA interrupts */ -#define _3COM_GACFR_NIM 0x80 /* Mask NIC interrupts */ -#define _3COM_STREG 7 -#define _3COM_STREG_REV 0x07 /* GA revision */ -#define _3COM_STREG_DIP 0x08 /* DMA in progress */ -#define _3COM_STREG_DTC 0x10 /* DMA terminal count */ -#define _3COM_STREG_OFLW 0x20 /* Overflow */ -#define _3COM_STREG_UFLW 0x40 /* Underflow */ -#define _3COM_STREG_DPRDY 0x80 /* Data port ready */ -#define _3COM_IDCFR 8 -#define _3COM_IDCFR_DRQ0 0x01 /* DMA request 1 select */ -#define _3COM_IDCFR_DRQ1 0x02 /* DMA request 2 select */ -#define _3COM_IDCFR_DRQ2 0x04 /* DMA request 3 select */ -#define _3COM_IDCFR_UNUSED 0x08 /* not used */ -#define _3COM_IDCFR_IRQ2 0x10 /* Interrupt request 2 select */ -#define _3COM_IDCFR_IRQ3 0x20 /* Interrupt request 3 select */ -#define _3COM_IDCFR_IRQ4 0x40 /* Interrupt request 4 select */ -#define _3COM_IDCFR_IRQ5 0x80 /* Interrupt request 5 select */ -#define _3COM_IRQ2 2 -#define _3COM_IRQ3 3 -#define _3COM_IRQ4 4 -#define _3COM_IRQ5 5 -#define _3COM_DAMSB 9 -#define _3COM_DALSB 0x0a -#define _3COM_VPTR2 0x0b -#define _3COM_VPTR1 0x0c -#define _3COM_VPTR0 0x0d -#define _3COM_RFMSB 0x0e -#define _3COM_RFLSB 0x0f - -/************************************************************************** -NE1000/2000 definitions -**************************************************************************/ -#ifndef NE_BASE -#define NE_BASE 0x320 -#endif -#define NE_ASIC_OFFSET 0x10 -#define NE_RESET 0x0F /* Used to reset card */ -#define NE_DATA 0x00 /* Used to read/write NIC mem */ - -/************************************************************************** -8390 Register Definitions -**************************************************************************/ -#define D8390_P0_COMMAND 0x00 -#define D8390_P0_PSTART 0x01 -#define D8390_P0_PSTOP 0x02 -#define D8390_P0_BOUND 0x03 -#define D8390_P0_TSR 0x04 -#define D8390_P0_TPSR 0x04 -#define D8390_P0_TBCR0 0x05 -#define D8390_P0_TBCR1 0x06 -#define D8390_P0_ISR 0x07 -#define D8390_P0_RSAR0 0x08 -#define D8390_P0_RSAR1 0x09 -#define D8390_P0_RBCR0 0x0A -#define D8390_P0_RBCR1 0x0B -#define D8390_P0_RSR 0x0C -#define D8390_P0_RCR 0x0C -#define D8390_P0_TCR 0x0D -#define D8390_P0_DCR 0x0E -#define D8390_P0_IMR 0x0F -#define D8390_P1_COMMAND 0x00 -#define D8390_P1_PAR0 0x01 -#define D8390_P1_PAR1 0x02 -#define D8390_P1_PAR2 0x03 -#define D8390_P1_PAR3 0x04 -#define D8390_P1_PAR4 0x05 -#define D8390_P1_PAR5 0x06 -#define D8390_P1_CURR 0x07 -#define D8390_P1_MAR0 0x08 - -#define D8390_COMMAND_PS0 0x0 /* Page 0 select */ -#define D8390_COMMAND_PS1 0x40 /* Page 1 select */ -#define D8390_COMMAND_PS2 0x80 /* Page 2 select */ -#define D8390_COMMAND_RD2 0x20 /* Remote DMA control */ -#define D8390_COMMAND_RD1 0x10 -#define D8390_COMMAND_RD0 0x08 -#define D8390_COMMAND_TXP 0x04 /* transmit packet */ -#define D8390_COMMAND_STA 0x02 /* start */ -#define D8390_COMMAND_STP 0x01 /* stop */ - -#define D8390_RCR_MON 0x20 /* monitor mode */ - -#define D8390_DCR_FT1 0x40 -#define D8390_DCR_LS 0x08 /* Loopback select */ -#define D8390_DCR_WTS 0x01 /* Word transfer select */ - -#define D8390_ISR_PRX 0x01 /* successful recv */ -#define D8390_ISR_PTX 0x02 /* successful xmit */ -#define D8390_ISR_RXE 0x04 /* receive error */ -#define D8390_ISR_TXE 0x08 /* transmit error */ -#define D8390_ISR_OVW 0x10 /* Overflow */ -#define D8390_ISR_CNT 0x20 /* Counter overflow */ -#define D8390_ISR_RDC 0x40 /* Remote DMA complete */ -#define D8390_ISR_RST 0x80 /* reset */ - -#define D8390_RSTAT_PRX 0x01 /* successful recv */ -#define D8390_RSTAT_CRC 0x02 /* CRC error */ -#define D8390_RSTAT_FAE 0x04 /* Frame alignment error */ -#define D8390_RSTAT_OVER 0x08 /* overflow */ - -#define D8390_TXBUF_SIZE 6 -#define D8390_RXBUF_END 32 -#define D8390_PAGE_SIZE 256 - -struct ringbuffer { - unsigned char status; - unsigned char bound; - unsigned short len; -}; diff --git a/sys/i386/boot/netboot/if_epreg.h b/sys/i386/boot/netboot/if_epreg.h deleted file mode 100644 index 049f235bbc5b..000000000000 --- a/sys/i386/boot/netboot/if_epreg.h +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. 2. The name - * of the author may not be used to endorse or promote products derived from - * this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * if_epreg.h,v 1.4 1994/11/13 10:12:37 gibbs Exp Modified by: - * - October 2, 1994 - - Modified by: Andres Vega Garcia - - INRIA - Sophia Antipolis, France - e-mail: avega@sophia.inria.fr - finger: avega@pax.inria.fr - - */ - -/* - * Ethernet software status per interface. - */ -/* - * Some global constants - */ -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - -#define TX_INIT_RATE 16 -#define TX_INIT_MAX_RATE 64 -#define RX_INIT_LATENCY 64 -#define RX_INIT_EARLY_THRESH 64 -#define MIN_RX_EARLY_THRESHF 16 /* not less than ether_header */ -#define MIN_RX_EARLY_THRESHL 4 - -#define EEPROMSIZE 0x40 -#define MAX_EEPROMBUSY 1000 -#define EP_LAST_TAG 0xd7 -#define EP_MAX_BOARDS 16 -#define EP_ID_PORT 0x100 - -/* - * some macros to acces long named fields - */ -#define IS_BASE (eth_base) -#define BASE (eth_base) - -/* - * Commands to read/write EEPROM trough EEPROM command register (Window 0, - * Offset 0xa) - */ -#define EEPROM_CMD_RD 0x0080 /* Read: Address required (5 bits) */ -#define EEPROM_CMD_WR 0x0040 /* Write: Address required (5 bits) */ -#define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */ -#define EEPROM_CMD_EWEN 0x0030 /* Erase/Write Enable: No data required */ - -#define EEPROM_BUSY (1<<15) -#define EEPROM_TST_MODE (1<<14) - -/* - * Some short functions, worth to let them be a macro - */ -#define is_eeprom_busy(b) (inw((b)+EP_W0_EEPROM_COMMAND)&EEPROM_BUSY) -#define GO_WINDOW(x) outw(BASE+EP_COMMAND, WINDOW_SELECT|(x)) - -/************************************************************************** - * * - * These define the EEPROM data structure. They are used in the probe - * function to verify the existance of the adapter after having sent - * the ID_Sequence. - * - * There are others but only the ones we use are defined here. - * - **************************************************************************/ - -#define EEPROM_NODE_ADDR_0 0x0 /* Word */ -#define EEPROM_NODE_ADDR_1 0x1 /* Word */ -#define EEPROM_NODE_ADDR_2 0x2 /* Word */ -#define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */ -#define EEPROM_MFG_ID 0x7 /* 0x6d50 */ -#define EEPROM_ADDR_CFG 0x8 /* Base addr */ -#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */ - -/************************************************************************** - * * - * These are the registers for the 3Com 3c509 and their bit patterns when * - * applicable. They have been taken out the the "EtherLink III Parallel * - * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual * - * from 3com. * - * * - **************************************************************************/ - -#define EP_COMMAND 0x0e /* Write. BASE+0x0e is always a - * command reg. */ -#define EP_STATUS 0x0e /* Read. BASE+0x0e is always status - * reg. */ -#define EP_WINDOW 0x0f /* Read. BASE+0x0f is always window - * reg. */ -/* - * Window 0 registers. Setup. - */ -/* Write */ -#define EP_W0_EEPROM_DATA 0x0c -#define EP_W0_EEPROM_COMMAND 0x0a -#define EP_W0_RESOURCE_CFG 0x08 -#define EP_W0_ADDRESS_CFG 0x06 -#define EP_W0_CONFIG_CTRL 0x04 -/* Read */ -#define EP_W0_PRODUCT_ID 0x02 -#define EP_W0_MFG_ID 0x00 - -/* - * Window 1 registers. Operating Set. - */ -/* Write */ -#define EP_W1_TX_PIO_WR_2 0x02 -#define EP_W1_TX_PIO_WR_1 0x00 -/* Read */ -#define EP_W1_FREE_TX 0x0c -#define EP_W1_TX_STATUS 0x0b /* byte */ -#define EP_W1_TIMER 0x0a /* byte */ -#define EP_W1_RX_STATUS 0x08 -#define EP_W1_RX_PIO_RD_2 0x02 -#define EP_W1_RX_PIO_RD_1 0x00 - -/* - * Window 2 registers. Station Address Setup/Read - */ -/* Read/Write */ -#define EP_W2_ADDR_5 0x05 -#define EP_W2_ADDR_4 0x04 -#define EP_W2_ADDR_3 0x03 -#define EP_W2_ADDR_2 0x02 -#define EP_W2_ADDR_1 0x01 -#define EP_W2_ADDR_0 0x00 - -/* - * Window 3 registers. FIFO Management. - */ -/* Read */ -#define EP_W3_FREE_TX 0x0c -#define EP_W3_FREE_RX 0x0a - -/* - * Window 4 registers. Diagnostics. - */ -/* Read/Write */ -#define EP_W4_MEDIA_TYPE 0x0a -#define EP_W4_CTRLR_STATUS 0x08 -#define EP_W4_NET_DIAG 0x06 -#define EP_W4_FIFO_DIAG 0x04 -#define EP_W4_HOST_DIAG 0x02 -#define EP_W4_TX_DIAG 0x00 - -/* - * Window 5 Registers. Results and Internal status. - */ -/* Read */ -#define EP_W5_READ_0_MASK 0x0c -#define EP_W5_INTR_MASK 0x0a -#define EP_W5_RX_FILTER 0x08 -#define EP_W5_RX_EARLY_THRESH 0x06 -#define EP_W5_TX_AVAIL_THRESH 0x02 -#define EP_W5_TX_START_THRESH 0x00 - -/* - * Window 6 registers. Statistics. - */ -/* Read/Write */ -#define TX_TOTAL_OK 0x0c -#define RX_TOTAL_OK 0x0a -#define TX_DEFERRALS 0x08 -#define RX_FRAMES_OK 0x07 -#define TX_FRAMES_OK 0x06 -#define RX_OVERRUNS 0x05 -#define TX_COLLISIONS 0x04 -#define TX_AFTER_1_COLLISION 0x03 -#define TX_AFTER_X_COLLISIONS 0x02 -#define TX_NO_SQE 0x01 -#define TX_CD_LOST 0x00 - -/**************************************** - * - * Register definitions. - * - ****************************************/ - -/* - * Command register. All windows. - * - * 16 bit register. - * 15-11: 5-bit code for command to be executed. - * 10-0: 11-bit arg if any. For commands with no args; - * this can be set to anything. - */ -#define GLOBAL_RESET (u_short) 0x0000 /* Wait at least 1ms - * after issuing */ -#define WINDOW_SELECT (u_short) (0x1<<11) -#define START_TRANSCEIVER (u_short) (0x2<<11) /* Read ADDR_CFG reg to - * determine whether - * this is needed. If - * so; wait 800 uSec - * before using trans- - * ceiver. */ -#define RX_DISABLE (u_short) (0x3<<11) /* state disabled on - * power-up */ -#define RX_ENABLE (u_short) (0x4<<11) -#define RX_RESET (u_short) (0x5<<11) -#define RX_DISCARD_TOP_PACK (u_short) (0x8<<11) -#define TX_ENABLE (u_short) (0x9<<11) -#define TX_DISABLE (u_short) (0xa<<11) -#define TX_RESET (u_short) (0xb<<11) -#define REQ_INTR (u_short) (0xc<<11) -#define SET_INTR_MASK (u_short) (0xe<<11) -#define SET_RD_0_MASK (u_short) (0xf<<11) -#define SET_RX_FILTER (u_short) (0x10<<11) -#define FIL_INDIVIDUAL (u_short) (0x1) -#define FIL_GROUP (u_short) (0x2) -#define FIL_BRDCST (u_short) (0x4) -#define FIL_ALL (u_short) (0x8) -#define SET_RX_EARLY_THRESH (u_short) (0x11<<11) -#define SET_TX_AVAIL_THRESH (u_short) (0x12<<11) -#define SET_TX_START_THRESH (u_short) (0x13<<11) -#define STATS_ENABLE (u_short) (0x15<<11) -#define STATS_DISABLE (u_short) (0x16<<11) -#define STOP_TRANSCEIVER (u_short) (0x17<<11) -/* - * The following C_* acknowledge the various interrupts. Some of them don't - * do anything. See the manual. - */ -#define ACK_INTR (u_short) (0x6800) -#define C_INTR_LATCH (u_short) (ACK_INTR|0x1) -#define C_CARD_FAILURE (u_short) (ACK_INTR|0x2) -#define C_TX_COMPLETE (u_short) (ACK_INTR|0x4) -#define C_TX_AVAIL (u_short) (ACK_INTR|0x8) -#define C_RX_COMPLETE (u_short) (ACK_INTR|0x10) -#define C_RX_EARLY (u_short) (ACK_INTR|0x20) -#define C_INT_RQD (u_short) (ACK_INTR|0x40) -#define C_UPD_STATS (u_short) (ACK_INTR|0x80) - -/* - * Status register. All windows. - * - * 15-13: Window number(0-7). - * 12: Command_in_progress. - * 11: reserved. - * 10: reserved. - * 9: reserved. - * 8: reserved. - * 7: Update Statistics. - * 6: Interrupt Requested. - * 5: RX Early. - * 4: RX Complete. - * 3: TX Available. - * 2: TX Complete. - * 1: Adapter Failure. - * 0: Interrupt Latch. - */ -#define S_INTR_LATCH (u_short) (0x1) -#define S_CARD_FAILURE (u_short) (0x2) -#define S_TX_COMPLETE (u_short) (0x4) -#define S_TX_AVAIL (u_short) (0x8) -#define S_RX_COMPLETE (u_short) (0x10) -#define S_RX_EARLY (u_short) (0x20) -#define S_INT_RQD (u_short) (0x40) -#define S_UPD_STATS (u_short) (0x80) -#define S_5_INTS (S_CARD_FAILURE|S_TX_COMPLETE|\ - S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY) -#define S_COMMAND_IN_PROGRESS (u_short) (0x1000) - -/* - * FIFO Registers. - * RX Status. Window 1/Port 08 - * - * 15: Incomplete or FIFO empty. - * 14: 1: Error in RX Packet 0: Incomplete or no error. - * 13-11: Type of error. - * 1000 = Overrun. - * 1011 = Run Packet Error. - * 1100 = Alignment Error. - * 1101 = CRC Error. - * 1001 = Oversize Packet Error (>1514 bytes) - * 0010 = Dribble Bits. - * (all other error codes, no errors.) - * - * 10-0: RX Bytes (0-1514) - */ -#define ERR_RX_INCOMPLETE (u_short) (0x1<<15) -#define ERR_RX (u_short) (0x1<<14) -#define ERR_RX_OVERRUN (u_short) (0x8<<11) -#define ERR_RX_RUN_PKT (u_short) (0xb<<11) -#define ERR_RX_ALIGN (u_short) (0xc<<11) -#define ERR_RX_CRC (u_short) (0xd<<11) -#define ERR_RX_OVERSIZE (u_short) (0x9<<11) -#define ERR_RX_DRIBBLE (u_short) (0x2<<11) - -/* - * FIFO Registers. - * TX Status. Window 1/Port 0B - * - * Reports the transmit status of a completed transmission. Writing this - * register pops the transmit completion stack. - * - * Window 1/Port 0x0b. - * - * 7: Complete - * 6: Interrupt on successful transmission requested. - * 5: Jabber Error (TP Only, TX Reset required. ) - * 4: Underrun (TX Reset required. ) - * 3: Maximum Collisions. - * 2: TX Status Overflow. - * 1-0: Undefined. - * - */ -#define TXS_COMPLETE 0x80 -#define TXS_SUCCES_INTR_REQ 0x40 -#define TXS_JABBER 0x20 -#define TXS_UNDERRUN 0x10 -#define TXS_MAX_COLLISION 0x8 -#define TXS_STATUS_OVERFLOW 0x4 - -/* - * Configuration control register. - * Window 0/Port 04 - */ -/* Read */ -#define IS_AUI (1<<13) -#define IS_BNC (1<<12) -#define IS_UTP (1<<9) -/* Write */ -#define ENABLE_DRQ_IRQ 0x0001 -#define W0_P4_CMD_RESET_ADAPTER 0x4 -#define W0_P4_CMD_ENABLE_ADAPTER 0x1 -/* - * Media type and status. - * Window 4/Port 0A - */ -#define ENABLE_UTP 0xc0 -#define DISABLE_UTP 0x0 - -/* - * Resource control register - */ - -#define SET_IRQ(i) ( ((i)<<12) | 0xF00) /* set IRQ i */ - -/* - * Receive status register - */ - -#define RX_BYTES_MASK (u_short) (0x07ff) -#define RX_ERROR 0x4000 -#define RX_INCOMPLETE 0x8000 - - -/* - * Misc defines for various things. - */ -#define ACTIVATE_ADAPTER_TO_CONFIG 0xff /* to the id_port */ -#define MFG_ID 0x6d50 /* in EEPROM and W0 ADDR_CONFIG */ -#define PROD_ID 0x9150 - -#define AUI 0x1 -#define BNC 0x2 -#define UTP 0x4 - -#define ETHER_ADDR_LEN 6 -#define ETHER_MAX 1536 -#define RX_BYTES_MASK (u_short) (0x07ff) - - /* EISA support */ -#define EP_EISA_START 0x1000 -#define EP_EISA_W0 0x0c80 diff --git a/sys/i386/boot/netboot/netboot.doc b/sys/i386/boot/netboot/netboot.doc deleted file mode 100644 index d9d261e5610a..000000000000 --- a/sys/i386/boot/netboot/netboot.doc +++ /dev/null @@ -1,42 +0,0 @@ - -Configuring FreeBSD to run diskless Oct 15/1994 -=================================== - -1) Find a machine that will be your server. This machine will require - enough disk space to hold the FreeBSD 2.0 binaries and have bootp and - tftp services available. - -2) Create a bootptab entry for the diskless FreeBSD machine. - - sample entry: - - diskless:\ - :ht=ether:\ - :ha=0000c01f848a:\ - :sm=255.255.255.0:\ - :hn:\ - :ds=192.1.2.3:\ - :ip=192.1.2.4:\ - :vm=rfc1048: - - -3) Create a cfg.x.x.x.x file for your diskless machine. This is now an - ASCII file with netboot commands in it. - - sample cfg.x.x.x.x: - - hostname diskless.freebsd.com - rootfs server.freebsd.com:/var/rootfs/diskless - swapfs server.freebsd.com:/var/swap/diskless - -4) On the server, export the root and swap filesystems to the client. This - usually involves putting them in the /etc/exports file and one some - machines running /usr/etc/exportfs -av - -5) Make a BOOTROM by copying netboot.rom to an EPROM, or copy netboot.com to - a DOS diskette. - -6) Boot the diskless machine and run netboot.com if you're using DOS. - - -Martin Renters martin@innovus.com diff --git a/sys/i386/boot/rmaouthdr b/sys/i386/boot/rmaouthdr deleted file mode 100644 index 4bb9c84924d1..000000000000 --- a/sys/i386/boot/rmaouthdr +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/csh -f -# -# from: Mach, Revision 2.2 92/04/04 11:36:01 rpd -# $Id$ -# -dd if=$1 of=$2 ibs=32 skip=1 obs=1024b diff --git a/sys/i386/boot/serialboot/Makefile b/sys/i386/boot/serialboot/Makefile deleted file mode 100644 index a28284318870..000000000000 --- a/sys/i386/boot/serialboot/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# $Id: Makefile,v 1.22 1994/11/05 21:06:16 ache Exp $ -# - -PROG= boot - -.PATH: ${.CURDIR}/../biosboot -# Order is very important on the SRCS line for this prog -SRCS= start.S table.c boot2.S boot.c asm.S bios.S io.c disk.c sys.c - -BINDIR= /usr/mdec -BINMODE= 444 -CFLAGS= -O -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT} -DCOMCONSOLE=0x3F8 -CFLAGS+= -DBOOTSEG=${BOOTSEG} -DBOOTSTACK=${BOOTSTACK} -CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../biosboot -I${.CURDIR}/../.. -CLEANFILES+= boot.nohdr boot.strip boot1 boot2 -DPADD= ${LIBC} -LDFLAGS+= -N -T 0 -nostdlib -LDADD= -lc -LINKS= ${BINDIR}/sdboot ${BINDIR}/wdboot\ - ${BINDIR}/sdboot ${BINDIR}/fdboot\ - ${BINDIR}/bootsd ${BINDIR}/bootwd\ - ${BINDIR}/bootsd ${BINDIR}/bootfd -NOSHARED= YES -NOMAN= -STRIP= - -# tunable timeout parameter, waiting for keypress, calibrated in mS -BOOTWAIT?= 5000 - -# Location that boot2 is loaded at -BOOTSEG= 0x1000 - -# Offset in BOOTSEG for the top of the stack, keep this 16 byte aligned -BOOTSTACK= 0xFFF0 - -boot.strip: boot - cp -p boot boot.strip - strip boot.strip - size boot.strip - -boot.nohdr: boot.strip - dd if=boot.strip of=boot.nohdr ibs=32 skip=1 obs=1024b - ls -l boot.nohdr - -boot1: boot.nohdr - dd if=boot.nohdr of=boot1 bs=512 count=1 - -boot2: boot.nohdr - dd if=boot.nohdr of=boot2 bs=512 skip=1 - -all: boot1 boot2 - -beforeinstall: - install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}\ - boot1 ${DESTDIR}${BINDIR}/sdboot - install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}\ - boot2 ${DESTDIR}${BINDIR}/bootsd - -.include <bsd.prog.mk> diff --git a/sys/i386/boot/serialboot/bios.S b/sys/i386/boot/serialboot/bios.S deleted file mode 100644 index c2924528e30b..000000000000 --- a/sys/i386/boot/serialboot/bios.S +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id: bios.S,v 1.3 1994/10/02 05:18:25 rgrimes Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/* - * Serial bootblock interface routines - * Copyright (c) 1994, J"org Wunsch - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * THE AUTHOR ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. THE AUTHOR DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - */ - - .file "bios.s" - -#include "asm.h" - .text - -/* - * biosread(dev, cyl, head, sec, nsec, offset) - * Read "nsec" sectors from disk to offset "offset" in boot segment - * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory - * Call with %ah = 0x2 - * %al = number of sectors - * %ch = cylinder - * %cl = sector - * %dh = head - * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) - * %es:%bx = segment:offset of buffer - * Return: - * %al = 0x0 on success; err code on failure - */ - -ENTRY(biosread) - push %ebp - mov %esp, %ebp - - push %ebx - push %ecx - push %edx - push %es - - movb 0x10(%ebp), %dh - movw 0x0c(%ebp), %cx - /* cylinder; the highest 2 bits of cyl is in %cl */ - xchgb %ch, %cl - rorb $2, %cl - movb 0x14(%ebp), %al - orb %al, %cl - incb %cl /* sector; sec starts from 1, not 0 */ - movb 0x8(%ebp), %dl /* device */ - movl 0x1c(%ebp), %ebx /* offset */ - - /* prot_to_real will set %es to BOOTSEG */ - call EXT(prot_to_real) /* enter real mode */ - movb $0x2, %ah /* subfunction */ - addr32 - movb 0x18(%ebp), %al /* number of sectors */ - - sti - int $0x13 - cli - - /* save return value (actually movw %ax, %bx) */ - mov %eax, %ebx - - data32 - call EXT(real_to_prot) /* back to protected mode */ - - xor %eax, %eax - movb %bh, %al /* return value in %ax */ - - pop %es - pop %edx - pop %ecx - pop %ebx - pop %ebp - - ret - -/* - * The serial port interface routines implement a simple polled i/o - * interface to a standard serial port. Due to the space restrictions - * for the boot blocks, no BIOS support is used (since BIOS requires - * expensive real/protected mode switches), instead the rudimentary - * BIOS support is duplicated here. - * - * The base address for the i/o port is passed from the Makefile in - * the COMCONSOLE preprocessor macro. Console parameters are currently - * hard-coded to 9600 Bd, 8 bit. This can be changed in the - * init_serial() function. - */ - -/* - * void putc(char ch) - * send ch to serial port - * - */ - -ENTRY(putc) - push %ebp - mov %esp, %ebp - push %edx - - mov $COMCONSOLE + 5, %edx # line status reg -1: inb %dx, %al - test $0x20, %al - jz 1b # TX buffer not empty - - movb 0x8(%ebp), %al - - sub $5, %edx # TX output reg - outb %al, %dx # send this one - - pop %edx - pop %ebp - ret - -/* - * int getc(void) - * read a character from serial port - */ - -ENTRY(getc) - push %ebp - mov %esp, %ebp - push %edx - - mov $COMCONSOLE + 5, %edx # line status reg -1: - inb %dx, %al - testb $0x01, %al - jz 1b # no RX char available - - xor %eax, %eax - sub $5, %edx # RX buffer reg - inb %dx, %al # fetch (first) character - - cmp $0x7F, %eax # make DEL... - jne 2f - mov $0x08, %eax # look like BS -2: - pop %edx - pop %ebp - ret - -/* - * int ischar(void) - * if there is a character pending, return true; otherwise return 0 - */ -ENTRY(ischar) - push %ebp - mov %esp, %ebp - push %edx - - xorl %eax, %eax - mov $COMCONSOLE + 5, %edx # line status reg - inb %dx, %al - andb $0x01, %al # RX char available? - - pop %edx - pop %ebp - ret - -/* - * void init_serial(void) - * initialize the serial console port to 9600 Bd, 8 bpc - */ -ENTRY(init_serial) - push %ebp - mov %esp, %ebp - push %edx - - mov $COMCONSOLE + 3, %edx # line control reg - movb $0x80, %al - outb %al, %dx # enable DLAB - - sub $3, %edx # divisor latch, low byte - mov $12, %ax # divisor 12: 9600 Bd - outb %al, %dx - inc %edx # divisor latch, high byte - movb %ah, %al - outb %al, %dx - - add $2, %edx # line control reg - movb $0x13, %al - outb %al, %dx # 8 bit, no parity, 1 stop bit - - inc %edx # modem control reg - mov $3, %al - outb %al, %dx # enable DTR/RTS - - /* now finally, flush the input buffer */ - inc %edx # line status reg -1: - inb %dx, %al - testb $0x01, %al - jz 2f # no more characters buffered - sub $5, %edx # rx buffer reg - inb %dx, %al # throw away - add $5, %edx - jmp 1b -2: - pop %edx - pop %ebp - ret - -/* - * - * get_diskinfo(): return a word that represents the - * max number of sectors and heads and drives for this device - * - */ - -ENTRY(get_diskinfo) - push %ebp - mov %esp, %ebp - push %es - push %ebx - push %ecx - push %edx - - movb 0x8(%ebp), %dl /* diskinfo(drive #) */ - call EXT(prot_to_real) /* enter real mode */ - - movb $0x8, %ah /* ask for disk info */ - - sti - int $0x13 - cli - - jnc ok - /* - * Urk. Call failed. It is not supported for floppies by old BIOS's. - * Guess it's a 15-sector floppy. Initialize all the registers for - * documentation, although we only need head and sector counts. - */ - subb %ah, %ah /* %ax = 0 */ - movb %al, %al - movb %ah, %bh /* %bh = 0 */ - movb $2, %bl /* %bl bits 0-3 = drive type, - bit 2 = 1.2M */ - movb $79, %ch /* max track */ - movb $15, %cl /* max sector */ - movb $1, %dh /* max head */ - movb $1, %dl /* # floppy drives installed */ - /* es:di = parameter table */ - /* carry = 0 */ -ok: - - data32 - call EXT(real_to_prot) /* back to protected mode */ - - xor %eax, %eax - - /* form a longword representing all this gunk */ - movb %dh, %ah /* max head */ - andb $0x3f, %cl /* mask of cylinder gunk */ - movb %cl, %al /* max sector (and # sectors) */ - - pop %edx - pop %ecx - pop %ebx - pop %es - pop %ebp - ret - -/* - * - * memsize(i) : return the memory size in KB. i == 0 for conventional memory, - * i == 1 for extended memory - * BIOS call "INT 12H" to get conventional memory size - * BIOS call "INT 15H, AH=88H" to get extended memory size - * Both have the return value in AX. - * - */ - -ENTRY(memsize) - push %ebp - mov %esp, %ebp - push %ebx - - mov 8(%ebp), %ebx - - call EXT(prot_to_real) /* enter real mode */ - - cmpb $0x1, %bl - data32 - je xext - - sti - int $0x12 - cli - data32 - jmp xdone - -xext: movb $0x88, %ah - sti - int $0x15 - cli - -xdone: - mov %eax, %ebx - - data32 - call EXT(real_to_prot) - - mov %ebx, %eax - pop %ebx - pop %ebp - ret - diff --git a/sys/i386/boot/serialboot/boot.c b/sys/i386/boot/serialboot/boot.c deleted file mode 100644 index 06bd6ba38144..000000000000 --- a/sys/i386/boot/serialboot/boot.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, [92/04/03 16:51:14 rvb] - * $Id: boot.c,v 1.22 1994/11/07 11:26:26 davidg Exp $ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include <sys/param.h> -#include "boot.h" -#include <a.out.h> -#include <sys/reboot.h> -#include <machine/bootinfo.h> - -struct exec head; -struct bootinfo_t bootinfo; -char *name; -char *names[] = { - "/kernel" -}; -#define NUMNAMES (sizeof(names)/sizeof(char *)) - -extern void init_serial(void); -extern int end; -boot(drive) -int drive; -{ - int loadflags, currname = 0, ret; - char *t; - - init_serial(); - - printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n", - ouraddr, - memsize(0), - memsize(1)); - printf("Use hd(1,a)/kernel to boot sd0 when wd0 is also installed.\n"); - printf("Usage: [[[%s(0,a)]%s][-s][-r][-a][-c][-d][-b]]\nUse ? for file list.\n\n" - , devs[(drive & 0x80) ? 0 : 2] - , names[0]); - gateA20(); -loadstart: - /***************************************************************\ - * As a default set it to the first partition of the first * - * floppy or hard drive * - \***************************************************************/ - part = unit = 0; - maj = (drive&0x80 ? 0 : 2); /* a good first bet */ - name = names[currname++]; - - loadflags = 0; - if (currname == NUMNAMES) - currname = 0; - printf("Boot: "); - getbootdev(&loadflags); - ret = openrd(); - if (ret != 0) { - if (ret > 0) - printf("Can't find %s\n", name); - goto loadstart; - } -/* if (inode.i_mode&IEXEC) - loadflags |= RB_KDB; -*/ - loadprog(loadflags); - goto loadstart; -} - -loadprog(howto) - int howto; -{ - long int startaddr; - long int addr; /* physical address.. not directly useable */ - long int bootdev; - long int total; - int i; - unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ - - read(&head, sizeof(head)); - if ( N_BADMAG(head)) { - printf("Invalid format!\n"); - return; - } - - poff = N_TXTOFF(head); - /*if(poff==0) - poff = 32;*/ - - startaddr = (int)head.a_entry & 0x00FFFFFF; /* some MEG boundary */ - addr = startaddr; - printf("Booting %s(%d,%c)%s @ 0x%x\n" - , devs[maj] - , unit - , 'a'+part - , name - , addr); - if(addr < ouraddr) - { - if((addr + head.a_text + head.a_data) > ouraddr) - { - printf("kernel overlaps loader\n"); - return; - } - if((addr + head.a_text + head.a_data + head.a_bss) > 0xa0000) - { - printf("bss exceeds 640k limit\n"); - return; - } - } - printf("text=0x%x ", head.a_text); - /********************************************************/ - /* LOAD THE TEXT SEGMENT */ - /* don't clobber the first 4k yet (BIOS NEEDS IT) */ - /********************************************************/ - read(tmpbuf,4096); - addr += 4096; - xread(addr, head.a_text - 4096); - addr += head.a_text - 4096; - - /********************************************************/ - /* Load the Initialised data after the text */ - /********************************************************/ - while (addr & CLOFSET) - *(char *)addr++ = 0; - - printf("data=0x%x ", head.a_data); - xread(addr, head.a_data); - addr += head.a_data; - - /********************************************************/ - /* Skip over the uninitialised data */ - /* (but clear it) */ - /********************************************************/ - printf("bss=0x%x ", head.a_bss); - if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr)) - { - pbzero(addr,ouraddr - (int)addr); - } - else - { - pbzero(addr,head.a_bss); - } - addr += head.a_bss; - -#ifdef LOADSYMS /* not yet, haven't worked this out yet */ - if (addr > 0x100000) - { - /********************************************************/ - /*copy in the symbol header */ - /********************************************************/ - pcpy(&head.a_syms, addr, sizeof(head.a_syms)); - addr += sizeof(head.a_syms); - - /********************************************************/ - /* READ in the symbol table */ - /********************************************************/ - printf("symbols=[+0x%x", head.a_syms); - xread(addr, head.a_syms); - addr += head.a_syms; - - /********************************************************/ - /* Followed by the next integer (another header) */ - /* more debug symbols? */ - /********************************************************/ - read(&i, sizeof(int)); - pcpy(&i, addr, sizeof(int)); - i -= sizeof(int); - addr += sizeof(int); - - - /********************************************************/ - /* and that many bytes of (debug symbols?) */ - /********************************************************/ - printf("+0x%x] ", i); - xread(addr, i); - addr += i; - } -#endif LOADSYMS - /********************************************************/ - /* and note the end address of all this */ - /********************************************************/ - - total = ((addr+sizeof(int)-1))&~(sizeof(int)-1); - printf("total=0x%x ", total); - bootdev = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ; - /****************************************************************/ - /* copy that first page and overwrite any BIOS variables */ - /****************************************************************/ - printf("entry point=0x%x\n" ,(int)startaddr); - /* Under no circumstances overwrite precious BIOS variables! */ - pcpy(tmpbuf, startaddr, 0x400); - pcpy(tmpbuf + 0x500, startaddr + 0x500, 4096 - 0x500); - bootinfo.version=1; - bootinfo.kernelname=(char *)((int)name + (BOOTSEG<<4)); - bootinfo.nfs_diskless=0; - startprog((int)startaddr, howto, bootdev, (int)&bootinfo+(BOOTSEG<<4)); - return; -} - -#define NAMEBUF_LEN 100 - -char namebuf[NAMEBUF_LEN]; -getbootdev(howto) - int *howto; -{ - char c, *ptr = namebuf; - if (gets(namebuf)) { - while (c=*ptr) { - while (c==' ') - c = *++ptr; - if (!c) - return; - if (c=='-') - while ((c = *++ptr) && c!=' ') - switch (c) { - case 'r': - *howto |= RB_DFLTROOT; continue; - case 'a': - *howto |= RB_ASKNAME; continue; - case 'c': - *howto |= RB_CONFIG; continue; - case 's': - *howto |= RB_SINGLE; continue; - case 'd': - *howto |= RB_KDB; continue; - case 'b': - *howto |= RB_HALT; continue; - } - else { - name = ptr; - while ((c = *++ptr) && c!=' '); - if (c) - *ptr++ = 0; - } - } - } else - printf("\n"); -} - diff --git a/sys/i386/boot/start.S b/sys/i386/boot/start.S deleted file mode 100644 index d0bcbf89859a..000000000000 --- a/sys/i386/boot/start.S +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:29 rpd - * $Id: start.S,v 1.4 1994/10/02 05:18:26 rgrimes Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -#include "asm.h" - - .file "start.s" - -SIGNATURE= 0xaa55 -LOADSZ= 15 /* size of unix boot */ -PARTSTART= 0x1be /* starting address of partition table */ -NUMPART= 4 /* number of partitions in partition table */ -PARTSZ= 16 /* each partition table entry is 16 bytes */ -BSDPART= 0xA5 /* value of boot_ind, means bootable partition */ -BOOTABLE= 0x80 /* value of boot_ind, means bootable partition */ - - .text - -ENTRY(boot1) - /* - * start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 - * ljmp to the next instruction to adjust %cs - */ - data32 - ljmp $0x7c0, $start - -start: - /* set up %ds */ - mov %cs, %ax - mov %ax, %ds - - /* set up %ss and %esp */ - data32 - mov $BOOTSEG, %eax - mov %ax, %ss - data32 - mov $BOOTSTACK, %esp - - /* set up %es, (where we will load boot2 to) */ - mov %ax, %es - -#ifdef DEBUG - data32 - mov $one, %esi - data32 - call message -#endif - - /* bootstrap passes us drive number in %dl */ - cmpb $0x80, %dl - data32 - jae hd - -fd: - mov $0x0, %dl - /* reset the disk system */ -#ifdef DEBUG - data32 - mov $two, %esi - data32 - call message -#endif - movb $0x0, %ah - int $0x13 - data32 - mov $0x0001, %ecx /* cyl 0, sector 1 */ - movb $0, %dh /* head */ -#ifdef DEBUG - data32 - mov $three, %esi - data32 - call message -#endif - data32 - jmp load - -hd: /**** load sector 0 into the BOOTSEG ****/ -#ifdef DEBUG - data32 - mov $four, %esi - data32 - call message -#endif - data32 - mov $0x0201, %eax - xor %ebx, %ebx /* %bx = 0 */ - data32 - mov $0x0001, %ecx -#ifdef DEBUG - data32 - mov $five, %esi - data32 - call message -#endif - data32 - andl $0xff, %edx - /*mov $0x0080, %edx*/ - int $0x13 - data32 - jb read_error - - /* find the first 386BSD partition */ - data32 - mov $PARTSTART, %ebx - data32 - mov $NUMPART, %ecx -again: - addr32 - movb %es:4(%ebx), %al - cmpb $BSDPART, %al - data32 - je found - data32 - add $PARTSZ, %ebx - data32 - loop again - data32 - mov $enoboot, %esi - data32 - jmp err_stop - - -/* - * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory - * Call with %ah = 0x2 - * %al = number of sectors - * %ch = cylinder - * %cl = sector - * %dh = head - * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) - * %es:%bx = segment:offset of buffer - * Return: - * %al = 0x0 on success; err code on failure - */ - -found: - addr32 - movb %es:1(%ebx), %dh /* head */ - addr32 - movl %es:2(%ebx), %ecx /*sect, cyl (+ 2 bytes junk in top word) */ - -load: - movb $0x2, %ah /* function 2 */ - movb $LOADSZ, %al /* number of blocks */ - xor %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ - int $0x13 - data32 - jb read_error - - /* - * ljmp to the second stage boot loader (boot2). - * After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - * as an internal buffer "intbuf". - */ - -#ifdef DEBUG - data32 - mov $six, %esi - data32 - call message -#endif - data32 - ljmp $BOOTSEG, $ EXT(boot2) - -/* - * read_error - */ -read_error: - data32 - mov $eread, %esi -err_stop: - data32 - call message - data32 - jmp stop - -/* - * message: write the error message in %ds:%esi to console - */ -message: - /* - * Use BIOS "int 10H Function 0Eh" to write character in teletype mode - * %ah = 0xe %al = character - * %bh = page %bl = foreground color (graphics modes) - */ - - data32 - push %eax - data32 - push %ebx - data32 - mov $0x0001, %ebx - cld - -nextb: - lodsb /* load a byte into %al */ - cmpb $0x0, %al - data32 - je done - movb $0xe, %ah - int $0x10 /* display a byte */ - data32 - jmp nextb -done: - data32 - pop %ebx - data32 - pop %eax - data32 - ret - -stop: hlt - data32 - jmp stop /* halt doesnt actually halt forever */ - -/* error messages */ - -#ifdef DEBUG -one: String "1\r\n\0" -two: String "2\r\n\0" -three: String "3\r\n\0" -four: String "4\r\n\0" -five: String "5\r\n\0" -six: String "6\r\n\0" -seven: String "7\r\n\0" -#endif DEBUG -eread: String "Read error\r\n\0" -enoboot: String "No bootable partition\r\n\0" -endofcode: -/* throw in a partition in case we are block0 as well */ -/* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */ - . = EXT(boot1) + PARTSTART - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte BOOTABLE,0,1,0,BSDPART,255,255,255 - .long 0,50000 -/* the last 2 bytes in the sector 0 contain the signature */ - . = EXT(boot1) + 0x1fe - .value SIGNATURE -ENTRY(disklabel) - . = EXT(boot1) + 0x400 diff --git a/sys/i386/boot/start.s b/sys/i386/boot/start.s deleted file mode 100644 index f6f4bf0e7d11..000000000000 --- a/sys/i386/boot/start.s +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - * HISTORY - * $Log: start.s,v $ - * Revision 2.2 92/04/04 11:36:29 rpd - * Fix Intel Copyright as per B. Davies authorization. - * [92/04/03 rvb] - * Need to zero dh on hd path; at least for an adaptec card. - * [92/01/14 rvb] - * - * From 2.5 boot: - * Flush digit printing. - * Fuse floppy and hd boot by using Int 21 to tell - * boot type (slightly dubious since Int 21 is DOS - * not BIOS) - * [92/03/30 mg32] - * - * Revision 2.2 91/04/02 14:42:04 mbj - * Fix the BIG boot bug. We had missed a necessary data - * before a xor that was clearing a register used later - * as an index register. - * [91/03/01 rvb] - * Remember floppy type for swapgeneric - * Add Intel copyright - * [90/02/09 rvb] - * - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -#include "asm.h" - - .file "start.s" - -BOOTSEG = 0x9000 # boot will be loaded at 640k-64k -BOOTSTACK = 0xe000 # boot stack -SIGNATURE = 0xaa55 -LOADSZ = 14 # size of unix boot -PARTSTART = 0x1be # starting address of partition table -NUMPART = 4 # number of partitions in partition table -PARTSZ = 16 # each partition table entry is 16 bytes -BSDPART = 0xA5 # value of boot_ind, means bootable partition -BOOTABLE = 0x80 # value of boot_ind, means bootable partition - - .text - -ENTRY(boot1) - - # boot1 is loaded at 0x0:0x7c00 - # ljmp to the next instruction to set up %cs - data32 - ljmp $0x7c0, $start - -start: - # set up %ds - mov %cs, %ax - mov %ax, %ds - - - # set up %ss and %esp - data32 - mov $BOOTSEG, %eax - mov %ax, %ss - data32 - mov $BOOTSTACK, %esp - - /*** set up %es, (where we will load boot2 to) ***/ - mov %ax, %es - -#ifdef DEBUG - data32 - mov $one, %esi - data32 - call message -#endif - # get the boot drive id - movb $0x33, %ah - movb $0x05, %al - int $0x21 - - cmpb $0x80, %dl - data32 - jge hd - -fd: -# reset the disk system -#ifdef DEBUG - data32 - mov $two, %esi - data32 - call message -#endif - movb $0x0, %ah - int $0x13 - data32 - mov $0x0001, %ecx # cyl 0, sector 1 - data32 -#ifdef DEBUG - data32 - mov $three, %esi - data32 - call message -#endif - jmp load - -hd: /**** load sector 0 into the BOOTSEG ****/ -#ifdef DEBUG - data32 - mov $four, %esi - data32 - call message -#endif - data32 - mov $0x0201, %eax - xor %ebx, %ebx # %bx = 0 - data32 - mov $0x0001, %ecx -#ifdef DEBUG - data32 - mov $five, %esi - data32 - call message -#endif - data32 - andl $0xff, %edx - /*mov $0x0080, %edx*/ - int $0x13 - data32 - jb read_error - - /***# find the bootable partition *****/ - data32 - mov $PARTSTART, %ebx - data32 - mov $NUMPART, %ecx -again: - addr16 - movb %es:4(%ebx), %al - cmpb $BSDPART, %al - data32 - je found - data32 - add $PARTSZ, %ebx - data32 - loop again - data32 - mov $enoboot, %esi - data32 - jmp err_stop - - -/* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -found: - addr16 - movb %es:1(%ebx), %dh /* head */ - addr16 - xor %ecx, %ecx - addr16 - movw %es:2(%ebx), %ecx /*sect,cyl (+ 2 bytes junk in top word )*/ - -load: - movb $0x2, %ah /* function 2 */ - movb $LOADSZ, %al /* number of blocks */ - xor %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ - int $0x13 - data32 - jb read_error - - # ljmp to the second stage boot loader (boot2). - # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - # as an internal buffer "intbuf". - -#ifdef DEBUG - data32 - mov $six, %esi - data32 - call message -#endif - data32 - ljmp $BOOTSEG, $EXT(boot2) - -# -# read_error -# - -read_error: - - data32 - mov $eread, %esi -err_stop: - data32 - call message - data32 - jmp stop - -# -# message: write the error message in %ds:%esi to console -# - -message: - # Use BIOS "int 10H Function 0Eh" to write character in teletype mode - # %ah = 0xe %al = character - # %bh = page %bl = foreground color (graphics modes) - - data32 - push %eax - data32 - push %ebx - data32 - mov $0x0001, %ebx - cld - -nextb: - lodsb # load a byte into %al - cmpb $0x0, %al - data32 - je done - movb $0xe, %ah - int $0x10 # display a byte - data32 - jmp nextb -done: - data32 - pop %ebx - data32 - pop %eax - data32 - ret - -stop: hlt - data32 - jmp stop # halt doesnt actually halt forever - -/* error messages */ - -#ifdef DEBUG -one: String "1\r\n\0" -two: String "2\r\n\0" -three: String "3\r\n\0" -four: String "4\r\n\0" -five: String "5\r\n\0" -six: String "6\r\n\0" -seven: String "7\r\n\0" -#endif DEBUG -eread: String "Read error\r\n\0" -enoboot: String "No bootable partition\r\n\0" -endofcode: -/* throw in a partition in case we are block0 as well */ -/* flag,head,sec,cyl,typ,ehead,esect,ecyl,start,len */ - . = EXT(boot1) + PARTSTART - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte BOOTABLE,0,1,0,BSDPART,255,255,255 - .long 0,50000 -/* the last 2 bytes in the sector 0 contain the signature */ - . = EXT(boot1) + 0x1fe - .value SIGNATURE -ENTRY(disklabel) - . = EXT(boot1) + 0x400 diff --git a/sys/i386/boot/sys.c b/sys/i386/boot/sys.c deleted file mode 100644 index 48cbadeca7cf..000000000000 --- a/sys/i386/boot/sys.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:34 rpd - * $Id: sys.c,v 1.4 1994/08/21 17:47:26 paul Exp $ - */ - -#include "boot.h" -#include <sys/dir.h> -#include <sys/reboot.h> - -#ifdef 0 -/* #define BUFSIZE 4096 */ -#define BUFSIZE MAXBSIZE - -char buf[BUFSIZE], fsbuf[SBSIZE], iobuf[MAXBSIZE]; -#endif - -#define BUFSIZE 8192 -#define MAPBUFSIZE BUFSIZE -char buf[BUFSIZE], fsbuf[BUFSIZE], iobuf[BUFSIZE]; - -int xread(addr, size) - char * addr; - int size; -{ - int count = BUFSIZE; - while (size > 0) { - if (BUFSIZE > size) - count = size; - read(buf, count); - pcpy(buf, addr, count); - size -= count; - addr += count; - } -} - -read(buffer, count) - int count; - char *buffer; -{ - int logno, off, size; - int cnt2, bnum2; - - while (count) { - off = blkoff(fs, poff); - logno = lblkno(fs, poff); - cnt2 = size = blksize(fs, &inode, logno); - bnum2 = fsbtodb(fs, block_map(logno)) + boff; - cnt = cnt2; - bnum = bnum2; - if ( (!off) && (size <= count)) - { - iodest = buffer; - devread(); - } - else - { - iodest = iobuf; - size -= off; - if (size > count) - size = count; - devread(); - bcopy(iodest+off,buffer,size); - } - buffer += size; - count -= size; - poff += size; - } -} - -find(path) - char *path; -{ - char *rest, ch; - int block, off, loc, ino = ROOTINO; - struct direct *dp; -loop: iodest = iobuf; - cnt = fs->fs_bsize; - bnum = fsbtodb(fs,ino_to_fsba(fs,ino)) + boff; - devread(); - bcopy(&((struct dinode *)iodest)[ino % fs->fs_inopb], - &inode.i_din, - sizeof (struct dinode)); - if (!*path) - return 1; - while (*path == '/') - path++; - if (!inode.i_size || ((inode.i_mode&IFMT) != IFDIR)) - return 0; - for (rest = path; (ch = *rest) && ch != '/'; rest++) ; - *rest = 0; - loc = 0; - do { - if (loc >= inode.i_size) - return 0; - if (!(off = blkoff(fs, loc))) { - block = lblkno(fs, loc); - cnt = blksize(fs, &inode, block); - bnum = fsbtodb(fs, block_map(block)) + boff; - iodest = iobuf; - devread(); - } - dp = (struct direct *)(iodest + off); - loc += dp->d_reclen; - } while (!dp->d_ino || strcmp(path, dp->d_name)); - ino = dp->d_ino; - *(path = rest) = ch; - goto loop; -} - -char mapbuf[MAPBUFSIZE]; -int mapblock = 0; - -block_map(file_block) - int file_block; -{ - if (file_block < NDADDR) - return(inode.i_db[file_block]); - if ((bnum=fsbtodb(fs, inode.i_ib[0])+boff) != mapblock) { - iodest = mapbuf; - cnt = fs->fs_bsize; - devread(); - mapblock = bnum; - } - return (((int *)mapbuf)[(file_block - NDADDR) % NINDIR(fs)]); -} - -openrd() -{ - char **devp, *cp = name; - /*******************************************************\ - * If bracket given look for preceding device name * - \*******************************************************/ - while (*cp && *cp!='(') - cp++; - if (!*cp) - { - cp = name; - } - else - { - if (cp++ != name) - { - for (devp = devs; *devp; devp++) - if (name[0] == (*devp)[0] && - name[1] == (*devp)[1]) - break; - if (!*devp) - { - printf("Unknown device\n"); - return 1; - } - maj = devp-devs; - } - /*******************************************************\ - * Look inside brackets for unit number, and partition * - \*******************************************************/ - /* - * Allow any valid digit as the unit number, as the BIOS - * will complain if the unit number is out of range. - * Restricting the range here prevents the possibilty of using - * BIOSes that support more than 2 units. - * XXX Bad values may cause strange errors, need to check if - * what happens when a value out of range is supplied. - */ - if (*cp >= '0' && *cp <= '9') - unit = *cp++ - '0'; - if (!*cp || (*cp == ',' && !*++cp)) - return 1; - if (*cp >= 'a' && *cp <= 'p') - part = *cp++ - 'a'; - while (*cp && *cp++!=')') ; - if (!*cp) - return 1; - } - switch(maj) - { - case 1: - dosdev = unit | 0x80; - unit = 0; - break; - case 0: - case 4: - dosdev = unit | 0x80; - break; - case 2: - dosdev = unit; - break; - case 3: - printf("Wangtek unsupported\n"); - return 1; - break; - } - inode.i_dev = dosdev; - /***********************************************\ - * Now we know the disk unit and part, * - * Load disk info, (open the device) * - \***********************************************/ - if (devopen()) - return 1; - - /***********************************************\ - * Load Filesystem info (mount the device) * - \***********************************************/ - iodest = (char *)(fs = (struct fs *)fsbuf); - cnt = SBSIZE; - bnum = SBLOCK + boff; - devread(); - /***********************************************\ - * Find the actual FILE on the mounted device * - \***********************************************/ - if (!find(cp)) - { - return 1; - } - poff = 0; - name = cp; - return 0; -} diff --git a/sys/i386/boot/table.c b/sys/i386/boot/table.c deleted file mode 100644 index 677a12f473c0..000000000000 --- a/sys/i386/boot/table.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:43 rpd - * $Id: table.c,v 1.3 1993/10/16 19:11:40 rgrimes Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/* Segment Descriptor - * - * 31 24 19 16 7 0 - * ------------------------------------------------------------ - * | | |B| |A| | | |1|0|E|W|A| | - * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 | - * | | |D| |L| 19..16| | |1|1|C|R|A| | - * ------------------------------------------------------------ - * | | | - * | BASE 15..0 | LIMIT 15..0 | - * | | | - * ------------------------------------------------------------ - */ - -struct seg_desc { - unsigned short limit_15_0; - unsigned short base_15_0; - unsigned char base_23_16; - unsigned char p_dpl_type; - unsigned char g_b_a_limit; - unsigned char base_31_24; - }; - -#define RUN 0 /* not really 0, but filled in at boot time */ - -struct seg_desc Gdt[] = { - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* 0x0 : null */ - {0xFFFF, 0x0, 0x0, 0x9F, 0xCF, 0x0}, /* 0x08 : kernel code */ - /* 0x9E? */ - {0xFFFF, 0x0, 0x0, 0x93, 0xCF, 0x0}, /* 0x10 : kernel data */ - /* 0x92? */ - {0xFFFF, RUN, RUN, 0x9E, 0x40, 0x0}, /* 0x18 : boot code */ - {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* 0x20 : boot data */ - {0xFFFF, RUN, RUN, 0x9E, 0x0, 0x0}, /* 0x28 : boot code, 16 bits */ -#ifdef BDE_DEBUGGER - /* More for bdb. */ - {}, /* BIOS_CS_INDEX = 6 : null */ - {}, /* BIOS_TMP_INDEX = 7 : null */ - {}, /* TSS_INDEX = 8 : null */ - {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* DS_286_INDEX = 9 */ - {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* ES_286_INDEX = 10 */ - {}, /* Unused = 11 : null */ - {0x7FFF, 0x8000, 0xB, 0xB2, 0x40, 0x0}, /* COLOR_INDEX = 12 */ - {0x7FFF, 0x0, 0xB, 0xB2, 0x40, 0x0}, /* MONO_INDEX = 13 */ - {0xFFFF, RUN, RUN, 0x9A, 0x40, 0x0}, /* DB_CS_INDEX = 14 */ - {0xFFFF, RUN, RUN, 0x9A, 0x0, 0x0}, /* DB_CS16_INDEX = 15 */ - {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* DB_DS_INDEX = 16 */ - {8*18-1, RUN, RUN, 0x92, 0x40, 0x0}, /* GDT_INDEX = 17 */ -#endif /* BDE_DEBUGGER */ -}; - -#ifdef BDE_DEBUGGER -struct idt_desc { - unsigned short entry_15_0; - unsigned short selector; - unsigned char padding; - unsigned char p_dpl_type; - unsigned short entry_31_16; -}; - -struct idt_desc Idt[] = { - {}, /* Null (int 0) */ - {RUN, 0x70, 0, 0x8E, 0}, /* DEBUG_VECTOR = 1 */ - {}, /* Null (int 2) */ - {RUN, 0x70, 0, 0xEE, 0}, /* BREAKPOINT_VECTOR = 3 */ -}; -#endif /* BDE_DEBUGGER */ - -struct pseudo_desc { - unsigned short limit; - unsigned short base_low; - unsigned short base_high; - }; - -struct pseudo_desc Gdtr = { sizeof Gdt - 1, RUN, RUN }; -#ifdef BDE_DEBUGGER -struct pseudo_desc Idtr_prot = { sizeof Idt - 1, RUN, RUN }; -struct pseudo_desc Idtr_real = { 0x400 - 1, 0x0, 0x0 }; -#endif |