stable corebootable version

git-svn-id: svn://kolibrios.org@1952 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2011-06-12 17:56:51 +00:00
parent d7b0867c02
commit a3746b98d0
8 changed files with 278 additions and 176 deletions

View File

@ -344,6 +344,8 @@ include 'detect/biosmem.inc'
; READ DISKETTE TO MEMORY ; READ DISKETTE TO MEMORY
if 0
----
cmp [boot_dev],0 cmp [boot_dev],0
jne no_sys_on_floppy jne no_sys_on_floppy
xor ax, ax ; reset drive xor ax, ax ; reset drive
@ -648,6 +650,8 @@ no_sys_on_floppy:
mov dx, 0x3f2 ; floppy motor off mov dx, 0x3f2 ; floppy motor off
mov al, 0 mov al, 0
out dx, al out dx, al
---
end if
; SET GRAPHICS ; SET GRAPHICS

View File

@ -10,116 +10,116 @@ $Revision$
; READ RAMDISK IMAGE FROM HD ; READ RAMDISK IMAGE FROM HD
cmp [boot_dev+OS_BASE+0x10000],1 cmp [boot_dev+OS_BASE+0x10000],1
jne no_sys_on_hd ; jne no_sys_on_hd
test [DRIVE_DATA+1],byte 0x40 test [DRIVE_DATA+1],byte 0x40
jz position_2 jz position_2
mov [hdbase],0x1f0 mov [hdbase],0x1f0
mov [hdid],0x0 mov [hdid],0x0
mov [hdpos],1 mov [hdpos],1
mov [fat32part],0 mov [fat32part], 0
position_1_1: position_1_1:
inc [fat32part] inc [fat32part]
call search_and_read_image call search_and_read_image
cmp [image_retrieved],1 cmp [image_retrieved],1
je yes_sys_on_hd je yes_sys_on_hd
movzx eax,byte [DRIVE_DATA+2] movzx eax,byte [DRIVE_DATA+2]
cmp [fat32part],eax cmp [fat32part],eax
jle position_1_1 jle position_1_1
position_2: position_2:
test [DRIVE_DATA+1],byte 0x10 test [DRIVE_DATA+1],byte 0x10
jz position_3 jz position_3
mov [hdbase],0x1f0 mov [hdbase],0x1f0
mov [hdid],0x10 mov [hdid],0x10
mov [hdpos],2 mov [hdpos],2
mov [fat32part],0 mov [fat32part],0
position_2_1: position_2_1:
inc [fat32part] inc [fat32part]
call search_and_read_image call search_and_read_image
cmp [image_retrieved],1 cmp [image_retrieved],1
je yes_sys_on_hd je yes_sys_on_hd
movzx eax,byte [DRIVE_DATA+3] movzx eax,byte [DRIVE_DATA+3]
cmp eax,[fat32part] cmp eax,[fat32part]
jle position_2_1 jle position_2_1
position_3: position_3:
test [DRIVE_DATA+1],byte 0x4 test [DRIVE_DATA+1],byte 0x4
jz position_4 jz position_4
mov [hdbase],0x170 mov [hdbase],0x170
mov [hdid],0x0 mov [hdid],0x0
mov [hdpos],3 mov [hdpos],3
mov [fat32part],0 mov [fat32part],0
position_3_1: position_3_1:
inc [fat32part] inc [fat32part]
call search_and_read_image call search_and_read_image
cmp [image_retrieved],1 cmp [image_retrieved],1
je yes_sys_on_hd je yes_sys_on_hd
movzx eax,byte [DRIVE_DATA+4] movzx eax,byte [DRIVE_DATA+4]
cmp eax,[fat32part] cmp eax,[fat32part]
jle position_3_1 jle position_3_1
position_4: position_4:
test [DRIVE_DATA+1],byte 0x1 test [DRIVE_DATA+1],byte 0x1
jz no_sys_on_hd jz no_sys_on_hd
mov [hdbase],0x170 mov [hdbase],0x170
mov [hdid],0x10 mov [hdid],0x10
mov [hdpos],4 mov [hdpos],4
mov [fat32part],0 mov [fat32part],0
position_4_1: position_4_1:
inc [fat32part] inc [fat32part]
call search_and_read_image call search_and_read_image
cmp [image_retrieved],1 cmp [image_retrieved],1
je yes_sys_on_hd je yes_sys_on_hd
movzx eax,byte [DRIVE_DATA+5] movzx eax,byte [DRIVE_DATA+5]
cmp eax,[fat32part] cmp eax,[fat32part]
jle position_4_1 jle position_4_1
jmp yes_sys_on_hd jmp yes_sys_on_hd
search_and_read_image: search_and_read_image:
call set_FAT32_variables call set_FAT32_variables
mov edx, bootpath mov edx, bootpath
call read_image call read_image
test eax, eax test eax, eax
jz image_present jz image_present
mov edx, bootpath2 mov edx, bootpath2
call read_image call read_image
test eax, eax test eax, eax
jz image_present jz image_present
ret ret
image_present: image_present:
mov [image_retrieved],1 mov [image_retrieved],1
ret ret
read_image: read_image:
mov eax, hdsysimage+OS_BASE+0x10000 mov eax, hdsysimage+OS_BASE+0x10000
mov ebx, 1474560/512 mov ebx, 1474560/512
mov ecx, RAMDISK mov ecx, RAMDISK
mov esi, 0 mov esi, 0
mov edi, 12 mov edi, 12
call file_read call file_read
ret ret
image_retrieved db 0 image_retrieved db 0
counter_of_partitions db 0 counter_of_partitions db 0
no_sys_on_hd: no_sys_on_hd:
; test_to_format_ram_disk (need if not using ram disk) ; test_to_format_ram_disk (need if not using ram disk)
cmp [boot_dev+OS_BASE+0x10000],3 cmp [boot_dev+OS_BASE+0x10000],3
jne not_format_ram_disk jne not_format_ram_disk
; format_ram_disk ; format_ram_disk
mov edi, RAMDISK mov edi, RAMDISK
mov ecx, 0x1080 mov ecx, 0x1080
xor eax,eax xor eax,eax
@@: @@:
stosd stosd
loop @b loop @b
mov ecx, 0x58F7F mov ecx, 0x58F7F
mov eax,0xF6F6F6F6 mov eax,0xF6F6F6F6
@@: @@:
stosd stosd
loop @b loop @b
mov [RAMDISK+0x200],dword 0xFFFFF0 ; fat table mov [RAMDISK+0x200],dword 0xFFFFF0 ; fat table
mov [RAMDISK+0x4200],dword 0xFFFFF0 mov [RAMDISK+0x4200],dword 0xFFFFF0
not_format_ram_disk: not_format_ram_disk:
yes_sys_on_hd: yes_sys_on_hd:

