Subversion Repositories Kolibri OS

Rev

Rev 3500 | Rev 5201 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3500 Rev 3908
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
-
 
8
$Revision: 3908 $
8
$Revision: 3500 $
9
 
9
 
10
 
10
 
11
read_ramdisk:
11
; READ RAMDISK IMAGE FROM HD
12
; READ RAMDISK IMAGE FROM HD
12
 
13
 
13
        cmp     [boot_dev+OS_BASE+0x10000], 1
14
        cmp     [boot_dev+OS_BASE+0x10000], 1
14
        jne     no_sys_on_hd
15
        jne     no_sys_on_hd
15
 
-
 
16
        test    [DRIVE_DATA+1], byte 0x40
-
 
17
        jz      position_2
-
 
18
        mov     [hdbase], 0x1f0
16
 
19
        mov     [hdid], 0x0
-
 
20
        mov     [hdpos], 1
-
 
21
        mov     [fat32part], 0
17
        xor     ebp, ebp
22
  position_1_1:
18
.hd_loop:
23
        inc     [fat32part]
-
 
24
        call    search_and_read_image
19
        lea     eax, [ebp+'0']
25
        cmp     [image_retrieved], 1
-
 
26
        je      yes_sys_on_hd
20
        mov     [read_image_fsinfo.name_digit], al
27
        movzx   eax, byte [DRIVE_DATA+2]
21
        movzx   eax, byte [DRIVE_DATA+2+ebp]
28
        cmp     [fat32part], eax
-
 
29
        jle     position_1_1
-
 
30
  position_2:
-
 
31
        test    [DRIVE_DATA+1], byte 0x10
22
        test    eax, eax
32
        jz      position_3
-
 
33
        mov     [hdbase], 0x1f0
23
        jz      .next_hd
34
        mov     [hdid], 0x10
24
        push    eax
35
        mov     [hdpos], 2
-
 
36
        mov     [fat32part], 0
25
        mov     esi, 1
37
  position_2_1:
-
 
38
        inc     [fat32part]
-
 
39
        call    search_and_read_image
-
 
40
        cmp     [image_retrieved], 1
-
 
41
        je      yes_sys_on_hd
-
 
42
        movzx   eax, byte [DRIVE_DATA+3]
26
.partition_loop:
43
        cmp     eax, [fat32part]
27
        mov     eax, esi
44
        jle     position_2_1
28
        push    -'0'
45
  position_3:
-
 
46
        test    [DRIVE_DATA+1], byte 0x4
-
 
47
        jz      position_4
29
@@:
48
        mov     [hdbase], 0x170
30
        xor     edx, edx
49
        mov     [hdid], 0x0
31
        div     [_10]
50
        mov     [hdpos], 3
-
 
51
        mov     [fat32part], 0
-
 
52
  position_3_1:
32
        push    edx
53
        inc     [fat32part]
-
 
54
        call    search_and_read_image
-
 
55
        cmp     [image_retrieved], 1
33
        test    eax, eax
56
        je      yes_sys_on_hd
-
 
57
        movzx   eax, byte [DRIVE_DATA+4]
34
        jnz     @b
58
        cmp     eax, [fat32part]
-
 
59
        jle     position_3_1
35
        mov     edi, read_image_fsinfo.partition
60
  position_4:
-
 
61
        test    [DRIVE_DATA+1], byte 0x1
-
 
62
        jz      no_sys_on_hd
36
@@:
63
        mov     [hdbase], 0x170
37
        pop     eax
64
        mov     [hdid], 0x10
38
        add     al, '0'
65
        mov     [hdpos], 4
-
 
66
        mov     [fat32part], 0
-
 
67
  position_4_1:
39
        stosb
68
        inc     [fat32part]
-
 
69
        call    search_and_read_image
-
 
70
        cmp     [image_retrieved], 1
-
 
71
        je      yes_sys_on_hd
40
        jnz     @b
72
        movzx   eax, byte [DRIVE_DATA+5]
-
 
73
        cmp     eax, [fat32part]
41
        mov     byte [edi-1], '/'
74
        jle     position_4_1
42
        push    esi edi
75
        jmp     yes_sys_on_hd
-
 
76
 
-
 
77
  search_and_read_image:
43
        mov     esi, bootpath1
78
        call    set_FAT32_variables
44
        mov     ecx, bootpath1.len
79
        mov     edx, bootpath
45
        rep movsb
80
        call    read_image
46
        call    read_image
