Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5564 → Rev 5565

/kernel/branches/Kolibri-acpi/core/apic.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
63,7 → 63,7
call IRQ_mask_all
 
; IOAPIC init
stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW+PG_NOCACHE
stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_GLOBAL+PG_NOCACHE+PG_SWR
mov [IOAPIC_base], eax
 
mov eax, IOAPIC_VER
127,7 → 127,7
cmp [LAPIC_BASE], 0
jne .done
 
stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE
stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR
mov [LAPIC_BASE], eax
mov esi, eax
 
/kernel/branches/Kolibri-acpi/core/clipboard.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2013-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/conf_lib-sp.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2013-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/conf_lib.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/debug.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/dll.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
517,7 → 517,7
test eax, eax
jz .err_3
 
or eax, PG_UW
or eax, PG_UWR
stosd
dec edx
jnz @B
579,7 → 579,7
@@:
lodsd
and eax, 0xFFFFF000
or eax, PG_UW
or eax, PG_UWR
stosd
loop @B
 
1144,7 → 1144,7
.map_pages_loop:
mov eax, [page_tabs+ecx*4]
and eax, not 0xFFF
or al, PG_USER
or al, PG_UR
xchg eax, [page_tabs+edx*4]
test al, 1
jz @f
/kernel/branches/Kolibri-acpi/core/export.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/exports.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45,6 → 45,11
release_pages, 'ReleasePages', \
alloc_dma24, 'AllocDMA24', \ ; stdcall
\
init_rwsem, 'InitRwsem', \ ; gcc fastcall
down_read, 'DownRead', \ ; gcc fastcall
down_write, 'DownWrite', \ ; gcc fastcall
up_read, 'UpRead', \ ; gcc fastcall
up_write, 'UpWrite', \ ; gcc fastacll
mutex_init, 'MutexInit', \ ; gcc fastcall
mutex_lock, 'MutexLock', \ ; gcc fastcall
mutex_unlock, 'MutexUnlock', \ ; gcc fastcall
117,7 → 122,9
NET_remove_device, 'NetUnRegDev', \
NET_ptr_to_num, 'NetPtrToNum', \
NET_link_changed, 'NetLinkChanged', \
ETH_input, 'Eth_input', \
ETH_input, 'EthInput', \
NET_BUFF_alloc, 'NetAlloc', \
NET_BUFF_free, 'NetFree', \
\
get_pcidev_list, 'GetPCIList', \
\
/kernel/branches/Kolibri-acpi/core/ext_lib.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/fpu.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/heap.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
130,7 → 130,7
 
stdcall alloc_pages, dword 32
 
or eax, PG_SW
or eax, PG_SWR
mov ebx, HEAP_BASE
mov ecx, 32
call commit_pages
492,7 → 492,7
jz .err
 
mov ecx, ebx
or eax, PG_SW
or eax, PG_GLOBAL+PG_SWR
mov ebx, [lin_addr]
call commit_pages
 
506,7 → 506,7
test eax, eax
jz .err
 
stdcall map_page, edx, eax, dword PG_SW
stdcall map_page, edx, eax, dword (PG_GLOBAL+PG_SWR)
add edx, 0x1000
dec ebx
jnz @B
1451,7 → 1451,7
mov edx, [access]
or edx, [owner_access]
shl edx, 1
or edx, PG_USER+PG_SHARED
or edx, PG_SHARED+PG_UR
@@:
lodsd
and eax, 0xFFFFF000
/kernel/branches/Kolibri-acpi/core/irq.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/malloc.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/memory.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
127,8 → 127,8
map_page:
push ebx
mov eax, [esp+12] ; phis_addr
and eax, not 0xFFF
or eax, [esp+16] ; flags
and eax, [pte_valid_mask]
mov ebx, [esp+8] ; lin_addr
shr ebx, 12
mov [page_tabs+ebx*4], eax
191,8 → 191,8
mov edx, [base]
shr eax, 12
shr ecx, 12
and edx, -4096
or edx, [flags]
and edx, [pte_valid_mask]
@@:
mov [page_tabs+eax*4], edx
invlpg [ebx]
229,6 → 229,7
pop ecx
pop eax
 
