Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2130 → Rev 2129

/kernel/branches/Kolibri-acpi/core/timers.inc
File deleted
/kernel/branches/Kolibri-acpi/core/apic.inc
5,7 → 5,7
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
IRQ_RESERVED = 24 ; 16 or 24
IRQ_RESERVE = 24 ; 16 or 24
 
iglobal
IRQ_COUNT dd 24
62,11 → 62,10
shr eax, 16
inc al
movzx eax, al
cmp al, IRQ_RESERVED
cmp al, IRQ_RESERVE
jbe @f
mov al, IRQ_RESERVED
@@:
mov [IRQ_COUNT], eax
mov al, IRQ_RESERVE
@@: mov [IRQ_COUNT], eax
 
; Reroute IOAPIC & mask all interrupts
xor ecx, ecx
107,7 → 106,7
 
;init handlers table
 
mov ecx, IRQ_RESERVED
mov ecx, IRQ_RESERVE
mov edi, irqh_tab
@@:
mov eax, edi
/kernel/branches/Kolibri-acpi/core/exports.inc
85,14 → 85,7
szStrchr db 'strchr',0
szStrrchr db 'strrchr',0
 
szDiskAdd db 'DiskAdd',0
szDiskDel db 'DiskDel',0
szDiskMediaChanged db 'DiskMediaChanged',0
 
szTimerHS db 'TimerHS',0
szCancelTimerHS db 'CancelTimerHS',0
 
 
align 16
kernel_export:
dd szRegService , reg_service
/kernel/branches/Kolibri-acpi/core/irq.inc
5,10 → 5,6
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
IRQ_POOL_SIZE equ 48
 
 
macro __list_add new, prev, next
{
mov [next+LHEAD.prev], new
32,13 → 28,13
uglobal
 
align 16
irqh_tab rd LHEAD.sizeof * IRQ_RESERVED / 4
irqh_tab rd LHEAD.sizeof * IRQ_RESERVE / 4
 
irqh_pool rd IRQH.sizeof * IRQ_POOL_SIZE /4
irqh_pool rd IRQH.sizeof *48 /4
next_irqh rd 1
 
irq_active_set rd 1
irq_failed rd IRQ_RESERVED
irq_failed rd IRQ_RESERVE
 
endg
 
48,6 → 44,8
.irqh dd ?
endl
 
xchg bx, bx
 
and [.irqh], 0
 
push ebx
56,7 → 54,7
test ebx, ebx
jz .err
 
cmp ebx, IRQ_RESERVED
cmp ebx, IRQ_RESERVE
jae .err
 
mov edx, [handler]
74,10 → 72,9
 
mov eax, [ecx]
mov [next_irqh], eax
 
mov [.irqh], ecx
 
mov [irq_failed+ebx*4], 0 ;clear counter
 
mov eax, [user_data]
mov [ecx+IRQH.handler], edx
mov [ecx+IRQH.data], eax
84,8 → 81,9
 
lea edx, [irqh_tab+ebx*8]
list_add_tail ecx, edx ;clobber eax
stdcall enable_irq, ebx
 
stdcall enable_irq, [irq]
 
.fail:
popfd
.err:
118,6 → 116,7
endp
 
 
 
macro irq_serv_h [num] {
forward
align 4
143,6 → 142,8
.main:
save_ring3_context
 
xchg bx, bx
 
mov ebp, [esp + 32]
mov bx, app_data ;os_data
mov ds, bx
211,15 → 212,4
add esp, 4
iret
 
align 4
irqD:
push eax
push ecx
xor eax,eax
out 0xf0,al
mov eax, 13
call IRQ_EOI
pop ecx
pop eax
iret
 
/kernel/branches/Kolibri-acpi/core/sys32.inc
54,7 → 54,7
dd irq_serv.irq_22
dd irq_serv.irq_23
 
times 32 - IRQ_RESERVED dd unknown_interrupt
times 32 - IRQ_RESERVE dd unknown_interrupt
;int_0x40 gate trap (for directly copied)
dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16
 
246,6 → 246,18
 
 
align 4
irqD:
push eax
xor eax,eax
out 0xf0,al
mov al,0x20
out 0xa0,al
out 0x20,al
pop eax
iret
 
 
align 4
set_application_table_status:
push eax
 
670,13 → 682,8
restore .slot
 
iglobal
if lang eq ru
boot_sched_1 db '‘®§¤ ­¨¥ GDT TSS 㪠§ â¥«ï',0
boot_sched_2 db '‘®§¤ ­¨¥ IDT â ¡«¨æë',0
else
boot_sched_1 db 'Building gdt tss pointer',0
boot_sched_2 db 'Building IDT table',0
end if
endg
 
 
/kernel/branches/Kolibri-acpi/core/memory.inc
214,32 → 214,30
 
align 4
commit_pages:
push edi
test ecx, ecx
jz .fail
 
push edi
push eax
push ecx
mov ecx, pg_data.mutex
call mutex_lock
pop ecx
pop eax
mov edi, ebx
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
mov edi, ebx
shr edi, 12
lea edi, [page_tabs+edi*4]
mov edx, 0x1000
mov ebx, edi
shr ebx, 12
@@:
stosd
invlpg [ebx]
add eax, 0x1000
add ebx, 0x1000
loop @B
 
mov [page_tabs+ebx*4], eax
; push eax
invlpg [edi]
; pop eax
add edi, edx
add eax, edx
inc ebx
dec ecx
jnz @B
mov [pg_data.pg_mutex],ecx
.fail:
pop edi
 
mov ecx, pg_data.mutex
call mutex_unlock
.fail:
ret
 
 
250,22 → 248,16
align 4
release_pages:
 
push ebp
push esi
push edi
push ebx
pushad
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
mov esi, eax
mov edi, eax
 
shr esi, 12
lea esi, [page_tabs+esi*4]
shr esi, 10
add esi, page_tabs
 
push ecx
mov ecx, pg_data.mutex
call mutex_lock
pop ecx
 
mov ebp, [pg_data.pages_free]
mov ebx, [page_start]
mov edx, sys_pgmap
272,7 → 264,9
@@:
xor eax, eax
xchg eax, [esi]
push eax
invlpg [edi]
pop eax
 
test eax, 1
jz .next
291,16 → 285,11
.next:
add edi, 0x1000
add esi, 4
loop @B
 
dec ecx
jnz @B
mov [pg_data.pages_free], ebp
mov ecx, pg_data.mutex
call mutex_unlock
 
pop ebx
pop edi
pop esi
pop ebp
and [pg_data.pg_mutex],0
popad
ret
 
; param
434,8 → 423,8
align 4
proc new_mem_resize stdcall, new_size:dword
 
mov ecx, pg_data.mutex
call mutex_lock
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
mov edi, [new_size]
add edi,4095
475,10 → 464,8
mov ebx, [new_size]
call update_mem_size
 
mov ecx, pg_data.mutex
call mutex_unlock
 
xor eax, eax
dec [pg_data.pg_mutex]
ret
.expand:
 
552,11 → 539,9
pop edi
pop esi
.exit:
mov ecx, pg_data.mutex
call mutex_unlock
 
xor eax, eax
inc eax
dec [pg_data.pg_mutex]
ret
endp
 
/kernel/branches/Kolibri-acpi/core/taskman.inc
360,8 → 360,8
app_tabs dd ?
endl
 
mov ecx, pg_data.mutex
call mutex_lock
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
xor eax, eax
mov [dir_addr], eax
480,13 → 480,11
.done:
stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP
 
mov ecx, pg_data.mutex
call mutex_unlock
dec [pg_data.pg_mutex]
mov eax, [dir_addr]
ret
.fail:
mov ecx, pg_data.mutex
call mutex_unlock
dec [pg_data.pg_mutex]
cmp [dir_addr], 0
je @f
stdcall destroy_app_space, [dir_addr], 0
556,10 → 554,10
jg .ret
;if there isn't threads then clear memory.
mov esi, [dlls_list]
call destroy_all_hdlls ;ecx=APPDATA
call destroy_all_hdlls
 
mov ecx, pg_data.mutex
call mutex_lock
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
mov eax, [pg_dir]
and eax, not 0xFFF
585,8 → 583,7
.exit:
stdcall map_page,[tmp_task_ptab],0,PG_UNMAP
stdcall map_page,[tmp_task_pdir],0,PG_UNMAP
mov ecx, pg_data.mutex
call mutex_unlock
dec [pg_data.pg_mutex]
.ret:
ret
endp
959,7 → 956,25
ret
endp
 
; param
; ebx=mutex
 
align 4
wait_mutex:
;;Maxis use atomic bts for mutex 4.4.2009
push eax
push ebx
.do_wait:
bts dword [ebx],0
jnc .locked
call change_task
jmp .do_wait
.locked:
pop ebx
pop eax
ret
 
align 4
tls_app_entry:
 
call init_heap
/kernel/branches/Kolibri-acpi/core/v86.inc
328,7 → 328,7
cmp edx, -1
jz .noirqhook
uglobal
v86_irqhooks rd IRQ_RESERVED * 2
v86_irqhooks rd IRQ_RESERVE * 2
endg
cmp [v86_irqhooks+edx*8], 0
jz @f
839,7 → 839,6
; mov byte [BOOT_VAR + 48Eh], 0FFh
; ret
 
align 4
v86_irq:
; push irq/pushad/jmp v86_irq
; eax = irq
/kernel/branches/Kolibri-acpi/core/heap.inc
151,8 → 151,7
 
mov [mem_block_list+63*4], ebx
mov byte [mem_block_map], 0xFC
mov ecx, heap_mutex
call mutex_init
and [heap_mutex], 0
mov [heap_blocks], 4095
mov [free_blocks], 4094
ret
273,14 → 272,14
push esi
push edi
 
mov ecx, heap_mutex
call mutex_lock
 
mov eax, [size]
add eax, 4095
and eax, not 4095
mov [size], eax
 
mov ebx, heap_mutex
call wait_mutex ;ebx
 
cmp eax, [heap_free]
ja .error
 
356,11 → 355,10
mov [edx+list_bk], esi
 
mov [esi+block_flags], USED_BLOCK
mov eax, [esi+block_base]
mov ebx, [size]
sub [heap_free], ebx
mov ecx, heap_mutex
call mutex_unlock
mov eax, [esi+block_base]
and [heap_mutex], 0
pop edi
pop esi
pop ebx
380,19 → 378,17
mov [edx+list_bk], edi
 
mov [edi+block_flags], USED_BLOCK
mov eax, [edi+block_base]
mov ebx, [size]
sub [heap_free], ebx
mov ecx, heap_mutex
call mutex_unlock
mov eax, [edi+block_base]
and [heap_mutex], 0
pop edi
pop esi
pop ebx
ret
.error:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
pop edi
pop esi
pop ebx
404,10 → 400,9
push ebx
push esi
push edi
mov ebx, heap_mutex
call wait_mutex ;ebx
 
mov ecx, heap_mutex
call mutex_lock
 
mov eax, [base]
mov esi, [mem_used.fd]
@@:
496,10 → 491,9
@@:
bts [mem_block_mask], eax
.m_eq:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
not eax
mov [heap_mutex], eax
dec eax
pop edi
pop esi
pop ebx
519,18 → 513,16
@@:
bts [mem_block_mask], eax
mov [esi+block_flags],FREE_BLOCK
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
not eax
mov [heap_mutex], eax
dec eax
pop edi
pop esi
pop ebx
ret
.fail:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
pop edi
pop esi
pop ebx
615,8 → 607,8
proc kernel_free stdcall, base:dword
push ebx esi
 
mov ecx, heap_mutex
call mutex_lock
mov ebx, heap_mutex
call wait_mutex ;ebx
 
mov eax, [base]
mov esi, [mem_used.fd]
632,17 → 624,19
cmp [esi+block_flags], USED_BLOCK
jne .fail
 
call mutex_unlock
and [heap_mutex], 0
 
push ecx
mov ecx, [esi+block_size];
shr ecx, 12
call release_pages ;eax, ecx
pop ecx
stdcall free_kernel_space, [base]
pop esi ebx
ret
.fail:
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
pop esi ebx
ret
endp
/kernel/branches/Kolibri-acpi/core/malloc.inc
20,7 → 20,7
; esi= nb
; ebx= idx
;
align 4
align 16
malloc:
push esi
 
31,8 → 31,8
and esi, -8
add esi, 8
 
mov ecx, mst.mutex
call mutex_lock
mov ebx, mst.mutex
call wait_mutex ;ebx
 
cmp esi, 256
jae .large
92,13 → 92,9
pop edi
pop ebp
.done:
mov esi, eax
mov ecx, mst.mutex
call mutex_unlock
mov eax, esi
pop esi
mov [mst.mutex], 0
ret
 
.split:
lea ebx, [edx+8] ;ebx=mem
 
137,10 → 133,10
mov [edx+12], eax ; F->bk = r;
mov [eax+8], edx ; r->fd = F;
mov [eax+12], ecx ; r->bk = B;
 
mov eax, ebx
jmp .done
 
pop esi
mov [mst.mutex], 0
ret
.small:
 
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0)
154,8 → 150,9
call malloc_small
test eax, eax
jz .from_top
jmp .done
 
pop esi
and [mst.mutex], 0
ret
.large:
 
; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0)
192,15 → 189,18
mov [edx+4], eax
mov [ecx+4], esi
lea eax, [ecx+8]
jmp .done
 
