2011-10-15 01:38:50 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2015-01-08 23:10:22 +03:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
2011-10-15 01:38:50 +04:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
2013-07-01 20:29:16 +04:00
|
|
|
read_ramdisk:
|
2014-04-06 01:36:10 +04:00
|
|
|
; READ RAMDISK IMAGE FROM HD (only for IDE0, IDE1, IDE2, IDE3)
|
2011-10-15 01:38:50 +04:00
|
|
|
|
2020-10-02 16:05:10 +03:00
|
|
|
cmp byte [BOOT.rd_load_from], RD_LOAD_FROM_HD
|
2014-04-06 01:36:10 +04:00
|
|
|
jne no_sys_on_hd.1
|
2011-10-15 01:38:50 +04:00
|
|
|
|
2013-07-01 20:29:16 +04: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
|
2011-10-15 01:38:50 +04:00
|
|
|
call read_image
|
|
|
|
test eax, eax
|
2013-07-01 20:29:16 +04:00
|
|
|
jz .yes
|
|
|
|
cmp eax, 6
|
|
|
|
jz .yes
|
|
|
|
pop edi
|
|
|
|
push edi
|
|
|
|
mov esi, bootpath2
|
|
|
|
mov ecx, bootpath2.len
|
|
|
|
rep movsb
|
2011-10-15 01:38:50 +04:00
|
|
|
call read_image
|
|
|
|
test eax, eax
|
2013-07-01 20:29:16 +04: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-04-06 01:36:10 +04:00
|
|
|
DEBUGF 1, "K : RD found: %s\n", read_image_fsinfo.name
|
2013-07-01 20:29:16 +04:00
|
|
|
pop edi esi eax
|
2011-10-15 01:38:50 +04:00
|
|
|
|
2014-04-06 01:36:10 +04:00
|
|
|
call register_ramdisk
|
|
|
|
jmp yes_sys_on_hd
|
|
|
|
;-----------------------------------------------------------------------------
|
2012-04-23 13:19:34 +04:00
|
|
|
iglobal
|
|
|
|
align 4
|
|
|
|
read_image_fsinfo:
|
|
|
|
dd 0 ; function: read
|
|
|
|
dq 0 ; offset: zero
|
2013-07-02 01:08:50 +04:00
|
|
|
dd 1474560 ; size
|
2012-04-23 13:19:34 +04:00
|
|
|
dd RAMDISK ; buffer
|
2014-04-06 01:36:10 +04:00
|
|
|
.name db '/hd'
|
2013-07-01 20:29:16 +04: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-04-23 13:19:34 +04:00
|
|
|
endg
|
|
|
|
|
2011-10-15 01:38:50 +04:00
|
|
|
read_image:
|
2012-04-23 13:19:34 +04:00
|
|
|
mov ebx, read_image_fsinfo
|
|
|
|
pushad
|
2013-03-01 02:03:45 +04:00
|
|
|
call file_system_lfn_protected
|
2012-04-23 13:19:34 +04:00
|
|
|
popad
|
2011-10-15 01:38:50 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
no_sys_on_hd:
|
2014-04-06 01:36:10 +04:00
|
|
|
DEBUGF 1, "K : RD not found\n"
|
|
|
|
.1:
|
2011-10-15 01:38:50 +04:00
|
|
|
; test_to_format_ram_disk (need if not using ram disk)
|
2020-10-02 16:05:10 +03:00
|
|
|
cmp byte [BOOT.rd_load_from], RD_LOAD_FROM_FORMAT
|
2011-10-15 01:38:50 +04:00
|
|
|
jne not_format_ram_disk
|
|
|
|
; format_ram_disk
|
|
|
|
mov edi, RAMDISK
|
|
|
|
mov ecx, 0x1080
|
|
|
|
xor eax, eax
|
|
|
|
@@:
|
|
|
|
stosd
|
|
|
|
loop @b
|
|
|
|
|
|
|
|
mov ecx, 0x58F7F
|
|
|
|
mov eax, 0xF6F6F6F6
|
|
|
|
@@:
|
|
|
|
stosd
|
|
|
|
loop @b
|
|
|
|
|
|
|
|
mov [RAMDISK+0x200], dword 0xFFFFF0 ; fat table
|
|
|
|
mov [RAMDISK+0x4200], dword 0xFFFFF0
|
|
|
|
|
|
|
|
not_format_ram_disk:
|
|
|
|
yes_sys_on_hd:
|