and eax, [pte_valid_mask ]
mov edi, ebx
shr edi, 12
lea edi, [page_tabs+edi*4]
340,7 → 341,7
shr ebx, 22
mov eax, [phis_addr]
and eax, not 0xFFF
or eax, PG_UW ;+PG_NOCACHE
or eax, PG_UWR
mov dword [master_tab+ebx*4], eax
mov eax, [lin_addr]
shr eax, 10
420,7 → 421,7
call alloc_page
stdcall map_page_table, LFB_BASE, eax
pop eax
or eax, PG_UW
or eax, PG_UWR
mov ebx, LFB_BASE
; max VGA=640*480*4=1228800 bytes
; + 32*640*4=81920 bytes for mouse pointer
447,7 → 448,7
 
bt [cpu_caps], CAPS_PSE
jnc .map_page_tables
or esi, PG_LARGE+PG_UW
or esi, PDE_LARGE+PG_UWR
mov edx, sys_proc+PROC.pdt_0+(LFB_BASE shr 20)
@@:
mov [edx], esi
476,14 → 477,14
 
mov eax, [LFBAddress]
mov edi, page_tabs + (LFB_BASE shr 10)
or eax, PG_UW
or eax, PG_GLOBAL+PG_UWR
and eax, [pte_valid_mask]
mov ecx, [pg_count]
cld
@@:
stosd
add eax, 0x1000
dec ecx
jnz @B
loop @B
 
mov dword [LFBAddress], LFB_BASE
mov eax, cr3 ;flush TLB
679,7 → 680,7
ret
 
.user_space:
test eax, PG_MAP
test eax, PG_READ
jnz .err_access ;Страница присутствует
;Ошибка доступа ?
 
687,7 → 688,7
mov ecx, ebx
shr ecx, 10
mov edx, [master_tab+ecx*4]
test edx, PG_MAP
test edx, PG_READ
jz .fail ;таблица страниц не создана
;неверный адрес в программе
 
700,7 → 701,7
test eax, eax
jz .fail
 
stdcall map_page, [.err_addr], eax, PG_UW
stdcall map_page, [.err_addr], eax, PG_UWR
 
mov edi, [.err_addr]
and edi, 0xFFFFF000
737,7 → 738,7
call alloc_page
test eax, eax
jz .fail
stdcall map_page, ebx, eax, PG_UW
stdcall map_page, ebx, eax, PG_UWR
mov edi, ebx
mov ecx, 1024
sub ebx, [esi+HDLL.base]
748,7 → 749,7
jmp .exit
 
.kernel_space:
test eax, PG_MAP
test eax, PG_READ
jz .fail ;страница не присутствует
 
test eax, 12 ;U/S (+below)
774,7 → 775,7
jz .fail
 
push eax
stdcall map_page, [.err_addr], eax, dword PG_SW
stdcall map_page, [.err_addr], eax, dword PG_SWR
pop eax
mov edi, [.err_addr]
and edi, -4096
783,7 → 784,7
mov ebx, esi
shr ebx, 12
mov edx, [current_slot]
or eax, PG_SW
or eax, PG_SWR
mov [edx+APPDATA.io_map+ebx*4], eax
 
add esi, [default_io_map]
818,7 → 819,7
mov esi, [ipc_ptab]
and eax, 0xFFFFF000
jz .exit
stdcall map_page, esi, eax, PG_SW
stdcall map_page, esi, eax, PG_SWR
@@:
mov edi, [lin_addr]
and edi, 0xFFFFF000
849,7 → 850,7
and eax, 0xFFFFF000
jz .exit
 