pop esi
and [mst.mutex], 0
ret
.fail:
xor eax, eax
jmp .done
pop esi
and [mst.mutex], 0
ret
 
; param
; eax= mem
align 4
 
free:
push edi
mov edi, eax
211,8 → 211,8
test byte [edi+4], 2
je .fail
 
mov ecx, mst.mutex
call mutex_lock
mov ebx, mst.mutex
call wait_mutex ;ebx
 
; psize = p->head & (~3);
 
289,10 → 289,7
mov [mst.top], edi
mov [edi+4], eax
.fail2:
mov esi, eax
mov ecx, mst.mutex
call mutex_unlock
mov eax, esi
and [mst.mutex], 0
pop esi
.fail:
pop edi
413,15 → 410,13
mov [esi+8], edx ;P->fd = F
mov [esi+12], eax ;P->bk = B
pop esi
mov ecx, mst.mutex
call mutex_unlock
and [mst.mutex], 0
ret
.large:
mov ebx, eax
call insert_large_chunk
pop esi
mov ecx, mst.mutex
call mutex_unlock
and [mst.mutex], 0
ret
 
 
1030,8 → 1025,5
cmp eax, mst.smallbins+512
jb @B
 
mov ecx, mst.mutex
call mutex_init
 
ret
 
/kernel/branches/Kolibri-acpi/data32.inc
47,34 → 47,8
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
 
 
if lang eq ru
boot_fonts db '˜à¨äâë § £à㦥­ë',0
boot_memdetect db 'Š®«¨ç¥á⢮ ®¯¥à â¨¢­®© ¯ ¬ïâ¨',' ',' Œ¡',0
boot_tss db '“áâ ­®¢ª  TSSs',0
boot_cpuid db '—⥭¨¥ CPUIDs',0
boot_devices db '®¨áª ãáâனáâ¢',0
boot_timer db '“áâ ­®¢ª  â ©¬¥à ',0
boot_irqs db '¥à¥®¯à¥¤¥«¥­¨¥ IRQ',0
boot_setmouse db '“áâ ­®¢ª  ¬ëè¨',0
boot_windefs db '“áâ ­®¢ª  ­ áâ஥ª ®ª®­ ¯® 㬮«ç ­¨î',0
boot_bgr db '“áâ ­®¢ª  ä®­ ',0
boot_resirqports db '¥§¥à¢¨à®¢ ­¨¥ IRQ ¨ ¯®à⮢',0
boot_setrports db '“áâ ­®¢ª   ¤à¥á®¢ IRQ',0
boot_setostask db '‘®§¤ ­¨¥ ¯à®æ¥áá  ï¤à ',0
boot_allirqs db 'Žâªàë⨥ ¢á¥å IRQ',0
boot_tsc db '—⥭¨¥ TSC',0
boot_cpufreq db '— áâ®â  ¯à®æ¥áá®à  ',' ',' Œƒæ',0
boot_pal_ega db '“áâ ­®¢ª  EGA/CGA 320x200 ¯ «¨âàë',0
boot_pal_vga db '“áâ ­®¢ª  VGA 640x480 ¯ «¨âàë',0
boot_failed db '‡ £à㧪  ¯¥à¢®£® ¯à¨«®¦¥­¨ï ­¥ 㤠« áì',0
boot_mtrr db '“áâ ­®¢ª  MTRR',0
if preboot_blogesc
boot_tasking db '‚ᥠ£®â®¢® ¤«ï § ¯ã᪠, ­ ¦¬¨âॠESC ¤«ï áâ àâ ',0
end if
else
boot_memdetect db 'Determining amount of memory',0
boot_fonts db 'Fonts loaded',0
boot_memdetect db 'Determining amount of memory',0
boot_tss db 'Setting TSSs',0
boot_cpuid db 'Reading CPUIDs',0
boot_devices db 'Detecting devices',0
89,15 → 63,13
boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0
boot_pal_vga db 'Setting VGA 640x480 palette',0
boot_failed db 'Failed to start first app',0
boot_mtrr db 'Setting MTRR',0
boot_APIC_found db 'APIC enabled', 0
boot_APIC_nfound db 'APIC not found', 0
 
