2010-10-01 11:21:55 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2013-09-14 20:55:13 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
2010-10-01 11:21:55 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
2013-09-14 20:55:13 +02:00
|
|
|
read_ramdisk:
|
2014-12-01 04:51:07 +01:00
|
|
|
; READ RAMDISK IMAGE FROM HD (only for IDE0, IDE1, IDE2, IDE3)
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp [boot_dev+OS_BASE+0x10000], 1
|
2014-12-01 04:51:07 +01:00
|
|
|
jne no_sys_on_hd.1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2013-09-14 20:55:13 +02:00
|
|
|
xor ebp, ebp
|
|
|
|
.hd_loop:
|
|
|
|
lea eax, [ebp+'0']
|
|
|
|
mov [read_image_fsinfo.name_digit], al
|
|
|
|
movzx eax, byte [DRIVE_DATA+2+ebp]
|
|
|
|
test eax, eax
|
|
|
|
jz .next_hd
|
|
|
|
push eax
|
|
|
|
mov esi, 1
|
|
|
|
.partition_loop:
|
|
|
|
mov eax, esi
|
|
|
|
push -'0'
|
|
|
|
@@:
|
|
|
|
xor edx, edx
|
|
|
|
div [_10]
|
|
|
|
push edx
|
|
|
|
test eax, eax
|
|
|
|
jnz @b
|
|
|
|
mov edi, read_image_fsinfo.partition
|
|
|
|
@@:
|
|
|
|
pop eax
|
|
|
|
add al, '0'
|
|
|
|
stosb
|
|
|
|
jnz @b
|
|
|
|
mov byte [edi-1], '/'
|
|
|
|
push esi edi
|
|
|
|
mov esi, bootpath1
|
|
|
|
mov ecx, bootpath1.len
|
|
|
|
rep movsb
|
2012-03-08 09:33:38 +01:00
|
|
|
call read_image
|
|
|
|
test eax, eax
|
2013-09-14 20:55:13 +02:00
|
|
|
jz .yes
|
|
|
|
cmp eax, 6
|
|
|
|
jz .yes
|
|
|
|
pop edi
|
|
|
|
push edi
|
|
|
|
mov esi, bootpath2
|
|
|
|
mov ecx, bootpath2.len
|
|
|
|
rep movsb
|
2012-03-08 09:33:38 +01:00
|
|
|
call read_image
|
|
|
|
test eax, eax
|
2013-09-14 20:55:13 +02:00
|
|
|
jz .yes
|
|
|
|
cmp eax, 6
|
|
|
|
jz .yes
|
|
|
|
pop edi esi
|
|
|
|
inc esi
|
|
|
|
cmp esi, [esp]
|
|
|
|
jbe .partition_loop
|
|
|
|
pop eax
|
|
|
|
.next_hd:
|
|
|
|
inc ebp
|
|
|
|
cmp ebp, 4
|
|
|
|
jb .hd_loop
|
|
|
|
jmp no_sys_on_hd
|
|
|
|
.yes:
|
2014-12-01 04:51:07 +01:00
|
|
|
DEBUGF 1, "K : RD found: %s\n", read_image_fsinfo.name
|
2013-09-14 20:55:13 +02:00
|
|
|
pop edi esi eax
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2014-12-01 04:51:07 +01:00
|
|
|
call register_ramdisk
|
|
|
|
jmp yes_sys_on_hd
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; Register ramdisk file system
|
|
|
|
register_ramdisk:
|
|
|
|
mov esi, boot_initramdisk
|
|
|
|
call boot_log
|
|
|
|
call ramdisk_init
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
2012-10-12 20:24:48 +02:00
|
|
|
iglobal
|
|
|
|
align 4
|
|
|
|
read_image_fsinfo:
|
|
|
|
dd 0 ; function: read
|
|
|
|
dq 0 ; offset: zero
|
2013-09-14 20:55:13 +02:00
|
|
|
dd 1474560 ; size
|
2012-10-12 20:24:48 +02:00
|
|
|
dd RAMDISK ; buffer
|
2014-12-01 04:51:07 +01:00
|
|
|
.name db '/hd'
|
2013-09-14 20:55:13 +02:00
|
|
|
.name_digit db '0'
|
|
|
|
db '/'
|
|
|
|
.partition:
|
|
|
|
rb 64 ; should be enough for '255/KOLIBRI/KOLIBRI.IMG'
|
|
|
|
|
|
|
|
bootpath1 db 'KOLIBRI.IMG',0
|
|
|
|
.len = $ - bootpath1
|
|
|
|
bootpath2 db 'KOLIBRI/KOLIBRI.IMG',0
|
|
|
|
.len = $ - bootpath2
|
2012-10-12 20:24:48 +02:00
|
|
|
endg
|
|
|
|
|
2010-10-01 11:21:55 +02:00
|
|
|
read_image:
|
2012-10-12 20:24:48 +02:00
|
|
|
mov ebx, read_image_fsinfo
|
|
|
|
pushad
|
2013-05-11 14:38:27 +02:00
|
|
|
call file_system_lfn_protected
|
2012-10-12 20:24:48 +02:00
|
|
|
popad
|
2010-10-01 11:21:55 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
no_sys_on_hd:
|
2014-12-01 04:51:07 +01:00
|
|
|
DEBUGF 1, "K : RD not found\n"
|
|
|
|
.1:
|
2010-10-01 11:21:55 +02:00
|
|
|
; test_to_format_ram_disk (need if not using ram disk)
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp [boot_dev+OS_BASE+0x10000], 3
|
|
|
|
jne not_format_ram_disk
|
2010-10-01 11:21:55 +02:00
|
|
|
; format_ram_disk
|
2012-03-08 09:33:38 +01:00
|
|
|
mov edi, RAMDISK
|
|
|
|
mov ecx, 0x1080
|
|
|
|
xor eax, eax
|
|
|
|
@@:
|
|
|
|
stosd
|
|
|
|
loop @b
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ecx, 0x58F7F
|
|
|
|
mov eax, 0xF6F6F6F6
|
|
|
|
@@:
|
|
|
|
stosd
|
|
|
|
loop @b
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
mov [RAMDISK+0x200], dword 0xFFFFF0 ; fat table
|
|
|
|
mov [RAMDISK+0x4200], dword 0xFFFFF0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
not_format_ram_disk:
|
|
|
|
yes_sys_on_hd:
|