stdcall map_page, esi, eax, PG_SW
stdcall map_page, esi, eax, PG_SWR
xor edx, edx
jmp .map
.exit:
881,7 → 882,7
mov esi, [proc_mem_tab]
and eax, 0xFFFFF000
jz .exit
stdcall map_page, esi, eax, PG_SW
stdcall map_page, esi, eax, PG_SWR
@@:
mov edi, [lin_addr]
and edi, 0xFFFFF000
912,7 → 913,7
and eax, 0xFFFFF000
jz .exit
 
stdcall map_page, esi, eax, PG_SW
stdcall map_page, esi, eax, PG_SWR
xor edx, edx
jmp .map
.exit:
927,7 → 928,7
; destroys: only eax
proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword
mov eax, [esi+edx*4]
test al, PG_MAP
test al, PG_READ
jz .not_present
test al, PG_WRITE
jz .resolve_readonly
947,7 → 948,7
pop ecx
test eax, eax
jz .fail
or al, PG_UW
or al, PG_UWR
mov [esi+edx*4], eax
jmp .map
.resolve_readonly:
989,7 → 990,7
call alloc_page
test eax, eax
jz .no_hdll
or al, PG_UW
or al, PG_UWR
mov [esi+edx*4], eax
stdcall map_page, edi, eax, [req_access]
push esi edi
1090,7 → 1091,7
@@:
mov [used_buf], ecx
stdcall map_mem_ipc, ecx, [dst_slot], \
edi, esi, PG_SW
edi, esi, PG_SWR
 
mov edi, [dst_offset]
add edi, [used_buf]
/kernel/branches/Kolibri-acpi/core/mtrr.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25,21 → 25,65
 
; Helper procedure for mtrr_reconfigure and set_mtrr,
; called before changes in MTRRs.
; 1. disable and flush caches
; 2. clear PGE bit in cr4
; 3. flush TLB
; 4. disable mtrr
 
proc mtrr_begin_change
mov eax, cr0
or eax, 0x60000000 ;disable caching
mov cr0, eax
wbinvd ;invalidate cache
 
bt [cpu_caps], CAPS_PGE
jnc .cr3_flush
 
mov eax, cr4
btr eax, 7 ;clear cr4.PGE
mov cr4, eax ;flush TLB
jmp @F ;skip extra serialization
 
.cr3_flush:
mov eax, cr3
mov cr3, eax ;flush TLB
@@:
mov ecx, MSR_MTRR_DEF_TYPE
rdmsr
btr eax, 11 ;clear enable flag
wrmsr ;disable mtrr
ret
endp
 
; Helper procedure for mtrr_reconfigure and set_mtrr,
; called after changes in MTRRs.
; 1. enable mtrr
; 2. flush all caches
; 3. flush TLB
; 4. restore cr4.PGE flag, if required
 
proc mtrr_end_change
mov ecx, MSR_MTRR_DEF_TYPE
rdmsr
or ah, 8 ; enable variable-ranges MTRR
and al, 0xF0 ; default memtype = UC
wrmsr
 
wbinvd ;again invalidate
mov eax, cr0
and eax, not 0x60000000
mov cr0, eax ; enable caching
 
mov eax, cr3
mov cr3, eax ;flush tlb
 
bt [cpu_caps], CAPS_PGE
jnc @F
 
mov eax, cr4
bts eax, 7 ;set cr4.PGE flag
mov cr4, eax
@@:
ret
endp
 
695,12 → 739,15
jmp @b
@@:
 
; 9i. Configure MTRR_DEF_TYPE.
mov ecx, 0x2FF
rdmsr
or ah, 8 ; enable variable-ranges MTRR
and al, 0xF0; default memtype = UC
; 9i. Check PAT support and reprogram PAT_MASR for write combining memory
bt [cpu_caps], CAPS_PAT
jnc @F
 