-
 
47
        test    eax, eax
-
 
48
        jz      .yes
81
        test    eax, eax
49
        cmp     eax, 6
-
 
50
        jz      .yes
-
 
51
        pop     edi
82
        jz      image_present
52
        push    edi
-
 
53
        mov     esi, bootpath2
-
 
54
        mov     ecx, bootpath2.len
83
        mov     edx, bootpath2
55
        rep movsb
84
        call    read_image
56
        call    read_image
-
 
57
        test    eax, eax
-
 
58
        jz      .yes
85
        test    eax, eax
59
        cmp     eax, 6
-
 
60
        jz      .yes
86
        jz      image_present
61
        pop     edi esi
87
        ret
62
        inc     esi
88
    image_present:
63
        cmp     esi, [esp]
-
 
64
        jbe     .partition_loop
-
 
65
        pop     eax
89
        mov     [image_retrieved], 1
66
.next_hd:
-
 
67
        inc     ebp
-
 
68
        cmp     ebp, 4
-
 
69
        jb      .hd_loop
-
 
70
        jmp     no_sys_on_hd
-
 
71
.yes:
-
 
72
        pop     edi esi eax
90
        ret
73
        jmp     yes_sys_on_hd
91
 
74
 
92
iglobal
75
iglobal
93
align 4
76
align 4
94
read_image_fsinfo:
77
read_image_fsinfo:
95
        dd      0               ; function: read
78
        dd      0               ; function: read
96
        dq      0               ; offset: zero
79
        dq      0               ; offset: zero
97
        dd      1474560/512     ; size
80
        dd      1474560         ; size
98
        dd      RAMDISK         ; buffer
81
        dd      RAMDISK         ; buffer
-
 
82
        db      '/hd'
-
 
83
.name_digit db  '0'
99
        db      0
84
        db      '/'
-
 
85
.partition:
-
 
86
        rb      64      ; should be enough for '255/KOLIBRI/KOLIBRI.IMG'
-
 
87
 
-
 
88
bootpath1       db      'KOLIBRI.IMG',0
-
 
89
.len = $ - bootpath1
100
        dd      hdsysimage+OS_BASE+0x10000
90
bootpath2       db      'KOLIBRI/KOLIBRI.IMG',0
-
 
91
.len = $ - bootpath2
101
endg
92
endg
102
 
93
 
103
read_image:
94
read_image:
104
        mov     ebx, read_image_fsinfo
95
        mov     ebx, read_image_fsinfo
105
        pushad
96
        pushad
106
        call    file_system_lfn_protected
97
        call    file_system_lfn_protected
107
        popad
98
        popad
108
        ret
99
        ret
109
 
-
 
110
image_retrieved  db 0
-
 
111
counter_of_partitions db 0
100
 
112
no_sys_on_hd:
101
no_sys_on_hd:
113
        ; test_to_format_ram_disk (need if not using ram disk)
102
        ; test_to_format_ram_disk (need if not using ram disk)
114
        cmp     [boot_dev+OS_BASE+0x10000], 3
103
        cmp     [boot_dev+OS_BASE+0x10000], 3
115
        jne     not_format_ram_disk
104
        jne     not_format_ram_disk
116
        ; format_ram_disk
105
        ; format_ram_disk
117
        mov     edi, RAMDISK
106
        mov     edi, RAMDISK
118
        mov     ecx, 0x1080
107
        mov     ecx, 0x1080
119
        xor     eax, eax
108
        xor     eax, eax
120
@@:             
109
@@:             
121
        stosd
110
        stosd
122
        loop    @b
111
        loop    @b
123
 
112
 
124
        mov     ecx, 0x58F7F
113
        mov     ecx, 0x58F7F
125
        mov     eax, 0xF6F6F6F6
114
        mov     eax, 0xF6F6F6F6
126
@@:             
115
@@:             
127
        stosd
116
        stosd
128
        loop    @b
117
        loop    @b
129
        
118
        
130
        mov     [RAMDISK+0x200], dword 0xFFFFF0         ; fat table
119
        mov     [RAMDISK+0x200], dword 0xFFFFF0         ; fat table
131
        mov     [RAMDISK+0x4200], dword 0xFFFFF0
120
        mov     [RAMDISK+0x4200], dword 0xFFFFF0
132
        
121
        
133
not_format_ram_disk:
122
not_format_ram_disk:
134
yes_sys_on_hd:
123
yes_sys_on_hd: