Tvùrce webu je i pro tebe! Postav tøeba web. Bez grafika. Bez kodéra. Hned.
wz

DRIVER.ASM

General Driver


; =============================================================================
;
;                           Litos - General driver
;
; =============================================================================

		CODE_SECTION	32

; ------------- Macro - call driver interface function (with return)
; %1 = pointer to driver, %2 = function offset

%macro		DRVFNC	2

		push	eax		; push EAX
		mov	eax,[%1+DPB_Func] ; EAX <- driver function block
		mov	eax,[eax+%2]	; EAX <- pointer to function
		xchg	eax,[esp]	; EAX <- pop EAX, [ESP] <- function
		ret			; jump to function ([ESP] = ret addr.)

%endmacro

; -----------------------------------------------------------------------------
;                              Detect device
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	CY = device not detected
; -----------------------------------------------------------------------------

DrvDetect:	DRVFNC	ebx,DFB_Detect

; -----------------------------------------------------------------------------
;                           Initialize driver
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	CY = initialization error
; -----------------------------------------------------------------------------

DrvInit:	DRVFNC	ebx,DFB_Init

; -----------------------------------------------------------------------------
;                          Deinitialize driver
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	CY = deinitialization error
; -----------------------------------------------------------------------------

DrvDeInit:	DRVFNC	ebx,DFB_DeInit

; -----------------------------------------------------------------------------
;                           Enable device
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	CY = cannot enable
; -----------------------------------------------------------------------------

DrvEnable:	DRVFNC	ebx,DFB_Enable

; -----------------------------------------------------------------------------
;                           Disable device
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	CY = cannot disable
; -----------------------------------------------------------------------------

DrvDisable:	DRVFNC	ebx,DFB_Disable

; -----------------------------------------------------------------------------
;                          Lock/unlock driver
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; NOTES:	Use macro DRVLOCK to lock, DRVUNLOCK to unlock.
; -----------------------------------------------------------------------------

; ------------- Driver lock function

%ifdef	SMP
		LOCK_LockFnc DriverLock,(ebx+DPB_Lock) ; declare driver lock
%endif

; ------------- Macro - call driver lock function

%macro		DRVLOCK 0
%ifdef	SMP
		call	DriverLock	; call driver lock function
%endif
%endmacro

; ------------- Macro - driver unlock (it saves flags)

%macro		DRVUNLOCK 0
%ifdef	SMP
		LOCK_Unlock (ebx+DPB_Lock) ; unlock driver
%endif
%endmacro

; -----------------------------------------------------------------------------
;                         Lock/unlock driver list
; -----------------------------------------------------------------------------
; NOTES:	Use macro DRVLSTLOCK to lock, DRVLSTUNLOCK to unlock.
; -----------------------------------------------------------------------------

; ------------- Driver list lock function

%ifdef	SMP
		LOCK_LockFnc DrvLstLock,DrvListLock ; declare driver list lock
%endif

; ------------- Macro - call driver list lock function

%macro		DRVLSTLOCK 0
%ifdef	SMP
		call	DrvLstLock	; call driver list lock function
%endif
%endmacro

; ------------- Macro - driver list unlock (it saves flags)

%macro		DRVLSTUNLOCK 0
%ifdef	SMP
		LOCK_Unlock DrvListLock ; unlock driver list
%endif
%endmacro

; -----------------------------------------------------------------------------
;                          Get number of drivers
; -----------------------------------------------------------------------------
; OUTPUT:	EAX = number of drivers
; NOTES:	Driver list should be locked and interrupts should be disabled.
; -----------------------------------------------------------------------------

DrvLstGetNum:	mov	eax,[DrvList+RBR_Count] ; EAX <- number of drivers
		ret

; -----------------------------------------------------------------------------
;                     Get first driver from the driver list
; -----------------------------------------------------------------------------
; OUTPUT:	EBX = driver parameter block (or NULL if CY)
;		CY = no driver (EBX = NULL)
; NOTES:	Driver list should be locked and interrupts should be disabled.
; -----------------------------------------------------------------------------

DrvLstGetFirst:	push	edx		; push EDX
		mov	edx,DrvList	; EDX <- list of al drivers
		call	RBTreeFirst	; get first driver (-> EBX)
		pop	edx		; pop EDX
		ret

; -----------------------------------------------------------------------------
;                      Get last driver from the driver list
; -----------------------------------------------------------------------------
; OUTPUT:	EBX = driver parameter block (or NULL if CY)
;		CY = no driver (EBX = NULL)
; NOTES:	Driver list should be locked and interrupts should be disabled.
; -----------------------------------------------------------------------------

DrvLstGetLast:	push	edx		; push EDX
		mov	edx,DrvList	; EDX <- list of al drivers
		call	RBTreeLast	; get last driver (-> EBX)
		pop	edx		; pop EDX
		ret

; -----------------------------------------------------------------------------
;                     Get next driver from the driver list
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	EBX = next driver parameter block (or NULL if CY)
;		CY = no next driver (EBX = NULL)
; NOTES:	Driver list should be locked and interrupts should be disabled.
; -----------------------------------------------------------------------------

%define		DrvLstGetNext	RBTreeNext

; -----------------------------------------------------------------------------
;                  Get previous driver from the driver list
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	EBX = previous driver parameter block (or NULL if CY)
;		CY = no previous driver (EBX = NULL)
; NOTES:	Driver list should be locked and interrupts should be disabled.
; -----------------------------------------------------------------------------

%define		DrvLstGetPrev	RBTreePrev

; -----------------------------------------------------------------------------
;        Test driver address validity (test if it is in the driver list)
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	CY = entry not found
; NOTES:	Driver list should be locked and interrupts should be disabled.
; -----------------------------------------------------------------------------

DrvLstTest:	push	edx		; push EDX
		mov	edx,DrvList	; EDX <- list of al drivers
		xchg	eax,ebx		; EAX <- entry
		call	RBTreeSrcAddr	; search entry
		xchg	eax,ebx		; EBX <- entry
		pop	edx		; pop EDX
		ret

; -----------------------------------------------------------------------------
;                       Insert driver into driver list
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; OUTPUT:	CY = entry already exists
; NOTES:	It locks driver list lock.
; -----------------------------------------------------------------------------

; ------------- Push registers

DrvLstInsert:	push	eax		; push EAX
		push	edx		; push EDX
		pushf			; push flags
		cli			; disable interrupts

; ------------- Lock driver list

		DRVLSTLOCK		; lock driver list

; ------------- Insert entry into driver list

		mov	edx,DrvList	; EDX <- list of al drivers
		xchg	eax,ebx		; EAX <- new entry
		call	RBTreeInsAddr	; insert entry into list
		xchg	eax,ebx		; EAX <- old/new entry,EBX <- new entry

; ------------- Unlock driver list

		DRVLSTUNLOCK		; unlock driver list

; ------------- Pop registers

		popf			; enable interrupts
		pop	edx		; pop EDX
		pop	eax		; pop EAX
		ret

; -----------------------------------------------------------------------------
;                      Delete driver from the driver list
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block (it must be valid entry)
; NOTES:	Driver list should be locked and interrupts should be disabled.
;		Driver parameter block is not destroyed, it is only detached.
; -----------------------------------------------------------------------------

DrvLstDelete:	push	edx		; push EDX
		mov	edx,DrvList	; EDX <- list of al drivers
		call	RBTreeDelete	; insert entry into list
		pop	edx		; pop EDX
		ret

; -----------------------------------------------------------------------------
;                       Add new resource into driver
; -----------------------------------------------------------------------------
; INPUT:	AL = resource type (RES_IRQ, RES_DMA, RES_PORT, RES_MEM)
;		AH = resource flags (RES_AUTO, RES_CANMANUAL, RES_PAGES)
;		EBX = driver parameter block
;		ECX = size of resource (1 to 64K)
;		EDX = start of resource (interrupt number, channel, address)
; OUTPUT:	CY = memory error
; NOTES:	It does not check if such resource already exists.
; -----------------------------------------------------------------------------

; ------------- Push registers

DrvResAdd:	push	eax		; push EAX
		push	ebx		; push EBX
		push	ecx		; push ECX
		push	edx		; push EDX

; ------------- Prepare resource flags (-> ECX)

		dec	ecx		; correct size of resource
		shl	eax,16		; EAX <- flags*64K
		or	ecx,eax		; ECX <- flags and size