mov ecx, MSR_CR_PAT
mov eax, PAT_VALUE ;UC UCM WC WB
mov edx, eax
wrmsr
@@:
 
; 9j. Changes are done.
call mtrr_end_change
738,7 → 785,9
ret
.found:
; found, write values
push ecx
call mtrr_begin_change
pop ecx
xor edx, edx
mov eax, [base]
or eax, [mem_type]
842,13 → 891,13
; It must be write-combined.
test word [SCR_MODE], 0x4000
jz .exit
mov eax, [_display.pitch]
mov eax, [_display.lfb_pitch]
mul [_display.height]
dec eax
; LFB is mapped to virtual address LFB_BASE,
; it uses global pages if supported by CPU.
mov ebx, [sys_proc+PROC.pdt_0+(LFB_BASE shr 20)]
test ebx, PG_LARGE
test ebx, PDE_LARGE
jnz @f
mov ebx, [page_tabs+(LFB_BASE shr 10)]
@@:
/kernel/branches/Kolibri-acpi/core/peload.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42,6 → 42,7
jz .cleanup
 
mov [base], eax
DEBUGF 1,'K : driver %s mapped to %x\n',[file_name],[base]
 
push ebx ebp
mov ebx, [image]
/kernel/branches/Kolibri-acpi/core/sched.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
116,8 → 116,6
Mov [tss._esp0],eax,[ebx+APPDATA.saved_esp0]
 
mov edx, [ebx+APPDATA.tls_base]
cmp edx, [esi+APPDATA.tls_base]
je @f
 
mov [tls_data_l+2], dx
shr edx, 16
126,7 → 124,7
 
mov dx, app_tls
mov fs, dx
@@:
 
; set gs selector unconditionally
Mov gs,ax,graph_data
; set CR0.TS
155,22 → 153,24
;end.
 
 
 
struct MUTEX_WAITER
list LHEAD
task dd ?
type dd ?
ends
 
RWSEM_WAITING_FOR_WRITE equ 0
RWSEM_WAITING_FOR_READ equ 1
 
;void __fastcall mutex_init(struct mutex *lock)
 
align 4
mutex_init:
mov [ecx+MUTEX.lhead.next], ecx
mov [ecx+MUTEX.lhead.prev], ecx
mov [ecx+MUTEX.wait_list.next], ecx
mov [ecx+MUTEX.wait_list.prev], ecx
mov [ecx+MUTEX.count], 1
ret
 
 
;void __fastcall mutex_lock(struct mutex *lock)
 
align 4
200,15 → 200,13
call change_task
jmp .forever
@@:
mov edx, [esp+MUTEX_WAITER.list.next]
mov eax, [esp+MUTEX_WAITER.list.prev]
mov eax, ecx
list_del esp
 
mov [eax+MUTEX_WAITER.list.next], edx
mov [edx+MUTEX_WAITER.list.prev], eax
cmp [ecx+MUTEX.lhead.next], ecx
cmp [eax+MUTEX.wait_list.next], eax
jne @F
 
mov [ecx+MUTEX.count], 0
mov [eax+MUTEX.count], 0
@@:
add esp, sizeof.MUTEX_WAITER
 
224,7 → 222,7
pushfd
cli
 
mov eax, [ecx+MUTEX.lhead.next]
mov eax, [ecx+MUTEX.wait_list.next]
cmp eax, ecx
mov [ecx+MUTEX.count], 1
je @F
236,8 → 234,167
ret
 
 
;void __fastcall init_rwsem(struct rw_semaphore *sem)
 
align 4
init_rwsem:
mov [ecx+RWSEM.wait_list.next], ecx
mov [ecx+RWSEM.wait_list.prev], ecx
mov [ecx+RWSEM.count], 0
ret
 
;void __fastcall down_read(struct rw_semaphore *sem)
 
align 4
down_read:
pushfd
cli
 
mov eax, [ecx+RWSEM.count]
test eax, eax
js @F
 
