2009-09-17 13:55:38 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2012-04-02 17:18:46 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
2009-09-17 13:55:38 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2012-04-02 17:18:46 +02:00
|
|
|
$Revision $
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
; READ RAMDISK IMAGE FROM HD
|
|
|
|
|
2013-03-10 13:28:37 +01:00
|
|
|
cmp [boot_dev+OS_BASE+0x10000], 1
|
|
|
|
jne no_sys_on_hd
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-03-10 13:28:37 +01:00
|
|
|
test [DRIVE_DATA+1], byte 0x40
|
|
|
|
jz position_2
|
|
|
|
mov [hdbase], 0x1f0
|
|
|
|
mov [hdid], 0x0
|
|
|
|
mov [hdpos], 1
|
|
|
|
mov [fat32part], 0
|
2009-09-17 13:55:38 +02:00
|
|
|
position_1_1:
|
2013-03-10 13:28:37 +01:00
|
|
|
inc [fat32part]
|
|
|
|
call search_and_read_image
|
|
|
|
cmp [image_retrieved], 1
|
|
|
|
je yes_sys_on_hd
|
|
|
|
movzx eax, byte [DRIVE_DATA+2]
|
|
|
|
cmp [fat32part], eax
|
2009-09-17 13:55:38 +02:00
|
|
|
jle position_1_1
|
|
|
|
position_2:
|
2013-03-10 13:28:37 +01:00
|
|
|
test [DRIVE_DATA+1], byte 0x10
|
|
|
|
jz position_3
|
|
|
|
mov [hdbase], 0x1f0
|
|
|
|
mov [hdid], 0x10
|
|
|
|
mov [hdpos], 2
|
|
|
|
mov [fat32part], 0
|
2009-09-17 13:55:38 +02:00
|
|
|
position_2_1:
|
2013-03-10 13:28:37 +01:00
|
|
|
inc [fat32part]
|
|
|
|
call search_and_read_image
|
|
|
|
cmp [image_retrieved], 1
|
|
|
|
je yes_sys_on_hd
|
|
|
|
movzx eax, byte [DRIVE_DATA+3]
|
|
|
|
cmp eax, [fat32part]
|
2009-09-17 13:55:38 +02:00
|
|
|
jle position_2_1
|
|
|
|
position_3:
|
2013-03-10 13:28:37 +01:00
|
|
|
test [DRIVE_DATA+1], byte 0x4
|
|
|
|
jz position_4
|
|
|
|
mov [hdbase], 0x170
|
|
|
|
mov [hdid], 0x0
|
|
|
|
mov [hdpos], 3
|
|
|
|
mov [fat32part], 0
|
2009-09-17 13:55:38 +02:00
|
|
|
position_3_1:
|
2013-03-10 13:28:37 +01:00
|
|
|
inc [fat32part]
|
|
|
|
call search_and_read_image
|
|
|
|
cmp [image_retrieved], 1
|
|
|
|
je yes_sys_on_hd
|
|
|
|
movzx eax, byte [DRIVE_DATA+4]
|
|
|
|
cmp eax, [fat32part]
|
2009-09-17 13:55:38 +02:00
|
|
|
jle position_3_1
|
|
|
|
position_4:
|
2013-03-10 13:28:37 +01:00
|
|
|
test [DRIVE_DATA+1], byte 0x1
|
|
|
|
jz no_sys_on_hd
|
|
|
|
mov [hdbase], 0x170
|
|
|
|
mov [hdid], 0x10
|
|
|
|
mov [hdpos], 4
|
|
|
|
mov [fat32part], 0
|
2009-09-17 13:55:38 +02:00
|
|
|
position_4_1:
|
2013-03-10 13:28:37 +01:00
|
|
|
inc [fat32part]
|
|
|
|
call search_and_read_image
|
|
|
|
cmp [image_retrieved], 1
|
|
|
|
je yes_sys_on_hd
|
|
|
|
movzx eax, byte [DRIVE_DATA+5]
|
|
|
|
cmp eax, [fat32part]
|
2009-09-17 13:55:38 +02:00
|
|
|
jle position_4_1
|
2013-03-10 13:28:37 +01:00
|
|
|
jmp yes_sys_on_hd
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
search_and_read_image:
|
2013-03-10 13:28:37 +01:00
|
|
|
call set_FAT32_variables
|
|
|
|
mov edx, bootpath
|
|
|
|
call read_image
|
|
|
|
test eax, eax
|
|
|
|
jz image_present
|
|
|
|
mov edx, bootpath2
|
|
|
|
call read_image
|
|
|
|
test eax, eax
|
|
|
|
jz image_present
|
2009-09-17 13:55:38 +02:00
|
|
|
ret
|
|
|
|
image_present:
|
2013-03-10 13:28:37 +01:00
|
|
|
mov [image_retrieved], 1
|
|
|
|
ret
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
align 4
|
|
|
|
read_image_fsinfo:
|
|
|
|
dd 0 ; function: read
|
|
|
|
dq 0 ; offset: zero
|
|
|
|
dd 1474560/512 ; size
|
|
|
|
dd RAMDISK ; buffer
|
|
|
|
db 0
|
|
|
|
dd hdsysimage+OS_BASE+0x10000
|
|
|
|
endg
|
|
|
|
|
|
|
|
read_image:
|
|
|
|
mov ebx, read_image_fsinfo
|
|
|
|
pushad
|
|
|
|
call file_system_lfn_protected
|
|
|
|
popad
|
|
|
|
ret
|
|
|
|
|
|
|
|
image_retrieved db 0
|
2009-09-17 13:55:38 +02:00
|
|
|
counter_of_partitions db 0
|
|
|
|
no_sys_on_hd:
|
|
|
|
; test_to_format_ram_disk (need if not using ram disk)
|
2013-03-10 13:28:37 +01:00
|
|
|
cmp [boot_dev+OS_BASE+0x10000], 3
|
|
|
|
jne not_format_ram_disk
|
2009-09-17 13:55:38 +02:00
|
|
|
; format_ram_disk
|
2013-03-10 13:28:37 +01:00
|
|
|
mov edi, RAMDISK
|
|
|
|
mov ecx, 0x1080
|
|
|
|
xor eax, eax
|
2012-04-02 17:18:46 +02:00
|
|
|
@@:
|
2013-03-10 13:28:37 +01:00
|
|
|
stosd
|
|
|
|
loop @b
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-03-10 13:28:37 +01:00
|
|
|
mov ecx, 0x58F7F
|
|
|
|
mov eax, 0xF6F6F6F6
|
2012-04-02 17:18:46 +02:00
|
|
|
@@:
|
2013-03-10 13:28:37 +01:00
|
|
|
stosd
|
|
|
|
loop @b
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-03-10 13:28:37 +01:00
|
|
|
mov [RAMDISK+0x200], dword 0xFFFFF0 ; fat table
|
|
|
|
mov [RAMDISK+0x4200], dword 0xFFFFF0
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
not_format_ram_disk:
|
|
|
|
yes_sys_on_hd:
|