if preboot_blogesc
boot_tasking db 'All set - press ESC to start',0
end if
end if
 
boot_APIC_found db 'APIC enabled', 0
boot_APIC_nfound db 'APIC not found', 0
 
;new_process_loading db 'K : New Process - loading',13,10,0
;new_process_running db 'K : New Process - done',13,10,0
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
308,7 → 280,7
mem_block_start rd 1
mem_block_end rd 1
 
heap_mutex MUTEX
heap_mutex rd 1
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
/kernel/branches/Kolibri-acpi/docs/drivers_api.txt
File deleted
/kernel/branches/Kolibri-acpi/drivers/vidintel.asm
File deleted
/kernel/branches/Kolibri-acpi/drivers/vt823x.asm
File deleted
\ No newline at end of file
/kernel/branches/Kolibri-acpi/drivers/sb16/sb16.asm
240,7 → 240,6
stdcall [callback],SB16Buffer1 ;for 64k buffer
end if
xor eax, eax
not eax
ret
 
.fill_second_half:
251,7 → 250,6
stdcall [callback],SB16Buffer3 ;for 64k buffer
end if
xor eax, eax
not eax
ret
endp
;-------------------------------------------------------------------------------
/kernel/branches/Kolibri-acpi/drivers/com_mouse.asm
332,7 → 332,7
 
