OpenCores
URL https://opencores.org/ocsvn/zet86/zet86/trunk

Subversion Repositories zet86

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /zet86/trunk/soc/bios
    from Rev 49 to Rev 52
    Reverse comparison

Rev 49 → Rev 52

/biossums.c
1,5 → 1,5
/*
* $Id: biossums.c,v 1.7 2009-02-06 03:48:27 zeus Exp $
* $Id: biossums.c,v 1.4 2007/05/28 08:09:13 vruppert Exp $
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/makesym.perl
1,6 → 1,6
#!/usr/bin/perl
#
# $Id: makesym.perl,v 1.7 2009-02-06 03:48:27 zeus Exp $
# $Id: makesym.perl,v 1.2 2008/01/26 09:15:27 sshwarts Exp $
#
# Read output file from as86 (e.g. rombios.txt) and write out a symbol
# table suitable for the Bochs debugger.
/rombios.c
421,6 → 421,16
dec bx
ret
 
lincl:
lincul:
inc word ptr [bx]
je LINC_HIGH_WORD
ret
.even
LINC_HIGH_WORD:
inc word ptr 2[bx]
ret
 
ASM_END
 
// for access to RAM area which is used by interrupt vectors
1014,8 → 1024,10
}
}
 
static char bios_svn_version_string[] = "$Revision: 1.13 $ $Date: 2009-03-05 00:26:53 $";
static char bios_svn_version_string[] = "$Version: 0.4.3 $ $Date: Tue, 10 Mar 2009 21:02:08 +0100 $";
 
#define BIOS_COPYRIGHT_STRING "(c) 2009 Zeus Gomez Marmolejo and (c) 2002 MandrakeSoft S.A."
 
//--------------------------------------------------------------------------
// print_bios_banner
// displays a the bios version
1042,7 → 1054,7
// http://www.phoenix.com/en/Customer+Services/White+Papers-Specs/pc+industry+specifications.htm
//--------------------------------------------------------------------------
 
static char drivetypes[][20]={"", "Floppy flash image" };
static char drivetypes[][20]={"", "Floppy flash image", "Compact Flash" };
 
static void
init_boot_vectors()
1062,6 → 1074,11
memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
count++;
 
/* First HDD */
e.type = IPL_TYPE_HARDDISK; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
count++;
 