cmp ecx, [ecx+RWSEM.wait_list.next]
je .ok
@@:
sub esp, sizeof.MUTEX_WAITER
 
mov eax, [TASK_BASE]
mov [esp+MUTEX_WAITER.task], eax
mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_READ
mov [eax+TASKDATA.state], 1
 
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
 
call change_task
 
add esp, sizeof.MUTEX_WAITER
popfd
ret
.ok:
inc eax
mov [ecx+RWSEM.count], eax
 
popfd
ret
 
;void __fastcall down_write(struct rw_semaphore *sem)
 
align 4
down_write:
pushfd
cli
sub esp, sizeof.MUTEX_WAITER
 
mov edx, [TASK_BASE]
mov [esp+MUTEX_WAITER.task], edx
mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_WRITE
mov [edx+TASKDATA.state], 1
 
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
 
xor eax, eax
not eax
 
.forever:
test eax, [ecx+RWSEM.count]
jz @F
 
mov [edx+TASKDATA.state], 1
call change_task
jmp .forever
@@:
mov [ecx+RWSEM.count], eax
list_del esp
 
add esp, sizeof.MUTEX_WAITER
popfd
ret
 
;void __fastcall up_read(struct rw_semaphore *sem)
 
align 4
up_read:
pushfd
cli
 
dec [ecx+RWSEM.count]
jnz @F
 
mov eax, [ecx+RWSEM.wait_list.next]
cmp eax, ecx
je @F
 
mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], 0
@@:
popfd
ret
 
;void __fastcall up_write(struct rw_semaphore *sem)
 
align 4
up_write:
 
pushfd
cli
 
mov eax, [ecx+RWSEM.wait_list.next]
mov [ecx+RWSEM.count], 0
 
cmp ecx, eax
je .done
 
mov edx, [eax+MUTEX_WAITER.type]
test edx, edx
jnz .wake
 
mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], 0
.done:
popfd
ret
 
.wake:
push ebx
push esi
push edi
 
xor esi, esi
mov edi, ecx
 
.wake_list:
 
mov ebx, [eax+MUTEX_WAITER.list.next]
list_del eax
mov edx, [eax+MUTEX_WAITER.task]
mov [edx+TASKDATA.state], 0
inc esi
cmp edi, ebx
je .wake_done
 
mov ecx, [ebx+MUTEX_WAITER.type]
test ecx, ecx
jz .wake_done
 
mov eax, ebx
jmp .wake_list
 
.wake_done:
add [edi+RWSEM.count], esi
 
pop edi
pop esi
pop ebx
popfd
ret
 
 
purge MUTEX_WAITER
purge RWSEM_WAITING_FOR_WRITE
purge RWSEM_WAITING_FOR_READ
 
 
MAX_PRIORITY = 0 ; highest, used for kernel tasks
USER_PRIORITY = 1 ; default
IDLE_PRIORITY = 2 ; lowest, only IDLE thread goes here
/kernel/branches/Kolibri-acpi/core/string.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; Author: Kees J. Bot 1 Jan 1994 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/sync.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Synhronization for MenuetOS. ;;
/kernel/branches/Kolibri-acpi/core/sys32-sp.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2014. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2013-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/sys32.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ;;
308,7 → 308,7
mov ecx, ebx
shr ecx, 10
mov edx, [master_tab+ecx*4]
test edx, PG_MAP
test edx, PG_READ
jz .fail ;page table is not created
;incorrect address in the program
 
/kernel/branches/Kolibri-acpi/core/syscall.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/taskman.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
489,7 → 489,7
cmp eax, ecx
jbe @B
 
mov [edi-4096+PROC.ht_next], 1 ;reserve handle 0
mov [edi-4096+PROC.ht_next], 3 ;reserve handles for stdin stdout and stderr
mov eax, edi
call get_pg_addr
mov [edi-4096+PROC.pdt_0_phys], eax
503,16 → 503,13
rep movsd
 
