Remove ifdef PC98.
This commit is contained in:
parent
7ccdf6dff3
commit
27c543668b
@ -10,7 +10,7 @@ BINMODE= 444
|
||||
CFLAGS= -Os -mrtd \
|
||||
-fno-guess-branch-probability \
|
||||
-fno-unit-at-a-time \
|
||||
-D_KERNEL -DPC98 -DBOOTWAIT=${BOOTWAIT} -DTIMEOUT=${TIMEOUT}
|
||||
-D_KERNEL -DBOOTWAIT=${BOOTWAIT} -DTIMEOUT=${TIMEOUT}
|
||||
CFLAGS+= -DBOOTSEG=${BOOTSEG} -DBOOTSTACK=${BOOTSTACK}
|
||||
CFLAGS+= ${CWARNFLAGS}
|
||||
CFLAGS+= -I${.CURDIR}/../../.. -I.
|
||||
|
@ -81,24 +81,16 @@ static void readfile(char *path, char *buf, size_t nbytes);
|
||||
void
|
||||
boot(int drive)
|
||||
{
|
||||
int ret;
|
||||
#ifdef PC98
|
||||
int i;
|
||||
int i, ret;
|
||||
unsigned char disk_equips;
|
||||
#endif
|
||||
|
||||
/* Pick up the story from the Bios on geometry of disks */
|
||||
|
||||
#ifdef PC98
|
||||
for(ret = 0; ret < 2; ret ++) {
|
||||
if (*(unsigned char*)V(0xA155d) & (1 << ret)) {
|
||||
bootinfo.bi_bios_geom[ret] = get_diskinfo(ret + 0x80);
|
||||
}
|
||||
}
|
||||
#else /* IBM-PC */
|
||||
for(ret = 0; ret < N_BIOS_GEOM; ret ++)
|
||||
bootinfo.bi_bios_geom[ret] = get_diskinfo(ret + 0x80);
|
||||
#endif /* PC98 */
|
||||
|
||||
bootinfo.bi_basemem = memsize(0);
|
||||
bootinfo.bi_extmem = memsize(1);
|
||||
@ -106,17 +98,14 @@ boot(int drive)
|
||||
|
||||
gateA20();
|
||||
|
||||
#ifdef PC98
|
||||
/* set machine type to PC98_SYSTEM_PARAMETER */
|
||||
machine_check();
|
||||
#endif /* PC98 */
|
||||
|
||||
/*
|
||||
* The default boot device is the first partition in the
|
||||
* compatibility slice on the boot drive.
|
||||
*/
|
||||
dosdev = drive;
|
||||
#ifdef PC98
|
||||
maj = (drive&0x70) >> 3; /* a good first bet */
|
||||
if (maj == 4) { /* da */
|
||||
disk_equips = *(unsigned char *)V(0xA1482);
|
||||
@ -132,29 +121,6 @@ boot(int drive)
|
||||
} else {
|
||||
unit = drive & 0x0f;
|
||||
}
|
||||
#else /* IBM-PC */
|
||||
maj = 2;
|
||||
unit = drive & 0x7f;
|
||||
#ifdef dontneed
|
||||
slice = 0;
|
||||
part = 0;
|
||||
#endif
|
||||
if (drive & 0x80) {
|
||||
/* Hard drive. Adjust. */
|
||||
maj = 0;
|
||||
#if BOOT_HD_BIAS > 0
|
||||
if (unit >= BOOT_HD_BIAS) {
|
||||
/*
|
||||
* The drive is probably a SCSI drive with a unit
|
||||
* number BOOT_HD_BIAS less than the BIOS drive
|
||||
* number.
|
||||
*/
|
||||
maj = 4;
|
||||
unit -= BOOT_HD_BIAS;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* PC98 */
|
||||
readfile("boot.config", boot_config, BOOT_CONFIG_SIZE);
|
||||
name = "/boot/loader";
|
||||
if (boot_config[0] != '\0') {
|
||||
@ -173,11 +139,7 @@ loadstart:
|
||||
ouraddr, bootinfo.bi_basemem, bootinfo.bi_extmem,
|
||||
(loadflags & RB_SERIAL) ? "serial" : "internal",
|
||||
(loadflags & RB_DUAL) ? "/dual" : "",
|
||||
#ifdef PC98
|
||||
dosdev & 0x0f, devs[maj], unit, 'a' + part,
|
||||
#else
|
||||
dosdev & 0x7f, devs[maj], unit, 'a' + part,
|
||||
#endif
|
||||
name ? name : "*specify_a_kernel_name*",
|
||||
boot_help);
|
||||
|
||||
@ -242,11 +204,7 @@ loadprog(void)
|
||||
startaddr = head.a_entry & 0x00FFFFFF;
|
||||
addr = startaddr;
|
||||
printf("Booting %d:%s(%d,%c)%s @ 0x%x\n"
|
||||
#ifdef PC98
|
||||
, dosdev & 0x0f
|
||||
#else
|
||||
, dosdev & 0x7f
|
||||
#endif
|
||||
, devs[maj]
|
||||
, unit
|
||||
, 'a'+part
|
||||
|
@ -89,9 +89,7 @@ int strcasecmp(const char *s1, const char *s2);
|
||||
#endif /* !CDBOOT */
|
||||
void memcpy(const void *from, void *to, size_t len);
|
||||
void twiddle(void);
|
||||
#ifdef PC98
|
||||
void machine_check(void);
|
||||
#endif
|
||||
|
||||
/* probe_keyboard.c */
|
||||
int probe_keyboard(void);
|
||||
@ -107,7 +105,4 @@ void xread(char *addr, int size);
|
||||
void read(char *buffer, int count);
|
||||
int openrd(void);
|
||||
|
||||
#ifdef PC98
|
||||
#define V(ra) (ra - BOOTSEG * 0x10)
|
||||
#endif
|
||||
|
||||
|
@ -173,9 +173,7 @@ ENTRY(boot2)
|
||||
movl %esp, EXT(dflt_name)
|
||||
#endif
|
||||
|
||||
#ifdef PC98
|
||||
movb 0xA1584 - BOOTSEG * 0x10, %dl
|
||||
#endif
|
||||
movzbl %dl, %edx /* discard head (%dh) and random high bits */
|
||||
pushl %edx
|
||||
call EXT(boot)
|
||||
|
@ -98,7 +98,6 @@ devopen(void)
|
||||
#ifdef EMBEDDED_DISKLABEL
|
||||
dl = &disklabel;
|
||||
#else /* EMBEDDED_DISKLABEL */
|
||||
#ifdef PC98
|
||||
p = Bread(dosdev_copy, 1);
|
||||
dptr = (struct pc98_partition *)p;
|
||||
slice = WHOLE_DISK_SLICE;
|
||||
@ -111,20 +110,6 @@ devopen(void)
|
||||
p = Bread(dosdev, sector + LABELSECTOR);
|
||||
dl=((struct disklabel *)p);
|
||||
disklabel = *dl; /* structure copy (maybe useful later)*/
|
||||
#else
|
||||
p = Bread(dosdev_copy, 0);
|
||||
dptr = (struct dos_partition *)(p+DOSPARTOFF);
|
||||
slice = WHOLE_DISK_SLICE;
|
||||
for (i = 0; i < NDOSPART; i++, dptr++)
|
||||
if (dptr->dp_typ == DOSPTYP_386BSD) {
|
||||
slice = BASE_SLICE + i;
|
||||
sector = dptr->dp_start;
|
||||
break;
|
||||
}
|
||||
p = Bread(dosdev_copy, sector + LABELSECTOR);
|
||||
dl=((struct disklabel *)p);
|
||||
disklabel = *dl; /* structure copy (maybe useful later)*/
|
||||
#endif /* PC98 */
|
||||
#endif /* EMBEDDED_DISKLABEL */
|
||||
if (dl->d_magic != DISKMAGIC) {
|
||||
printf("bad disklabel\n");
|
||||
@ -133,16 +118,6 @@ devopen(void)
|
||||
/* This little trick is for OnTrack DiskManager disks */
|
||||
boff = dl->d_partitions[part].p_offset -
|
||||
dl->d_partitions[2].p_offset + sector;
|
||||
|
||||
#ifndef PC98
|
||||
bsize = dl->d_partitions[part].p_size;
|
||||
if (bsize == 0) {
|
||||
printf("empty partition\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif /* RAWBOOT */
|
||||
return 0;
|
||||
@ -176,12 +151,6 @@ Bread(int dosdev, int sector)
|
||||
int cyl, head, sec, nsec;
|
||||
|
||||
cyl = sector/spc;
|
||||
#ifndef PC98
|
||||
if (cyl > 1023) {
|
||||
printf("Error: C:%d > 1023 (BIOS limit)\n", cyl);
|
||||
for(;;); /* loop forever */
|
||||
}
|
||||
#endif
|
||||
head = (sector % spc) / spt;
|
||||
sec = sector % spt;
|
||||
nsec = spt - sec;
|
||||
|
@ -32,10 +32,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "boot.h"
|
||||
#include <machine/cpufunc.h>
|
||||
#include <sys/reboot.h>
|
||||
#ifdef PC98
|
||||
#include <pc98/pc98/pc98.h>
|
||||
#endif
|
||||
|
||||
|
||||
static int getchar(int in_buf);
|
||||
|
||||
@ -159,15 +156,10 @@ loop:
|
||||
void
|
||||
delay1ms(void)
|
||||
{
|
||||
#ifdef PC98
|
||||
int i = 800;
|
||||
|
||||
while (--i >= 0)
|
||||
(void)outb(0x5f,0); /* about 600ns */
|
||||
#else
|
||||
int i = 800;
|
||||
while (--i >= 0)
|
||||
(void)inb(0x84);
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline int
|
||||
@ -193,7 +185,6 @@ isch(void)
|
||||
static __inline unsigned
|
||||
pword(unsigned physaddr)
|
||||
{
|
||||
#ifdef PC98
|
||||
static int counter = 0;
|
||||
int i;
|
||||
|
||||
@ -201,28 +192,13 @@ pword(unsigned physaddr)
|
||||
(void)outb(0x5f, 0);
|
||||
|
||||
return (counter++);
|
||||
#else
|
||||
unsigned result;
|
||||
|
||||
/*
|
||||
* Give the fs prefix separately because gas omits it for
|
||||
* "movl %fs:0x46c, %eax".
|
||||
*/
|
||||
__asm __volatile("fs; movl %1, %0" : "=r" (result)
|
||||
: "m" (*(unsigned *)physaddr));
|
||||
return (result);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
gets(char *buf)
|
||||
{
|
||||
#define bios_tick pword(0x46c)
|
||||
#ifdef PC98
|
||||
#define BIOS_TICK_MS 1
|
||||
#else
|
||||
#define BIOS_TICK_MS 55
|
||||
#endif
|
||||
unsigned initial_bios_tick;
|
||||
char *ptr=buf;
|
||||
|
||||
|
@ -262,11 +262,7 @@ openrd(void)
|
||||
}
|
||||
biosdrive = biosdrivedigit - '0';
|
||||
if (biosdrivedigit == '\0') {
|
||||
#ifdef PC98
|
||||
biosdrive = dosdev & 0x0f;
|
||||
#else
|
||||
biosdrive = unit;
|
||||
#endif
|
||||
#if BOOT_HD_BIAS > 0
|
||||
/* XXX */
|
||||
if (maj == 4)
|
||||
@ -275,29 +271,16 @@ openrd(void)
|
||||
}
|
||||
switch(maj)
|
||||
{
|
||||
#ifdef PC98
|
||||
case 4: /* da */
|
||||
dosdev_copy = biosdrive | 0xA0; /* SCSI HD or MO */
|
||||
#else /* IBM-PC */
|
||||
case 0:
|
||||
case 4:
|
||||
dosdev_copy = biosdrive | 0x80;
|
||||
#endif
|
||||
break;
|
||||
#ifdef PC98
|
||||
case 0: /* wd */
|
||||
case 2: /* 1200KB fd */
|
||||
dosdev_copy = (maj << 3) | unit | 0x80;
|
||||
#else
|
||||
case 2:
|
||||
dosdev_copy = biosdrive;
|
||||
#endif
|
||||
break;
|
||||
#ifdef PC98
|
||||
case 6: /* 1440KB fd */
|
||||
dosdev_copy = (maj << 3) | unit;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
printf("Unknown device\n");
|
||||
return 1;
|
||||
|
@ -85,16 +85,12 @@ struct seg_desc Gdt[] = {
|
||||
{0xFFFF, 0x0, 0x0, 0x93, 0xCF, 0x0}, /* 0x10 : kernel data */
|
||||
/* 0x92? */
|
||||
{0xFFFF, RUN, RUN, 0x9E, 0x40, 0x0}, /* 0x18 : boot code */
|
||||
#ifdef PC98
|
||||
/*
|
||||
* The limit of boot data should be more than or equal to 0x9FFFF
|
||||
* for saving BIOS parameter and EPSON machine ID into 2'nd T-VRAM,
|
||||
* because base address is normally 0x10000.
|
||||
*/
|
||||
{0xFFFF, RUN, RUN, 0x92, 0x4F, 0x0}, /* 0x20 : boot data */
|
||||
#else
|
||||
{0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* 0x20 : boot data */
|
||||
#endif
|
||||
{0xFFFF, RUN, RUN, 0x9E, 0x0, 0x0}, /* 0x28 : boot code, 16 bits */
|
||||
{0xFFFF, 0x0, 0x0, 0x92, 0x0, 0x0}, /* 0x30 : boot data, 16 bits */
|
||||
#ifdef BDE_DEBUGGER
|
||||
|
@ -5,8 +5,6 @@ INTERNALPROG=
|
||||
NO_MAN=
|
||||
SRCS= btx.S
|
||||
|
||||
CFLAGS+=-DPC98
|
||||
|
||||
.if defined(PAGING)
|
||||
CFLAGS+=-DPAGING
|
||||
.endif
|
||||
|
@ -71,27 +71,15 @@
|
||||
/*
|
||||
* Screen defaults and assumptions.
|
||||
*/
|
||||
#ifdef PC98
|
||||
.set SCR_MAT,0xe1 # Mode/attribute
|
||||
#else
|
||||
.set SCR_MAT,0x7 # Mode/attribute
|
||||
#endif
|
||||
.set SCR_COL,0x50 # Columns per row
|
||||
.set SCR_ROW,0x19 # Rows per screen
|
||||
/*
|
||||
* BIOS Data Area locations.
|
||||
*/
|
||||
#ifdef PC98
|
||||
.set BDA_MEM,0x501 # Free memory
|
||||
.set BDA_KEYFLAGS,0x53a # Keyboard shift-state flags
|
||||
.set BDA_POS,0x53e # Cursor position
|
||||
#else
|
||||
.set BDA_MEM,0x413 # Free memory
|
||||
.set BDA_KEYFLAGS,0x417 # Keyboard shift-state flags
|
||||
.set BDA_SCR,0x449 # Video mode
|
||||
.set BDA_POS,0x450 # Cursor position
|
||||
.set BDA_BOOT,0x472 # Boot howto flag
|
||||
#endif
|
||||
/*
|
||||
* Derivations, for brevity.
|
||||
*/
|
||||
@ -233,13 +221,9 @@ init.8: xorl %ecx,%ecx # Zero
|
||||
ltr %cx # register
|
||||
movl $MEM_USR,%edx # User base address
|
||||
movzwl %ss:BDA_MEM,%eax # Get free memory
|
||||
#ifdef PC98
|
||||
andl $0x7,%eax
|
||||
incl %eax
|
||||
shll $0x11,%eax # To bytes
|
||||
#else
|
||||
shll $0xa,%eax # To bytes
|
||||
#endif
|
||||
subl $0x1000,%eax # Less arg space
|
||||
subl %edx,%eax # Less base
|
||||
movb $SEL_UDATA,%cl # User data selector
|
||||
@ -302,11 +286,7 @@ exit.1: mov $SEL_RDATA,%cl # 16-bit selector
|
||||
exit.2: xor %ax,%ax # Real mode segment
|
||||
mov %ax,%ss # Reload SS
|
||||
mov %ax,%ds # Address data
|
||||
#ifdef PC98
|
||||
mov $0x1008,%bx # Set real mode
|
||||
#else
|
||||
mov $0x7008,%bx # Set real mode
|
||||
#endif
|
||||
callw setpic # IRQ offsets
|
||||
lidt ivtdesc # Set IVT
|
||||
/*
|
||||
@ -315,20 +295,14 @@ exit.2: xor %ax,%ax # Real mode segment
|
||||
sti # Enable interrupts
|
||||
testb $0x1,btx_hdr+0x7 # Reboot?
|
||||
exit.3: jz exit.3 # No
|
||||
#ifdef PC98
|
||||
movb $0xa0,%al
|
||||
outb %al,$0x35
|
||||
movb 0,%al
|
||||
outb %al,$0xf0
|
||||
exit.4: jmp exit.4
|
||||
#else
|
||||
movw $0x1234, BDA_BOOT # Do a warm boot
|
||||
ljmp $0xf000,$0xfff0 # reboot the machine
|
||||
#endif
|
||||
/*
|
||||
* Set IRQ offsets by reprogramming 8259A PICs.
|
||||
*/
|
||||
#ifdef PC98
|
||||
setpic: in $0x02,%al # Save master
|
||||
push %ax # IMR
|
||||
in $0x0a,%al # Save slave
|
||||
@ -352,30 +326,6 @@ setpic: in $0x02,%al # Save master
|
||||
outb %al,$0x0a # IMR
|
||||
pop %ax # Restore master
|
||||
outb %al,$0x02 # IMR
|
||||
#else
|
||||
setpic: in $0x21,%al # Save master
|
||||
push %ax # IMR
|
||||
in $0xa1,%al # Save slave
|
||||
push %ax # IMR
|
||||
movb $0x11,%al # ICW1 to
|
||||
outb %al,$0x20 # master,
|
||||
outb %al,$0xa0 # slave
|
||||
movb %bl,%al # ICW2 to
|
||||
outb %al,$0x21 # master
|
||||
movb %bh,%al # ICW2 to
|
||||
outb %al,$0xa1 # slave
|
||||
movb $0x4,%al # ICW3 to
|
||||
outb %al,$0x21 # master
|
||||
movb $0x2,%al # ICW3 to
|
||||
outb %al,$0xa1 # slave
|
||||
movb $0x1,%al # ICW4 to
|
||||
outb %al,$0x21 # master,
|
||||
outb %al,$0xa1 # slave
|
||||
pop %ax # Restore slave
|
||||
outb %al,$0xa1 # IMR
|
||||
pop %ax # Restore master
|
||||
outb %al,$0x21 # IMR
|
||||
#endif
|
||||
retw # To caller
|
||||
.code32
|
||||
/*
|
||||
@ -455,7 +405,6 @@ except.2: push $SEL_SDATA # Set up
|
||||
movl %esp,%ebx # Stack frame
|
||||
movl $dmpfmt,%esi # Dump format string
|
||||
movl $MEM_BUF,%edi # Buffer
|
||||
#ifdef PC98
|
||||
pushl %eax
|
||||
pushl %edx
|
||||
wait.1:
|
||||
@ -482,7 +431,6 @@ wait.2:
|
||||
movw %ax,(%edx)
|
||||
popl %edx
|
||||
popl %eax
|
||||
#endif
|
||||
pushl %edi # Dump to
|
||||
call dump # buffer
|
||||
popl %esi # and
|
||||
@ -751,13 +699,8 @@ v86intn: lodsb # Get int no
|
||||
v86intn.1: cmpw $0x4f53,%ax # is it the delete key callout?
|
||||
jne v86intn.2 # no, handle the int normally
|
||||
movb BDA_KEYFLAGS,%al # get the shift key state
|
||||
#ifdef PC98
|
||||
andb $0x18,%al # mask off just Ctrl and Alt
|
||||
cmpb $0x18,%al # are both Ctrl and Alt down?
|
||||
#else
|
||||
andb $0xc,%al # mask off just Ctrl and Alt
|
||||
cmpb $0xc,%al # are both Ctrl and Alt down?
|
||||
#endif
|
||||
jne v86intn.2 # no, handle the int normally
|
||||
popl %eax # restore EAX
|
||||
jmp reboot # reboot the machine
|
||||
@ -794,7 +737,6 @@ intx20: push $0x8 # Int 0x20: IRQ0
|
||||
jmp int_hw # V86 int 0xe
|
||||
push $0xf # Int 0x27: IRQ7
|
||||
jmp int_hw # V86 int 0xf
|
||||
#ifdef PC98
|
||||
push $0x10 # Int 0x28: IRQ8
|
||||
jmp int_hw # V86 int 0x10
|
||||
push $0x11 # Int 0x29: IRQ9
|
||||
@ -811,24 +753,6 @@ intx20: push $0x8 # Int 0x20: IRQ0
|
||||
jmp int_hw # V86 int 0x16
|
||||
push $0x17 # Int 0x2f: IRQ15
|
||||
jmp int_hw # V86 int 0x17
|
||||
#else
|
||||
push $0x70 # Int 0x28: IRQ8
|
||||
jmp int_hw # V86 int 0x70
|
||||
push $0x71 # Int 0x29: IRQ9
|
||||
jmp int_hw # V86 int 0x71
|
||||
push $0x72 # Int 0x2a: IRQ10
|
||||
jmp int_hw # V86 int 0x72
|
||||
push $0x73 # Int 0x2b: IRQ11
|
||||
jmp int_hw # V86 int 0x73
|
||||
push $0x74 # Int 0x2c: IRQ12
|
||||
jmp int_hw # V86 int 0x74
|
||||
push $0x75 # Int 0x2d: IRQ13
|
||||
jmp int_hw # V86 int 0x75
|
||||
push $0x76 # Int 0x2e: IRQ14
|
||||
jmp int_hw # V86 int 0x76
|
||||
push $0x77 # Int 0x2f: IRQ15
|
||||
jmp int_hw # V86 int 0x77
|
||||
#endif
|
||||
/*
|
||||
* Reflect hardware interrupts.
|
||||
*/
|
||||
@ -1163,17 +1087,9 @@ putchr: pusha # Save
|
||||
movb $SCR_MAT,%ah # Mode/attribute
|
||||
movl $BDA_POS,%ebx # BDA pointer
|
||||
movw (%ebx),%dx # Cursor position
|
||||
#ifdef PC98
|
||||
movl $0xa0000,%edi
|
||||
#else
|
||||
movl $0xb8000,%edi # Regen buffer (color)
|
||||
cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
|
||||
jne putchr.1 # No
|
||||
xorw %di,%di # Regen buffer (mono)
|
||||
#endif
|
||||
putchr.1: cmpb $0xa,%al # New line?
|
||||
je putchr.2 # Yes
|
||||
#ifdef PC98
|
||||
movw %dx,%cx
|
||||
movb %al,(%edi,%ecx,1) # Write char
|
||||
addl $0x2000,%ecx
|
||||
@ -1187,39 +1103,17 @@ putchr.2: movw %dx,%ax
|
||||
mul %dl
|
||||
movw %ax,%dx
|
||||
putchr.3: cmpw $SCR_ROW*SCR_COL*2,%dx
|
||||
#else
|
||||
xchgl %eax,%ecx # Save char
|
||||
movb $SCR_COL,%al # Columns per row
|
||||
mulb %dh # * row position
|
||||
addb %dl,%al # + column
|
||||
adcb $0x0,%ah # position
|
||||
shll %eax # * 2
|
||||
xchgl %eax,%ecx # Swap char, offset
|
||||
movw %ax,(%edi,%ecx,1) # Write attr:char
|
||||
incl %edx # Bump cursor
|
||||
cmpb $SCR_COL,%dl # Beyond row?
|
||||
jb putchr.3 # No
|
||||
putchr.2: xorb %dl,%dl # Zero column
|
||||
incb %dh # Bump row
|
||||
putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
|
||||
#endif
|
||||
jb putchr.4 # No
|
||||
leal 2*SCR_COL(%edi),%esi # New top line
|
||||
movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
|
||||
rep # Scroll
|
||||
movsl # screen
|
||||
movb $0x20,%al # Space
|
||||
#ifdef PC98
|
||||
xorb %ah,%ah
|
||||
#endif
|
||||
movb $SCR_COL,%cl # Columns to clear
|
||||
rep # Clear
|
||||
stosw # line
|
||||
#ifdef PC98
|
||||
movw $(SCR_ROW-1)*SCR_COL*2,%dx
|
||||
#else
|
||||
movb $SCR_ROW-1,%dh # Bottom line
|
||||
#endif
|
||||
putchr.4: movw %dx,(%ebx) # Update position
|
||||
popa # Restore
|
||||
ret # To caller
|
||||
|
@ -5,7 +5,6 @@ INTERNALPROG=
|
||||
NO_MAN=
|
||||
SRCS= btxldr.S
|
||||
|
||||
CFLAGS+=-DPC98
|
||||
CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS}
|
||||
|
||||
.if defined(BTXLDR_VERBOSE)
|
||||
|
@ -43,24 +43,14 @@
|
||||
/*
|
||||
* Screen constants.
|
||||
*/
|
||||
#ifdef PC98
|
||||
.set SCR_MAT,0xe1 # Mode/attribute
|
||||
#else
|
||||
.set SCR_MAT,0x7 # Mode/attribute
|
||||
#endif
|
||||
.set SCR_COL,0x50 # Columns per row
|
||||
.set SCR_ROW,0x19 # Rows per screen
|
||||
/*
|
||||
* BIOS Data Area locations.
|
||||
*/
|
||||
#ifdef PC98
|
||||
.set BDA_MEM,0xa1501 # Free memory
|
||||
.set BDA_POS,0xa153e # Cursor position
|
||||
#else
|
||||
.set BDA_MEM,0x413 # Free memory
|
||||
.set BDA_SCR,0x449 # Video mode
|
||||
.set BDA_POS,0x450 # Cursor position
|
||||
#endif
|
||||
/*
|
||||
* Required by aout gas inadequacy.
|
||||
*/
|
||||
@ -73,7 +63,6 @@
|
||||
* BTX program loader for ELF clients.
|
||||
*/
|
||||
start: cld # String ops inc
|
||||
#ifdef PC98
|
||||
cli
|
||||
gdcwait.1: inb $0x60,%al
|
||||
testb $0x04,%al
|
||||
@ -94,17 +83,12 @@ gdcwait.2: inb $0x60,%al
|
||||
shlw $1,%dx
|
||||
movl $BDA_POS,%ebx
|
||||
movw %dx,(%ebx)
|
||||
#endif
|
||||
movl $m_logo,%esi # Identify
|
||||
call putstr # ourselves
|
||||
movzwl BDA_MEM,%eax # Get base memory
|
||||
#ifdef PC98
|
||||
andl $0x7,%eax
|
||||
incl %eax
|
||||
shll $0x11,%eax # in bytes
|
||||
#else
|
||||
shll $0xa,%eax # in bytes
|
||||
#endif
|
||||
movl %eax,%ebp # Base of user stack
|
||||
#ifdef BTXLDR_VERBOSE
|
||||
movl $m_mem,%esi # Display
|
||||
@ -330,17 +314,9 @@ putchr: pusha # Save
|
||||
movb $SCR_MAT,%ah # Mode/attribute
|
||||
movl $BDA_POS,%ebx # BDA pointer
|
||||
movw (%ebx),%dx # Cursor position
|
||||
#ifdef PC98
|
||||
movl $0xa0000,%edi # Regen buffer (color)
|
||||
#else
|
||||
movl $0xb8000,%edi # Regen buffer (color)
|
||||
cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
|
||||
jne putchr.1 # No
|
||||
xorw %di,%di # Regen buffer (mono)
|
||||
#endif
|
||||
putchr.1: cmpb $0xa,%al # New line?
|
||||
je putchr.2 # Yes
|
||||
#ifdef PC98
|
||||
movw %dx,%cx
|
||||
movb %al,(%edi,%ecx,1) # Write char
|
||||
addl $0x2000,%ecx
|
||||
@ -354,35 +330,16 @@ putchr.2: movw %dx,%ax
|
||||
mul %dl
|
||||
movw %ax,%dx
|
||||
putchr.3: cmpw $SCR_COL*SCR_ROW*2,%dx
|
||||
#else
|
||||
xchgl %eax,%ecx # Save char
|
||||
movb $SCR_COL,%al # Columns per row
|
||||
mulb %dh # * row position
|
||||
addb %dl,%al # + column
|
||||
adcb $0x0,%ah # position
|
||||
shll %eax # * 2
|
||||
xchgl %eax,%ecx # Swap char, offset
|
||||
movw %ax,(%edi,%ecx,1) # Write attr:char
|
||||
incl %edx # Bump cursor
|
||||
cmpb $SCR_COL,%dl # Beyond row?
|
||||
jb putchr.3 # No
|
||||
putchr.2: xorb %dl,%dl # Zero column
|
||||
incb %dh # Bump row
|
||||
putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
|
||||
#endif
|
||||
jb putchr.4 # No
|
||||
leal 2*SCR_COL(%edi),%esi # New top line
|
||||
movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
|
||||
rep # Scroll
|
||||
movsl # screen
|
||||
movb $' ',%al # Space
|
||||
#ifdef PC98
|
||||
xorb %ah,%ah
|
||||
#endif
|
||||
movb $SCR_COL,%cl # Columns to clear
|
||||
rep # Clear
|
||||
stosw # line
|
||||
#ifdef PC98
|
||||
movw $(SCR_ROW-1)*SCR_COL*2,%dx
|
||||
putchr.4: movw %dx,(%ebx) # Update position
|
||||
shrw $1,%dx
|
||||
@ -395,10 +352,6 @@ gdcwait.3: inb $0x60,%al
|
||||
outb %al,$0x60
|
||||
movb %dh,%al
|
||||
outb %al,$0x60
|
||||
#else
|
||||
movb $SCR_ROW-1,%dh # Bottom line
|
||||
putchr.4: movw %dx,(%ebx) # Update position
|
||||
#endif
|
||||
popa # Restore
|
||||
ret # To caller
|
||||
/*
|
||||
|
@ -15,8 +15,6 @@ LDFLAGS=-Wl,-r
|
||||
.PATH: ${.CURDIR}/../../i386/kgzldr
|
||||
|
||||
BOOT_COMCONSOLE_PORT?= 0x238
|
||||
|
||||
AFLAGS+=--defsym PC98=1
|
||||
AFLAGS+=--defsym SIO_PRT=${BOOT_COMCONSOLE_PORT}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -29,22 +29,13 @@
|
||||
|
||||
# Screen defaults and assumptions.
|
||||
|
||||
.ifdef PC98
|
||||
.set SCR_MAT,0xe1 # Mode/attribute
|
||||
.else
|
||||
.set SCR_MAT,0x7 # Mode/attribute
|
||||
.endif
|
||||
.set SCR_COL,0x50 # Columns per row
|
||||
.set SCR_ROW,0x19 # Rows per screen
|
||||
|
||||
# BIOS Data Area locations.
|
||||
|
||||
.ifdef PC98
|
||||
.set BDA_POS,0x53e # Cursor position
|
||||
.else
|
||||
.set BDA_SCR,0x449 # Video mode
|
||||
.set BDA_POS,0x450 # Cursor position
|
||||
.endif
|
||||
|
||||
.globl crt_putchr
|
||||
|
||||
@ -56,17 +47,9 @@ crt_putchr: movb 0x4(%esp,1),%al # Get character
|
||||
movb $SCR_MAT,%ah # Mode/attribute
|
||||
movl $BDA_POS,%ebx # BDA pointer
|
||||
movw (%ebx),%dx # Cursor position
|
||||
.ifdef PC98
|
||||
movl $0xa0000,%edi
|
||||
.else
|
||||
movl $0xb8000,%edi # Regen buffer (color)
|
||||
cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
|
||||
jne crt_putchr.1 # No
|
||||
xorw %di,%di # Regen buffer (mono)
|
||||
.endif
|
||||
crt_putchr.1: cmpb $0xa,%al # New line?
|
||||
je crt_putchr.2 # Yes
|
||||
.ifdef PC98
|
||||
movw %dx,%cx
|
||||
movb %al,(%edi,%ecx,1) # Write char
|
||||
addl $0x2000,%ecx
|
||||
@ -80,39 +63,17 @@ crt_putchr.2: movw %dx,%ax
|
||||
mul %dl
|
||||
movw %ax,%dx
|
||||
crt_putchr.3: cmpw $SCR_ROW*SCR_COL*2,%dx
|
||||
.else
|
||||
xchgl %eax,%ecx # Save char
|
||||
movb $SCR_COL,%al # Columns per row
|
||||
mulb %dh # * row position
|
||||
addb %dl,%al # + column
|
||||
adcb $0x0,%ah # position
|
||||
shll %eax # * 2
|
||||
xchgl %eax,%ecx # Swap char, offset
|
||||
movw %ax,(%edi,%ecx,1) # Write attr:char
|
||||
incl %edx # Bump cursor
|
||||
cmpb $SCR_COL,%dl # Beyond row?
|
||||
jb crt_putchr.3 # No
|
||||
crt_putchr.2: xorb %dl,%dl # Zero column
|
||||
incb %dh # Bump row
|
||||
crt_putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
|
||||
.endif
|
||||
jb crt_putchr.4 # No
|
||||
leal 2*SCR_COL(%edi),%esi # New top line
|
||||
movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
|
||||
rep # Scroll
|
||||
movsl # screen
|
||||
movb $' ',%al # Space
|
||||
.ifdef PC98
|
||||
xorb %ah,%ah
|
||||
.endif
|
||||
movb $SCR_COL,%cl # Columns to clear
|
||||
rep # Clear
|
||||
stosw # line
|
||||
.ifdef PC98
|
||||
movw $(SCR_ROW-1)*SCR_COL*2,%dx
|
||||
.else
|
||||
movb $SCR_ROW-1,%dh # Bottom line
|
||||
.endif
|
||||
crt_putchr.4: movw %dx,(%ebx) # Update position
|
||||
popa # Restore
|
||||
ret # To caller
|
||||
|
@ -24,7 +24,6 @@ CFLAGS+= -DDISK_DEBUG
|
||||
# Include simple terminal emulation (cons25-compatible)
|
||||
CFLAGS+= -DTERM_EMU
|
||||
|
||||
CFLAGS+= -DPC98
|
||||
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib \
|
||||
-I${.CURDIR}/../../i386/libi386 \
|
||||
-I${.CURDIR}/../../.. -I.
|
||||
|
@ -81,9 +81,7 @@ struct open_disk {
|
||||
#define BD_FLOPPY 0x0004
|
||||
#define BD_LABELOK 0x0008
|
||||
#define BD_PARTTABOK 0x0010
|
||||
#ifdef PC98
|
||||
#define BD_OPTICAL 0x0020
|
||||
#endif
|
||||
struct disklabel od_disklabel;
|
||||
int od_nslices; /* slice count */
|
||||
struct pc98_partition od_slicetab[NDOSPART];
|
||||
@ -98,9 +96,7 @@ static struct bdinfo
|
||||
int bd_unit; /* BIOS unit number */
|
||||
int bd_flags;
|
||||
int bd_type; /* BIOS 'drive type' (floppy only) */
|
||||
#ifdef PC98
|
||||
int bd_da_unit; /* kernel unit number for da */
|
||||
#endif
|
||||
} bdinfo [MAXBDDEV];
|
||||
static int nbdinfo = 0;
|
||||
|
||||
@ -174,7 +170,6 @@ bd_unit2bios(int unit)
|
||||
static int
|
||||
bd_init(void)
|
||||
{
|
||||
#ifdef PC98
|
||||
int base, unit;
|
||||
int da_drive=0, n=-0x10;
|
||||
|
||||
@ -210,32 +205,6 @@ bd_init(void)
|
||||
nbdinfo++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int base, unit, nfd = 0;
|
||||
|
||||
/* sequence 0, 0x80 */
|
||||
for (base = 0; base <= 0x80; base += 0x80) {
|
||||
for (unit = base; (nbdinfo < MAXBDDEV); unit++) {
|
||||
/* check the BIOS equipment list for number of fixed disks */
|
||||
if((base == 0x80) &&
|
||||
(nfd >= *(unsigned char *)PTOV(BIOS_NUMDRIVES)))
|
||||
break;
|
||||
|
||||
bdinfo[nbdinfo].bd_unit = unit;
|
||||
bdinfo[nbdinfo].bd_flags = (unit < 0x80) ? BD_FLOPPY : 0;
|
||||
|
||||
if (!bd_int13probe(&bdinfo[nbdinfo]))
|
||||
break;
|
||||
|
||||
/* XXX we need "disk aliases" to make this simpler */
|
||||
printf("BIOS drive %c: is disk%d\n",
|
||||
(unit < 0x80) ? ('A' + unit) : ('C' + unit - 0x80), nbdinfo);
|
||||
nbdinfo++;
|
||||
if (base == 0x80)
|
||||
nfd++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -245,7 +214,6 @@ bd_init(void)
|
||||
static int
|
||||
bd_int13probe(struct bdinfo *bd)
|
||||
{
|
||||
#ifdef PC98
|
||||
int addr;
|
||||
|
||||
if (bd->bd_flags & BD_FLOPPY) {
|
||||
@ -269,34 +237,6 @@ bd_int13probe(struct bdinfo *bd)
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
#else
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
v86.eax = 0x800;
|
||||
v86.edx = bd->bd_unit;
|
||||
v86int();
|
||||
|
||||
if (!(v86.efl & 0x1) && /* carry clear */
|
||||
((v86.edx & 0xff) > ((unsigned)bd->bd_unit & 0x7f))) { /* unit # OK */
|
||||
bd->bd_flags |= BD_MODEINT13;
|
||||
bd->bd_type = v86.ebx & 0xff;
|
||||
|
||||
/* Determine if we can use EDD with this device. */
|
||||
v86.eax = 0x4100;
|
||||
v86.edx = bd->bd_unit;
|
||||
v86.ebx = 0x55aa;
|
||||
v86int();
|
||||
if (!(v86.efl & 0x1) && /* carry clear */
|
||||
((v86.ebx & 0xffff) == 0xaa55) && /* signature */
|
||||
(v86.ecx & 0x1)) { /* packets mode ok */
|
||||
bd->bd_flags |= BD_MODEEDD1;
|
||||
if((v86.eax & 0xff00) > 0x300)
|
||||
bd->bd_flags |= BD_MODEEDD3;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -312,12 +252,7 @@ bd_print(int verbose)
|
||||
struct pc98_partition *dptr;
|
||||
|
||||
for (i = 0; i < nbdinfo; i++) {
|
||||
#ifdef PC98
|
||||
sprintf(line, " disk%d: BIOS drive %c:\n", i, 'A' + i);
|
||||
#else
|
||||
sprintf(line, " disk%d: BIOS drive %c:\n", i,
|
||||
(bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit) : ('C' + bdinfo[i].bd_unit - 0x80));
|
||||
#endif
|
||||
pager_output(line);
|
||||
|
||||
/* try to open the whole disk */
|
||||
@ -332,7 +267,6 @@ bd_print(int verbose)
|
||||
dptr = &od->od_slicetab[0];
|
||||
|
||||
/* Check for a "dedicated" disk */
|
||||
#ifdef PC98
|
||||
for (j = 0; j < od->od_nslices; j++) {
|
||||
switch(dptr[j].dp_mid) {
|
||||
case DOSMID_386BSD:
|
||||
@ -346,103 +280,12 @@ bd_print(int verbose)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if ((dptr[3].dp_typ == DOSPTYP_386BSD) &&
|
||||
(dptr[3].dp_start == 0) &&
|
||||
(dptr[3].dp_size == 50000)) {
|
||||
sprintf(line, " disk%d", i);
|
||||
bd_printbsdslice(od, 0, line, verbose);
|
||||
} else {
|
||||
for (j = 0; j < od->od_nslices; j++) {
|
||||
sprintf(line, " disk%ds%d", i, j + 1);
|
||||
bd_printslice(od, &dptr[j], line, verbose);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
bd_closedisk(od);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PC98
|
||||
/*
|
||||
* Print information about slices on a disk. For the size calculations we
|
||||
* assume a 512 byte sector.
|
||||
*/
|
||||
static void
|
||||
bd_printslice(struct open_disk *od, struct dos_partition *dp, char *prefix,
|
||||
int verbose)
|
||||
{
|
||||
char line[80];
|
||||
|
||||
switch (dp->dp_typ) {
|
||||
case DOSPTYP_386BSD:
|
||||
bd_printbsdslice(od, (daddr_t)dp->dp_start, prefix, verbose);
|
||||
return;
|
||||
case DOSPTYP_LINSWP:
|
||||
if (verbose)
|
||||
sprintf(line, "%s: Linux swap %.6dMB (%d - %d)\n",
|
||||
prefix, dp->dp_size / 2048,
|
||||
dp->dp_start, dp->dp_start + dp->dp_size);
|
||||
else
|
||||
sprintf(line, "%s: Linux swap\n", prefix);
|
||||
break;
|
||||
case DOSPTYP_LINUX:
|
||||
/*
|
||||
* XXX
|
||||
* read the superblock to confirm this is an ext2fs partition?
|
||||
*/
|
||||
if (verbose)
|
||||
sprintf(line, "%s: ext2fs %.6dMB (%d - %d)\n", prefix,
|
||||
dp->dp_size / 2048, dp->dp_start,
|
||||
dp->dp_start + dp->dp_size);
|
||||
else
|
||||
sprintf(line, "%s: ext2fs\n", prefix);
|
||||
break;
|
||||
case 0x00: /* unused partition */
|
||||
case DOSPTYP_EXT:
|
||||
return;
|
||||
case 0x01:
|
||||
if (verbose)
|
||||
sprintf(line, "%s: FAT-12 %.6dMB (%d - %d)\n", prefix,
|
||||
dp->dp_size / 2048, dp->dp_start,
|
||||
dp->dp_start + dp->dp_size);
|
||||
else
|
||||
sprintf(line, "%s: FAT-12\n", prefix);
|
||||
break;
|
||||
case 0x04:
|
||||
case 0x06:
|
||||
case 0x0e:
|
||||
if (verbose)
|
||||
sprintf(line, "%s: FAT-16 %.6dMB (%d - %d)\n", prefix,
|
||||
dp->dp_size / 2048, dp->dp_start,
|
||||
dp->dp_start + dp->dp_size);
|
||||
else
|
||||
sprintf(line, "%s: FAT-16\n", prefix);
|
||||
break;
|
||||
case 0x0b:
|
||||
case 0x0c:
|
||||
if (verbose)
|
||||
sprintf(line, "%s: FAT-32 %.6dMB (%d - %d)\n", prefix,
|
||||
dp->dp_size / 2048, dp->dp_start,
|
||||
dp->dp_start + dp->dp_size);
|
||||
else
|
||||
sprintf(line, "%s: FAT-32\n", prefix);
|
||||
break;
|
||||
default:
|
||||
if (verbose)
|
||||
sprintf(line, "%s: Unknown fs: 0x%x %.6dMB (%d - %d)\n",
|
||||
prefix, dp->dp_typ, dp->dp_size / 2048,
|
||||
dp->dp_start, dp->dp_start + dp->dp_size);
|
||||
else
|
||||
sprintf(line, "%s: Unknown fs: 0x%x\n", prefix,
|
||||
dp->dp_typ);
|
||||
}
|
||||
pager_output(line);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Print out each valid partition in the disklabel of a FreeBSD slice.
|
||||
* For size calculations, we assume a 512 byte sector size.
|
||||
@ -580,12 +423,10 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
|
||||
/*
|
||||
* Find the slice in the DOS slice table.
|
||||
*/
|
||||
#ifdef PC98
|
||||
if (od->od_flags & BD_FLOPPY) {
|
||||
sector = 0;
|
||||
goto unsliced;
|
||||
}
|
||||
#endif
|
||||
if (bd_read(od, 0, 1, buf)) {
|
||||
DEBUG("error reading MBR");
|
||||
error = EIO;
|
||||
@ -605,26 +446,18 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
|
||||
sector = 0;
|
||||
goto unsliced; /* may be a floppy */
|
||||
}
|
||||
#ifdef PC98
|
||||
if (bd_read(od, 1, 1, buf)) {
|
||||
DEBUG("error reading MBR");
|
||||
error = EIO;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* copy the partition table, then pick up any extended partitions.
|
||||
*/
|
||||
bcopy(buf + DOSPARTOFF, &od->od_slicetab,
|
||||
sizeof(struct pc98_partition) * NDOSPART);
|
||||
#ifdef PC98
|
||||
od->od_nslices = NDOSPART; /* extended slices start here */
|
||||
#else
|
||||
od->od_nslices = 4; /* extended slices start here */
|
||||
for (i = 0; i < NDOSPART; i++)
|
||||
bd_checkextended(od, i);
|
||||
#endif
|
||||
od->od_flags |= BD_PARTTABOK;
|
||||
dptr = &od->od_slicetab[0];
|
||||
|
||||
@ -646,18 +479,6 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PC98
|
||||
/*
|
||||
* Check for the historically bogus MBR found on true dedicated disks
|
||||
*/
|
||||
if ((dptr[3].dp_typ == DOSPTYP_386BSD) &&
|
||||
(dptr[3].dp_start == 0) &&
|
||||
(dptr[3].dp_size == 50000)) {
|
||||
sector = 0;
|
||||
goto unsliced;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Try to auto-detect the best slice; this should always give a slice number */
|
||||
if (dev->d_kind.biosdisk.slice == 0) {
|
||||
slice = bd_bestslice(od);
|
||||
@ -674,7 +495,6 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
|
||||
* at a DOS partition).
|
||||
*/
|
||||
dptr += (dev->d_kind.biosdisk.slice - 1); /* we number 1-4, offsets are 0-3 */
|
||||
#ifdef PC98
|
||||
sector = dptr->dp_scyl * od->od_hds * od->od_sec +
|
||||
dptr->dp_shd * od->od_sec + dptr->dp_ssect;
|
||||
{
|
||||
@ -683,19 +503,11 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
|
||||
DEBUG("slice entry %d at %d, %d sectors",
|
||||
dev->d_kind.biosdisk.slice - 1, sector, end-sector);
|
||||
}
|
||||
#else
|
||||
sector = dptr->dp_start;
|
||||
DEBUG("slice entry %d at %d, %d sectors", dev->d_kind.biosdisk.slice - 1, sector, dptr->dp_size);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If we are looking at a BSD slice, and the partition is < 0, assume the 'a' partition
|
||||
*/
|
||||
#ifdef PC98
|
||||
if ((dptr->dp_mid == DOSMID_386BSD) && (dev->d_kind.biosdisk.partition < 0))
|
||||
#else
|
||||
if ((dptr->dp_typ == DOSPTYP_386BSD) && (dev->d_kind.biosdisk.partition < 0))
|
||||
#endif
|
||||
dev->d_kind.biosdisk.partition = 0;
|
||||
|
||||
unsliced:
|
||||
@ -755,51 +567,6 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
|
||||
return(error);
|
||||
}
|
||||
|
||||
#ifndef PC98
|
||||
static void
|
||||
bd_checkextended(struct open_disk *od, int slicenum)
|
||||
{
|
||||
char buf[BIOSDISK_SECSIZE];
|
||||
struct dos_partition *dp;
|
||||
u_int base;
|
||||
int i, start, end;
|
||||
|
||||
dp = &od->od_slicetab[slicenum];
|
||||
start = od->od_nslices;
|
||||
|
||||
if (dp->dp_size == 0)
|
||||
goto done;
|
||||
if (dp->dp_typ != DOSPTYP_EXT)
|
||||
goto done;
|
||||
if (bd_read(od, (daddr_t)dp->dp_start, 1, buf))
|
||||
goto done;
|
||||
if (((u_char)buf[0x1fe] != 0x55) || ((u_char)buf[0x1ff] != 0xaa)) {
|
||||
DEBUG("no magic in extended table");
|
||||
goto done;
|
||||
}
|
||||
base = dp->dp_start;
|
||||
dp = (struct dos_partition *)(&buf[DOSPARTOFF]);
|
||||
for (i = 0; i < NDOSPART; i++, dp++) {
|
||||
if (dp->dp_size == 0)
|
||||
continue;
|
||||
if (od->od_nslices == NDOSPART)
|
||||
goto done;
|
||||
dp->dp_start += base;
|
||||
bcopy(dp, &od->od_slicetab[od->od_nslices], sizeof(*dp));
|
||||
od->od_nslices++;
|
||||
}
|
||||
end = od->od_nslices;
|
||||
|
||||
/*
|
||||
* now, recursively check the slices we just added
|
||||
*/
|
||||
for (i = start; i < end; i++)
|
||||
bd_checkextended(od, i);
|
||||
done:
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Search for a slice with the following preferences:
|
||||
*
|
||||
@ -834,8 +601,6 @@ bd_bestslice(struct open_disk *od)
|
||||
|
||||
dp = &od->od_slicetab[0];
|
||||
for (i = 0; i < od->od_nslices; i++, dp++) {
|
||||
|
||||
#ifdef PC98
|
||||
switch(dp->dp_mid & 0x7f) {
|
||||
case DOSMID_386BSD & 0x7f: /* FreeBSD */
|
||||
if ((dp->dp_mid & 0x80) &&
|
||||
@ -864,33 +629,6 @@ bd_bestslice(struct open_disk *od)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch (dp->dp_typ) {
|
||||
case DOSPTYP_386BSD: /* FreeBSD */
|
||||
pref = dp->dp_flag & 0x80 ? PREF_FBSD_ACT : PREF_FBSD;
|
||||
break;
|
||||
|
||||
case DOSPTYP_LINUX:
|
||||
pref = dp->dp_flag & 0x80 ? PREF_LINUX_ACT : PREF_LINUX;
|
||||
break;
|
||||
|
||||
case 0x01: /* DOS/Windows */
|
||||
case 0x04:
|
||||
case 0x06:
|
||||
case 0x0b:
|
||||
case 0x0c:
|
||||
case 0x0e:
|
||||
pref = dp->dp_flag & 0x80 ? PREF_DOS_ACT : PREF_DOS;
|
||||
break;
|
||||
|
||||
default:
|
||||
pref = PREF_NONE;
|
||||
}
|
||||
if (pref < preflevel) {
|
||||
preflevel = pref;
|
||||
prefslice = i + 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return (prefslice);
|
||||
}
|
||||
@ -1016,12 +754,7 @@ bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
p = dest;
|
||||
|
||||
/* Decide whether we have to bounce */
|
||||
#ifdef PC98
|
||||
if (
|
||||
#else
|
||||
if ((od->od_unit < 0x80) &&
|
||||
#endif
|
||||
((VTOP(dest) >> 16) != (VTOP(dest + blks * BIOSDISK_SECSIZE) >> 16))) {
|
||||
if (((VTOP(dest) >> 16) != (VTOP(dest + blks * BIOSDISK_SECSIZE) >> 16))) {
|
||||
|
||||
/*
|
||||
* There is a 64k physical boundary somewhere in the destination buffer, so we have
|
||||
@ -1029,11 +762,7 @@ bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
* need to. Use the bottom half unless there is a break there, in which case we
|
||||
* use the top half.
|
||||
*/
|
||||
#ifdef PC98
|
||||
x = min(od->od_sec, (unsigned)blks);
|
||||
#else
|
||||
x = min(FLOPPY_BOUNCEBUF, (unsigned)blks);
|
||||
#endif
|
||||
bbuf = malloc(x * 2 * BIOSDISK_SECSIZE);
|
||||
if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(bbuf + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
|
||||
breg = bbuf;
|
||||
@ -1062,31 +791,19 @@ bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
xp = bbuf == NULL ? p : breg;
|
||||
|
||||
/* correct sector number for 1-based BIOS numbering */
|
||||
#ifdef PC98
|
||||
if ((od->od_unit & 0xf0) == 0x30 || (od->od_unit & 0xf0) == 0x90)
|
||||
sec++;
|
||||
#else
|
||||
sec++;
|
||||
#endif
|
||||
|
||||
/* Loop retrying the operation a couple of times. The BIOS may also retry. */
|
||||
for (retry = 0; retry < 3; retry++) {
|
||||
/* if retrying, reset the drive */
|
||||
if (retry > 0) {
|
||||
#ifdef PC98
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x1b;
|
||||
v86.eax = 0x0300 | od->od_unit;
|
||||
#else
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
v86.eax = 0;
|
||||
v86.edx = od->od_unit;
|
||||
#endif
|
||||
v86int();
|
||||
}
|
||||
|
||||
#ifdef PC98
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x1b;
|
||||
if (od->od_flags & BD_FLOPPY) {
|
||||
@ -1111,64 +828,14 @@ bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
result = (v86.efl & 0x1);
|
||||
if (result == 0)
|
||||
break;
|
||||
#else
|
||||
if(cyl > 1023) {
|
||||
/* use EDD if the disk supports it, otherwise, return error */
|
||||
if(od->od_flags & BD_MODEEDD1) {
|
||||
static unsigned short packet[8];
|
||||
|
||||
packet[0] = 0x10;
|
||||
packet[1] = x;
|
||||
packet[2] = VTOPOFF(xp);
|
||||
packet[3] = VTOPSEG(xp);
|
||||
packet[4] = dblk & 0xffff;
|
||||
packet[5] = dblk >> 16;
|
||||
packet[6] = 0;
|
||||
packet[7] = 0;
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
v86.eax = 0x4200;
|
||||
v86.edx = od->od_unit;
|
||||
v86.ds = VTOPSEG(packet);
|
||||
v86.esi = VTOPOFF(packet);
|
||||
v86int();
|
||||
result = (v86.efl & 0x1);
|
||||
if(result == 0)
|
||||
break;
|
||||
} else {
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Use normal CHS addressing */
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
v86.eax = 0x200 | x;
|
||||
v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec;
|
||||
v86.edx = (hd << 8) | od->od_unit;
|
||||
v86.es = VTOPSEG(xp);
|
||||
v86.ebx = VTOPOFF(xp);
|
||||
v86int();
|
||||
result = (v86.efl & 0x1);
|
||||
if (result == 0)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PC98
|
||||
DEBUG("%d sectors from %d/%d/%d to %p (0x%x) %s", x, cyl, hd, od->od_flags & BD_FLOPPY ? sec - 1 : sec, p, VTOP(p), result ? "failed" : "ok");
|
||||
/* BUG here, cannot use v86 in printf because putchar uses it too */
|
||||
DEBUG("ax = 0x%04x cx = 0x%04x dx = 0x%04x status 0x%x",
|
||||
od->od_flags & BD_FLOPPY ? 0xd600 | od->od_unit : 0x0600 | od->od_unit,
|
||||
od->od_flags & BD_FLOPPY ? 0x0200 | cyl : cyl, (hd << 8) | sec,
|
||||
(v86.eax >> 8) & 0xff);
|
||||
#else
|
||||
DEBUG("%d sectors from %d/%d/%d to %p (0x%x) %s", x, cyl, hd, sec - 1, p, VTOP(p), result ? "failed" : "ok");
|
||||
/* BUG here, cannot use v86 in printf because putchar uses it too */
|
||||
DEBUG("ax = 0x%04x cx = 0x%04x dx = 0x%04x status 0x%x",
|
||||
0x200 | x, ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec, (hd << 8) | od->od_unit, (v86.eax >> 8) & 0xff);
|
||||
#endif
|
||||
if (result) {
|
||||
if (bbuf != NULL)
|
||||
free(bbuf);
|
||||
@ -1203,12 +870,7 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
p = dest;
|
||||
|
||||
/* Decide whether we have to bounce */
|
||||
#ifdef PC98
|
||||
if (
|
||||
#else
|
||||
if ((od->od_unit < 0x80) &&
|
||||
#endif
|
||||
((VTOP(dest) >> 16) != (VTOP(dest + blks * BIOSDISK_SECSIZE) >> 16))) {
|
||||
if (((VTOP(dest) >> 16) != (VTOP(dest + blks * BIOSDISK_SECSIZE) >> 16))) {
|
||||
|
||||
/*
|
||||
* There is a 64k physical boundary somewhere in the destination buffer, so we have
|
||||
@ -1217,11 +879,7 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
* use the top half.
|
||||
*/
|
||||
|
||||
#ifdef PC98
|
||||
x = min(od->od_sec, (unsigned)blks);
|
||||
#else
|
||||
x = min(FLOPPY_BOUNCEBUF, (unsigned)blks);
|
||||
#endif
|
||||
bbuf = malloc(x * 2 * BIOSDISK_SECSIZE);
|
||||
if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(bbuf + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
|
||||
breg = bbuf;
|
||||
@ -1250,13 +908,8 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
xp = bbuf == NULL ? p : breg;
|
||||
|
||||
/* correct sector number for 1-based BIOS numbering */
|
||||
#ifdef PC98
|
||||
if ((od->od_unit & 0xf0) == 0x30 || (od->od_unit & 0xf0) == 0x90)
|
||||
sec++;
|
||||
#else
|
||||
sec++;
|
||||
#endif
|
||||
|
||||
|
||||
/* Put your Data In, Put your Data out,
|
||||
Put your Data In, and shake it all about
|
||||
@ -1271,20 +924,12 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
for (retry = 0; retry < 3; retry++) {
|
||||
/* if retrying, reset the drive */
|
||||
if (retry > 0) {
|
||||
#ifdef PC98
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x1b;
|
||||
v86.eax = 0x0300 | od->od_unit;
|
||||
#else
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
v86.eax = 0;
|
||||
v86.edx = od->od_unit;
|
||||
#endif
|
||||
v86int();
|
||||
}
|
||||
|
||||
#ifdef PC98
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x1b;
|
||||
if (od->od_flags & BD_FLOPPY) {
|
||||
@ -1302,53 +947,8 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
result = (v86.efl & 0x1);
|
||||
if (result == 0)
|
||||
break;
|
||||
#else
|
||||
if(cyl > 1023) {
|
||||
/* use EDD if the disk supports it, otherwise, return error */
|
||||
if(od->od_flags & BD_MODEEDD1) {
|
||||
static unsigned short packet[8];
|
||||
|
||||
packet[0] = 0x10;
|
||||
packet[1] = x;
|
||||
packet[2] = VTOPOFF(xp);
|
||||
packet[3] = VTOPSEG(xp);
|
||||
packet[4] = dblk & 0xffff;
|
||||
packet[5] = dblk >> 16;
|
||||
packet[6] = 0;
|
||||
packet[7] = 0;
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
/* Should we Write with verify ?? 0x4302 ? */
|
||||
v86.eax = 0x4300;
|
||||
v86.edx = od->od_unit;
|
||||
v86.ds = VTOPSEG(packet);
|
||||
v86.esi = VTOPOFF(packet);
|
||||
v86int();
|
||||
result = (v86.efl & 0x1);
|
||||
if(result == 0)
|
||||
break;
|
||||
} else {
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Use normal CHS addressing */
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
v86.eax = 0x300 | x;
|
||||
v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec;
|
||||
v86.edx = (hd << 8) | od->od_unit;
|
||||
v86.es = VTOPSEG(xp);
|
||||
v86.ebx = VTOPOFF(xp);
|
||||
v86int();
|
||||
result = (v86.efl & 0x1);
|
||||
if (result == 0)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PC98
|
||||
DEBUG("%d sectors from %d/%d/%d to %p (0x%x) %s", x, cyl, hd,
|
||||
od->od_flags & BD_FLOPPY ? sec - 1 : sec, p, VTOP(p),
|
||||
result ? "failed" : "ok");
|
||||
@ -1357,12 +957,7 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
|
||||
od->od_flags & BD_FLOPPY ? 0xd600 | od->od_unit : 0x0600 | od->od_unit,
|
||||
od->od_flags & BD_FLOPPY ? 0x0200 | cyl : cyl, (hd << 8) | sec,
|
||||
(v86.eax >> 8) & 0xff);
|
||||
#else
|
||||
DEBUG("%d sectors from %d/%d/%d to %p (0x%x) %s", x, cyl, hd, sec - 1, p, VTOP(p), result ? "failed" : "ok");
|
||||
/* BUG here, cannot use v86 in printf because putchar uses it too */
|
||||
DEBUG("ax = 0x%04x cx = 0x%04x dx = 0x%04x status 0x%x",
|
||||
0x200 | x, ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec, (hd << 8) | od->od_unit, (v86.eax >> 8) & 0xff);
|
||||
#endif
|
||||
|
||||
if (result) {
|
||||
if (bbuf != NULL)
|
||||
free(bbuf);
|
||||
@ -1379,7 +974,6 @@ static int
|
||||
bd_getgeom(struct open_disk *od)
|
||||
{
|
||||
|
||||
#ifdef PC98
|
||||
if (od->od_flags & BD_FLOPPY) {
|
||||
od->od_cyl = 79;
|
||||
od->od_hds = 2;
|
||||
@ -1400,23 +994,6 @@ bd_getgeom(struct open_disk *od)
|
||||
if (v86.efl & 0x1)
|
||||
return(1);
|
||||
}
|
||||
#else
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
v86.eax = 0x800;
|
||||
v86.edx = od->od_unit;
|
||||
v86int();
|
||||
|
||||
if ((v86.efl & 0x1) || /* carry set */
|
||||
((v86.edx & 0xff) <= (unsigned)(od->od_unit & 0x7f))) /* unit # bad */
|
||||
return(1);
|
||||
|
||||
/* convert max cyl # -> # of cylinders */
|
||||
od->od_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1;
|
||||
/* convert max head # -> # of heads */
|
||||
od->od_hds = ((v86.edx & 0xff00) >> 8) + 1;
|
||||
od->od_sec = v86.ecx & 0x3f;
|
||||
#endif
|
||||
|
||||
DEBUG("unit 0x%x geometry %d/%d/%d", od->od_unit, od->od_cyl, od->od_hds, od->od_sec);
|
||||
return(0);
|
||||
@ -1439,8 +1016,6 @@ bd_getgeom(struct open_disk *od)
|
||||
u_int32_t
|
||||
bd_getbigeom(int bunit)
|
||||
{
|
||||
|
||||
#ifdef PC98
|
||||
int hds = 0;
|
||||
int unit = 0x80; /* IDE HDD */
|
||||
u_int addr = 0xA155d;
|
||||
@ -1470,17 +1045,6 @@ bd_getbigeom(int bunit)
|
||||
if (v86.efl & 0x1)
|
||||
return 0x4F020F; /* 1200KB FD C:80 H:2 S:15 */
|
||||
return ((v86.ecx & 0xffff) << 16) | (v86.edx & 0xffff);
|
||||
#else
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x13;
|
||||
v86.eax = 0x800;
|
||||
v86.edx = 0x80 + bunit;
|
||||
v86int();
|
||||
if (v86.efl & 0x1)
|
||||
return 0x4f010f;
|
||||
return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) |
|
||||
(v86.edx & 0xff00) | (v86.ecx & 0x3f);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1506,11 +1070,7 @@ bd_getdev(struct i386_devdesc *dev)
|
||||
if (bd_opendisk(&od, dev) != 0) /* oops, not a viable device */
|
||||
return(-1);
|
||||
|
||||
#ifdef PC98
|
||||
if ((biosdev & 0xf0) == 0x90 || (biosdev & 0xf0) == 0x30) {
|
||||
#else
|
||||
if (biosdev < 0x80) {
|
||||
#endif
|
||||
/* floppy (or emulated floppy) or ATAPI device */
|
||||
if (bdinfo[dev->d_kind.biosdisk.unit].bd_type == DT_ATAPI) {
|
||||
/* is an ATAPI disk */
|
||||
@ -1537,14 +1097,10 @@ bd_getdev(struct i386_devdesc *dev)
|
||||
}
|
||||
}
|
||||
/* default root disk unit number */
|
||||
#ifdef PC98
|
||||
if ((biosdev & 0xf0) == 0xa0)
|
||||
unit = bdinfo[dev->d_kind.biosdisk.unit].bd_da_unit;
|
||||
else
|
||||
unit = biosdev & 0xf;
|
||||
#else
|
||||
unit = (biosdev & 0x7f) - unitofs;
|
||||
#endif
|
||||
|
||||
/* XXX a better kludge to set the root disk unit number */
|
||||
if ((nip = getenv("root_disk_unit")) != NULL) {
|
||||
|
@ -37,76 +37,13 @@ __FBSDID("$FreeBSD$");
|
||||
vm_offset_t memtop;
|
||||
u_int32_t bios_basemem, bios_extmem;
|
||||
|
||||
#ifndef PC98
|
||||
#define SMAPSIG 0x534D4150
|
||||
|
||||
struct smap {
|
||||
u_int64_t base;
|
||||
u_int64_t length;
|
||||
u_int32_t type;
|
||||
} __packed;
|
||||
|
||||
static struct smap smap;
|
||||
#endif
|
||||
|
||||
void
|
||||
bios_getmem(void)
|
||||
{
|
||||
|
||||
#ifdef PC98
|
||||
bios_basemem = ((*(u_char *)PTOV(0xA1501) & 0x07) + 1) * 128 * 1024;
|
||||
bios_extmem = *(u_char *)PTOV(0xA1401) * 128 * 1024 +
|
||||
*(u_int16_t *)PTOV(0xA1594) * 1024 * 1024;
|
||||
#else
|
||||
/* Parse system memory map */
|
||||
v86.ebx = 0;
|
||||
do {
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x15; /* int 0x15 function 0xe820*/
|
||||
v86.eax = 0xe820;
|
||||
v86.ecx = sizeof(struct smap);
|
||||
v86.edx = SMAPSIG;
|
||||
v86.es = VTOPSEG(&smap);
|
||||
v86.edi = VTOPOFF(&smap);
|
||||
v86int();
|
||||
if ((v86.efl & 1) || (v86.eax != SMAPSIG))
|
||||
break;
|
||||
/* look for a low-memory segment that's large enough */
|
||||
if ((smap.type == 1) && (smap.base == 0) && (smap.length >= (512 * 1024)))
|
||||
bios_basemem = smap.length;
|
||||
/* look for the first segment in 'extended' memory */
|
||||
if ((smap.type == 1) && (smap.base == 0x100000)) {
|
||||
bios_extmem = smap.length;
|
||||
}
|
||||
} while (v86.ebx != 0);
|
||||
|
||||
/* Fall back to the old compatibility function for base memory */
|
||||
if (bios_basemem == 0) {
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x12; /* int 0x12 */
|
||||
v86int();
|
||||
|
||||
bios_basemem = (v86.eax & 0xffff) * 1024;
|
||||
}
|
||||
|
||||
/* Fall back through several compatibility functions for extended memory */
|
||||
if (bios_extmem == 0) {
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x15; /* int 0x15 function 0xe801*/
|
||||
v86.eax = 0xe801;
|
||||
v86int();
|
||||
if (!(v86.efl & 1)) {
|
||||
bios_extmem = ((v86.ecx & 0xffff) + ((v86.edx & 0xffff) * 64)) * 1024;
|
||||
}
|
||||
}
|
||||
if (bios_extmem == 0) {
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x15; /* int 0x15 function 0x88*/
|
||||
v86.eax = 0x8800;
|
||||
v86int();
|
||||
bios_extmem = (v86.eax & 0xffff) * 1024;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set memtop to actual top of memory */
|
||||
memtop = 0x100000 + bios_extmem;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*-
|
||||
* Copyright (c) 1998 Michael Smith (msmith@freebsd.org)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -37,11 +37,7 @@ __FBSDID("$FreeBSD$");
|
||||
#define COMC_BPS(x) (115200 / (x)) /* speed to DLAB divisor */
|
||||
|
||||
#ifndef COMPORT
|
||||
#ifdef PC98
|
||||
#define COMPORT 0x238
|
||||
#else
|
||||
#define COMPORT 0x3f8
|
||||
#endif
|
||||
#endif
|
||||
#ifndef COMSPEED
|
||||
#define COMSPEED 9600
|
||||
|
@ -2,11 +2,11 @@
|
||||
* $NetBSD: gatea20.c,v 1.2 1997/10/29 00:32:49 fvdl Exp $
|
||||
*/
|
||||
|
||||
/* extracted from freebsd:sys/i386/boot/biosboot/io.c */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/* extracted from freebsd:sys/i386/boot/biosboot/io.c */
|
||||
|
||||
#include <stand.h>
|
||||
#include <machine/cpufunc.h>
|
||||
|
||||
@ -36,24 +36,7 @@ static unsigned char x_20 = KB_A20;
|
||||
void gateA20()
|
||||
{
|
||||
__asm("pushfl ; cli");
|
||||
#ifdef PC98
|
||||
outb(0xf2, 0x00);
|
||||
outb(0xf6, 0x02);
|
||||
#else /* IBM PC */
|
||||
#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);
|
||||
delay(100);
|
||||
while (inb(K_STATUS) & K_IBUF_FUL);
|
||||
outb(K_RDWR, x_20);
|
||||
delay(100);
|
||||
while (inb(K_STATUS) & K_IBUF_FUL);
|
||||
#endif /* IBM_L40 */
|
||||
#endif /* IBM PC */
|
||||
__asm("popfl");
|
||||
}
|
||||
|
@ -29,9 +29,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stand.h>
|
||||
#include <btxv86.h>
|
||||
#ifdef PC98
|
||||
#include <machine/cpufunc.h>
|
||||
#endif
|
||||
#include "bootstrap.h"
|
||||
#include "libi386.h"
|
||||
|
||||
@ -48,32 +46,18 @@ time(time_t *t)
|
||||
{
|
||||
static time_t lasttime, now;
|
||||
int hr, minute, sec;
|
||||
|
||||
#ifdef PC98
|
||||
unsigned char bios_time[6];
|
||||
#endif
|
||||
|
||||
v86.ctl = 0;
|
||||
#ifdef PC98
|
||||
v86.addr = 0x1c; /* int 0x1c, function 0 */
|
||||
v86.eax = 0x0000;
|
||||
v86.es = VTOPSEG(bios_time);
|
||||
v86.ebx = VTOPOFF(bios_time);
|
||||
#else
|
||||
v86.addr = 0x1a; /* int 0x1a, function 2 */
|
||||
v86.eax = 0x0200;
|
||||
#endif
|
||||
v86int();
|
||||
|
||||
#ifdef PC98
|
||||
hr = bcd2bin(bios_time[3]);
|
||||
minute = bcd2bin(bios_time[4]);
|
||||
sec = bcd2bin(bios_time[5]);
|
||||
#else
|
||||
hr = bcd2bin((v86.ecx & 0xff00) >> 8); /* hour in %ch */
|
||||
minute = bcd2bin(v86.ecx & 0xff); /* minute in %cl */
|
||||
sec = bcd2bin((v86.edx & 0xff00) >> 8); /* second in %dh */
|
||||
#endif
|
||||
|
||||
now = hr * 3600 + minute * 60 + sec;
|
||||
if (now < lasttime)
|
||||
@ -94,18 +78,10 @@ time(time_t *t)
|
||||
void
|
||||
delay(int period)
|
||||
{
|
||||
#ifdef PC98
|
||||
int i;
|
||||
|
||||
period = (period + 500) / 1000;
|
||||
for( ; period != 0 ; period--)
|
||||
for(i=800;i != 0; i--)
|
||||
outb(0x5f,0); /* wait 600ns */
|
||||
#else
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x15; /* int 0x15, function 0x86 */
|
||||
v86.eax = 0x8600;
|
||||
v86.ecx = period >> 16;
|
||||
v86.edx = period & 0xffff;
|
||||
v86int();
|
||||
#endif
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*-
|
||||
* Copyright (c) 1998 Michael Smith (msmith@freebsd.org)
|
||||
* Copyright (c) 1997 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
|
||||
* All rights reserved.
|
||||
@ -34,9 +34,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <bootstrap.h>
|
||||
#include <btxv86.h>
|
||||
#include <machine/psl.h>
|
||||
#ifdef PC98
|
||||
#include <machine/cpufunc.h>
|
||||
#endif
|
||||
#include "libi386.h"
|
||||
|
||||
#if KEYBOARD_PROBE
|
||||
@ -73,7 +71,6 @@ static int fg_c, bg_c, curx, cury;
|
||||
static int esc;
|
||||
#endif
|
||||
|
||||
#ifdef PC98
|
||||
static unsigned short *crtat, *Crtat;
|
||||
static int row = 25, col = 80;
|
||||
#ifdef TERM_EMU
|
||||
@ -114,7 +111,6 @@ static u_int8_t ibmpc_to_pc98[256] = {
|
||||
};
|
||||
#define at2pc98(fg_at, bg_at) ibmpc_to_pc98[((bg_at) << 4) | (fg_at)]
|
||||
#endif /* TERM_EMU */
|
||||
#endif /* PC98 */
|
||||
|
||||
struct console vidconsole = {
|
||||
"vidconsole",
|
||||
@ -147,15 +143,11 @@ vidc_probe(struct console *cp)
|
||||
static int
|
||||
vidc_init(int arg)
|
||||
{
|
||||
int i;
|
||||
#ifdef PC98
|
||||
int hw_cursor;
|
||||
#endif
|
||||
int i, hw_cursor;
|
||||
|
||||
if (vidc_started && arg == 0)
|
||||
return (0);
|
||||
vidc_started = 1;
|
||||
#ifdef PC98
|
||||
Crtat = (unsigned short *)PTOV(0xA0000);
|
||||
while ((inb(0x60) & 0x04) == 0)
|
||||
;
|
||||
@ -168,7 +160,6 @@ vidc_init(int arg)
|
||||
inb(0x62);
|
||||
inb(0x62);
|
||||
crtat = Crtat + hw_cursor;
|
||||
#endif
|
||||
#ifdef TERM_EMU
|
||||
/* Init terminal emulator */
|
||||
end_term();
|
||||
@ -182,7 +173,6 @@ vidc_init(int arg)
|
||||
return (0); /* XXX reinit? */
|
||||
}
|
||||
|
||||
#ifdef PC98
|
||||
static void
|
||||
beep(void)
|
||||
{
|
||||
@ -191,13 +181,11 @@ beep(void)
|
||||
delay(40000);
|
||||
outb(0x37, 7);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void
|
||||
vidc_biosputchar(int c)
|
||||
{
|
||||
#ifdef PC98
|
||||
unsigned short *cp;
|
||||
int i, pos;
|
||||
|
||||
@ -238,14 +226,6 @@ vidc_biosputchar(int c)
|
||||
outb(0x60, pos & 0xff);
|
||||
outb(0x60, pos >> 8);
|
||||
#endif
|
||||
#else
|
||||
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0xe00 | (c & 0xff);
|
||||
v86.ebx = 0x7;
|
||||
v86int();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -259,17 +239,10 @@ vidc_rawputchar(int c)
|
||||
for (i = 0; i < 8; i++)
|
||||
vidc_rawputchar(' ');
|
||||
else {
|
||||
#if !defined(TERM_EMU) && !defined(PC98)
|
||||
vidc_biosputchar(c);
|
||||
#else
|
||||
/* Emulate AH=0eh (teletype output) */
|
||||
switch(c) {
|
||||
case '\a':
|
||||
#ifdef PC98
|
||||
beep();
|
||||
#else
|
||||
vidc_biosputchar(c);
|
||||
#endif
|
||||
return;
|
||||
case '\r':
|
||||
curx = 0;
|
||||
@ -306,7 +279,6 @@ vidc_rawputchar(int c)
|
||||
}
|
||||
}
|
||||
curs_move(curx, cury);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,28 +290,16 @@ vidc_rawputchar(int c)
|
||||
void
|
||||
get_pos(void)
|
||||
{
|
||||
#ifdef PC98
|
||||
int pos = crtat - Crtat;
|
||||
|
||||
curx = pos % col;
|
||||
cury = pos / col;
|
||||
#else
|
||||
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0300;
|
||||
v86.ebx = 0x0;
|
||||
v86int();
|
||||
curx = v86.edx & 0x00ff;
|
||||
cury = (v86.edx & 0xff00) >> 8;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move cursor to x rows and y cols (0-based). */
|
||||
void
|
||||
curs_move(int x, int y)
|
||||
{
|
||||
#ifdef PC98
|
||||
int pos;
|
||||
|
||||
pos = x + y * col;
|
||||
@ -355,29 +315,6 @@ curs_move(int x, int y)
|
||||
if (!isvisible(*crtat & 0x00ff)) {
|
||||
write_char(' ', fg_c, bg_c);
|
||||
}
|
||||
#else
|
||||
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0200;
|
||||
v86.ebx = 0x0;
|
||||
v86.edx = ((0x00ff & y) << 8) + (0x00ff & x);
|
||||
v86int();
|
||||
curx = x;
|
||||
cury = y;
|
||||
/* If there is ctrl char at this position, cursor would be invisible.
|
||||
* Make it a space instead.
|
||||
*/
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0800;
|
||||
v86.ebx = 0x0;
|
||||
v86int();
|
||||
#define isvisible(c) (((c) >= 32) && ((c) < 255))
|
||||
if (!isvisible(v86.eax & 0x00ff)) {
|
||||
write_char(' ', fg_c, bg_c);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Scroll up the whole window by a number of rows. If rows==0,
|
||||
@ -387,7 +324,6 @@ curs_move(int x, int y)
|
||||
void
|
||||
scroll_up(int rows, int fgcol, int bgcol)
|
||||
{
|
||||
#ifdef PC98
|
||||
unsigned short *cp;
|
||||
int i;
|
||||
|
||||
@ -402,18 +338,6 @@ scroll_up(int rows, int fgcol, int bgcol)
|
||||
*(cp + 0x1000) = at2pc98(fgcol, bgcol);
|
||||
*cp++ = ' ';
|
||||
}
|
||||
#else
|
||||
|
||||
if (rows == 0)
|
||||
rows = 25;
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0600 + (0x00ff & rows);
|
||||
v86.ebx = (bgcol << 12) + (fgcol << 8);
|
||||
v86.ecx = 0x0;
|
||||
v86.edx = 0x184f;
|
||||
v86int();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Write character and attribute at cursor position. */
|
||||
@ -421,17 +345,8 @@ void
|
||||
write_char(int c, int fgcol, int bgcol)
|
||||
{
|
||||
|
||||
#ifdef PC98
|
||||
*crtat = (c == 0x5c ? 0xfc : (c & 0xff));
|
||||
*(crtat + 0x1000) = at2pc98(fgcol, bgcol);
|
||||
#else
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0900 + (0x00ff & c);
|
||||
v86.ebx = (bgcol << 4) + fgcol;
|
||||
v86.ecx = 0x1;
|
||||
v86int();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
@ -445,7 +360,6 @@ write_char(int c, int fgcol, int bgcol)
|
||||
void
|
||||
CD(void)
|
||||
{
|
||||
#ifdef PC98
|
||||
int pos;
|
||||
|
||||
get_pos();
|
||||
@ -454,31 +368,6 @@ CD(void)
|
||||
*(crtat + pos + 0x1000) = at2pc98(fg_c, bg_c);
|
||||
}
|
||||
end_term();
|
||||
#else
|
||||
|
||||
get_pos();
|
||||
if (curx > 0) {
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0600;
|
||||
v86.ebx = (bg_c << 4) + fg_c;
|
||||
v86.ecx = (cury << 8) + curx;
|
||||
v86.edx = (cury << 8) + 79;
|
||||
v86int();
|
||||
if (++cury > 24) {
|
||||
end_term();
|
||||
return;
|
||||
}
|
||||
}
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0600;
|
||||
v86.ebx = (bg_c << 4) + fg_c;
|
||||
v86.ecx = (cury << 8) + 0;
|
||||
v86.edx = (24 << 8) + 79;
|
||||
v86int();
|
||||
end_term();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Absolute cursor move to args[0] rows and args[1] columns
|
||||
@ -679,11 +568,7 @@ vidc_getchar(void)
|
||||
|
||||
if (vidc_ischar()) {
|
||||
v86.ctl = 0;
|
||||
#ifdef PC98
|
||||
v86.addr = 0x18;
|
||||
#else
|
||||
v86.addr = 0x16;
|
||||
#endif
|
||||
v86.eax = 0x0;
|
||||
v86int();
|
||||
return (v86.eax & 0xff);
|
||||
@ -696,137 +581,17 @@ static int
|
||||
vidc_ischar(void)
|
||||
{
|
||||
|
||||
#ifdef PC98
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x18;
|
||||
v86.eax = 0x100;
|
||||
v86int();
|
||||
return ((v86.ebx >> 8) & 0x1);
|
||||
#else
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x16;
|
||||
v86.eax = 0x100;
|
||||
v86int();
|
||||
return (!(v86.efl & PSL_Z));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if KEYBOARD_PROBE
|
||||
|
||||
#ifdef PC98
|
||||
static int
|
||||
probe_keyboard(void)
|
||||
{
|
||||
return (*(u_char *)PTOV(0xA1481) & 0x48);
|
||||
}
|
||||
#else /* PC98 */
|
||||
#define PROBE_MAXRETRY 5
|
||||
#define PROBE_MAXWAIT 400
|
||||
#define IO_DUMMY 0x84
|
||||
#define IO_KBD 0x060 /* 8042 Keyboard */
|
||||
|
||||
/* selected defines from kbdio.h */
|
||||
#define KBD_STATUS_PORT 4 /* status port, read */
|
||||
#define KBD_DATA_PORT 0 /* data port, read/write
|
||||
* also used as keyboard command
|
||||
* and mouse command port
|
||||
*/
|
||||
#define KBDC_ECHO 0x00ee
|
||||
#define KBDS_ANY_BUFFER_FULL 0x0001
|
||||
#define KBDS_INPUT_BUFFER_FULL 0x0002
|
||||
#define KBD_ECHO 0x00ee
|
||||
|
||||
/* 7 microsec delay necessary for some keyboard controllers */
|
||||
static void
|
||||
delay7(void)
|
||||
{
|
||||
/*
|
||||
* I know this is broken, but no timer is available yet at this stage...
|
||||
* See also comments in `delay1ms()'.
|
||||
*/
|
||||
inb(IO_DUMMY); inb(IO_DUMMY);
|
||||
inb(IO_DUMMY); inb(IO_DUMMY);
|
||||
inb(IO_DUMMY); inb(IO_DUMMY);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 address to the ISA bus as they know it
|
||||
* is not a valid ISA bus address, those machines execute this inb in
|
||||
* 60 nS :-(.
|
||||
*
|
||||
*/
|
||||
static void
|
||||
delay1ms(void)
|
||||
{
|
||||
int i = 800;
|
||||
while (--i >= 0)
|
||||
(void)inb(0x84);
|
||||
}
|
||||
|
||||
/*
|
||||
* We use the presence/absence of a keyboard to determine whether the internal
|
||||
* console can be used for input.
|
||||
*
|
||||
* Perform a simple test on the keyboard; issue the ECHO command and see
|
||||
* if the right answer is returned. We don't do anything as drastic as
|
||||
* full keyboard reset; it will be too troublesome and take too much time.
|
||||
*/
|
||||
static int
|
||||
probe_keyboard(void)
|
||||
{
|
||||
int retry = PROBE_MAXRETRY;
|
||||
int wait;
|
||||
int i;
|
||||
|
||||
while (--retry >= 0) {
|
||||
/* flush any noise */
|
||||
while (inb(IO_KBD + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) {
|
||||
delay7();
|
||||
inb(IO_KBD + KBD_DATA_PORT);
|
||||
delay1ms();
|
||||
}
|
||||
|
||||
/* wait until the controller can accept a command */
|
||||
for (wait = PROBE_MAXWAIT; wait > 0; --wait) {
|
||||
if (((i = inb(IO_KBD + KBD_STATUS_PORT))
|
||||
& (KBDS_INPUT_BUFFER_FULL | KBDS_ANY_BUFFER_FULL)) == 0)
|
||||
break;
|
||||
if (i & KBDS_ANY_BUFFER_FULL) {
|
||||
delay7();
|
||||
inb(IO_KBD + KBD_DATA_PORT);
|
||||
}
|
||||
delay1ms();
|
||||
}
|
||||
if (wait <= 0)
|
||||
continue;
|
||||
|
||||
/* send the ECHO command */
|
||||
outb(IO_KBD + KBD_DATA_PORT, KBDC_ECHO);
|
||||
|
||||
/* wait for a response */
|
||||
for (wait = PROBE_MAXWAIT; wait > 0; --wait) {
|
||||
if (inb(IO_KBD + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL)
|
||||
break;
|
||||
delay1ms();
|
||||
}
|
||||
if (wait <= 0)
|
||||
continue;
|
||||
|
||||
delay7();
|
||||
i = inb(IO_KBD + KBD_DATA_PORT);
|
||||
#ifdef PROBE_KBD_BEBUG
|
||||
printf("probe_keyboard: got 0x%x.\n", i);
|
||||
#endif
|
||||
if (i == KBD_ECHO) {
|
||||
/* got the right answer */
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
#endif /* PC98 */
|
||||
#endif /* KEYBOARD_PROBE */
|
||||
|
@ -6,7 +6,6 @@ NEWVERSWHAT= "bootstrap loader" pc98
|
||||
|
||||
# architecture-specific loader code
|
||||
SRCS= main.c conf.c vers.c
|
||||
CFLAGS+= -DPC98
|
||||
.PATH: ${.CURDIR}/../../i386/loader
|
||||
|
||||
# Enable PXE TFTP or NFS support, not both.
|
||||
|
@ -137,11 +137,6 @@ main(void)
|
||||
initial_bootinfo->bi_extmem = bios_extmem / 1024;
|
||||
}
|
||||
|
||||
#ifndef PC98
|
||||
/* detect ACPI for future reference */
|
||||
biosacpi_detect();
|
||||
#endif
|
||||
|
||||
printf("\n");
|
||||
printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
|
||||
printf("(%s, %s)\n", bootprog_maker, bootprog_date);
|
||||
@ -212,17 +207,12 @@ extract_currdev(void)
|
||||
* and we are not booting from the lowest-numbered disk type
|
||||
* (ie. SCSI when IDE also exists).
|
||||
*/
|
||||
#ifdef PC98
|
||||
if ((biosdev == 0) && (B_TYPE(initial_bootdev) != 2)) { /* biosdev doesn't match major */
|
||||
if (B_TYPE(initial_bootdev) == 6)
|
||||
biosdev = 0x30 + B_UNIT(initial_bootdev);
|
||||
else
|
||||
biosdev = (major << 3) + 0x80 + B_UNIT(initial_bootdev);
|
||||
}
|
||||
#else
|
||||
if ((biosdev == 0) && (B_TYPE(initial_bootdev) != 2)) /* biosdev doesn't match major */
|
||||
biosdev = 0x80 + B_UNIT(initial_bootdev); /* assume harddisk */
|
||||
#endif
|
||||
}
|
||||
new_currdev.d_type = new_currdev.d_dev->dv_type;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user