View File

@ -0,0 +1,82 @@
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

@ -0,0 +1 @@
fasm bev.asm

View File

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

View File

@ -194,74 +194,78 @@ TASK_BASE equ (OS_BASE+0x0003010)
TASK_DATA equ (OS_BASE+0x0003020) TASK_DATA equ (OS_BASE+0x0003020)
TASK_EVENT equ (OS_BASE+0x0003020) TASK_EVENT equ (OS_BASE+0x0003020)
FLOPPY_BUFF equ (OS_BASE+0x0005000) mouseunder equ (OS_BASE+0x0006900)
CDDataBuf equ (OS_BASE+0x0007000)
idts equ (OS_BASE+0x0007400) ; sys32.inc FLOPPY_BUFF equ (OS_BASE+0x0008000)
;ACTIVE_PROC_STACK equ (OS_BASE+0x000A400) ;unused
mouseunder equ (OS_BASE+0x0007900) idts equ (OS_BASE+0x000B100)
SB16_Status equ (OS_BASE+0x0007F00) ; <<
RAMDISK_FAT equ (OS_BASE+0x0008000)
FLOPPY_FAT equ (OS_BASE+0x000A000) ; fs/fat12.inc
WIN_STACK equ (OS_BASE+0x000C000) WIN_STACK equ (OS_BASE+0x000C000)
WIN_POS equ (OS_BASE+0x000C400) WIN_POS equ (OS_BASE+0x000C400)
FDD_BUFF equ (OS_BASE+0x000D000) FDD_BUFF equ (OS_BASE+0x000D000)
;unused ? only one reference
;ENABLE_TASKSWITCH equ (OS_BASE+0x000E000)
KEY_COUNT equ (OS_BASE+0x000FA00) PUTPIXEL equ (OS_BASE+0x000E020)
KEY_BUFF equ (OS_BASE+0x000FA01) GETPIXEL equ (OS_BASE+0x000E024)
BTN_COUNT equ (OS_BASE+0x000FB00) ;unused ? only one reference
BTN_BUFF equ (OS_BASE+0x000FB01) ; BANK_SWITCH equ (OS_BASE+0x000E030) ; VESA 1.2 - not used
;unused ? store mousepointer
;MOUSE_PICTURE equ (OS_BASE+0x000F200) ; mousedrv.inc - not used
;reserved ? mouse buffer space 0xFC00-FCFF MOUSE_VISIBLE equ (OS_BASE+0x000F204)
WIN_TEMP_XY equ (OS_BASE+0x000F300)
KEY_COUNT equ (OS_BASE+0x000F400)
KEY_BUFF equ (OS_BASE+0x000F401)
BTN_COUNT equ (OS_BASE+0x000F500)
BTN_BUFF equ (OS_BASE+0x000F501)
CPU_FREQ equ (OS_BASE+0x000F600)
;unused ? no active references
MOUSE_PORT equ (OS_BASE+0x000F604)
;unused
PS2_CHUNK equ (OS_BASE+0x000FB00)
MOUSE_SCROLL_H equ (OS_BASE+0x000FB08)
MOUSE_X equ (OS_BASE+0x000FB0A)
MOUSE_Y equ (OS_BASE+0x000FB0C)
MOUSE_SCROLL_V equ (OS_BASE+0x000FB0E)
MOUSE_COLOR_MEM equ (OS_BASE+0x000FB10)
COLOR_TEMP equ (OS_BASE+0x000FB30)
BTN_DOWN equ (OS_BASE+0x000FB40)
MOUSE_DOWN equ (OS_BASE+0x000FB44)
X_UNDER equ (OS_BASE+0x000FB4A)
Y_UNDER equ (OS_BASE+0x000FB4C)
ScreenBPP equ (OS_BASE+0x000FBF1)
;unused ? only one reference
MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF) MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF)
;unused ? Screen_Max_X equ (OS_BASE+0x000FE00)
PS2_CHUNK equ (OS_BASE+0x000FE00) Screen_Max_Y equ (OS_BASE+0x000FE04)
MOUSE_SCROLL_H equ (OS_BASE+0x000FE08) BytesPerScanLine equ (OS_BASE+0x000FE08)
MOUSE_X equ (OS_BASE+0x000FE0A) SCR_MODE equ (OS_BASE+0x000FE0C)
MOUSE_Y equ (OS_BASE+0x000FE0C)
MOUSE_SCROLL_V equ (OS_BASE+0x000FE0E)
MOUSE_COLOR_MEM equ (OS_BASE+0x000FE10) KERNEL_ALLOC_FLAG equ (OS_BASE+0x000FE70)
COLOR_TEMP equ (OS_BASE+0x000FE30) mmio_pcie_cfg_addr equ (OS_BASE+0x000FE74)
BTN_DOWN equ (OS_BASE+0x000FE40) mmio_pcie_cfg_lim equ (OS_BASE+0x000FE78)
MOUSE_DOWN equ (OS_BASE+0x000FE44) mmio_pcie_cfg_pdes equ (OS_BASE+0x000FE7C)
X_UNDER equ (OS_BASE+0x000FE4A) PCIe_bus_range equ (OS_BASE+0x000FE7E)
Y_UNDER equ (OS_BASE+0x000FE4C)
PUTPIXEL equ (OS_BASE+0x000FEB8) UserDMAaddr equ (OS_BASE+0x000FE80)
GETPIXEL equ (OS_BASE+0x000FEBC) LFBAddress equ (OS_BASE+0x000FE84)
ScreenBPP equ (OS_BASE+0x000FEC1) BTN_ADDR equ (OS_BASE+0x000FE88)
MOUSE_VISIBLE equ (OS_BASE+0x000FEC4) MEM_AMOUNT equ (OS_BASE+0x000FE8C)
WIN_TEMP_XY equ (OS_BASE+0x000FEC8)
CPU_FREQ equ (OS_BASE+0x000FECC)
Screen_Max_X equ (OS_BASE+0x000FED0)
Screen_Max_Y equ (OS_BASE+0x000FED4)
BytesPerScanLine equ (OS_BASE+0x000FED8)
SCR_MODE equ (OS_BASE+0x000FEDC)
KERNEL_ALLOC_FLAG equ (OS_BASE+0x000FEE0)
mmio_pcie_cfg_addr equ (OS_BASE+0x000FEE4)
mmio_pcie_cfg_lim equ (OS_BASE+0x000FEE8)
mmio_pcie_cfg_pdes equ (OS_BASE+0x000FEEC)
PCIe_bus_range equ (OS_BASE+0x000FEEE)
UserDMAaddr equ (OS_BASE+0x000FEF0)
LFBAddress equ (OS_BASE+0x000FEF4)
BTN_ADDR equ (OS_BASE+0x000FEF8)
MEM_AMOUNT equ (OS_BASE+0x000FEFC)
SYS_SHUTDOWN equ (OS_BASE+0x000FF00) SYS_SHUTDOWN equ (OS_BASE+0x000FF00)
TASK_ACTIVATE equ (OS_BASE+0x000FF01) TASK_ACTIVATE equ (OS_BASE+0x000FF01)
BgrDrawMode equ (OS_BASE+0x000FFE4)
BgrDataWidth equ (OS_BASE+0x000FFE8)
BgrDataHeight equ (OS_BASE+0x000FFEC)
REDRAW_BACKGROUND equ (OS_BASE+0x000FFF0) REDRAW_BACKGROUND equ (OS_BASE+0x000FFF0)
BACKGROUND_CHANGED equ (OS_BASE+0x000FFF1) BACKGROUND_CHANGED equ (OS_BASE+0x000FFF1)
BANK_RW equ (OS_BASE+0x000FFF2) BANK_RW equ (OS_BASE+0x000FFF2)
@ -280,38 +284,48 @@ DRIVE_DATA equ (OS_BASE+0x0070000)
SLOT_BASE equ (OS_BASE+0x0080000) SLOT_BASE equ (OS_BASE+0x0080000)
SB16Buffer equ (OS_BASE+0x0090000) ; << ;unused
TMP_BUFF equ (OS_BASE+0x0090000)
VGABasePtr equ (OS_BASE+0x00A0000) VGABasePtr equ (OS_BASE+0x00A0000)
RAMDISK equ (OS_BASE+0x0100000) RAMDISK equ (OS_BASE+0x0100000)
RAMDISK_FAT equ (OS_BASE+0x0280000)
FLOPPY_FAT equ (OS_BASE+0x0282000)
CLEAN_ZONE equ 0x3f0000 CLEAN_ZONE equ 0x280000
IDE_DMA equ 0x284000
IDE_DMA equ 0x03F4000 BgrAuxTable equ (OS_BASE+0x0298000)
; unused?
SB16Buffer equ (OS_BASE+0x2A0000)
SB16_Status equ (OS_BASE+0x02B0000)
BgrAuxTable equ (OS_BASE+0x0408000) BUTTON_INFO equ (OS_BASE+0x02C0000)
RESERVED_PORTS equ (OS_BASE+0x02D0000)
BUTTON_INFO equ (OS_BASE+0x0430000) IRQ_SAVE equ (OS_BASE+0x02E0000)
RESERVED_PORTS equ (OS_BASE+0x0440000) ;BOOT_VAR equ (OS_BASE+0x02F0000)
IRQ_SAVE equ (OS_BASE+0x0450000)
BOOT_VAR equ (OS_BASE+0x0460000)
stack_data_start equ (OS_BASE+0x0470000)
eth_data_start equ (OS_BASE+0x0470000)
stack_data equ (OS_BASE+0x0474000)
stack_data_end equ (OS_BASE+0x048ffff)
resendQ equ (OS_BASE+0x0490000)
VMODE_BASE equ (OS_BASE+0x0498000)
skin_data equ (OS_BASE+0x04A0000)
draw_data equ (OS_BASE+0x04A8000);
sys_pgmap equ (OS_BASE+0x04B0000) ; << stack_data_start equ (OS_BASE+0x0300000)
eth_data_start equ (OS_BASE+0x0300000)
stack_data equ (OS_BASE+0x0304000)
stack_data_end equ (OS_BASE+0x031ffff)
resendQ equ (OS_BASE+0x0320000)
VMODE_BASE equ (OS_BASE+0x0328000)
skin_data equ (OS_BASE+0x0330000)
draw_data equ (OS_BASE+0x0338000);
;UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000) BgrDrawMode equ (OS_BASE+0x033BFF4)
BgrDataWidth equ (OS_BASE+0x033BFF8)
BgrDataHeight equ (OS_BASE+0x033BFFC)
BOOT_VAR equ (OS_BASE+0x0340000)
virtual at (OS_BASE+0x06FFF80) sys_pgmap equ (OS_BASE+0x0350000)
UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000)
virtual at (OS_BASE+0x05FFF80)
tss TSS tss TSS
end virtual end virtual

