Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 5083 → Rev 5082

/kernel/trunk/drivers/imports.inc
0,0 → 1,112
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
macro kernel_export [name]{
forward
if used name
if DEBUG
display 'uses: ',`name,#13,#10
end if
extrn name
end if
}
; all exported kernel functions and data
 
 
kernel_export \
RegService,\
GetService,\
ServiceHandler,\
AttachIntHandler,\
GetIntHandler,\
FpuSave,\
FpuRestore,\
ReservePortArea,\
Boot_Log,\
\
MutexInit,\
MutexLock,\
MutexUnlock,\
\
PciApi,\
PciRead32,\
PciRead16,\
PciRead8,\
PciWrite8,\
PciWrite16,\
PciWrite32,\
\
AllocPage,\
AllocPages,\
FreePage,\
MapPage,\
MapSpace,\
MapIoMem,\
GetPgAddr,\
CommitPages,\
ReleasePages,\
\
AllocKernelSpace,\
FreeKernelSpace,\
KernelAlloc,\
KernelFree,\
UserAlloc,\
UserFree,\
Kmalloc,\
Kfree,\
CreateRingBuffer,\
\
GetPid,\
CreateThread,\
CreateObject,\
DestroyObject,\
CreateEvent,\
RaiseEvent,\
WaitEvent,\
DestroyEvent,\
ClearEvent,\
\
LoadCursor,\
SelectHwCursor,\
SetHwCursor,\
HwCursorRestore,\
HwCursorCreate,\
\
SysMsgBoardStr,\
SysMsgBoard,\
GetCurrentTask,\
LoadFile,\
SendEvent,\
SetMouseData,\
SetKeyboardData,\
RegKeyboard,\
DelKeyboard,\
Sleep,\
GetTimerTicks,\
\
strncat,\
strncpy,\
strncmp,\
strnlen,\
strchr,\
strrchr,\
\
LFBAddress,\
GetDisplay,\
SetScreen,\
\
RegUSBDriver,\
USBOpenPipe,\
USBNormalTransferAsync,\
USBControlTransferAsync,\
USBGetParam,\
\
DiskAdd,\
DiskMediaChanged,\
DiskDel,\
\
TimerHS,\
CancelTimerHS
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Rev
\ No newline at end of property
/kernel/trunk/drivers/fdo.inc
0,0 → 1,453
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
_esp equ esp
 
;
; Formatted Debug Output (FDO)
; Copyright (c) 2005-2006, mike.dld
; Created: 2005-01-29, Changed: 2006-11-10
;
; For questions and bug reports, mail to mike.dld@gmail.com
;
; Available format specifiers are: %s, %d, %u, %x (with partial width support)
;
 
; to be defined:
; __DEBUG__ equ 1
; __DEBUG_LEVEL__ equ 5
 
; MOV Immediate.
; Useful for things like movi eax,10:
; shorter than regular mov, but slightly slower,
; do not use it in performance-critical places.
macro movi dst, imm
{
if imm >= -0x80 & imm <= 0x7F
push imm
pop dst
else
mov dst, imm
end if
}
 
macro debug_func name {
if used name
name@of@func equ name
}
 
macro debug_beginf {
align 4
name@of@func:
}
 
debug_endf fix end if
 
macro DEBUGS _sign,[_str] {
common
local tp
tp equ 0
match _arg:_num,_str \{
DEBUGS_N _sign,_num,_arg
tp equ 1
\}
match =0 _arg,tp _str \{
DEBUGS_N _sign,,_arg
\}
}
 
macro DEBUGS_N _sign,_num,[_str] {
common
pushf
pushad
local ..str,..label,is_str
is_str = 0
forward
if _str eqtype ''
is_str = 1
end if
common
if is_str = 1
jmp ..label
..str db _str,0
..label:
mov edx, ..str
else
esp equ esp+4*8+4
mov edx, _str
esp equ _esp
end if
if ~_num eq
if _num eqtype eax
if _num in <eax,ebx,ecx,edx,edi,ebp,esp>
mov esi, _num
else if ~_num eq esi
movzx esi, _num
end if
else if _num eqtype 0
mov esi, _num
else
local tp
tp equ 0
match [_arg],_num \{
mov esi, dword[_arg]
tp equ 1
\}
match =0 =dword[_arg],tp _num \{
mov esi, dword[_arg]
tp equ 1
\}
match =0 =word[_arg],tp _num \{
movzx esi, word[_arg]
tp equ 1
\}
match =0 =byte[_arg],tp _num \{
movzx esi, byte[_arg]
tp equ 1
\}
match =0,tp \{
'Error: specified string width is incorrect'
\}
end if
else
mov esi, 0x7FFFFFFF
end if
call fdo_debug_outstr
popad
popf
}
 
macro DEBUGD _sign,_dec {
local tp
tp equ 0
match _arg:_num,_dec \{
DEBUGD_N _sign,_num,_arg
tp equ 1
\}
match =0 _arg,tp _dec \{
DEBUGD_N _sign,,_arg
\}
}
 
macro DEBUGD_N _sign,_num,_dec {
pushf
pushad
if (~_num eq)
if (_dec eqtype eax | _dec eqtype 0)
'Error: precision allowed only for in-memory variables'
end if
if (~_num in <1,2,4>)
if _sign
'Error: 1, 2 and 4 are only allowed for precision in %d'
else
'Error: 1, 2 and 4 are only allowed for precision in %u'
end if
end if
end if
if _dec eqtype eax
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp>
mov eax, _dec
else if ~_dec eq eax
if _sign = 1
movsx eax, _dec
else
movzx eax, _dec
end if
end if
else if _dec eqtype 0
mov eax, _dec
else
esp equ esp+4*8+4
if _num eq
mov eax, dword _dec
else if _num = 1
if _sign = 1
movsx eax, byte _dec
else
movzx eax, byte _dec
end if
else if _num = 2
if _sign = 1
movsx eax, word _dec
else
movzx eax, word _dec
end if
else
mov eax, dword _dec
end if
esp equ _esp
end if
mov cl, _sign
call fdo_debug_outdec
popad
popf
}
 
macro DEBUGH _sign,_hex {
local tp
tp equ 0
match _arg:_num,_hex \{
DEBUGH_N _sign,_num,_arg
tp equ 1
\}
match =0 _arg,tp _hex \{
DEBUGH_N _sign,,_arg
\}
}
 
macro DEBUGH_N _sign,_num,_hex {
pushf
pushad
if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>)
'Error: 1..8 are only allowed for precision in %x'
end if
if _hex eqtype eax
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
if ~_hex eq eax
mov eax, _hex
end if
mov edx, 8
else if _hex in <ax,bx,cx,dx,si,di,bp,sp>
if ~_hex eq ax
movzx eax, _hex
end if
if (_num eq)
mov edx, 4
end if
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh>
if ~_hex eq al
movzx eax, _hex
end if
if (_num eq)
mov edx, 2
end if
end if
else if _hex eqtype 0
mov eax, _hex
else
esp equ esp+4*8+4
mov eax, dword _hex
esp equ _esp
end if
if ~_num eq
mov edx, _num
else
if ~_hex eqtype eax
mov edx, 8
end if
end if
call fdo_debug_outhex
popad
popf
}
 
;-----------------------------------------------------------------------------
 
debug_func fdo_debug_outchar
debug_beginf
pushad
movzx ecx, al
mov ebx, 1
; mov ecx,sys_msg_board
; call ecx ; sys_msg_board
stdcall SysMsgBoard
popad
ret
debug_endf
 
debug_func fdo_debug_outstr
debug_beginf
mov ebx, 1
.l1:
dec esi
js .l2
movzx ecx, byte[edx]
or cl, cl
jz .l2
; mov ecx,sys_msg_board
; call ecx ; sys_msg_board
stdcall SysMsgBoard
inc edx
jmp .l1
.l2:
ret
debug_endf
 
debug_func fdo_debug_outdec
debug_beginf
or cl, cl
jz @f
or eax, eax
jns @f
neg eax
push eax
mov al, '-'
call fdo_debug_outchar
pop eax
@@:
movi ecx, 10
push -'0'
.l1:
xor edx, edx
div ecx
push edx
test eax, eax
jnz .l1
.l2:
pop eax
add al, '0'
jz .l3
call fdo_debug_outchar
jmp .l2
.l3:
ret
debug_endf
 
debug_func fdo_debug_outhex
__fdo_hexdigits db '0123456789ABCDEF'
debug_beginf
mov cl, dl
neg cl
add cl, 8
shl cl, 2
rol eax, cl
.l1:
rol eax, 4
push eax
and eax, 0x0000000F
mov al, [__fdo_hexdigits+eax]
call fdo_debug_outchar
pop eax
dec edx
jnz .l1
ret
debug_endf
 
;-----------------------------------------------------------------------------
 
macro DEBUGF _level,_format,[_arg] {
common
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__
local ..f1,f2,a1,a2,c1,c2,c3,..lbl
_debug_str_ equ __debug_str_ # a1
a1 = 0
c2 = 0
c3 = 0
f2 = 0
repeat ..lbl-..f1
virtual at 0
db _format,0,0
load c1 word from %-1
end virtual
if c1 = '%s'
virtual at 0
db _format,0,0
store word 0 at %-1
load c1 from f2-c2
end virtual
if c1 <> 0
DEBUGS 0,_debug_str_+f2-c2
end if
c2 = c2 + 1
f2 = %+1
DEBUGF_HELPER S,a1,0,_arg
else if c1 = '%x'
virtual at 0
db _format,0,0
store word 0 at %-1
load c1 from f2-c2
end virtual
if c1 <> 0
DEBUGS 0,_debug_str_+f2-c2
end if
c2 = c2 + 1
f2 = %+1
DEBUGF_HELPER H,a1,0,_arg
else if c1 = '%d' | c1 = '%u'
local c4
if c1 = '%d'
c4 = 1
else
c4 = 0
end if
virtual at 0
db _format,0,0
store word 0 at %-1
load c1 from f2-c2
end virtual
if c1 <> 0
DEBUGS 0,_debug_str_+f2-c2
end if
c2 = c2 + 1
f2 = %+1
DEBUGF_HELPER D,a1,c4,_arg
else if c1 = '\n'
c3 = c3 + 1
end if
end repeat
virtual at 0
db _format,0,0
load c1 from f2-c2
end virtual
if (c1<>0)&(f2<>..lbl-..f1-1)
DEBUGS 0,_debug_str_+f2-c2
end if
virtual at 0
..f1 db _format,0
..lbl:
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3
end virtual
end if
}
 
macro __include_debug_strings dummy,[_id,_fmt,_len] {
common
local c1,a1,a2
forward
if defined _len & ~_len eq
_id:
a1 = 0
a2 = 0
repeat _len
virtual at 0
db _fmt,0,0
load c1 word from %+a2-1
end virtual
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u')
db 0
a2 = a2 + 1
else if (c1='\n')
dw $0A0D
a1 = a1 + 1
a2 = a2 + 1
else
db c1 and 0x0FF
end if
end repeat
db 0
end if
}
 
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] {
common
local num
num = 0
forward
if num = _num
DEBUG#_letter _sign,_arg
end if
num = num+1
common
_num = _num+1
}
 
macro include_debug_strings {
if __DEBUG__ = 1
match dbg_str,__debug_strings \{
__include_debug_strings dbg_str
\}
end if
}
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/kernel/trunk/drivers/apm.asm
0,0 → 1,350
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
; 11.09.2009 staper@inbox.ru
; see kernel\docs\apm.txt
 
use32
 
org 0x0
 
db 'MENUET01'
dd 0x1
dd START
dd I_END
dd (I_END+100) and not 3
dd (I_END+100) and not 3
dd 0x0,0x0
 
include 'macros.inc'
 
START:
mcall 40,0x7
 
mcall 49,0x0001,0x0001,0x5308 ;CX = FFFFh APM v1.0
; mcall 49,0x0001,0x0001,0x530d
; mcall 49,0x0001,0x0001,0x530f
 
; mcall 49,0x0000,,0x5310 ;bl - number of batteries
redraw:
mcall 49,0x0000,,0x530c
dec cl
jz still
mcall 49,0x0001,0x0001,0x5308
mcall 49,0x01ff,,0x530c
test cl, cl
jz @f
mcall 49,0x0000,0x0001,0x530d
mcall 49,0x0000,0x0000,0x5307
mcall 49,0x0000,0x0001,0x5308
@@:
mcall 12,1
mcall 0,100*65536+235,100*65536+90,0x34ffffff,0x000000,title
mcall 49,0x0000,,0x5300
jnc @f
mcall 4,10*65536+3,0x80000000,text.4
bts [flags], 1
jmp .end
@@:
cmp al, 0
jne @f
mov edx, text.1
jmp .0
@@:
cmp al, 1
jne @f
mov edx, text.2
jmp .0
@@:
mov edx, text.3
.0:
push edx
mcall 4,169*65536+3,0x80dddddd,text.0
pop edx
add ebx, 47*65536
mcall
mcall 49,0x0001,,0x530a
jc .error
push si dx cx bx ;time of battery life, b. flag, b. status, AC line status
 
;AC line status
cmp bh, 0
jne @f
mov edx, text.01
jmp .1
@@:
cmp bh, 1
jne @f
mov edx, text.02
jmp .1
@@:
cmp bh, 2
jne @f
mov edx, text.03
jmp .1
@@:
mov edx, text.04
.1:
push edx
mcall 4,10*65536+10,0x80000000,text.00
pop edx
mcall ,100*65536+10,;0x80000000
 
;battery status
pop bx
cmp bl, 0
jne @f
mov edx, text.11
jmp .2
@@:
cmp bl, 1
jne @f
mov edx, text.12
jmp .2
@@:
cmp bl, 2
jne @f
mov edx, text.13
jmp .2
@@:
cmp bl, 3
jne @f
mov edx, text.14
jmp .2
@@:
mov edx, text.04
.2:
push edx
mcall 4,10*65536+20,0x80000000,text.10
pop edx
mcall ,100*65536+20,
 
;battery life, percentage and minutes/seconds
mcall ,10*65536+30,,text.20
pop cx
cmp cl, 0xff
jne @f
mcall ,100*65536+30,0x80000000,text.04
pop eax
jmp .end
@@:
shl ecx, 24
shr ecx, 24
mcall 47,0x80030000,,100*65536+30,0x347636
.3:
mcall 4,115*65536+30,0x80000000,text.15
mov dx, [esp]
shl edx, 17
shr edx, 17
mov ecx, edx
mcall 47,0x80030000,,140*65536+30
pop cx
mov edx, text.21
bt cx, 15
jc @f
mov edx, text.22
@@:
mcall 4,160*65536+30,0x80000000
pop si
.error:
.end:
;buttons
mcall 8,148*65536+16,45*65536+15,3,0x00677ab0
mcall ,166*65536+16,,4,
mcall ,184*65536+16,,5,
mcall ,202*65536+16,,6,
bt [flags], 1
jc @f
mcall ,65*65536+45,,2,
@@:
mcall 4,10*65536+50,0x80564242,text.30
mcall 12,2
 
still:
; mcall 10
mcall 23,12000
test eax, eax
jz redraw
 
dec al
jz redraw
dec al
jz key
dec al
jz button
jmp still
 
 
 
 
key:
mcall 2
jmp still
 
button:
mcall 17
cmp ah, 1
jne @f
mcall -1
 
@@:
cmp ah, 2
jne @f
mcall 5,50
mcall 49,0x0001,0x0001,0x5307
jmp redraw
 
@@:
cmp ah, 4
jg @f
mov edx, 0x01f7 ;primary chan.
call reserv_ports
jc redraw
sub bh, 3
.1:
call set_drive
btc [flags], 2
jnc .2
call device_reset
jmp .3
.2:
call standby_hdd
.3:
call free_ports
jmp redraw
 
@@:
cmp ah, 6
jg redraw
mov edx, 0x0177 ;secondary chan.
call reserv_ports
jc redraw
sub bh, 5
jmp .1
 
set_drive:
dec dx
in al, dx
test bh, bh
jnz @f
btr ax, 4
.1:
out dx, al
inc dx
ret
@@:
bts ax, 4
jmp .1
 
 
standby_hdd:
; 94h E0h nondata standby immediate
; 95h E1h nondata idle immediate
; 96h E2h nondata standby
; 97h E3h nondata idle
; 98h E5h nondata check power mode
; 99h E6h nondata set sleep mode
xor ecx, ecx
@@:
in al, dx
dec cx
jz @f
bt ax, 6
jnc @b
mov al, 0x96
out dx, al
mov al, 0xe2
out dx, al
@@:
ret
 
reserv_ports:
mov ecx, edx
dec ecx
push ax
mcall 46,0
test al, al
jnz @f
pop bx
clc
ret
@@:
pop bx
stc
ret
 
device_reset:
xor ecx, ecx
@@:
in al, dx
dec cx
jz @f
bt ax, 6
jnc @b
mov al, 0x10
out dx, al
@@:
ret
 
free_ports:
mov ecx, edx
dec ecx
mcall 46,1
ret
 
 
; ДАННЫЕ ПРОГРАММЫ
title db '',0
flags dw 0
 
text:
.0:
db 'APM v.1.',0
.1:
db '0',0
.2:
db '1',0
.3:
db '2',0
.4:
db 'APM not supported',0
 
.00:
db 'power status:',0
.01:
db 'off-line',0
.02:
db 'on-line',0
.03:
db 'on backup power',0
.04:
db 'unknown',0
 
.10:
db 'battery flag:',0
.11:
db 'high',0
.12:
db 'low',0
.13:
db 'critical',0
.14:
db 'charging',0
.15:
db ' % ,',0
 
.20:
db 'battery life:',0
.21:
db 'min',0
.22:
db 'sec',0
 
.30:
db 'STAND-BY: SYSTEM HDD: 0 1 2 3',0
 
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/kernel/trunk/drivers/proc32.inc
0,0 → 1,267
; Macroinstructions for defining and calling procedures
 
macro stdcall proc,[arg] ; directly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call proc }
 
macro invoke proc,[arg] ; indirectly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call [proc] }
 
macro ccall proc,[arg] ; directly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call proc
if size@ccall
add esp, size@ccall
end if }
 
macro cinvoke proc,[arg] ; indirectly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call [proc]
if size@ccall
add esp, size@ccall
end if }
 
macro proc [args] ; define procedure
{ common
match name params, args>
\{ define@proc name,<params \} }
 
prologue@proc equ prologuedef
 
macro prologuedef procname,flag,parmbytes,localbytes,reglist
{ if parmbytes | localbytes
push ebp
mov ebp, esp
if localbytes
sub esp, localbytes
end if
end if
irps reg, reglist \{ push reg \} }
 
epilogue@proc equ epiloguedef
 
macro epiloguedef procname,flag,parmbytes,localbytes,reglist
{ irps reg, reglist \{ reverse pop reg \}
if parmbytes | localbytes
leave
end if
if flag and 10000b
retn
else
retn parmbytes
end if }
 
macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current
if used name
name:
match =stdcall args, statement \{ params equ args
flag = 11b \}
match =stdcall, statement \{ params equ
flag = 11b \}
match =c args, statement \{ params equ args
flag = 10001b \}
match =c, statement \{ params equ
flag = 10001b \}
match =params, params \{ params equ statement
flag = 0 \}
virtual at ebp+8
match =uses reglist=,args, params \{ regs equ reglist
params equ args \}
match =regs =uses reglist, regs params \{ regs equ reglist
params equ \}
match =regs, regs \{ regs equ \}
match =,args, params \{ defargs@proc args \}
match =args@proc args, args@proc params \{ defargs@proc args \}
parmbytes = $ - (ebp+8)
end virtual
name # % = parmbytes/4
all@vars equ
current = 0
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
macro locals
\{ virtual at ebp-localbytes+current
macro label . \\{ deflocal@proc .,:, \\}
struc db [val] \\{ \common deflocal@proc .,db,val \\}
struc dw [val] \\{ \common deflocal@proc .,dw,val \\}
struc dp [val] \\{ \common deflocal@proc .,dp,val \\}
struc dd [val] \\{ \common deflocal@proc .,dd,val \\}
struc dt [val] \\{ \common deflocal@proc .,dt,val \\}
struc dq [val] \\{ \common deflocal@proc .,dq,val \\}
struc rb cnt \\{ deflocal@proc .,rb cnt, \\}
struc rw cnt \\{ deflocal@proc .,rw cnt, \\}
struc rp cnt \\{ deflocal@proc .,rp cnt, \\}
struc rd cnt \\{ deflocal@proc .,rd cnt, \\}
struc rt cnt \\{ deflocal@proc .,rt cnt, \\}
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \}
macro endl
\{ purge label
restruc db,dw,dp,dd,dt,dq
restruc rb,rw,rp,rd,rt,rq
restruc byte,word,dword,pword,tword,qword
current = $-(ebp-localbytes)
end virtual \}
macro ret operand
\{ match any, operand \\{ retn operand \\}
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2
end if \} }
 
macro defargs@proc [arg]
{ common
if ~ arg eq
forward
local ..arg,current@arg
match argname:type, arg
\{ current@arg equ argname
label ..arg type
argname equ ..arg
if dqword eq type
dd ?,?,?,?
else if tbyte eq type
dd ?,?,?
else if qword eq type | pword eq type
dd ?,?
else
dd ?
end if \}
match =current@arg,current@arg
\{ current@arg equ arg
arg equ ..arg
..arg dd ? \}
common
args@proc equ current@arg
forward
restore current@arg
common
end if }
 
macro deflocal@proc name,def,[val]
{ common
match vars, all@vars \{ all@vars equ all@vars, \}
all@vars equ all@vars name
forward
local ..var,..tmp
..var def val
match =?, val \{ ..tmp equ \}
match any =dup (=?), val \{ ..tmp equ \}
match tmp : value, ..tmp : val
\{ tmp: end virtual
initlocal@proc ..var,def value
virtual at tmp\}
common
match first rest, ..var, \{ name equ first \} }
 
macro initlocal@proc name,def
{ virtual at name
def
size@initlocal = $ - name
end virtual
position@initlocal = 0
while size@initlocal > position@initlocal
virtual at name
def
if size@initlocal - position@initlocal < 2
current@initlocal = 1
load byte@initlocal byte from name+position@initlocal
else if size@initlocal - position@initlocal < 4
current@initlocal = 2
load word@initlocal word from name+position@initlocal
else
current@initlocal = 4
load dword@initlocal dword from name+position@initlocal
end if
end virtual
if current@initlocal = 1
mov byte [name+position@initlocal], byte@initlocal
else if current@initlocal = 2
mov word [name+position@initlocal], word@initlocal
else
mov dword [name+position@initlocal], dword@initlocal
end if
position@initlocal = position@initlocal + current@initlocal
end while }
 
macro endp
{ purge ret,locals,endl
finish@proc
purge finish@proc
restore regs@proc
match all,args@proc \{ restore all \}
restore args@proc
match all,all@vars \{ restore all \} }
 
macro local [var]
{ common
locals
forward done@local equ
match varname[count]:vartype, var
\{ match =BYTE, vartype \\{ varname rb count
restore done@local \\}
match =WORD, vartype \\{ varname rw count
restore done@local \\}
match =DWORD, vartype \\{ varname rd count
restore done@local \\}
match =PWORD, vartype \\{ varname rp count
restore done@local \\}
match =QWORD, vartype \\{ varname rq count
restore done@local \\}
match =TBYTE, vartype \\{ varname rt count
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
rq count+count
restore done@local \\}
match , done@local \\{ virtual
varname vartype
end virtual
rb count*sizeof.\#vartype
restore done@local \\} \}
match :varname:vartype, done@local:var
\{ match =BYTE, vartype \\{ varname db ?
restore done@local \\}
match =WORD, vartype \\{ varname dw ?
restore done@local \\}
match =DWORD, vartype \\{ varname dd ?
restore done@local \\}
match =PWORD, vartype \\{ varname dp ?
restore done@local \\}
match =QWORD, vartype \\{ varname dq ?
restore done@local \\}
match =TBYTE, vartype \\{ varname dt ?
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
dq ?,?
restore done@local \\}
match , done@local \\{ varname vartype
restore done@local \\} \}
match ,done@local
\{ var
restore done@local \}
common
endl }
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Rev
\ No newline at end of property
/kernel/trunk/drivers
Property changes:
Added: svn:ignore
+*.mnt
+lang.inc
+*.bat
+out.txt
+scin*
+*.obj
/kernel/trunk/build.bat
1,10 → 1,11
@echo off
cls
set languages=en ru ge et sp
set targets=kernel clean
set drivers=com_mouse emu10k1x fm801 infinity sis sound viasound vt823x
set targets=all kernel drivers clean
 
call :Check_Target %1
for %%a in (kernel) do if %%a==%target% call :Check_Lang %2
for %%a in (all kernel) do if %%a==%target% call :Check_Lang %2
call :Target_%target%
 
if ERRORLEVEL 0 goto Exit_OK
55,6 → 56,51
goto :eof
 
 
:Target_all
call :Target_kernel
call :Target_drivers
goto :eof
 
 
:Target_drivers
echo *** building drivers ...
 
if not exist bin\drivers mkdir bin\drivers
cd drivers
for %%a in (%drivers%) do (
fasm -m 65536 %%a.asm ..\bin\drivers\%%a.obj
if not %errorlevel%==0 goto :Error_FasmFailed
)
cd ..
 
kpack >nul 2>&1
 
if %errorlevel%==9009 goto :Error_KpackFailed
 
echo *
echo ##############################################
echo *
echo Kpack KolibriOS drivers?
echo *
 
set /P res=[y/n]?
 
if "%res%"=="y" (
 
echo *
echo Compressing system
 
echo *
for %%a in (bin\drivers\*.obj) do (
echo ================== kpack %%a
kpack %%a
if not %errorlevel%==0 goto :Error_KpackFailed
)
 
)
goto :eof
 
 
:Target_clean
echo *** cleaning ...
rmdir /S /Q bin
68,6 → 114,14
pause
exit 1
 
:Error_KpackFailed
echo *** NOTICE ***
echo If you want to pack all applications you may
echo place "kpack" in accessible directory or system %PATH%.
echo You can get this tool from KolibriOS distribution kit.
pause
exit 1
 
:Exit_OK
echo.
echo all operations have been done
/kernel/trunk/makefile
1,10 → 1,11
FASM=fasm
FLAGS=-m 65536
languages=en|ru|ge|et|sp
drivers_src=com_mouse emu10k1x fm801 infinity sis sound vt823x
 
.PHONY: all kernel bootloader clean
.PHONY: all kernel drivers bootloader clean
 
all: kernel bootloader
all: kernel drivers bootloader
 
kernel: check_lang
@echo "*** building kernel with language '$(lang)' ..."
14,6 → 15,14
@$(FASM) $(FLAGS) kernel.asm bin/kernel.mnt
@rm -f lang.inc
 
drivers:
@echo "*** building drivers ..."
@mkdir -p bin/drivers
@cd drivers; for f in $(drivers_src); do \
echo "--- building 'bin/drivers/$${f}.obj' ..."; \
$(FASM) $(FLAGS) "$${f}.asm" "../bin/drivers/$${f}.obj" || exit $?; \
done
 
bootloader: check_lang
@echo "*** building bootloader with language '$(lang)' ..."
@mkdir -p bin