VHDL code generator for PCI BIOS extension ROMs

git-svn-id: svn://kolibrios.org@6442 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2016-06-07 15:14:38 +00:00
parent 227eb8887f
commit b718363009
6 changed files with 151 additions and 84 deletions

View File

@ -0,0 +1,108 @@
include 'cfg_bios.inc'
use16
org 0
rom_header:
; PnP Option ROM header
rom_signature dw 0xAA55 ; +0 : magic
rom_length db 1 ; +2 : number of 512byte blocks
rom_entry:
jmp init_entry ; +3 : initialization entry point
; retf ; +5
@@:
times (24-$) db 0 ; : left blank
rom_pci_struc dw pci_header ; +18h : offset to PCI data structure
times (32-$) db 0
; +32
pci_header:
; PCI Data Structure
pci_magic db 'PCIR' ; +0 : magic
pci_vendor dw BIOS_PCI_VENDOR ; +4 : 10EE
pci_device dw BIOS_PCI_DEVICE ; +6 : 0007
pci_vdata dw 0 ; +8 : 0 = no vital product data
pci_length dw 0x18 ; +A : PCI data structure length
pci_classrev dd BIOS_PCI_CLASS ; +C : rev.00 + class 05.00.00
pci_size dw 1 ; +10 : image length (512byte blocks)
pci_rev dw 0 ; +12
pci_codetype db 0 ; +14 : x86
pci_indicator db 0x80 ; +15 : last image
pci_maxlen dw 1 ; +16 : max length (512b blocks)
pci_hdrptr dw 0; manstr ; +18 : ExROM's config utility code header
pci_dmtf_entry dw 0 ; +1A : DMTP CLP entry point
times (64-$) db 0
manstr:
db 1,'Kolibri-A Operating System',13,10,0
; utility code header size = 42 bytes
times (64+41-$) db 0 ;
db 1 ; ver.1
utility_entry:
jmp boot_failure
times (128-$) db 0
;align 128
boot_failure:
int 18h ; return to BIOS Boot sequence
align 4
init_entry:
; note x86 "unreal" mode!
; ax = b:d.f
; bx = run-time segment
; cx = PMM segment
; dx = PMM entry offset
mov dx, 0x0cf8 ; PCI config address
; mov eax, 0x80010010 ; BAR0
and eax, 0x0FFFF
shl eax, 8
or eax, 0x80000010 ;BAR0
out dx, eax
out dx, eax
add dl, 4
in eax, dx
and eax, 0xFFFFFF00
add eax, 0x0400 ; LPC control reg
mov dword[eax], 0x90050000 ; LED port
mov dword[eax+4], 0x055
xor eax, eax
sub dl, 4
out dx, eax
mov bx, ax
retf
; mov edx,[esp] ; get the origin
; and dl, 0xF0
; shl ebx, 4 ; correct run-time address
; mov cx, 0 ; words counter
;@@:
; mov ax, word[edx+ecx]
; mov [ebx+ecx],ax
; inc cx
; inc cx
; test cx,0x200
; jz @b
; xor ax, ax
; mov bx, ax
; mov al, 0x20 ; IPL device's attached
; retd ; double !
times (0xDF-$) db 0 ; checksum position
sum = 0
repeat $-$$
load a byte from $$+% -1
sum = a + sum
end repeat
check = sum mod 256
check_byte db (0x100 - check ) mod 256
times (512-$) db 0

View File

@ -0,0 +1,30 @@
; file 'pcirom.bin':0,0x49
file 'pcirom.bin'
db 13,10
line = '0'
block = 0
repeat 7
db 'INIT_0',line,' => X"'
repeat 32
pos = 32-%
load a byte from pos+block
b = a mod 16
if b<10
c = b + '0'
else
c = b-10+'A'
end if
b = a / 16
if b<10
d = b + '0'
else
d = b-10+'A'
end if
db d, c
end repeat
db '",',13,10
block = block + 32
line = line + 1
end repeat