mov [esi+COM_MOUSE_DATA.MouseByteNumber],0
.EndMouseInterrupt:
mov al, 1
 
ret
 
;all initialized data place here
/kernel/branches/Kolibri-acpi/fs/disk.inc
File deleted
/kernel/branches/Kolibri-acpi/fs/fat32.inc
60,7 → 60,6
ERROR_DISK_FULL = 8
ERROR_FAT_TABLE = 9
ERROR_ACCESS_DENIED = 10
ERROR_DEVICE = 11
 
PUSHAD_EAX equ [esp+28]
PUSHAD_ECX equ [esp+24]
/kernel/branches/Kolibri-acpi/fs/fs_lfn.inc
85,7 → 85,6
 
fs_additional_handlers:
dd biosdisk_handler, biosdisk_enum_root
dd dyndisk_handler, dyndisk_enum_root
; add new handlers here
dd 0
 
384,8 → 383,7
.notfounda:
cmp edi, esp
jnz .notfound
call dword [edi+4]
add esp, 16
add esp, 8
jmp .notfound
 
.found1:
852,8 → 850,6
jmp file_system_lfn.maindir_noesi
@@:
push ecx
push ecx
push biosdisk_cleanup
push fs_OnBd
mov edi, esp
jmp file_system_lfn.found2
862,11 → 858,10
cmp eax, [BiosDiskPartitions+ecx*4]
inc eax
cmc
biosdisk_cleanup:
ret
 
