/drivers/kglobals.inc |
---|
0,0 → 1,66 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;------------------------------------------------------------------ |
; use "iglobal" for inserting initialized global data definitions. |
;------------------------------------------------------------------ |
macro iglobal { |
IGlobals equ IGlobals, |
macro __IGlobalBlock { } |
macro iglobal_nested { |
IGlobals equ IGlobals, |
macro __IGlobalBlock \{ } |
;------------------------------------------------------------- |
; use 'uglobal' for inserting uninitialized global definitions. |
; even when you define some data values, these variables |
; will be stored as uninitialized data. |
;------------------------------------------------------------- |
macro uglobal { |
UGlobals equ UGlobals, |
macro __UGlobalBlock { } |
macro uglobal_nested { |
UGlobals equ UGlobals, |
macro __UGlobalBlock \{ } |
endg fix } ; Use endg for ending iglobal and uglobal blocks. |
endg_nested fix \} |
macro IncludeIGlobals{ |
macro IGlobals dummy,[n] \{ __IGlobalBlock |
purge __IGlobalBlock \} |
match I, IGlobals \{ I \} } |
macro IncludeUGlobals{ |
macro UGlobals dummy,[n] \{ |
\common |
\local begin, size |
begin = $ |
virtual at $ |
\forward |
__UGlobalBlock |
purge __UGlobalBlock |
\common |
size = $ - begin |
end virtual |
rb size |
\} |
match U, UGlobals \{ U \} } |
macro IncludeAllGlobals { |
IncludeIGlobals |
IncludeUGlobals |
} |
iglobal |
endg |
uglobal |
endg |
/drivers/macros.inc |
---|
0,0 → 1,106 |
include 'kglobals.inc' |
PG_UNMAP equ 0x000 |
PG_MAP equ 0x001 |
PG_WRITE equ 0x002 |
PG_SW equ 0x003 |
PG_USER equ 0x005 |
PG_UW equ 0x007 |
PG_NOCACHE equ 0x018 |
PG_LARGE equ 0x080 |
PG_GLOBAL equ 0x100 |
DRV_ENTRY equ 1 |
DRV_EXIT equ -1 |
struct LHEAD |
next dd ? ;next object in list |
prev dd ? ;prev object in list |
ends |
struct MUTEX |
lhead LHEAD |
count dd ? |
ends |
struct PCIDEV |
bk dd ? |
fd dd ? |
vendor_device_id dd ? |
class dd ? |
devfn db ? |
bus db ? |
rb 2 |
owner dd ? ; pointer to SRV or 0 |
ends |
; The following macro assume that we are on uniprocessor machine. |
; Serious work is needed for multiprocessor machines. |
macro spin_lock_irqsave spinlock |
{ |
pushf |
cli |
} |
macro spin_unlock_irqrestore spinlock |
{ |
popf |
} |
macro spin_lock_irq spinlock |
{ |
cli |
} |
macro spin_unlock_irq spinlock |
{ |
sti |
} |
; \begin{diamond}[29.09.2006] |
; may be useful for kernel debugging |
; example 1: |
; dbgstr 'Hello, World!' |
; example 2: |
; dbgstr 'Hello, World!', save_flags |
macro dbgstr string*, f |
{ |
local a |
iglobal_nested |
a db 'K : ',string,13,10,0 |
endg_nested |
if ~ f eq |
pushfd |
end if |
push esi |
mov esi, a |
if defined SysMsgBoardStr._pe_import |
invoke SysMsgBoardStr |
else |
call SysMsgBoardStr |
end if |
pop esi |
if ~ f eq |
popfd |
end if |
} |
; \end{diamond}[29.09.2006] |
; 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 call name |
{ |
if name eqtype func & defined name#._pe_import |
err Use invoke, not call/stdcall for PE imports! |
end if |
call name |
} |
/drivers/peimport.inc |
---|
0,0 → 1,152 |
; Macroinstructions for making import section |
; Based on import32.inc from FASM, with small modifications |
; and list of actual kernel exports. |
macro library [name,string] |
{ common |
import.data: |
forward |
local _label |
if defined name#.redundant |
if ~ name#.redundant |
dd 0,0,0,RVA _label,RVA name#.address |
end if |
end if |
name#.referred = 1 |
common |
dd 0,0,0,0,0 |
forward |
if defined name#.redundant |
if ~ name#.redundant |
_label db string,0 |
end if |
end if } |
macro import name,[label] |
{ common |
rb (- rva $) and 3 |
if defined name#.referred |
name#.address: |
forward |
if used label |
local _label |
label dd RVA _label |
label#._pe_import = 1 |
end if |
common |
if $ > name#.address |
name#.redundant = 0 |
dw 0 |
else |
name#.redundant = 1 |
end if |
forward |
if used label |
_label dw 0 |
db `label |
end if |
common |
db 0 |
end if } |
align 4 |
data import |
library core,'core.dll' |
import core,\ |
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,\ |
GetPhysAddr,\ |
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,\ |
USBHCFunc,\ |
\ |
DiskAdd,\ |
DiskMediaChanged,\ |
DiskDel,\ |
\ |
TimerHS,\ |
CancelTimerHS |
end data |