/* Remember how many devices we have */
write_word(IPL_SEG, IPL_COUNT_OFFSET, count);
/* Not tried booting anything yet */
1501,27 → 1518,495
int13_harddisk(DS, ES, DI, SI, BP, ELDX, BX, DX, CX, AX, IP, CS, FLAGS)
Bit16u DS, ES, DI, SI, BP, ELDX, BX, DX, CX, AX, IP, CS, FLAGS;
{
Bit8u drive, num_sectors, sector, head, status;
Bit8u drive_map;
Bit8u n_drives;
Bit16u max_cylinder, cylinder;
Bit16u hd_cylinders;
Bit8u hd_heads, hd_sectors;
Bit8u sector_count;
Bit16u tempbx;
 
Bit32u log_sector;
 
write_byte(0x0040, 0x008e, 0); // clear completion flag
 
/* at this point, DL is >= 0x80 to be passed from the floppy int13h
handler code */
/* check how many disks first (cmos reg 0x12), return an error if
drive not present */
drive_map = 1;
n_drives = 1;
 
if (!(drive_map & (1<<(GET_ELDL()&0x7f)))) { /* allow 0, 1, or 2 disks */
SET_AH(0x01);
SET_DISK_RET_STATUS(0x01);
SET_CF(); /* error occurred */
return;
}
 
switch (GET_AH()) {
 
case 0x00: /* disk controller reset */
 
SET_AH(0);
SET_DISK_RET_STATUS(0);
set_diskette_ret_status(0);
set_diskette_current_cyl(0, 0); /* current cylinder, diskette 1 */
set_diskette_current_cyl(1, 0); /* current cylinder, diskette 2 */
CLEAR_CF(); /* successful */
return;
break;
 
case 0x01: /* read disk status */
status = read_byte(0x0040, 0x0074);
SET_AH(status);
SET_DISK_RET_STATUS(0);
/* set CF if error status read */
if (status) SET_CF();
else CLEAR_CF();
return;
break;
 
case 0x04: // verify disk sectors
case 0x02: // read disk sectors
drive = GET_ELDL();
 
// get_hd_geometry(drive, &hd_cylinders, &hd_heads, &hd_sectors);
// fixed geometry:
hd_cylinders = 993;
hd_heads = 16;
hd_sectors = 63;
 
num_sectors = GET_AL();
cylinder = (GET_CL() & 0x00c0) << 2 | GET_CH();
sector = (GET_CL() & 0x3f);
head = GET_DH();
 
if ( (cylinder >= hd_cylinders) ||
(sector > hd_sectors) ||
(head >= hd_heads) ) {
SET_AH(1);
SET_DISK_RET_STATUS(1);
SET_CF(); /* error occurred */
return;
}
 
if ( GET_AH() == 0x04 ) {
SET_AH(0);
SET_DISK_RET_STATUS(0);
CLEAR_CF();
return;
}
 
log_sector = ((Bit32u)cylinder) * ((Bit32u)hd_heads) * ((Bit32u)hd_sectors)
+ ((Bit32u)head) * ((Bit32u)hd_sectors)
+ ((Bit32u)sector) - 1;
 
sector_count = 0;
tempbx = BX;
 
ASM_START
sti ;; enable higher priority interrupts
ASM_END
 
while (1) {
ASM_START
;; store temp bx in real DI register
push bp
mov bp, sp
mov di, _int13_harddisk.tempbx + 2 [bp]
pop bp
 
;; adjust if there will be an overrun
cmp di, #0xfe00
jbe i13_f02_no_adjust
i13_f02_adjust:
sub di, #0x0200 ; sub 512 bytes from offset
mov ax, es
add ax, #0x0020 ; add 512 to segment
mov es, ax
 
i13_f02_no_adjust:
; timeout = TIMEOUT;
mov cx, #0xffff
 
; while((timeout > 0) && (!(CSR_ACE_STATUSL & ACE_STATUSL_CFCMDRDY))) timeout--;
mov dx, #0xe204
 
i13_f02_ace_statusl2:
in ax, dx
and ax, #0x100
loopz i13_f02_ace_statusl2
 
; if(timeout == 0) return 0;
cmp cx, #0
jnz i13_f02_success2
ASM_END
printf("i13_f02(1): Timeout\n");
ASM_START
jmp _int13_fail
 
i13_f02_success2:
; CSR_ACE_MLBAL = blocknr & 0x0000ffff;
push bp
mov bp, sp
mov ax, _int13_harddisk.log_sector + 2 [bp]
mov dx, #0xe210
out dx, ax
 
; CSR_ACE_MLBAH = (blocknr & 0x0fff0000) >> 16;
mov ax, _int13_harddisk.log_sector + 4 [bp]
mov dx, #0xe212
out dx, ax
pop bp
 
; CSR_ACE_SECCMD = ACE_SECCMD_READ|0x01;
mov ax, #0x0301
mov dx, #0xe214
out dx, ax
 
; CSR_ACE_CTLL |= ACE_CTLL_CFGRESET;
mov dx, #0xe218
in ax, dx
or ax, #0x0080
out dx, ax
 
; buffer_count = 16;
mov si, #16
 
; while(buffer_count > 0) {
i13_f02_cond_loop:
cmp si, #0
jbe i13_f02_exit_loop
 
; timeout = TIMEOUT;
mov cx, #0xffff
mov bx, #0x000f
 
; while((timeout > 0) && (!(CSR_ACE_STATUSL & ACE_STATUSL_DATARDY))) timeout--;
mov dx, #0xe204
i13_f02_ace_statusl3:
in ax, dx
and ax, #0x20
loopz i13_f02_ace_statusl3
 
; if(timeout == 0) return 0;
cmp cx, #0
jnz i13_f02_success3
dec bx
mov cx, #0xffff
jne i13_f02_ace_statusl3
ASM_END
printf("i13_f02(2): Timeout\n");
ASM_START
jmp _int13_fail
 
i13_f02_success3:
; for(i=0;i<16;i++) {
mov cx, #16
; *bufw = CSR_ACE_DATA;
mov dx, #0xe240
i13_f02_ace_data:
in ax, dx
eseg
mov [di], ax
; bufw++;
add di, #2
; }
loop i13_f02_ace_data
 
; buffer_count--;
dec si
jmp i13_f02_cond_loop
 
; }
 
i13_f02_exit_loop:
; CSR_ACE_CTLL &= ~ACE_CTLL_CFGRESET;
mov dx, #0xe218
in ax, dx
and ax, #0xff7f
out dx, ax
 
i13_f02_done:
;; store real DI register back to temp bx
push bp
mov bp, sp
mov _int13_harddisk.tempbx + 2 [bp], di
pop bp
ASM_END
 
sector_count++;
log_sector++;
num_sectors--;
if (num_sectors) continue;
else break;
}
 
SET_AH(0);
SET_DISK_RET_STATUS(0);
SET_AL(sector_count);
CLEAR_CF(); /* successful */
return;
break;
 
case 0x03: /* write disk sectors */
drive = GET_ELDL ();
 
// get_hd_geometry(drive, &hd_cylinders, &hd_heads, &hd_sectors);
// fixed geometry:
hd_cylinders = 993;
hd_heads = 16;
hd_sectors = 63;
 
num_sectors = GET_AL();
cylinder = GET_CH();
cylinder |= ( ((Bit16u) GET_CL()) << 2) & 0x300;
sector = (GET_CL() & 0x3f);
head = GET_DH();
 
if ( (cylinder >= hd_cylinders) ||
(sector > hd_sectors) ||
(head >= hd_heads) ) {
SET_AH( 1);
SET_DISK_RET_STATUS(1);
SET_CF(); /* error occurred */
return;
}
 
log_sector = ((Bit32u)cylinder) * ((Bit32u)hd_heads) * ((Bit32u)hd_sectors)
+ ((Bit32u)head) * ((Bit32u)hd_sectors)
+ ((Bit32u)sector) - 1;
 
sector_count = 0;
tempbx = BX;
 
ASM_START
sti ;; enable higher priority interrupts
ASM_END
 
while (1) {
ASM_START
;; store temp bx in real SI register
push bp
mov bp, sp
mov si, _int13_harddisk.tempbx + 2 [bp]
pop bp
 
;; adjust if there will be an overrun
cmp si, #0xfe00
jbe i13_f03_no_adjust
i13_f03_adjust:
sub si, #0x0200 ; sub 512 bytes from offset
mov ax, es
add ax, #0x0020 ; add 512 to segment
mov es, ax
 
i13_f03_no_adjust:
; timeout = TIMEOUT;
mov cx, #0xffff
 
; while((timeout > 0) && (!(CSR_ACE_STATUSL & ACE_STATUSL_CFCMDRDY))) timeout--;
mov dx, #0xe204
 
i13_f03_ace_statusl2:
in ax, dx
and ax, #0x100
loopz i13_f03_ace_statusl2
 
; if(timeout == 0) return 0;
cmp cx, #0
jnz i13_f03_success2
ASM_END
printf("i13_f03(1): Timeout\n");
ASM_START
jmp _int13_fail
 
i13_f03_success2:
; CSR_ACE_MLBAL = blocknr & 0x0000ffff;
push bp
mov bp, sp
mov ax, _int13_harddisk.log_sector + 2 [bp]
mov dx, #0xe210
out dx, ax
 
; CSR_ACE_MLBAH = (blocknr & 0x0fff0000) >> 16;
mov ax, _int13_harddisk.log_sector + 4 [bp]
mov dx, #0xe212
out dx, ax
pop bp
 
; CSR_ACE_SECCMD = ACE_SECCMD_WRITE|0x01;
mov ax, #0x0401
mov dx, #0xe214
out dx, ax
 
; CSR_ACE_CTLL |= ACE_CTLL_CFGRESET;
mov dx, #0xe218
in ax, dx
or ax, #0x0080
out dx, ax
 
; buffer_count = 16;
mov di, #16
 
; while(buffer_count > 0) {
i13_f03_cond_loop:
cmp di, #0
jbe i13_f03_exit_loop
 
; timeout = TIMEOUT;
mov cx, #0xffff
mov bx, #0x000f
 
; while((timeout > 0) && (!(CSR_ACE_STATUSL & ACE_STATUSL_DATARDY))) timeout--;
mov dx, #0xe204
i13_f03_ace_statusl3:
in ax, dx
and ax, #0x20
loopz i13_f03_ace_statusl3
 
; if(timeout == 0) return 0;
cmp cx, #0
jnz i13_f03_success3
dec bx
mov cx, #0xffff
jne i13_f03_ace_statusl3
ASM_END
printf("i13_f03(2): Timeout\n");
ASM_START
jmp _int13_fail
 
i13_f03_success3:
; for(i=0;i<16;i++) {
mov cx, #16
; *bufw = CSR_ACE_DATA;
mov dx, #0xe240
i13_f03_ace_data:
eseg
mov ax, [si]
out dx, ax
; bufw++;
add si, #2
; }
loop i13_f03_ace_data
 
; buffer_count--;
dec di
jmp i13_f03_cond_loop
 
; }
 
i13_f03_exit_loop:
; CSR_ACE_CTLL &= ~ACE_CTLL_CFGRESET;
mov dx, #0xe218
in ax, dx
and ax, #0xff7f
out dx, ax
 
i13_f03_done:
;; store real SI register back to temp bx
push bp
mov bp, sp
mov _int13_harddisk.tempbx + 2 [bp], si
pop bp
ASM_END
 
sector_count++;
log_sector++;
num_sectors--;
if (num_sectors) continue;
else break;
}
 
SET_AH(0);
SET_DISK_RET_STATUS(0);
SET_AL(sector_count);
CLEAR_CF(); /* successful */
return;
break;
 
case 0x08:
 
drive = GET_ELDL ();
 
// get_hd_geometry(drive, &hd_cylinders, &hd_heads, &hd_sectors);
// fixed geometry:
hd_cylinders = 993;
hd_heads = 16;
hd_sectors = 63;
 
max_cylinder = hd_cylinders - 2; /* 0 based */
SET_AL(0);
SET_CH(0);
SET_CL(0);
SET_DH(0);
SET_DL(0); /* FIXME returns 0, 1, or n hard drives */
SET_CH(max_cylinder & 0xff);
SET_CL(((max_cylinder >> 2) & 0xc0) | (hd_sectors & 0x3f));
SET_DH(hd_heads - 1);
SET_DL(n_drives); /* returns 0, 1, or 2 hard drives */
SET_AH(0);
SET_DISK_RET_STATUS(0);
CLEAR_CF(); /* successful */
 
// FIXME should set ES & DI
return;
break;
 
goto int13_fail;
case 0x09: /* initialize drive parameters */
case 0x0c: /* seek to specified cylinder */
case 0x0d: /* alternate disk reset */
case 0x10: /* check drive ready */
case 0x11: /* recalibrate */
SET_AH(0);
SET_DISK_RET_STATUS(0);
CLEAR_CF(); /* successful */
return;
break;
 
case 0x14: /* controller internal diagnostic */
SET_AH(0);
SET_DISK_RET_STATUS(0);
CLEAR_CF(); /* successful */
SET_AL(0);
return;
break;
 
case 0x15: /* read disk drive size */
drive = GET_ELDL();
// get_hd_geometry(drive, &hd_cylinders, &hd_heads, &hd_sectors);
// fixed geometry:
hd_cylinders = 993;
hd_heads = 16;
hd_sectors = 63;
 
ASM_START
push bp
mov bp, sp
mov al, _int13_harddisk.hd_heads + 2 [bp]
mov ah, _int13_harddisk.hd_sectors + 2 [bp]
mul al, ah ;; ax = heads * sectors
mov bx, _int13_harddisk.hd_cylinders + 2 [bp]
dec bx ;; use (cylinders - 1) ???
mul ax, bx ;; dx:ax = (cylinders -1) * (heads * sectors)
;; now we need to move the 32bit result dx:ax to what the
;; BIOS wants which is cx:dx.
;; and then into CX:DX on the stack
mov _int13_harddisk.CX + 2 [bp], dx
mov _int13_harddisk.DX + 2 [bp], ax
pop bp
ASM_END
SET_AH(3); // hard disk accessible
SET_DISK_RET_STATUS(0); // ??? should this be 0
CLEAR_CF(); // successful
return;
break;
 
default:
BX_INFO("int13_harddisk: function %02xh unsupported, returns fail\n", GET_AH());
goto int13_fail;
break;
}
 
ASM_START
_int13_fail:
ASM_END
int13_fail:
SET_AH(0x01); // defaults to invalid function in AH or invalid parameter
int13_fail_noah:
1681,9 → 2166,9
Bit8u drive;
Bit8u cyl;
{
/* TEMP HACK: FOR MSDOS */
/* TEMP HACK: FOR MSDOS
if (drive > 1)
drive = 1;
drive = 1; */
/* BX_PANIC("set_diskette_current_cyl(): drive > 1\n"); */
write_byte(0x0040, 0x0094+drive, cyl);
}
1725,7 → 2210,7
bootdev >>= 4 * seq_nr;
bootdev &= 0xf;
*/
bootdev = 0x1;
bootdev = 0x2; // 1: flopy disk, 2: hard disk
 
/* Read user selected device */
bootfirst = read_word(IPL_SEG, IPL_BOOTFIRST_OFFSET);
1912,6 → 2397,16
; shl eax, #16
 
int13_out:
;
; ZEUS HACK: put IF flag on.
; Seems that MS-DOS does a 'cli' before calling this
; but after int13 it doesn't set the interrupts back
;
mov bp, sp
mov ax, 24[bp] ; FLAGS location
or ax, #0x0200 ; IF on
mov 24[bp], ax
 
pop ds
pop es
; popa ; we do this instead:
1989,7 → 2484,80
int1c_handler: ;; User Timer Tick
iret
 
;--------------------
;- POST: HARD DRIVE -
;--------------------
; relocated here because the primary POST area isnt big enough.
hard_drive_post:
// IRQ 14 = INT 76h
// INT 76h calls INT 15h function ax=9100
 
xor ax, ax
mov ds, ax
mov 0x0474, al /* hard disk status of last operation */
mov 0x0477, al /* hard disk port offset (XT only ???) */
mov 0x048c, al /* hard disk status register */
mov 0x048d, al /* hard disk error register */
mov 0x048e, al /* hard disk task complete flag */
mov al, #0x01
mov 0x0475, al /* hard disk number attached */
mov al, #0xc0
mov 0x0476, al /* hard disk control byte */
SET_INT_VECTOR(0x13, #0xF000, #int13_handler)
SET_INT_VECTOR(0x76, #0xF000, #int76_handler)
 
;; Initialize the sysace controller
; CSR_ACE_BUSMODE = ACE_BUSMODE_16BIT;
mov dx, #0xe200
mov ax, #0x0001
out dx, ax
 
; if(!(CSR_ACE_STATUSL & ACE_STATUSL_CFDETECT)) return 0;
mov dx, #0xe204
in ax, dx
and ax, #0x0010
jne cf_detect
hlt ;; error
 
cf_detect:
; if((CSR_ACE_ERRORL != 0) || (CSR_ACE_ERRORH != 0)) return 0;
mov dx, #0xe208
in ax, dx
cmp ax, #0x0
jne error_l
mov dx, #0xe20a
in ax, dx
cmp ax, #0x0
je lock_req
error_l:
hlt
 
lock_req:
; CSR_ACE_CTLL |= ACE_CTLL_LOCKREQ;
mov dx, #0xe218
in ax, dx
or ax, #0x2
out dx, ax
 
; timeout = TIMEOUT;
mov cx, #0xffff
 
; while((timeout > 0) && (!(CSR_ACE_STATUSL & ACE_STATUSL_MPULOCK))) timeout--;
mov dx, #0xe204
ace_statusl:
in ax, dx
and ax, #0x2
loopz ace_statusl
 
; if(timeout == 0) return 0;
cmp cx, #0x0
jnz success
hlt ;; error obtaining lock
 
success:
ret
 
 
;--------------------
;- POST: EBDA segment
;--------------------
2000,6 → 2568,20
mov word ptr [0x40E], #EBDA_SEG
ret;;
 
;--------------------
int76_handler:
;; record completion in BIOS task complete flag
push ax
push ds
mov ax, #0x0040
mov ds, ax
mov 0x008E, #0xff
; call eoi_both_pics
pop ds
pop ax
iret
 
 
rom_checksum:
push ax
push bx
2225,6 → 2807,10
;; EBDA setup
call ebda_post
 
;; PIT setup
SET_INT_VECTOR(0x08, #0xF000, #int08_handler)
;; int 1C already points at dummy_iret_handler (above)
 
;; Keyboard
SET_INT_VECTOR(0x09, #0xF000, #int09_handler)
SET_INT_VECTOR(0x16, #0xF000, #int16_handler)
2267,8 → 2853,10
 
call _print_bios_banner
 
;; Floppy setup
SET_INT_VECTOR(0x13, #0xF000, #int13_handler)
;;
;; Hard Drive setup
;;
call hard_drive_post
 
call _init_boot_vectors
 
2548,6 → 3136,67
pop ds
iret
 
;---------
;- INT08 -
;---------
.org 0xfea5 ; INT 08h System Timer ISR Entry Point
int08_handler:
sti
push ax
push bx
push ds
xor ax, ax
mov ds, ax
 
mov ax, 0x046c ;; get ticks dword
mov bx, 0x046e
inc ax
jne i08_linc_done
inc bx ;; inc high word
 
i08_linc_done:
push bx
;; compare eax to one days worth of timer ticks at 18.2 hz
sub bx, #0x0018
jne i08_lcmp_done
cmp ax, #0x00B0
jb i08_lcmp_b_and_lt
jge i08_lcmp_done
inc bx
jmp i08_lcmp_done
 
i08_lcmp_b_and_lt:
dec bx
 
i08_lcmp_done:
pop bx
jb int08_store_ticks
;; there has been a midnight rollover at this point
xor ax, ax ;; zero out counter
xor bx, bx
inc BYTE 0x0470 ;; increment rollover flag
 
int08_store_ticks:
mov 0x046c, ax ;; store new ticks dword
mov 0x046e, bx
;; chain to user timer tick INT #0x1c
//pushf
//;; call_ep [ds:loc]
//CALL_EP( 0x1c << 2 )
int #0x1c
cli
;; call eoi_master_pic
pop ds
pop bx
pop ax
iret
 
.org 0xfef3 ; Initial Interrupt Vector Offsets Loaded by POST
 
 
.org 0xff00
.ascii BIOS_COPYRIGHT_STRING
 
;------------------------------------------------
;- IRET Instruction for Dummy Interrupt Handler -
;------------------------------------------------
/vgabios.c
240,7 → 240,7
 
#if defined(USE_BX_INFO) || defined(DEBUG)
msg_vga_init:
.ascii "VGABios $Id: vgabios.c,v 1.9 2009-03-05 19:58:40 zeus Exp $"
.ascii "VGABios $Id: vgabios.c,v 1.66 2006/07/10 07:47:51 vruppert Exp $"
.byte 0x0d,0x0a,0x00
#endif
ASM_END

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.