View File

@ -0,0 +1 @@
file 'step1.bin':512

View File

@ -1,82 +0,0 @@
include 'cfg_bios.inc'
use16
;org 0
rom_header:
; PnP Option ROM header
rom_signature dw 0xAA55 ; +0 : magic
rom_length db BIOS_BOOT_BLOCK_SIZE ; +2 : number of 512byte blocks
rom_entry:
jmp init_entry ; +3 : initialization entry point
db 'AZ'
rom_reserved rb 0x11 ; +7 : reserved (17 bytes)
rom_pci_struc dw pci_header ; +18h : offset to PCI data structure
rom_expansion dw pnp_header ; +1Ah : offset to expansion header structure
align 16
pnp_header:
; PnP Expansion Header
pnp_signature db '$PnP' ; +0 : magic
pnp_revision db 1 ; +4 : revision
pnp_length db 2 ; +5 : length (in 16byte paragraphs)
pnp_next dw 0 ; +6 : offset of the next header (0 if none)
pnp_reserv1 db 0 ; +8
pnp_checksum db 0 ; +9 : checksum
pnp_devid dd 0x0 ; +A : device identifier
pnp_manstr dw manstr ; +E : pointer to manufacturer string
pnp_prodstr dw prodstr ; +10 : pointer to product name string
pnp_devtype1 db 2 ; +12 : device type code
pnp_devtype2 dw 0x000
pnp_devind db 0x14 ; +15 : device indicators
pnp_bcv dw 0 ; +16 : boot connection vector (must be 0)
pnp_discv dw 0 ; +18 : disconnect vector
pnp_bev dw boot_entry ; +1A : boot entry vector
pnp_reserv2 dw 0 ; +1C
pnp_info dw 0 ; +1E : static resource information vector
align 16
pci_header:
; PCI Data Structure
pci_magic db 'PCIR' ; +0 : magic
pci_vendor dw BIOS_PCI_VENDOR ; +4 :
pci_device dw BIOS_PCI_DEVICE ; +6 : sb700 PCI bridge
pci_vdata dw 0 ; +8 : vital product data offset
pci_length dw 0x18 ; +A : PCI data structure length
pci_classrev dd BIOS_PCI_CLASS ; +C : rev.00 + class 04.00.00
pci_size dw BIOS_BOOT_BLOCK_SIZE ; +10 : image length (512byte blocks)
pci_rev dw 0 ; +12
pci_codetype db 0 ; +14 : x86
pci_indicator db 0x80 ; +15 : last image
pci_reserved dw 0
align 4
manstr:
db 'Kolibri-A Operation System',0
prodstr:
db 'ver.ROM-0.1',0
align 4
boot_entry:
@@:
boot_failure:
int 18h ; return to BIOS Boot sequence
align 4
init_entry:
xor ax, ax
mov [cs:rom_length], al
mov al, 0x20
retf
check = 0
repeat $-$$
load a byte from $$+%-1
check = a + check
end repeat
check_byte db 0x100 - (check mod 256)
times (512-$) db 0

View File

@ -1 +1,11 @@
fasm bev.asm fasm pcirom.asm
fasm step1.asm
fasm step2.asm
ren step2.bin pcirom.vhd
del step1.bin
del pcirom.bin
echo off
echo ********************************
echo (C) Artem Jerdev, 2014
echo PCI ROM VHDL Template generated
pause

View File

@ -2,4 +2,4 @@ BIOS_BOOT_BLOCK_SIZE equ 1 ; in 512-blocks
BIOS_PCI_VENDOR equ 0x10EE BIOS_PCI_VENDOR equ 0x10EE
BIOS_PCI_DEVICE equ 0x0007 BIOS_PCI_DEVICE equ 0x0007
BIOS_PCI_CLASS equ 0x04000000 BIOS_PCI_CLASS equ 0x05000000