mov eax, [edi-8192+PROC.pdt_0_phys]
or eax, PG_SW
or eax, PG_SWR
mov [edi-4096+(page_tabs shr 20)], eax
 
lea eax, [edi-8192]
call set_cr3
 
mov ecx, [app_tabs]
test ecx, ecx
jz .done
 
mov edx, [app_tabs]
xor edi, edi
@@:
call alloc_page
521,7 → 518,8
 
stdcall map_page_table, edi, eax
add edi, 0x00400000
loop @B
dec edx
jnz @B
 
mov edi, page_tabs
 
530,13 → 528,9
xor eax, eax
rep stosd
 
mov ecx, [img_pages]
mov ebx, PG_UWR
xor edx, edx
mov ecx, [img_pages]
jcxz .bss
 
sub [app_pages], ecx
 
mov ebx, PG_UW
mov esi, [img_base]
shr esi, 10
add esi, page_tabs
547,21 → 541,23
or eax, ebx; force user level r/w access
stosd
add edx, 0x1000
loop .remap
.bss:
mov ebx, [app_pages]
test ebx, ebx
dec [app_pages]
dec ecx
jnz .remap
 
mov ecx, [app_pages]
test ecx, ecx
jz .done
 
.map_bss:
.alloc:
call alloc_page
test eax, eax
jz .fail
 
stdcall map_page, edx, eax, dword PG_UW
stdcall map_page, edx, eax, dword PG_UWR
add edx, 0x1000
dec ebx
jnz .map_bss
dec [app_pages]
jnz .alloc
 
.done:
mov ecx, pg_data.mutex
647,7 → 643,7
test eax, 1
jz .next
and eax, not 0xFFF
stdcall map_page, [tmp_task_ptab], eax, PG_SW
stdcall map_page, [tmp_task_ptab], eax, PG_SWR
stdcall destroy_page_table, [tmp_task_ptab]
mov eax, [esi]
call free_page
792,7 → 788,7
 
push ecx
stdcall map_memEx, [proc_mem_map], \
[slot], ebx, ecx, PG_MAP
[slot], ebx, ecx, PG_READ
pop ecx
 
mov esi, [offset]
863,7 → 859,7
; add ebx, new_app_base
push ecx
stdcall map_memEx, [proc_mem_map], \
[slot], ebx, ecx, PG_SW
[slot], ebx, ecx, PG_SWR
pop ecx
 
mov edi, [offset]
1145,9 → 1141,9
xor eax, eax
mov [ecx+0], dword eax
mov [ecx+4], dword eax
mov eax, [Screen_Max_X]
mov eax, [screen_workarea.right]
mov [ecx+8], eax
mov eax, [Screen_Max_Y]
mov eax, [screen_workarea.bottom]
mov [ecx+12], eax
 
mov ebx, [pl0_stack]
/kernel/branches/Kolibri-acpi/core/test_malloc.asm
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2009-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/timers.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2012-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/Kolibri-acpi/core/v86.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2007-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2007-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
78,7 → 78,7
; (I have seen one computer with EBDA segment = 0x9D80,
; all other computers use less memory)
 
mov eax, PG_UW
mov eax, PG_UWR
mov [page_tabs], eax
invlpg [eax]
 
89,7 → 89,7
mov byte [0x504], 0x10
mov byte [0x505], 0xF4
 
mov eax, 0x99000+PG_UW
mov eax, 0x99000+PG_UWR
mov edi, page_tabs+0x99*4
mov edx, 0x1000
mov ecx, 7
101,7 → 101,7
; addresses 0xC0000 - 0xFFFFF - BIOS code (shared between all machines!)
; physical address = 0xC0000
 
mov eax, 0xC0000+PG_UW
mov eax, 0xC0000+PG_UWR
mov edi, page_tabs+0xC0*4
mov ecx, 64
@@: