Rev 774 | Rev 1038 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
431 | serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
593 | mikedld | 8 | $Revision: 819 $ |
9 | |||
10 | |||
357 | serge | 11 | GREEDY_KERNEL equ 0 |
164 | serge | 12 | |
13 | struc APP_HEADER_00 |
||
14 | { .banner dq ? |
||
15 | .version dd ? ;+8 |
||
16 | .start dd ? ;+12 |
||
17 | .i_end dd ? ;+16 |
||
18 | .mem_size dd ? ;+20 |
||
19 | .i_param dd ? ;+24 |
||
20 | } |
||
21 | |||
22 | struc APP_HEADER_01 |
||
23 | { .banner dq ? |
||
24 | .version dd ? ;+8 |
||
25 | .start dd ? ;+12 |
||
26 | .i_end dd ? ;+16 |
||
27 | .mem_size dd ? ;+20 |
||
28 | .stack_top dd ? ;+24 |
||
29 | .i_param dd ? ;+28 |
||
30 | .i_icon dd ? ;+32 |
||
31 | } |
||
32 | |||
237 | serge | 33 | |
34 | struc APP_PARAMS |
||
774 | Rus | 35 | { .app_cmdline ;0x00 |
36 | .app_path ;0x04 |
||
37 | .app_eip ;0x08 |
||
38 | .app_esp ;0x0C |
||
39 | .app_mem ;0x10 |
||
237 | serge | 40 | } |
41 | |||
42 | macro _clear_ op |
||
43 | { mov ecx, op/4 |
||
44 | xor eax, eax |
||
45 | cld |
||
46 | rep stosd |
||
47 | } |
||
48 | |||
521 | diamond | 49 | fs_execute_from_sysdir: |
774 | Rus | 50 | xor ebx, ebx |
51 | xor edx, edx |
||
52 | mov esi, sysdir_path |
||
363 | serge | 53 | |
164 | serge | 54 | align 4 |
363 | serge | 55 | proc fs_execute |
56 | |||
57 | ;fn_read:dword, file_size:dword, cluster:dword |
||
58 | |||
59 | ; ebx - cmdline |
||
60 | ; edx - flags |
||
61 | ; ebp - full filename |
||
62 | ; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it |
||
63 | |||
774 | Rus | 64 | locals |
65 | cmdline rd 64 ;256/4 |
||
66 | filename rd 256 ;1024/4 |
||
67 | flags dd ? |
||
363 | serge | 68 | |
774 | Rus | 69 | save_cr3 dd ? |
70 | slot dd ? |
||
71 | slot_base dd ? |
||
72 | file_base dd ? |
||
73 | file_size dd ? |
||
74 | ;app header data |
||
75 | hdr_cmdline dd ? ;0x00 |
||
76 | hdr_path dd ? ;0x04 |
||
77 | hdr_eip dd ? ;0x08 |
||
78 | hdr_esp dd ? ;0x0C |
||
79 | hdr_mem dd ? ;0x10 |
||
80 | hdr_i_end dd ? ;0x14 |
||
81 | endl |
||
164 | serge | 82 | |
774 | Rus | 83 | pushad |
363 | serge | 84 | |
774 | Rus | 85 | mov [flags], edx |
363 | serge | 86 | |
87 | ; [ebp] pointer to filename |
||
88 | |||
774 | Rus | 89 | lea edi, [filename] |
90 | lea ecx, [edi+1024] |
||
91 | mov al, '/' |
||
92 | stosb |
||
521 | diamond | 93 | @@: |
774 | Rus | 94 | cmp edi, ecx |
95 | jae .bigfilename |
||
96 | lodsb |
||
97 | stosb |
||
98 | test al, al |
||
99 | jnz @b |
||
100 | mov esi, [ebp] |
||
101 | test esi, esi |
||
102 | jz .namecopied |
||
103 | mov byte [edi-1], '/' |
||
521 | diamond | 104 | @@: |
774 | Rus | 105 | cmp edi, ecx |
106 | jae .bigfilename |
||
107 | lodsb |
||
108 | stosb |
||
109 | test al, al |
||
110 | jnz @b |
||
111 | jmp .namecopied |
||
521 | diamond | 112 | .bigfilename: |
774 | Rus | 113 | popad |
114 | mov eax, -ERROR_FILE_NOT_FOUND |
||
115 | ret |
||
521 | diamond | 116 | .namecopied: |
363 | serge | 117 | |
774 | Rus | 118 | mov [cmdline], ebx |
119 | test ebx, ebx |
||
120 | jz @F |
||
519 | serge | 121 | |
774 | Rus | 122 | lea eax, [cmdline] |
123 | mov dword [eax+252], 0 |
||
124 | stdcall strncpy, eax, ebx, 255 |
||
519 | serge | 125 | @@: |
774 | Rus | 126 | lea eax, [filename] |
127 | stdcall load_file, eax |
||
128 | mov ecx, -ERROR_FILE_NOT_FOUND |
||
129 | test eax, eax |
||
130 | jz .err_file |
||
237 | serge | 131 | |
774 | Rus | 132 | mov [file_base], eax |
133 | mov [file_size], ebx |
||
237 | serge | 134 | |
774 | Rus | 135 | lea ebx, [hdr_cmdline] |
136 | call test_app_header |
||
137 | mov ecx, -0x1F |
||
138 | test eax, eax |
||
139 | jz .err_hdr |
||
237 | serge | 140 | |
774 | Rus | 141 | ;mov esi, new_process_loading |
142 | ;call sys_msg_board_str ; write message to message board |
||
143 | DEBUGF 1,"%s",new_process_loading |
||
237 | serge | 144 | |
145 | .wait_lock: |
||
774 | Rus | 146 | cmp [application_table_status],0 |
147 | je .get_lock |
||
148 | call change_task |
||
149 | jmp .wait_lock |
||
237 | serge | 150 | |
151 | .get_lock: |
||
774 | Rus | 152 | mov eax, 1 |
153 | xchg eax, [application_table_status] |
||
154 | cmp eax, 0 |
||
155 | jne .wait_lock |
||
237 | serge | 156 | |
774 | Rus | 157 | call set_application_table_status |
237 | serge | 158 | |
774 | Rus | 159 | call get_new_process_place |
160 | test eax, eax |
||
161 | mov ecx, -0x20 ; too many processes |
||
162 | jz .err |
||
237 | serge | 163 | |
774 | Rus | 164 | mov [slot], eax |
165 | shl eax, 8 |
||
166 | add eax, SLOT_BASE |
||
167 | mov [slot_base], eax |
||
168 | mov edi, eax |
||
169 | _clear_ 256 ;clean extended information about process |
||
237 | serge | 170 | |
171 | ; write application name |
||
774 | Rus | 172 | lea eax, [filename] |
173 | stdcall strrchr, eax, '/' ; now eax points to name without path |
||
237 | serge | 174 | |
774 | Rus | 175 | lea esi, [eax+1] |
176 | test eax, eax |
||
177 | jnz @F |
||
178 | lea esi, [filename] |
||
237 | serge | 179 | @@: |
774 | Rus | 180 | mov ecx, 8 ; 8 chars for name |
181 | mov edi, [slot_base] |
||
237 | serge | 182 | .copy_process_name_loop: |
774 | Rus | 183 | lodsb |
184 | cmp al, '.' |
||
185 | jz .copy_process_name_done |
||
186 | test al, al |
||
187 | jz .copy_process_name_done |
||
188 | stosb |
||
189 | loop .copy_process_name_loop |
||
237 | serge | 190 | .copy_process_name_done: |
191 | |||
774 | Rus | 192 | mov ebx, cr3 |
193 | mov [save_cr3], ebx |
||
269 | serge | 194 | |
774 | Rus | 195 | stdcall create_app_space,[hdr_mem],[file_base],[file_size] |
196 | mov ecx, -30 ; no memory |
||
197 | test eax, eax |
||
198 | jz .failed |
||
237 | serge | 199 | |
774 | Rus | 200 | mov ebx,[slot_base] |
201 | mov [ebx+APPDATA.dir_table],eax |
||
202 | mov eax,[hdr_mem] |
||
203 | mov [ebx+APPDATA.mem_size],eax |
||
237 | serge | 204 | |
357 | serge | 205 | if GREEDY_KERNEL |
206 | else |
||
774 | Rus | 207 | mov ecx, [hdr_mem] |
208 | mov edi, [file_size] |
||
209 | add edi, 4095 |
||
210 | and edi, not 4095 |
||
211 | sub ecx, edi |
||
212 | jna @F |
||
269 | serge | 213 | |
774 | Rus | 214 | xor eax, eax |
819 | serge | 215 | cld |
774 | Rus | 216 | rep stosb |
247 | serge | 217 | @@: |
269 | serge | 218 | end if |
219 | |||
220 | ; release only virtual space, not phisical memory |
||
221 | |||
774 | Rus | 222 | stdcall free_kernel_space, [file_base] |
223 | lea eax, [hdr_cmdline] |
||
224 | lea ebx, [cmdline] |
||
225 | lea ecx, [filename] |
||
226 | stdcall set_app_params ,[slot],eax,ebx,ecx,[flags] |
||
237 | serge | 227 | |
774 | Rus | 228 | mov eax, [save_cr3] |
229 | call set_cr3 |
||
237 | serge | 230 | |
774 | Rus | 231 | xor ebx, ebx |
232 | mov [application_table_status],ebx ;unlock application_table_status mutex |
||
233 | mov eax,[process_number] ;set result |
||
234 | ret |
||
237 | serge | 235 | .failed: |
774 | Rus | 236 | mov eax, [save_cr3] |
237 | call set_cr3 |
||
269 | serge | 238 | .err: |
247 | serge | 239 | .err_hdr: |
774 | Rus | 240 | stdcall kernel_free,[file_base] |
247 | serge | 241 | .err_file: |
774 | Rus | 242 | xor eax, eax |
243 | mov [application_table_status],eax |
||
244 | mov eax, ecx |
||
245 | ret |
||
237 | serge | 246 | endp |
164 | serge | 247 | |
237 | serge | 248 | align 4 |
249 | test_app_header: |
||
774 | Rus | 250 | virtual at eax |
251 | APP_HEADER_00 APP_HEADER_00 |
||
252 | end virtual |
||
253 | virtual at eax |
||
254 | APP_HEADER_01 APP_HEADER_01 |
||
255 | end virtual |
||
164 | serge | 256 | |
774 | Rus | 257 | cmp dword [eax], 'MENU' |
258 | jne .fail |
||
259 | cmp word [eax+4],'ET' |
||
260 | jne .fail |
||
164 | serge | 261 | |
774 | Rus | 262 | cmp [eax+6], word '00' |
263 | jne .check_01_header |
||
164 | serge | 264 | |
774 | Rus | 265 | mov ecx,[APP_HEADER_00.start] |
266 | mov [ebx+0x08], ecx ;app_eip |
||
267 | mov edx,[APP_HEADER_00.mem_size] |
||
268 | mov [ebx+0x10], edx ;app_mem |
||
269 | shr edx,1 |
||
270 | sub edx,0x10 |
||
271 | mov [ebx+0x0C], edx ;app_esp |
||
272 | mov ecx,[APP_HEADER_00.i_param] |
||
273 | mov [ebx], ecx ;app_cmdline |
||
274 | mov [ebx+4], dword 0 ;app_path |
||
275 | mov edx, [APP_HEADER_00.i_end] |
||
276 | mov [ebx+0x14], edx |
||
277 | ret |
||
164 | serge | 278 | |
237 | serge | 279 | .check_01_header: |
164 | serge | 280 | |
774 | Rus | 281 | cmp [eax+6],word '01' |
282 | jne .fail |
||
237 | serge | 283 | |
774 | Rus | 284 | mov ecx,[APP_HEADER_01.start] |
285 | mov [ebx+0x08], ecx ;app_eip |
||
286 | mov edx,[APP_HEADER_01.mem_size] |
||
381 | serge | 287 | |
288 | ; \begin{diamond}[20.08.2006] |
||
289 | ; sanity check (functions 19,58 load app_i_end bytes and that must |
||
290 | ; fit in allocated memory to prevent kernel faults) |
||
774 | Rus | 291 | cmp edx,[APP_HEADER_01.i_end] |
292 | jb .fail |
||
381 | serge | 293 | ; \end{diamond}[20.08.2006] |
294 | |||
774 | Rus | 295 | mov [ebx+0x10], edx ;app_mem |
296 | mov ecx,[APP_HEADER_01.stack_top] |
||
297 | mov [ebx+0x0C], ecx ;app_esp |
||
298 | mov edx,[APP_HEADER_01.i_param] |
||
299 | mov [ebx], edx ;app_cmdline |
||
300 | mov ecx,[APP_HEADER_01.i_icon] |
||
301 | mov [ebx+4], ecx ;app_path |
||
302 | mov edx, [APP_HEADER_01.i_end] |
||
303 | mov [ebx+0x14], edx |
||
304 | ret |
||
237 | serge | 305 | .fail: |
774 | Rus | 306 | xor eax, eax |
307 | ret |
||
164 | serge | 308 | |
309 | align 4 |
||
310 | proc get_new_process_place |
||
311 | ;input: |
||
312 | ; none |
||
313 | ;result: |
||
314 | ; eax=[new_process_place]<>0 - ok |
||
315 | ; 0 - failed. |
||
316 | ;This function find least empty slot. |
||
317 | ;It doesn't increase [TASK_COUNT]! |
||
774 | Rus | 318 | mov eax,CURRENT_TASK |
319 | mov ebx,[TASK_COUNT] |
||
320 | inc ebx |
||
321 | shl ebx,5 |
||
322 | add ebx,eax ;ebx - address of process information for (last+1) slot |
||
164 | serge | 323 | .newprocessplace: |
324 | ;eax = address of process information for current slot |
||
774 | Rus | 325 | cmp eax,ebx |
326 | jz .endnewprocessplace ;empty slot after high boundary |
||
327 | add eax,0x20 |
||
328 | cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty |
||
329 | jnz .newprocessplace |
||
164 | serge | 330 | .endnewprocessplace: |
774 | Rus | 331 | mov ebx,eax |
332 | sub eax,CURRENT_TASK |
||
333 | shr eax,5 ;calculate slot index |
||
334 | cmp eax,256 |
||
335 | jge .failed ;it should be <256 |
||
336 | mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) |
||
337 | ret |
||
164 | serge | 338 | .failed: |
774 | Rus | 339 | xor eax,eax |
340 | ret |
||
164 | serge | 341 | endp |
342 | |||
343 | align 4 |
||
269 | serge | 344 | proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword |
774 | Rus | 345 | locals |
346 | app_pages dd ? |
||
347 | img_pages dd ? |
||
348 | dir_addr dd ? |
||
349 | app_tabs dd ? |
||
350 | endl |
||
164 | serge | 351 | |
774 | Rus | 352 | mov ebx, pg_data.pg_mutex |
353 | call wait_mutex ;ebx |
||
164 | serge | 354 | |
774 | Rus | 355 | xor eax, eax |
356 | mov [dir_addr], eax |
||
164 | serge | 357 | |
774 | Rus | 358 | mov eax, [app_size] |
359 | add eax, 4095 |
||
360 | and eax, NOT(4095) |
||
361 | mov [app_size], eax |
||
362 | mov ebx, eax |
||
363 | shr eax, 12 |
||
364 | mov [app_pages], eax |
||
170 | serge | 365 | |
774 | Rus | 366 | add ebx, 0x3FFFFF |
367 | and ebx, NOT(0x3FFFFF) |
||
368 | shr ebx, 22 |
||
369 | mov [app_tabs], ebx |
||
164 | serge | 370 | |
774 | Rus | 371 | mov ecx, [img_size] |
372 | add ecx, 4095 |
||
373 | and ecx, NOT(4095) |
||
164 | serge | 374 | |
774 | Rus | 375 | mov [img_size], ecx |
376 | shr ecx, 12 |
||
377 | mov [img_pages], ecx |
||
164 | serge | 378 | |
170 | serge | 379 | if GREEDY_KERNEL |
774 | Rus | 380 | lea eax, [ecx+ebx+2] ;only image size |
170 | serge | 381 | else |
774 | Rus | 382 | lea eax, [eax+ebx+2] ;all requested memory |
170 | serge | 383 | end if |
774 | Rus | 384 | cmp eax, [pg_data.pages_free] |
385 | ja .fail |
||
170 | serge | 386 | |
774 | Rus | 387 | call alloc_page |
388 | test eax, eax |
||
389 | jz .fail |
||
390 | mov [dir_addr], eax |
||
391 | stdcall map_page,[tmp_task_pdir],eax,dword PG_SW |
||
164 | serge | 392 | |
774 | Rus | 393 | mov edi, [tmp_task_pdir] |
394 | mov ecx, (OS_BASE shr 20)/4 |
||
395 | xor eax, eax |
||
396 | cld |
||
397 | rep stosd |
||
465 | serge | 398 | |
774 | Rus | 399 | mov ecx, (OS_BASE shr 20)/4 |
400 | mov esi, sys_pgdir+(OS_BASE shr 20) |
||
401 | rep movsd |
||
164 | serge | 402 | |
774 | Rus | 403 | mov eax, [dir_addr] |
404 | or eax, PG_SW |
||
405 | mov [edi-4096+(page_tabs shr 20)], eax |
||
378 | serge | 406 | |
774 | Rus | 407 | and eax, -4096 |
408 | call set_cr3 |
||
164 | serge | 409 | |
774 | Rus | 410 | mov edx, [app_tabs] |
411 | mov edi, new_app_base |
||
164 | serge | 412 | @@: |
774 | Rus | 413 | call alloc_page |
414 | test eax, eax |
||
415 | jz .fail |
||
164 | serge | 416 | |
774 | Rus | 417 | stdcall map_page_table, edi, eax |
418 | add edi, 0x00400000 |
||
419 | dec edx |
||
420 | jnz @B |
||
164 | serge | 421 | |
774 | Rus | 422 | mov edi, new_app_base |
423 | shr edi, 10 |
||
424 | add edi, page_tabs |
||
269 | serge | 425 | |
774 | Rus | 426 | mov ecx, [app_tabs] |
427 | shl ecx, 10 |
||
428 | xor eax, eax |
||
429 | rep stosd |
||
164 | serge | 430 | |
774 | Rus | 431 | mov ecx, [img_pages] |
432 | mov ebx, PG_UW |
||
433 | mov edx, new_app_base |
||
434 | mov esi, [img_base] |
||
435 | mov edi, new_app_base |
||
436 | shr esi, 10 |
||
437 | shr edi, 10 |
||
438 | add esi, page_tabs |
||
439 | add edi, page_tabs |
||
269 | serge | 440 | .remap: |
774 | Rus | 441 | lodsd |
442 | or eax, ebx ; force user level r/w access |
||
443 | stosd |
||
444 | add edx, 0x1000 |
||
445 | dec [app_pages] |
||
446 | dec ecx |
||
447 | jnz .remap |
||
269 | serge | 448 | |
774 | Rus | 449 | mov ecx, [app_pages] |
450 | test ecx, ecx |
||
451 | jz .done |
||
269 | serge | 452 | |
453 | if GREEDY_KERNEL |
||
774 | Rus | 454 | mov eax, 0x02 |
819 | serge | 455 | rep stosd |
269 | serge | 456 | else |
457 | |||
164 | serge | 458 | .alloc: |
774 | Rus | 459 | call alloc_page |
460 | test eax, eax |
||
461 | jz .fail |
||
164 | serge | 462 | |
774 | Rus | 463 | stdcall map_page,edx,eax,dword PG_UW |
464 | add edx, 0x1000 |
||
465 | dec [app_pages] |
||
466 | jnz .alloc |
||
269 | serge | 467 | end if |
164 | serge | 468 | |
269 | serge | 469 | .done: |
774 | Rus | 470 | stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP |
164 | serge | 471 | |
774 | Rus | 472 | dec [pg_data.pg_mutex] |
473 | mov eax, [dir_addr] |
||
474 | ret |
||
164 | serge | 475 | .fail: |
774 | Rus | 476 | dec [pg_data.pg_mutex] |
477 | cmp [dir_addr], 0 |
||
478 | je @f |
||
479 | stdcall destroy_app_space, [dir_addr] |
||
164 | serge | 480 | @@: |
774 | Rus | 481 | xor eax, eax |
482 | ret |
||
164 | serge | 483 | endp |
484 | |||
485 | align 4 |
||
486 | set_cr3: |
||
465 | serge | 487 | |
774 | Rus | 488 | mov ebx, [current_slot] |
489 | mov [ebx+APPDATA.dir_table], eax |
||
490 | mov cr3, eax |
||
491 | ret |
||
164 | serge | 492 | |
493 | align 4 |
||
494 | proc destroy_page_table stdcall, pg_tab:dword |
||
495 | |||
774 | Rus | 496 | push esi |
164 | serge | 497 | |
774 | Rus | 498 | mov esi, [pg_tab] |
499 | mov ecx, 1024 |
||
164 | serge | 500 | .free: |
774 | Rus | 501 | mov eax, [esi] |
502 | test eax, 1 |
||
503 | jz .next |
||
819 | serge | 504 | test eax, 1 shl 9 |
505 | jnz .next ;skip shared pages |
||
774 | Rus | 506 | call free_page |
164 | serge | 507 | .next: |
774 | Rus | 508 | add esi, 4 |
509 | dec ecx |
||
510 | jnz .free |
||
511 | pop esi |
||
512 | ret |
||
164 | serge | 513 | endp |
514 | |||
515 | align 4 |
||
516 | proc destroy_app_space stdcall, pg_dir:dword |
||
517 | |||
774 | Rus | 518 | mov ebx, pg_data.pg_mutex |
519 | call wait_mutex ;ebx |
||
164 | serge | 520 | |
774 | Rus | 521 | xor edx,edx |
522 | mov eax,0x2 |
||
523 | mov ebx, [pg_dir] |
||
164 | serge | 524 | .loop: |
525 | ;eax = current slot of process |
||
774 | Rus | 526 | mov ecx,eax |
527 | shl ecx,5 |
||
528 | cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? |
||
529 | jz @f ;skip empty slots |
||
530 | shl ecx,3 |
||
531 | cmp [SLOT_BASE+ecx+0xB8],ebx ;compare page directory addresses |
||
532 | jnz @f |
||
533 | inc edx ;thread found |
||
164 | serge | 534 | @@: |
774 | Rus | 535 | inc eax |
536 | cmp eax,[TASK_COUNT] ;exit loop if we look through all processes |
||
537 | jle .loop |
||
164 | serge | 538 | |
539 | ;edx = number of threads |
||
540 | ;our process is zombi so it isn't counted |
||
774 | Rus | 541 | cmp edx,1 |
542 | jg .exit |
||
164 | serge | 543 | ;if there isn't threads then clear memory. |
544 | |||
774 | Rus | 545 | mov eax, [pg_dir] |
546 | and eax, not 0xFFF |
||
547 | stdcall map_page,[tmp_task_pdir],eax,dword PG_SW |
||
548 | mov esi, [tmp_task_pdir] |
||
549 | mov edi, (OS_BASE shr 20)/4 |
||
164 | serge | 550 | .destroy: |
774 | Rus | 551 | mov eax, [esi] |
552 | test eax, 1 |
||
553 | jz .next |
||
554 | and eax, not 0xFFF |
||
555 | stdcall map_page,[tmp_task_ptab],eax,dword PG_SW |
||
556 | stdcall destroy_page_table, [tmp_task_ptab] |
||
557 | mov eax, [esi] |
||
558 | call free_page |
||
164 | serge | 559 | .next: |
774 | Rus | 560 | add esi, 4 |
561 | dec edi |
||
562 | jnz .destroy |
||
164 | serge | 563 | |
774 | Rus | 564 | mov eax, [pg_dir] |
565 | call free_page |
||
164 | serge | 566 | .exit: |
774 | Rus | 567 | stdcall map_page,[tmp_task_ptab],dword 0,dword PG_UNMAP |
568 | stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP |
||
569 | dec [pg_data.pg_mutex] |
||
570 | ret |
||
164 | serge | 571 | endp |
572 | |||
520 | serge | 573 | align 4 |
574 | get_pid: |
||
774 | Rus | 575 | mov eax, [TASK_BASE] |
819 | serge | 576 | mov eax, [eax+TASKDATA.pid] |
774 | Rus | 577 | ret |
520 | serge | 578 | |
164 | serge | 579 | pid_to_slot: |
580 | ;Input: |
||
581 | ; eax - pid of process |
||
582 | ;Output: |
||
583 | ; eax - slot of process or 0 if process don't exists |
||
584 | ;Search process by PID. |
||
585 | push ebx |
||
586 | push ecx |
||
587 | mov ebx,[TASK_COUNT] |
||
588 | shl ebx,5 |
||
589 | mov ecx,2*32 |
||
590 | |||
591 | .loop: |
||
592 | ;ecx=offset of current process info entry |
||
593 | ;ebx=maximum permitted offset |
||
594 | cmp byte [CURRENT_TASK+ecx+0xa],9 |
||
774 | Rus | 595 | jz .endloop ;skip empty slots |
164 | serge | 596 | cmp [CURRENT_TASK+ecx+0x4],eax ;check PID |
774 | Rus | 597 | jz .pid_found |
164 | serge | 598 | .endloop: |
599 | add ecx,32 |
||
600 | cmp ecx,ebx |
||
601 | jle .loop |
||
602 | |||
603 | pop ecx |
||
604 | pop ebx |
||
605 | xor eax,eax |
||
606 | ret |
||
607 | |||
608 | .pid_found: |
||
609 | shr ecx,5 |
||
774 | Rus | 610 | mov eax,ecx ;convert offset to index of slot |
164 | serge | 611 | pop ecx |
612 | pop ebx |
||
613 | ret |
||
614 | |||
615 | check_region: |
||
616 | ;input: |
||
617 | ; ebx - start of buffer |
||
618 | ; ecx - size of buffer |
||
619 | ;result: |
||
620 | ; eax = 1 region lays in app memory |
||
621 | ; eax = 0 region don't lays in app memory |
||
622 | mov eax,[CURRENT_TASK] |
||
623 | jmp check_process_region |
||
624 | ;----------------------------------------------------------------------------- |
||
625 | check_process_region: |
||
626 | ;input: |
||
627 | ; eax - slot |
||
628 | ; ebx - start of buffer |
||
629 | ; ecx - size of buffer |
||
630 | ;result: |
||
631 | ; eax = 1 region lays in app memory |
||
632 | ; eax = 0 region don't lays in app memory |
||
633 | |||
634 | test ecx,ecx |
||
635 | jle .ok |
||
636 | shl eax,5 |
||
637 | cmp word [CURRENT_TASK+eax+0xa],0 |
||
638 | jnz .failed |
||
639 | shl eax,3 |
||
380 | serge | 640 | mov eax,[SLOT_BASE+eax+0xb8] |
164 | serge | 641 | test eax,eax |
642 | jz .failed |
||
643 | |||
644 | mov eax,1 |
||
645 | ret |
||
646 | |||
647 | |||
648 | ; call MEM_Get_Linear_Address |
||
649 | ; push ebx |
||
650 | ; push ecx |
||
651 | ; push edx |
||
652 | ; mov edx,ebx |
||
653 | ; and edx,not (4096-1) |
||
654 | ; sub ebx,edx |
||
655 | ; add ecx,ebx |
||
656 | ; mov ebx,edx |
||
657 | ; add ecx,(4096-1) |
||
658 | ; and ecx,not (4096-1) |
||
659 | ;.loop: |
||
660 | ;;eax - linear address of page directory |
||
661 | ;;ebx - current page |
||
662 | ;;ecx - current size |
||
663 | ; mov edx,ebx |
||
664 | ; shr edx,22 |
||
665 | ; mov edx,[eax+4*edx] |
||
666 | ; and edx,not (4096-1) |
||
667 | ; test edx,edx |
||
668 | ; jz .failed1 |
||
669 | ; push eax |
||
670 | ; mov eax,edx |
||
671 | ; call MEM_Get_Linear_Address |
||
672 | ; mov edx,ebx |
||
673 | ; shr edx,12 |
||
674 | ; and edx,(1024-1) |
||
675 | ; mov eax,[eax+4*edx] |
||
676 | ; and eax,not (4096-1) |
||
677 | ; test eax,eax |
||
678 | ; pop eax |
||
679 | ; jz .failed1 |
||
680 | ; add ebx,4096 |
||
681 | ; sub ecx,4096 |
||
682 | ; jg .loop |
||
683 | ; pop edx |
||
684 | ; pop ecx |
||
685 | ; pop ebx |
||
686 | .ok: |
||
687 | mov eax,1 |
||
688 | ret |
||
689 | ; |
||
690 | ;.failed1: |
||
691 | ; pop edx |
||
692 | ; pop ecx |
||
693 | ; pop ebx |
||
694 | .failed: |
||
695 | xor eax,eax |
||
696 | ret |
||
697 | |||
698 | align 4 |
||
699 | proc read_process_memory |
||
700 | ;Input: |
||
701 | ; eax - process slot |
||
702 | ; ebx - buffer address |
||
703 | ; ecx - buffer size |
||
704 | ; edx - start address in other process |
||
705 | ;Output: |
||
706 | ; eax - number of bytes read. |
||
774 | Rus | 707 | locals |
708 | slot dd ? |
||
709 | buff dd ? |
||
710 | r_count dd ? |
||
711 | offset dd ? |
||
712 | tmp_r_cnt dd ? |
||
713 | endl |
||
164 | serge | 714 | |
774 | Rus | 715 | mov [slot], eax |
716 | mov [buff], ebx |
||
717 | and [r_count], 0 |
||
718 | mov [tmp_r_cnt], ecx |
||
719 | mov [offset], edx |
||
164 | serge | 720 | |
774 | Rus | 721 | pushad |
164 | serge | 722 | .read_mem: |
774 | Rus | 723 | mov edx, [offset] |
724 | mov ebx, [tmp_r_cnt] |
||
164 | serge | 725 | |
774 | Rus | 726 | mov ecx, 0x400000 |
727 | and edx, 0x3FFFFF |
||
728 | sub ecx, edx |
||
729 | cmp ecx, ebx |
||
730 | jbe @f |
||
731 | mov ecx, ebx |
||
164 | serge | 732 | @@: |
774 | Rus | 733 | cmp ecx, 0x8000 |
734 | jna @F |
||
735 | mov ecx, 0x8000 |
||
164 | serge | 736 | @@: |
774 | Rus | 737 | mov eax, [slot] |
738 | shl eax,8 |
||
739 | mov ebx, [offset] |
||
465 | serge | 740 | ; add ebx, new_app_base |
774 | Rus | 741 | push ecx |
742 | stdcall map_memEx, [proc_mem_map],\ |
||
743 | [SLOT_BASE+eax+0xB8],\ |
||
744 | ebx, ecx |
||
745 | pop ecx |
||
164 | serge | 746 | |
774 | Rus | 747 | mov esi, [offset] |
748 | and esi, 0xfff |
||
749 | add esi, [proc_mem_map] |
||
750 | mov edi, [buff] |
||
751 | mov edx, ecx |
||
752 | rep movsb |
||
753 | add [r_count], edx |
||
164 | serge | 754 | |
774 | Rus | 755 | add [offset], edx |
756 | sub [tmp_r_cnt], edx |
||
757 | jnz .read_mem |
||
164 | serge | 758 | |
774 | Rus | 759 | popad |
760 | mov eax, [r_count] |
||
761 | ret |
||
164 | serge | 762 | endp |
763 | |||
764 | align 4 |
||
765 | proc write_process_memory |
||
766 | ;Input: |
||
767 | ; eax - process slot |
||
768 | ; ebx - buffer address |
||
769 | ; ecx - buffer size |
||
770 | ; edx - start address in other process |
||
771 | ;Output: |
||
772 | ; eax - number of bytes written |
||
773 | |||
774 | Rus | 774 | locals |
775 | slot dd ? |
||
776 | buff dd ? |
||
777 | w_count dd ? |
||
778 | offset dd ? |
||
779 | tmp_w_cnt dd ? |
||
780 | endl |
||
164 | serge | 781 | |
774 | Rus | 782 | mov [slot], eax |
783 | mov [buff], ebx |
||
784 | and [w_count], 0 |
||
785 | mov [tmp_w_cnt], ecx |
||
786 | mov [offset], edx |
||
164 | serge | 787 | |
774 | Rus | 788 | pushad |
164 | serge | 789 | .read_mem: |
774 | Rus | 790 | mov edx, [offset] |
791 | mov ebx, [tmp_w_cnt] |
||
164 | serge | 792 | |
774 | Rus | 793 | mov ecx, 0x400000 |
794 | and edx, 0x3FFFFF |
||
795 | sub ecx, edx |
||
796 | cmp ecx, ebx |
||
797 | jbe @f |
||
798 | mov ecx, ebx |
||
164 | serge | 799 | @@: |
774 | Rus | 800 | cmp ecx, 0x8000 |
801 | jna @F |
||
802 | mov ecx, 0x8000 |
||
164 | serge | 803 | @@: |
774 | Rus | 804 | mov eax, [slot] |
805 | shl eax,8 |
||
806 | mov ebx, [offset] |
||
465 | serge | 807 | ; add ebx, new_app_base |
774 | Rus | 808 | push ecx |
809 | stdcall map_memEx, [proc_mem_map],\ |
||
810 | [SLOT_BASE+eax+0xB8],\ |
||
811 | ebx, ecx |
||
812 | pop ecx |
||
164 | serge | 813 | |
774 | Rus | 814 | mov edi, [offset] |
815 | and edi, 0xfff |
||
816 | add edi, [proc_mem_map] |
||
817 | mov esi, [buff] |
||
818 | mov edx, ecx |
||
819 | rep movsb |
||
164 | serge | 820 | |
774 | Rus | 821 | add [w_count], edx |
822 | add [offset], edx |
||
823 | sub [tmp_w_cnt], edx |
||
824 | jnz .read_mem |
||
164 | serge | 825 | |
774 | Rus | 826 | popad |
827 | mov eax, [w_count] |
||
828 | ret |
||
164 | serge | 829 | endp |
830 | |||
831 | align 4 |
||
832 | proc new_sys_threads |
||
774 | Rus | 833 | locals |
834 | slot dd ? |
||
835 | app_cmdline dd ? ;0x00 |
||
836 | app_path dd ? ;0x04 |
||
837 | app_eip dd ? ;0x08 |
||
838 | app_esp dd ? ;0x0C |
||
839 | app_mem dd ? ;0x10 |
||
840 | endl |
||
164 | serge | 841 | |
774 | Rus | 842 | cmp eax,1 |
843 | jne .failed ;other subfunctions |
||
164 | serge | 844 | |
774 | Rus | 845 | xor eax,eax |
846 | mov [app_cmdline], eax |
||
847 | mov [app_path], eax |
||
848 | mov [app_eip], ebx |
||
849 | mov [app_esp], ecx |
||
164 | serge | 850 | |
774 | Rus | 851 | ;mov esi,new_process_loading |
852 | ;call sys_msg_board_str |
||
853 | DEBUGF 1,"%s",new_process_loading |
||
164 | serge | 854 | .wait_lock: |
774 | Rus | 855 | cmp [application_table_status],0 |
856 | je .get_lock |
||
857 | call change_task |
||
858 | jmp .wait_lock |
||
164 | serge | 859 | |
860 | .get_lock: |
||
774 | Rus | 861 | mov eax, 1 |
862 | xchg eax, [application_table_status] |
||
863 | cmp eax, 0 |
||
864 | jne .wait_lock |
||
164 | serge | 865 | |
774 | Rus | 866 | call set_application_table_status |
164 | serge | 867 | |
774 | Rus | 868 | call get_new_process_place |
869 | test eax, eax |
||
870 | jz .failed |
||
164 | serge | 871 | |
774 | Rus | 872 | mov [slot], eax |
164 | serge | 873 | |
774 | Rus | 874 | mov esi,[current_slot] |
875 | mov ebx,esi ;ebx=esi - pointer to extended information about current thread |
||
164 | serge | 876 | |
774 | Rus | 877 | mov edi, eax |
878 | shl edi,8 |
||
879 | add edi,SLOT_BASE |
||
880 | mov edx,edi ;edx=edi - pointer to extended infomation about new thread |
||
881 | mov ecx,256/4 |
||
882 | xor eax, eax |
||
883 | cld |
||
884 | rep stosd ;clean extended information about new thread |
||
885 | mov esi,ebx |
||
886 | mov edi,edx |
||
887 | mov ecx,11 |
||
888 | rep movsb ;copy process name |
||
164 | serge | 889 | |
774 | Rus | 890 | mov eax,[ebx+APPDATA.heap_base] |
891 | mov [edx+APPDATA.heap_base], eax |
||
164 | serge | 892 | |
774 | Rus | 893 | mov ecx,[ebx+APPDATA.heap_top] |
894 | mov [edx+APPDATA.heap_top], ecx |
||
237 | serge | 895 | |
774 | Rus | 896 | mov eax,[ebx+APPDATA.mem_size] |
897 | mov [edx+APPDATA.mem_size], eax |
||
237 | serge | 898 | |
774 | Rus | 899 | mov ecx,[ebx+APPDATA.dir_table] |
900 | mov [edx+APPDATA.dir_table],ecx ;copy page directory |
||
237 | serge | 901 | |
774 | Rus | 902 | lea eax, [app_cmdline] |
903 | stdcall set_app_params ,[slot],eax,dword 0,\ |
||
904 | dword 0,dword 0 |
||
237 | serge | 905 | |
774 | Rus | 906 | ;mov esi,new_process_running |
907 | ;call sys_msg_board_str ;output information about succefull startup |
||
908 | DEBUGF 1,"%s",new_process_running |
||
164 | serge | 909 | |
774 | Rus | 910 | mov [application_table_status],0 ;unlock application_table_status mutex |
911 | mov eax,[process_number] ;set result |
||
912 | ret |
||
164 | serge | 913 | .failed: |
774 | Rus | 914 | mov [application_table_status],0 |
915 | mov eax,-1 |
||
916 | ret |
||
164 | serge | 917 | endp |
918 | |||
276 | serge | 919 | ; param |
920 | ; ebx=mutex |
||
921 | |||
164 | serge | 922 | align 4 |
276 | serge | 923 | wait_mutex: |
774 | Rus | 924 | push eax |
925 | push ebx |
||
321 | diamond | 926 | .do_wait: |
774 | Rus | 927 | cmp dword [ebx],0 |
928 | je .get_lock |
||
929 | call change_task |
||
930 | jmp .do_wait |
||
164 | serge | 931 | .get_lock: |
774 | Rus | 932 | mov eax, 1 |
933 | xchg eax, [ebx] |
||
934 | test eax, eax |
||
935 | jnz .do_wait |
||
936 | pop ebx |
||
937 | pop eax |
||
938 | ret |
||
164 | serge | 939 | |
774 | Rus | 940 | EFL_IF equ 0x0200 |
465 | serge | 941 | EFL_IOPL1 equ 0x1000 |
942 | EFL_IOPL2 equ 0x2000 |
||
943 | EFL_IOPL3 equ 0x3000 |
||
944 | |||
945 | |||
237 | serge | 946 | align 4 |
947 | proc set_app_params stdcall,slot:dword, params:dword,\ |
||
774 | Rus | 948 | cmd_line:dword, app_path:dword, flags:dword |
164 | serge | 949 | |
774 | Rus | 950 | locals |
951 | pl0_stack dd ? |
||
952 | endl |
||
237 | serge | 953 | |
774 | Rus | 954 | stdcall kernel_alloc, RING0_STACK_SIZE+512 |
955 | mov [pl0_stack], eax |
||
357 | serge | 956 | |
774 | Rus | 957 | lea edi, [eax+RING0_STACK_SIZE] |
357 | serge | 958 | |
774 | Rus | 959 | mov eax, [slot] |
960 | mov ebx, eax |
||
357 | serge | 961 | |
774 | Rus | 962 | shl eax, 8 |
963 | mov [eax+SLOT_BASE+APPDATA.fpu_state], edi |
||
964 | mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0 |
||
965 | mov [eax+SLOT_BASE+APPDATA.sse_handler], 0 |
||
357 | serge | 966 | |
465 | serge | 967 | ;set default io permission map |
774 | Rus | 968 | mov [eax+SLOT_BASE+APPDATA.io_map],\ |
969 | (tss._io_map_0-OS_BASE+PG_MAP) |
||
970 | mov [eax+SLOT_BASE+APPDATA.io_map+4],\ |
||
971 | (tss._io_map_1-OS_BASE+PG_MAP) |
||
465 | serge | 972 | |
774 | Rus | 973 | mov esi, fpu_data |
974 | mov ecx, 512/4 |
||
975 | rep movsd |
||
237 | serge | 976 | |
774 | Rus | 977 | cmp ebx,[TASK_COUNT] |
978 | jle .noinc |
||
979 | inc dword [TASK_COUNT] ;update number of processes |
||
237 | serge | 980 | .noinc: |
774 | Rus | 981 | shl ebx,8 |
982 | lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET] |
||
983 | mov [SLOT_BASE+APPDATA.fd_ev+ebx],edx |
||
984 | mov [SLOT_BASE+APPDATA.bk_ev+ebx],edx |
||
354 | serge | 985 | |
774 | Rus | 986 | add edx, APP_OBJ_OFFSET-APP_EV_OFFSET |
987 | mov [SLOT_BASE+APPDATA.fd_obj+ebx],edx |
||
988 | mov [SLOT_BASE+APPDATA.bk_obj+ebx],edx |
||
237 | serge | 989 | |
774 | Rus | 990 | mov ecx, [def_cursor] |
991 | mov [SLOT_BASE+APPDATA.cursor+ebx],ecx |
||
992 | mov eax, [pl0_stack] |
||
993 | mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax |
||
994 | add eax, RING0_STACK_SIZE |
||
995 | mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax |
||
281 | serge | 996 | |
774 | Rus | 997 | push ebx |
998 | stdcall kernel_alloc, 0x1000 |
||
999 | pop ebx |
||
1000 | mov esi,[current_slot] |
||
1001 | mov esi,[esi+APPDATA.cur_dir] |
||
1002 | mov ecx,0x1000/4 |
||
1003 | mov edi,eax |
||
1004 | mov [ebx+SLOT_BASE+APPDATA.cur_dir],eax |
||
1005 | rep movsd |
||
521 | diamond | 1006 | |
774 | Rus | 1007 | shr ebx,3 |
1008 | mov eax, new_app_base |
||
1009 | mov dword [CURRENT_TASK+ebx+0x10],eax |
||
237 | serge | 1010 | |
1011 | .add_command_line: |
||
774 | Rus | 1012 | mov edx,[params] |
1013 | mov edx,[edx] ;app_cmdline |
||
1014 | test edx,edx |
||
1015 | jz @f ;application doesn't need parameters |
||
281 | serge | 1016 | |
774 | Rus | 1017 | mov eax, edx |
1018 | add eax, 256 |
||
1019 | jc @f |
||
281 | serge | 1020 | |
774 | Rus | 1021 | cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
1022 | ja @f |
||
281 | serge | 1023 | |
774 | Rus | 1024 | mov byte [edx], 0 ;force empty string if no cmdline given |
1025 | mov eax, [cmd_line] |
||
1026 | test eax, eax |
||
1027 | jz @f |
||
1028 | stdcall strncpy, edx, eax, 256 |
||
237 | serge | 1029 | @@: |
774 | Rus | 1030 | mov edx,[params] |
1031 | mov edx, [edx+4] ;app_path |
||
1032 | test edx,edx |
||
1033 | jz @F ;application don't need path of file |
||
1034 | mov eax, edx |
||
1035 | add eax, 1024 |
||
1036 | jc @f |
||
1037 | cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
||
1038 | ja @f |
||
1039 | stdcall strncpy, edx, [app_path], 1024 |
||
237 | serge | 1040 | @@: |
774 | Rus | 1041 | mov ebx,[slot] |
1042 | mov eax,ebx |
||
1043 | shl ebx,5 |
||
1044 | lea ecx,[draw_data+ebx] ;ecx - pointer to draw data |
||
465 | serge | 1045 | |
237 | serge | 1046 | ; set window state to 'normal' (non-minimized/maximized/rolled-up) state |
774 | Rus | 1047 | mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL |
1048 | mov [ebx+window_data+WDATA.fl_redraw], 1 |
||
1049 | add ebx,CURRENT_TASK ;ebx - pointer to information about process |
||
1050 | mov [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot |
||
237 | serge | 1051 | |
774 | Rus | 1052 | mov [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function) |
237 | serge | 1053 | |
774 | Rus | 1054 | inc dword [process_number] |
1055 | mov eax,[process_number] |
||
1056 | mov [ebx+4],eax ;set PID |
||
237 | serge | 1057 | |
1058 | ;set draw data to full screen |
||
1059 | |||
774 | Rus | 1060 | mov [ecx+0],dword 0 |
1061 | mov [ecx+4],dword 0 |
||
1062 | mov eax,[Screen_Max_X] |
||
1063 | mov [ecx+8],eax |
||
1064 | mov eax,[Screen_Max_Y] |
||
1065 | mov [ecx+12],eax |
||
237 | serge | 1066 | |
774 | Rus | 1067 | mov ebx, [pl0_stack] |
1068 | mov esi,[params] |
||
1069 | lea ecx, [ebx+REG_EIP] |
||
1070 | xor eax, eax |
||
237 | serge | 1071 | |
774 | Rus | 1072 | mov [ebx+REG_RET], dword irq0.return |
1073 | mov [ebx+REG_EDI], eax |
||
1074 | mov [ebx+REG_ESI], eax |
||
1075 | mov [ebx+REG_EBP], eax |
||
1076 | mov [ebx+REG_ESP], ecx ;ebx+REG_EIP |
||
1077 | mov [ebx+REG_EBX], eax |
||
1078 | mov [ebx+REG_EDX], eax |
||
1079 | mov [ebx+REG_ECX], eax |
||
1080 | mov [ebx+REG_EAX], eax |
||
237 | serge | 1081 | |
774 | Rus | 1082 | mov eax, [esi+0x08] ;app_eip |
1083 | mov [ebx+REG_EIP], eax ;app_entry |
||
1084 | mov [ebx+REG_CS], dword app_code |
||
1085 | mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF |
||
465 | serge | 1086 | |
774 | Rus | 1087 | mov eax, [esi+0x0C] ;app_esp |
1088 | mov [ebx+REG_APP_ESP], eax ;app_stack |
||
1089 | mov [ebx+REG_SS], dword app_data |
||
237 | serge | 1090 | |
774 | Rus | 1091 | lea ecx, [ebx+REG_RET] |
1092 | mov ebx, [slot] |
||
1093 | shl ebx, 5 |
||
1094 | mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], ecx |
||
237 | serge | 1095 | |
774 | Rus | 1096 | xor ecx, ecx ; process state - running |
237 | serge | 1097 | ; set if debuggee |
774 | Rus | 1098 | test byte [flags], 1 |
1099 | jz .no_debug |
||
1100 | inc ecx ; process state - suspended |
||
1101 | mov eax,[CURRENT_TASK] |
||
1102 | mov [SLOT_BASE+ebx*8+APPDATA.debugger_slot],eax |
||
237 | serge | 1103 | .no_debug: |
774 | Rus | 1104 | mov [CURRENT_TASK+ebx+TASKDATA.state], cl |
1105 | ;mov esi,new_process_running |
||
1106 | ;call sys_msg_board_str ;output information about succefull startup |
||
1107 | DEBUGF 1,"%s",new_process_running |
||
1108 | ret |
||
237 | serge | 1109 | endp |
1110 | |||
164 | serge | 1111 | include "debug.inc"256 |