; ------------- Create resource descriptor

		mov	eax,RESOURCE_size ; EAX <- size of resource descriptor
		call	SysMemAlloc	; get system memory block
		jc	DrvResAdd8	; memory error

; ------------- Initialize resource descriptor

		mov	[eax+RES_Start],edx ; start of resource
		mov	[eax+RES_SizeFlagsDW],ecx ; size and flags

; ------------- Add resource descriptor into driver parameter block

		add	ebx,DPB_Resource ; EBX <- resource list
		call	ListLast	; add resource descriptor into list

; ------------- Pop registers

		clc			; clear error flag
DrvResAdd8:	pop	edx		; pop EDX
		pop	ecx		; pop ECX
		pop	ebx		; pop EBX
		pop	eax		; pop EAX
		ret

; -----------------------------------------------------------------------------
;                     Add resource descriptor into driver
; -----------------------------------------------------------------------------
; INPUT:	EAX = resource descriptor (RES_STATIC = static descriptor)
;		EBX = driver parameter block
; -----------------------------------------------------------------------------

DrvResStatAdd:	push	ebx		; push EBX
		add	ebx,DPB_Resource ; EBX <- resource list
		call	ListLast	; add resource descriptor into list
		pop	ebx		; pop EBX
		ret

; -----------------------------------------------------------------------------
;                       Delete one resource of the driver
; -----------------------------------------------------------------------------
; INPUT:	AL = resource type (RES_IRQ, RES_DMA, RES_PORT, RES_MEM)
;		EBX = driver parameter block
;		EDX = start of resource (interrupt number, channel, address)
; OUTPUT:	CY = no such resource found
; -----------------------------------------------------------------------------

; ------------- Push registers

DrvResDel:	push	eax		; push EAX
		push	ebx		; push EBX
		push	ecx		; push ECX

; ------------- Get next resource descriptor (-> ECX)

		add	ebx,DPB_Resource ; EBX <- resource list head
		mov	ecx,ebx		; ECX <- resource list head
DrvResDel2:	mov	ecx,[ecx+LIST_Next] ; ECX <- next resource descriptor
		cmp	ecx,ebx		; any other resource descriptor?
		je	DrvResDel8	; no other resource descriptor

; ------------- Check if it is required resource

		cmp	al,[ecx+RES_Type] ; check resource type
		jne	DrvResDel2	; resource type is not valid
		cmp	edx,[ecx+RES_Start] ; check start address
		jne	DrvResDel2	; start address is not valid

; ------------- Delete resource descriptor from the list

		xchg	eax,ecx		; EAX <- resource descriptor
		call	ListDel		; delete resource descriptor from list

; ------------- Destroy resource descriptor (except static descriptor)

		test	byte [eax+RES_Flags],RES_STATIC ; static descriptor?
		jnz	DrvResDel8	; cannot delete static descriptor
                call	SysMemFree	; destroy resource descriptor
		clc			; clear error flag

; ------------- Pop registers

DrvResDel8:	pop	ecx		; pop ECX
		pop	ebx		; pop EBX
		pop	eax		; pop EAX
		ret

; -----------------------------------------------------------------------------
;                       Delete all resource of the driver
; -----------------------------------------------------------------------------
; INPUT:	EBX = driver parameter block
; -----------------------------------------------------------------------------

; ------------- Push registers

DrvResDelAll:	push	eax		; push EAX
		push	ebx		; push EBX
		push	ecx		; push ECX

; ------------- Get next resource descriptor (-> EAX)

		add	ebx,DPB_Resource ; EBX <- resource list head
		mov	eax,ebx		; EAX <- resource list
DrvResDelAll2:	xchg	eax,ecx		; ECX <- resource list
DrvResDelAll4:	mov	eax,[ecx+LIST_Next] ; EAX <- next resource descriptor
		cmp	eax,ebx		; any other resource descriptor?
		je	DrvResDelAll8	; no other resource descriptor

; ------------- Delete resource descriptor from the list

		call	ListDel		; delete resource descriptor from list

; ------------- Destroy resource descriptor

		test	byte [eax+RES_Flags],RES_STATIC ; static descriptor?
		jnz	DrvResDelAll2	; cannot delete static descriptor
                call	SysMemFree	; destroy resource descriptor
		jmp	short DrvResDelAll4 ; next descriptor

; ------------- Pop registers

DrvResDelAll8:	pop	ecx		; pop ECX
		pop	ebx		; pop EBX
		pop	eax		; pop EAX
		ret

; -----------------------------------------------------------------------------
;              Initialize standard system drivers and resources
; -----------------------------------------------------------------------------

; ------------- DMA controller

DrvStdInit:	mov	ebx,DMADrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list

; ------------- Interrupt controller

		mov	ebx,IRQDrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list

; ------------- System timer

		mov	ebx,TimerDrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list

; ------------- Keyboard controller

		mov	ebx,KeybDrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list

; ------------- CMOS real-time clock

		mov	ebx,CMOSDrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list

; ------------- Mathematic coprocessor

		mov	ebx,FPUDrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list

; ------------- Kernel data

		mov	eax,DataEnd-1	; EAX <- end of data - 1
		sub	eax,DataStart	; EAX <- size of data - 1
		mov	[DataDrvDPB22],ax ; set size of data
		mov	eax,BSSEnd	; EAX <- end of BSS
		sub	eax,BSSStart	; EAX <- size of BSS
		add	eax,PAGE_SIZE-1	; round up
		shr	eax,PAGE_SHIFT	; EAX <- size in pages
		dec	eax		; EAX <- size in pages - 1
		mov	[DataDrvDPB32],ax ; set size of data
		mov	ebx,DataDrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list

; ------------- Kernel code

		mov	eax,CodeEnd-1	; EAX <- end of code - 1
		sub	eax,CodeStart	; EAX <- size of code - 1
		mov	[CodeDrvDPB3],ax ; set size of code
		mov	ebx,CodeDrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list

; ------------- ROM BIOS

		mov	ebx,BIOSDrvDPB	; EBX <- driver parameter block
		call	DrvLstInsert	; insert driver into list
		ret

; -----------------------------------------------------------------------------
;                          Standard function
; -----------------------------------------------------------------------------

DrvStdFuncOK:	clc			; clear error flag
		ret

DrvStdFuncERR:	stc			; set error flag
		ret


; -----------------------------------------------------------------------------
;                         Display list of drivers
; -----------------------------------------------------------------------------

%ifdef	DEBUG_DRVLIST

; ------------- Lock list of drivers

DrvLstDisp:	DRVLSTLOCK		; lock list of drivers

; ------------- Get first driver (-> EBX)

		call	DebNewLine	; display new line
		call	DrvLstGetFirst	; get first driver
		jc	DrvLstDisp9	; no driver

; ------------- Display driver name

DrvLstDisp2:	mov	esi,[ebx+DPB_Name] ; ESI <- driver name
		call	DebOutSText	; display driver name

; ------------- Display model name

		mov	esi,[ebx+DPB_Model] ; ESI <- model name
		cmp	byte [esi],0	; empty text?
		je	DrvLstDisp3	; empty text
		mov	al," "		; AL <- space character
		call	DebOutChar	; display space
		mov	al,"("		; AL <- left bracket
		call	DebOutChar	; display left bracket
		call	DebOutSText	; display model name
		mov	al,")"		; AL <- right bracket
		call	DebOutChar	; display right bracket

; ------------- Get next resource

DrvLstDisp3:   	lea	ecx,[ebx+DPB_Resource] ; ECX <- resource list
		mov	edx,ecx		; EDX <- list head
DrvLstDisp4:	mov	edx,[edx+LIST_Next] ; EDX <- next resource
		cmp	edx,ecx		; last resource?
		je	DrvLstDisp8	; no other resource

; ------------- Type of resource

		movzx	eax,byte [edx+RES_Type] ; EAX <- type of resource
		mov	esi,[DebDrvLstTab+eax*4] ; ESI <- type string
		call	DebOutSText	; display resource type

; ------------- Memory

		cmp	al,RES_MEM	; memory?
		jne	DrvLstDisp5	; not memory
		mov	eax,[edx+RES_Start] ; EAX <- start address
		call	DebOutHexD0	; display start address
		mov	al,"-"		; AL <- separator
		call	DebOutChar	; display separator
		movzx	eax,word [edx+RES_Size] ; EAX <- size-1
		test	byte [edx+RES_Flags],RES_PAGES ; size is in pages?
		jz	DrvLstDisp44	; size is not in pages
		inc	eax		; EAX <- number of pages
		shl	eax,PAGE_SHIFT	; EAX <- size
		dec	eax		; EAX <- size - 1