View File

@ -16,9 +16,9 @@ MEM_UC equ 0 ;uncached memory
align 4 align 4
preinit_mem: preinit_mem:
; clear [0x280000..HEAP_BASE] ; clear [CLEAN_ZONE..HEAP_BASE]
xor eax,eax xor eax,eax
mov edi, CLEAN_ZONE ; 0x280000 = ramdisk FAT ? mov edi,CLEAN_ZONE ; 0x280000 = ramdisk FAT ?
mov ecx,(HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 mov ecx,(HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4
cld cld
rep stosd rep stosd
@ -35,7 +35,7 @@ preinit_mem:
; save [0..0xffff] ; save [0..0xffff]
xor esi, esi xor esi, esi
mov edi,(BOOT_VAR-OS_BASE) ; low mem storage area mov edi, (BOOT_VAR - OS_BASE) ; low mem storage area
mov ecx, 0x10000 / 4 mov ecx, 0x10000 / 4
rep movsd rep movsd
; clear [0x1000..0x0ffff] ; clear [0x1000..0x0ffff]
@ -83,24 +83,20 @@ proc init_mem
mov eax, PG_LARGE+PG_SW mov eax, PG_LARGE+PG_SW
mov cr4, ebx mov cr4, ebx
dec [pg_data.kernel_tables-OS_BASE] dec [pg_data.kernel_tables-OS_BASE]
sub [pg_data.kernel_pages -OS_BASE], 1024 ; 1 large page = 1024 ordinary pages
mov [edx], eax ; map first (physical) 4M bytes mov [edx], eax ; map first (physical) 4M bytes
add edx, 4 add edx, 4
mov edi, [tmp_page_tabs] mov edi, [tmp_page_tabs]
mov ecx, [pg_data.kernel_pages -OS_BASE] ; map the rest of kernel space mov ecx, [pg_data.kernel_pages -OS_BASE] ; safety cleaning of already-zeroed space
mov eax, 0x00400000+PG_SW xor eax, eax
.map_kernel_pages: rep stosd
stosd
add eax, 4096
dec ecx
jnz .map_kernel_pages
mov ecx, [pg_data.kernel_tables-OS_BASE] ; build some PDEs to hold empty PTEs mov ecx, [pg_data.kernel_tables-OS_BASE] ; build some PDEs to hold empty PTEs
mov eax, [tmp_page_tabs] mov eax, [tmp_page_tabs]
or eax, PG_SW or eax, PG_SW
mov edi, edx ; edi = sys_pgdir+0x804 mov edi, edx ; edi = sys_pgdir+0x804
.map_kernel_tabs: .map_kernel_tabs:
stosd stosd
add eax, 0x1000 add eax, 0x1000

View File

@ -219,7 +219,7 @@ diff16 "32-bit code start ",0,$
call init_BIOS32 ; (init.inc - to be removed later) call init_BIOS32 ; (init.inc - to be removed later)
; PCIe extended config space access ; PCIe extended config space access
; call rs7xx_pcie_init ; (bus/HT.inc) ; call rs7xx_pcie_init ; (bus/HT.inc)
call fusion_pcie_init ; (bus/HT.inc) call fusion_pcie_init ; (bus/HT.inc)
; MEMORY MODEL ; MEMORY MODEL