fs_OnBd:
pop edx edx edx edx
pop edx edx
; edx = disk number, ecx = partition number
; esi+ebp = name
call reserve_hd1
/kernel/branches/Kolibri-acpi/kernel.asm
321,12 → 321,6
mov eax, cr3
mov cr3, eax ; flush TLB
 
mov ecx, pg_data.mutex
call mutex_init
 
mov ecx, disk_list_mutex
call mutex_init
 
; SAVE REAL MODE VARIABLES
mov ax, [BOOT_VAR + 0x9031]
mov [IDEContrRegsBaseAddr], ax
719,11 → 713,7
call boot_log
 
movzx ecx, word [boot_y]
if lang eq ru
or ecx, (10+30*6) shl 16
else
or ecx, (10+29*6) shl 16
end if
or ecx, (10+29*6) shl 16 ; "Determining amount of memory"
sub ecx, 10
mov edx, 0xFFFFFF
mov ebx, [MEM_AMOUNT]
842,11 → 832,7
 
mov ebx, edx
movzx ecx, word [boot_y]
if lang eq ru
add ecx, (10+19*6) shl 16 - 10; 'Determining amount of memory'
else
add ecx, (10+17*6) shl 16 - 10; 'Determining amount of memory'
end if
add ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is '
mov edx, 0xFFFFFF
xor edi,edi
mov eax, 0x00040000
2284,18 → 2270,18
sound_flag db 0
endg
 
UID_NONE=0
UID_MENUETOS=1 ;official
UID_KOLIBRI=2 ;russian
 
iglobal
version_inf:
db 0,7,7,0 ; version 0.7.7.0
db 0
db UID_KOLIBRI
dd __REV__
version_end:
endg
 
UID_NONE=0
UID_MENUETOS=1 ;official
UID_KOLIBRI=2 ;russian
 
sys_cachetodiskette:
cmp ebx, 1
jne .no_floppy_a_save
/kernel/branches/Kolibri-acpi/kernel32.inc
223,7 → 223,6
include "core/v86.inc" ; virtual-8086 manager
include "core/apic.inc" ; Interrupt Controller functions
include "core/irq.inc" ; irq handling functions
include "core/timers.inc"
 
; GUI stuff
include "gui/window.inc"
235,7 → 234,6
 
; file system
 
include "fs/disk.inc" ; support for plug-n-play disks
include "fs/fs.inc" ; syscall
include "fs/fat32.inc" ; read / write for fat32 filesystem
include "fs/ntfs.inc" ; read / write for ntfs filesystem
/kernel/branches/Kolibri-acpi/const.inc
645,7 → 645,7
end virtual
 
struc MEM_STATE
{ .mutex MUTEX
{ .mutex rd 1
.smallmap rd 1
.treemap rd 1
.topsize rd 1
664,7 → 664,7
.kernel_pages dd ?
.kernel_tables dd ?
.sys_page_dir dd ?
.mutex MUTEX
.pg_mutex dd ?
}
 
;struc LIB
/kernel/branches/Kolibri-acpi/network/socket.inc
54,7 → 54,7
.SEG_LEN dd ? ; segment length
.SEG_WND dd ? ; segment window
.wndsizeTimer dd ? ; window size timer
.lock MUTEX ; lock mutex
.lock dd ? ; lock mutex
.rxData dd ? ; receive data buffer here
ends
 
99,11 → 99,6
rep stosd
pop eax
 
mov ebx, eax
lea ecx, [eax+SOCKET.lock]
call mutex_init
mov eax, ebx
 
; add socket to the list by changing pointers
mov ebx, net_sockets
push [ebx + SOCKET.NextPtr]
708,10 → 703,10
or eax, eax
jz .error
 
lea ebx, [eax + SOCKET.lock]
call wait_mutex
 
mov ebx, eax
lea ecx, [eax + SOCKET.lock]
call mutex_lock
 
mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes
test eax, eax
jz .error_release
732,18 → 727,15
and ecx, 3
rep movsb
 
lea ecx, [ebx + SOCKET.lock]
mov [ebx + SOCKET.lock], 0
mov ebx, eax
call mutex_unlock
mov eax, ebx
 
ret
 
.error_release:
lea ecx, [ebx + SOCKET.lock]
call mutex_unlock
mov [ebx + SOCKET.lock], 0
.error:
xor ebx, ebx
xor eax, eax
ret
endp
 
764,11 → 756,10
or eax, eax
jz .error
 
lea ebx, [eax + SOCKET.lock]
call wait_mutex
 
mov ebx, eax
 
lea ecx, [eax + SOCKET.lock]
call mutex_lock
 
mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes
test eax, eax ; if count of bytes is zero..
jz .exit ; exit function (eax will be zero)
798,9 → 789,7
rep movsb ; copy remaining bytes
 
.exit:
lea ecx, [ebx + SOCKET.lock]
call mutex_unlock
mov eax, edx
mov [ebx + SOCKET.lock], 0
ret ; at last, exit
 
.error:
811,9 → 800,7
xor esi, esi
mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero)
call .start_copy
lea ecx, [ebx + SOCKET.lock]
call mutex_unlock
mov eax, edx
mov [ebx + SOCKET.lock], 0
ret
 
.start_copy:
/kernel/branches/Kolibri-acpi/network/tcp.inc
963,10 → 963,12
jmp .exit
 
.data:
push ebx
add ebx, SOCKET.lock
call wait_mutex
pop ebx
 
push ecx
lea ecx, [ebx+SOCKET.lock]
call mutex_lock
 
push ebx
mov eax, [ebx + SOCKET.rxDataCount]
add eax, ecx
984,10 → 986,8
 
cld
rep movsb ; copy the data across
mov [ebx + SOCKET.lock], 0 ; release mutex
 
lea ecx,[ebx + SOCKET.lock]
call mutex_unlock
 
; flag an event to the application
pop ebx
call signal_network_event
1031,9 → 1031,8
.overflow:
; no place in buffer
; so simply restore stack and exit
lea ecx, [ebx + SOCKET.lock]
call mutex_unlock
pop eax ecx
mov [ebx + SOCKET.lock], 0
ret
endp
 
/kernel/branches/Kolibri-acpi/init.inc
266,6 → 266,7
add ebx, [pg_data.pagemap_size-OS_BASE]
mov [page_end-OS_BASE], ebx
 
mov [pg_data.pg_mutex-OS_BASE], 0
ret
endp
 
/kernel/branches/Kolibri-acpi/macros.inc
20,9 → 20,6
struc name arg {
}
 
macro declare_sizeof xname,value
{ sizeof.#xname = value }
 
macro struct_helper name
{
match xname,name
29,7 → 26,7
\{
virtual at 0
xname xname
declare_sizeof xname, $ - xname
sizeof.#xname = $ - xname
name equ sizeof.#xname
end virtual
\}