DrvLstDisp44:	add	eax,[edx+RES_Start] ; EAX <- end address
		call	DebOutHexD0	; display end address
		jmp	short DrvLstDisp4 ; next resource

; ------------- Port

DrvLstDisp5:	cmp	al,RES_PORT	; port?
		jne	DrvLstDisp6	; not port
		mov	eax,[edx+RES_Start] ; EAX <- start address
		call	DebOutHexW	; display start address
		cmp	word [edx+RES_Size],0 ; size = 1 ?
		je	DrvLstDisp4	; next resource
		mov	al,"-"		; AL <- separator
		call	DebOutChar	; display separator
		movzx	eax,word [edx+RES_Size] ; EAX <- size-1
		add	eax,[edx+RES_Start] ; EAX <- end address
		call	DebOutHexW	; display end address
		jmp	DrvLstDisp4	; next resource

; ------------- IRQ and DMA

DrvLstDisp6:	mov	eax,[edx+RES_Start] ; EAX <- start address
		call	DebOutNum	; display start address
		cmp	byte [edx+RES_Size],0 ; size = 1 ?
		je	DrvLstDisp4	; next resource
		mov	al,"-"		; AL <- separator
		call	DebOutChar	; display separator
		mov	al,[edx+RES_Size] ; EAX <- size-1
		add	eax,[edx+RES_Start] ; EAX <- end address
		call	DebOutNum	; display end address
		jmp	DrvLstDisp4	; next resource

; ------------- Display new line

DrvLstDisp8:	call	DebNewLine	; display new line

; ------------- Get next driver (-> EBX)

		call	DrvLstGetNext	; get next driver
		jnc	DrvLstDisp2	; next driver is OK

; ------------- Unlock list of drivers

DrvLstDisp9:	DRVLSTUNLOCK		; unlock list of drivers
		ret

%endif

; -----------------------------------------------------------------------------
;                                   Data
; -----------------------------------------------------------------------------

		DATA_SECTION

; ------------- List of all drivers

		align	8, db 0
DrvList:	RBTREE			; list of all drivers
DrvListLock:	SPINLOCK		; lock of list of all drivers

; ------------- Debug display driver list

%ifdef	DEBUG_DRVLIST

DebDrvLstIRQ:	STEXT	',IRQ '
DebDrvLstDMA:	STEXT	',DMA '
DebDrvLstPort:	STEXT	',I/O '
DebDrvLstMem:	STEXT	',MEM '

		align	4, db 0
DebDrvLstTab:	dd	DebDrvLstIRQ
		dd	DebDrvLstDMA
		dd	DebDrvLstPort
		dd	DebDrvLstMem
%endif

; ------------- Standard function block

		align	4, db 0
DrvStdFuncTab:	dd	DrvStdFuncOK	; device detection
		dd	DrvStdFuncOK	; device initialization
		dd	DrvStdFuncERR	; device deinitialization
		dd	DrvStdFuncERR	; enable device
		dd	DrvStdFuncERR	; disable device

; ------------- System vendor name

DrvVendorName:	STEXT	'Litos Kernel'

; ------------- DMA controller

		align	8, db 0
DMADrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	0,DRV_SYS_DMA	; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	DMADrvName	; pointer to driver name
		dd	DMADrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
DMADrvDPB1:	LINKEDLIST DMADrvDPB2,DMADrvDPB5 ; resource list

DMADrvDPB2:	LINKEDLIST DMADrvDPB3,DMADrvDPB1 ; resource list
		dd	4		; start of resource
		dw	1-1		; size of resource-1
		db	RES_DMA		; resource type
		db	RES_STATIC+RES_AUTO ; flags

DMADrvDPB3:	LINKEDLIST DMADrvDPB4,DMADrvDPB2 ; resource list
		dd	0		; start of resource
		dw	16-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

