Rev 3711 | Rev 4700 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3711 | Rev 3742 | ||
---|---|---|---|
Line 1... | Line 1... | ||
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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line -... | ||
8 | $Revision: 3711 $ |
- | |
9 | - | ||
10 | - | ||
11 | ;**************************************************** |
- | |
12 | ; поиск логических дисков на обнаруженных HDD |
- | |
13 | ; и занесение данных в область таблицы |
- | |
14 | ; автор Mario79 |
- | |
15 | ;**************************************************** |
8 | $Revision: 3742 $ |
16 | mov [transfer_adress], DRIVE_DATA+0xa |
9 | |
17 | search_partitions_ide0: |
- | |
18 | test [DRIVE_DATA+1], byte 0x40 |
10 | search_partitions: |
19 | jz search_partitions_ide1 |
11 | ; 1. Fill missing parameters in HD_DATA structures. |
20 | mov eax, [hd_address_table] |
12 | mov eax, [hd_address_table] |
- | 13 | mov [hd0_data.hdbase], eax ;0x1f0 |
|
21 | mov [hdbase], eax ;0x1f0 |
14 | mov [hd1_data.hdbase], eax |
22 | mov [hdid], 0x0 |
15 | mov eax, [hd_address_table+16] |
23 | mov [hdpos], 1 |
16 | mov [hd2_data.hdbase], eax |
- | 17 | mov [hd3_data.hdbase], eax |
|
- | 18 | ; 2. Notify the system about /hd* disks. |
|
24 | mov [known_part], 1 |
19 | ; For every existing disk, call ide_disk_add with correct parameters. |
25 | search_partitions_ide0_1: |
20 | ; Generate name "hdN" on the stack; this is 4 bytes including terminating zero. |
26 | call set_PARTITION_variables |
21 | ; 2a. /hd0: exists if mask 0x40 in [DRIVE_DATA+1] is set, |
27 | test [problem_partition], 2 |
22 | ; data: hd0_data, |
28 | jnz search_partitions_ide1 ; not found part |
23 | ; number of partitions: [DRIVE_DATA+2] |
29 | test [problem_partition], 1 |
24 | test [DRIVE_DATA+1], byte 0x40 |
30 | jnz @F ; not found known_part |
25 | jz @f |
31 | ;cmp [problem_partition],0 |
26 | push 'hd0' |
32 | ;jne search_partitions_ide1 |
27 | mov eax, esp ; name |
33 | inc byte [DRIVE_DATA+2] |
28 | mov edx, hd0_data |
- | 29 | call ide_disk_add |
|
34 | call partition_data_transfer |
30 | mov [DRIVE_DATA+2], al |
35 | add [transfer_adress], 100 |
31 | pop ecx ; restore the stack |
36 | @@: |
32 | @@: |
37 | inc [known_part] |
- | |
38 | jmp search_partitions_ide0_1 |
33 | ; 2b. /hd1: exists if mask 0x10 in [DRIVE_DATA+1] is set, |
39 | 34 | ; data: hd1_data, |
|
40 | search_partitions_ide1: |
- | |
41 | test [DRIVE_DATA+1], byte 0x10 |
- | |
42 | jz search_partitions_ide2 |
- | |
43 | mov eax, [hd_address_table] |
- | |
44 | mov [hdbase], eax ;0x1f0 |
- | |
45 | mov [hdid], 0x10 |
- | |
46 | mov [hdpos], 2 |
- | |
47 | mov [known_part], 1 |
- | |
48 | search_partitions_ide1_1: |
- | |
49 | call set_PARTITION_variables |
- | |
50 | test [problem_partition], 2 |
- | |
51 | jnz search_partitions_ide2 |
35 | ; number of partitions: [DRIVE_DATA+3] |
52 | test [problem_partition], 1 |
- | |
53 | jnz @F |
- | |
54 | ;cmp [problem_partition],0 |
- | |
55 | ;jne search_partitions_ide2 |
- | |
56 | inc byte [DRIVE_DATA+3] |
- | |
57 | call partition_data_transfer |
- | |
58 | add [transfer_adress], 100 |
36 | test [DRIVE_DATA+1], byte 0x10 |
59 | @@: |
- | |
60 | inc [known_part] |
- | |
61 | jmp search_partitions_ide1_1 |
- | |
62 | - | ||
63 | search_partitions_ide2: |
- | |
64 | test [DRIVE_DATA+1], byte 0x4 |
37 | jz @f |
65 | jz search_partitions_ide3 |
- | |
66 | mov eax, [hd_address_table+16] |
38 | push 'hd1' |
67 | mov [hdbase], eax ;0x170 |
39 | mov eax, esp |
68 | mov [hdid], 0x0 |
40 | mov edx, hd1_data |
69 | mov [hdpos], 3 |
- | |
70 | mov [known_part], 1 |
- | |
71 | search_partitions_ide2_1: |
- | |
72 | call set_PARTITION_variables |
- | |
73 | test [problem_partition], 2 |
- | |
74 | jnz search_partitions_ide3 |
41 | call ide_disk_add |
75 | test [problem_partition], 1 |
- | |
76 | jnz @F |
- | |
77 | ;cmp [problem_partition],0 |
- | |
78 | ;jne search_partitions_ide3 |
- | |
79 | inc byte [DRIVE_DATA+4] |
- | |
80 | call partition_data_transfer |
42 | mov [DRIVE_DATA+3], al |
81 | add [transfer_adress], 100 |
43 | pop ecx |
82 | @@: |
44 | @@: |
83 | inc [known_part] |
- | |
84 | jmp search_partitions_ide2_1 |
45 | ; 2c. /hd2: exists if mask 4 in [DRIVE_DATA+1] is set, |
85 | 46 | ; data: hd2_data, |
|
86 | search_partitions_ide3: |
47 | ; number of partitions: [DRIVE_DATA+4] |
87 | test [DRIVE_DATA+1], byte 0x1 |
- | |
88 | jz end_search_partitions_ide |
- | |
89 | mov eax, [hd_address_table+16] |
48 | test [DRIVE_DATA+1], byte 4 |
90 | mov [hdbase], eax ;0x170 |
49 | jz @f |
91 | mov [hdid], 0x10 |
50 | push 'hd2' |
92 | mov [hdpos], 4 |
- | |
93 | mov [known_part], 1 |
51 | mov eax, esp |
94 | search_partitions_ide3_1: |
- | |
95 | call set_PARTITION_variables |
- | |
96 | test [problem_partition], 2 |
52 | mov edx, hd2_data |
97 | jnz end_search_partitions_ide |
53 | call ide_disk_add |
98 | test [problem_partition], 1 |
- | |
99 | jnz @F |
- | |
100 | ;cmp [problem_partition],0 |
- | |
101 | ;jne end_search_partitions_ide |
- | |
102 | inc byte [DRIVE_DATA+5] |
- | |
103 | call partition_data_transfer |
54 | mov [DRIVE_DATA+4], al |
104 | add [transfer_adress], 100 |
- | |
105 | @@: |
55 | pop ecx |
106 | inc [known_part] |
- | |
107 | jmp search_partitions_ide3_1 |
- | |
108 | 56 | @@: |
|
109 | end_search_partitions_ide: |
57 | ; 2d. /hd3: exists if mask 1 in [DRIVE_DATA+1] is set, |
110 | mov [hdpos], 80h |
58 | ; data: hd3_data, |
111 | mov ecx, [NumBiosDisks] |
59 | ; number of partitions: [DRIVE_DATA+5] |
112 | test ecx, ecx |
- | |
113 | jz end_search_partitions |
60 | test [DRIVE_DATA+1], byte 1 |
114 | start_search_partitions_bd: |
61 | jz @f |
115 | push ecx |
- | |
116 | mov eax, [hdpos] |
- | |
117 | and [BiosDiskPartitions+(eax-80h)*4], 0 |
- | |
118 | mov [known_part], 1 |
- | |
119 | search_partitions_bd: |
- | |
120 | call set_PARTITION_variables |
- | |
121 | test [problem_partition], 2 |
- | |
122 | jnz end_search_partitions_bd |
- | |
123 | test [problem_partition], 1 |
- | |
124 | jnz @F |
- | |
125 | ;cmp [problem_partition], 0 |
62 | push 'hd3' |
126 | ;jne end_search_partitions_bd |
- | |
127 | mov eax, [hdpos] |
63 | mov eax, esp |
128 | inc [BiosDiskPartitions+(eax-80h)*4] |
64 | mov edx, hd3_data |
129 | call partition_data_transfer |
- | |
130 | add [transfer_adress], 100 |
- | |
131 | @@: |
- | |
132 | inc [known_part] |
- | |
133 | jmp search_partitions_bd |
65 | call ide_disk_add |
- | 66 | mov [DRIVE_DATA+5], al |
|
- | 67 | pop ecx |
|
- | 68 | @@: |
|
- | 69 | ; 3. Notify the system about /bd* disks. |
|
- | 70 | ; 3a. Check whether there are BIOS disks. If no, skip step 3. |
|
- | 71 | xor esi, esi |
|
- | 72 | cmp esi, [NumBiosDisks] |
|
- | 73 | jz .nobd |
|
- | 74 | ; Loop over all disks. |
|
- | 75 | push 0 |
|
- | 76 | push 'bd' |
|
- | 77 | .bdloop: |
|
- | 78 | ; 3b. Get the drive number for using in /bd* name. |
|
- | 79 | movzx eax, byte [BiosDisksData+esi*4] |
|
- | 80 | sub al, 80h |
|
- | 81 | ; 3c. Convert eax to decimal and store starting with [esp+3]. |
|
- | 82 | ; First 2 bytes in [esp] are "bd". |
|
- | 83 | lea edi, [esp+2] |
|
- | 84 | ; store digits in the stack, ending with -'0' |
|
- | 85 | push -'0' |
|
- | 86 | @@: |
|
- | 87 | xor edx, edx |
|
- | 88 | iglobal |
|
- | 89 | align 4 |
|
- | 90 | _10 dd 10 |
|
- | 91 | endg |
|
- | 92 | div [_10] |
|
- | 93 | push edx |
|
- | 94 | test eax, eax |
|
- | 95 | jnz @b |
|
- | 96 | ; restore digits from the stack, this reverses the order; |
|
- | 97 | ; add '0', stop, when zero is reached |
|
- | 98 | @@: |
|
- | 99 | pop eax |
|
- | 100 | add al, '0' |
|
- | 101 | stosb |
|
- | 102 | jnz @b |
|
- | 103 | ; 3e. Call the API with userdata = 80h + ecx. |
|
- | 104 | mov eax, esp |
|
- | 105 | lea edx, [esi+80h] |
|
- | 106 | stdcall disk_add, bd_callbacks, eax, edx, 0 |
|
- | 107 | test eax, eax |
|
- | 108 | jz @f |
|
- | 109 | stdcall disk_media_changed, eax, 1 |
|
134 | end_search_partitions_bd: |
110 | @@: |
135 | pop ecx |
111 | ; 3f. Continue the loop. |
- | 112 | inc esi |
|
- | 113 | cmp esi, [NumBiosDisks] |
|
- | 114 | jnz .bdloop |
|
136 | inc [hdpos] |
115 | pop ecx ecx ; restore stack after name |
Line 137... | Line 116... | ||
137 | loop start_search_partitions_bd |
116 | .nobd: |
138 | jmp end_search_partitions |
- | |
- | 117 | jmp end_search_partitions |
|
139 | 118 | ||
140 | problem_partition db 0 ; used for partitions search |
- | |
141 | 119 | ; Helper procedure for search_partitions, adds one IDE disk. |
|
142 | include '../fs/part_set.inc' |
120 | ; For compatibility, number of partitions for IDE disks is kept in a separate variable, |
143 | 121 | ; so the procedure returns number of partitions. |
|
144 | partition_data_transfer: |
122 | ; eax -> name, edx -> disk data |
145 | mov edi, [transfer_adress] |
123 | proc ide_disk_add |
146 | mov esi, PARTITION_START ;start of file_system_data |
124 | stdcall disk_add, ide_callbacks, eax, edx, 0 |
147 | mov ecx, (file_system_data_size+3)/4 |
- | |
148 | rep movsd |
- | |
149 | ret |
- | |
150 | uglobal |
125 | test eax, eax |
151 | transfer_adress dd 0 |
- | |
152 | endg |
126 | jz @f |
153 | partition_data_transfer_1: |
127 | push eax |
154 | ; cli |
128 | stdcall disk_media_changed, eax, 1 |
155 | push edi |
- | |
156 | mov edi, PARTITION_START |
129 | pop eax |
157 | mov esi, [transfer_adress] |
130 | mov eax, [eax+DISK.NumPartitions] |
158 | mov ecx, (file_system_data_size+3)/4 |
131 | cmp eax, 255 |
159 | rep movsd |
132 | jbe @f |
- | 133 | mov eax, 255 |
|
Line 160... | Line 134... | ||
160 | pop edi |
134 | @@: |