DMADrvDPB4:	LINKEDLIST DMADrvDPB5,DMADrvDPB3 ; resource list
		dd	80h		; start of resource
		dw	16-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

DMADrvDPB5:	LINKEDLIST DMADrvDPB1,DMADrvDPB4 ; resource list
		dd	0c0h		; start of resource
		dw	32-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

DMADrvName:	STEXT	'DMA controller'
DMADrvModel:	STEXT	'8237A, 74612'

; ------------- Interrupt controller

		align	8, db 0
IRQDrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	0,DRV_SYS_IRQ	; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	IRQDrvName	; pointer to driver name
		dd	IRQDrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
IRQDrvDPB1:	LINKEDLIST IRQDrvDPB2,IRQDrvDPB4 ; resource list

IRQDrvDPB2:	LINKEDLIST IRQDrvDPB3,IRQDrvDPB1 ; resource list
		dd	2		; start of resource
		dw	1-1		; size of resource-1
		db	RES_IRQ		; resource type
		db	RES_STATIC+RES_AUTO ; flags

IRQDrvDPB3:	LINKEDLIST IRQDrvDPB4,IRQDrvDPB2 ; resource list
		dd	20h		; start of resource
		dw	2-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

IRQDrvDPB4:	LINKEDLIST IRQDrvDPB1,IRQDrvDPB3 ; resource list
		dd	0a0h		; start of resource
		dw	2-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

IRQDrvName:	STEXT	'Interrupt controller'
IRQDrvModel:	STEXT	'8259A'

; ------------- System timer

		align	8, db 0
TimerDrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	0,DRV_SYS_TIMER ; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	TimerDrvName	; pointer to driver name
		dd	TimerDrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
TimerDrvDPB1:	LINKEDLIST TimerDrvDPB2,TimerDrvDPB3 ; resource list

TimerDrvDPB2:	LINKEDLIST TimerDrvDPB3,TimerDrvDPB1 ; resource list
		dd	0		; start of resource
		dw	1-1		; size of resource-1
		db	RES_IRQ		; resource type
		db	RES_STATIC+RES_AUTO ; flags

TimerDrvDPB3:	LINKEDLIST TimerDrvDPB1,TimerDrvDPB2 ; resource list
		dd	40h		; start of resource
		dw	4-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

TimerDrvName:	STEXT	'System timer'
TimerDrvModel:	STEXT	'8254'

; ------------- Keyboard controller

		align	8, db 0
KeybDrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	0, DRV_SYS_KEYB	; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	KeybDrvName	; pointer to driver name
		dd	KeybDrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
KeybDrvDPB1:	LINKEDLIST KeybDrvDPB2,KeybDrvDPB4 ; resource list

KeybDrvDPB2:	LINKEDLIST KeybDrvDPB3,KeybDrvDPB1 ; resource list
		dd	1		; start of resource
		dw	1-1		; size of resource-1
		db	RES_IRQ		; resource type
		db	RES_STATIC+RES_AUTO ; flags

KeybDrvDPB3:	LINKEDLIST KeybDrvDPB4,KeybDrvDPB2 ; resource list
		dd	60h		; start of resource
		dw	1-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

KeybDrvDPB4:	LINKEDLIST KeybDrvDPB1,KeybDrvDPB3 ; resource list
		dd	64h		; start of resource
		dw	1-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

KeybDrvName:	STEXT	'Keyboard controller'
KeybDrvModel:	STEXT	'8042'

; ------------- CMOS real-time clock

		align	8, db 0
CMOSDrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	0,DRV_SYS_CMOS	; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	CMOSDrvName	; pointer to driver name
		dd	CMOSDrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
CMOSDrvDPB1:	LINKEDLIST CMOSDrvDPB2,CMOSDrvDPB3 ; resource list

CMOSDrvDPB2:	LINKEDLIST CMOSDrvDPB3,CMOSDrvDPB1 ; resource list
		dd	8		; start of resource
		dw	1-1		; size of resource-1
		db	RES_IRQ		; resource type
		db	RES_STATIC+RES_AUTO ; flags

CMOSDrvDPB3:	LINKEDLIST CMOSDrvDPB1,CMOSDrvDPB2 ; resource list
		dd	70h		; start of resource
		dw	2-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

CMOSDrvName:	STEXT	'CMOS real-time clock'
CMOSDrvModel:	STEXT	'MC146818'

; ------------- Mathematic coprocessor

		align	8, db 0
FPUDrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	0,DRV_SYS_FPU	; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	FPUDrvName	; pointer to driver name
		dd	FPUDrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
FPUDrvDPB1:	LINKEDLIST FPUDrvDPB2,FPUDrvDPB3 ; resource list

FPUDrvDPB2:	LINKEDLIST FPUDrvDPB3,FPUDrvDPB1 ; resource list
		dd	13		; start of resource
		dw	1-1		; size of resource-1
		db	RES_IRQ		; resource type
		db	RES_STATIC+RES_AUTO ; flags

FPUDrvDPB3:	LINKEDLIST FPUDrvDPB1,FPUDrvDPB2 ; resource list
		dd	0f0h		; start of resource
		dw	16-1		; size of resource-1
		db	RES_PORT	; resource type
		db	RES_STATIC+RES_AUTO ; flags

FPUDrvName:	STEXT	'Mathematic coprocessor'
FPUDrvModel:	STEXT	'80387'

; ------------- Kernel data
; If kernel exceed 64 KB then split area into more resource descriptors.

		align	8, db 0
DataDrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	1,DRV_SYS_SYS	; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	DataDrvName	; pointer to driver name
		dd	CodeDrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
DataDrvDPB1:	LINKEDLIST DataDrvDPB2,DataDrvDPB3 ; resource list

DataDrvDPB2:	LINKEDLIST DataDrvDPB3,DataDrvDPB1 ; resource list
		dd	DataStart-SYSTEM_ADDR ; start of resource
DataDrvDPB22:	dw	0		; size of resource-1
		db	RES_MEM		; resource type
		db	RES_STATIC+RES_AUTO ; flags

DataDrvDPB3:	LINKEDLIST DataDrvDPB1,DataDrvDPB2 ; resource list
		dd	BSSStart-SYSTEM_ADDR ; start of resource
DataDrvDPB32:	dw	0		; size of resource-1
		db	RES_MEM		; resource type
		db	RES_STATIC+RES_AUTO+RES_PAGES ; flags

DataDrvName:	STEXT	'System kernel data'

; ------------- Kernel code
; If kernel exceed 64 KB then split area into more resource descriptors.

		align	8, db 0
CodeDrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	0,DRV_SYS_SYS	; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	CodeDrvName	; pointer to driver name
		dd	CodeDrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
CodeDrvDPB1:	LINKEDLIST CodeDrvDPB2,CodeDrvDPB2 ; resource list

CodeDrvDPB2:	LINKEDLIST CodeDrvDPB1,CodeDrvDPB1 ; resource list
		dd	CodeStart-SYSTEM_ADDR ; start of resource
CodeDrvDPB3:	dw	0		; size of resource-1
		db	RES_MEM		; resource type
		db	RES_STATIC+RES_AUTO ; flags

CodeDrvName:	STEXT	'System kernel code'
CodeDrvModel:	STEXT	'RAM'

; ------------- ROM BIOS

		align	8, db 0
BIOSDrvDPB:	RBTREENODE		; red-black tree node
		SPINLOCK		; driver lock
		db	0,DRV_SYS_MB	; index, class and subclass
		db	DPB_STATIC,0	; flags and class flags
		db	0,0,0,1		; driver version
		dd	DrvVendorName	; pointer to vendor name
		dd	BIOSDrvName	; pointer to driver name
		dd	BIOSDrvModel	; pointer to model name
		dd	EmptySText	; modul path
		dd	DrvStdFuncTab	; pointer to function table
BIOSDrvDPB1:	LINKEDLIST BIOSDrvDPB2,BIOSDrvDPB2 ; resource list

BIOSDrvDPB2:	LINKEDLIST BIOSDrvDPB1,BIOSDrvDPB1 ; resource list
		dd	0c0000h		; start of resource
		dw	(40000h>>PAGE_SHIFT)-1 ; size of resource-1
		db	RES_MEM		; resource type
		db	RES_STATIC+RES_AUTO+RES_PAGES ; flags

BIOSDrvName:	STEXT	'System board'
BIOSDrvModel:	STEXT	'ROM BIOS area'

Back to source browser