willing to join someone's OS

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

My driver interface, works really well on my OS, but as my OS is based on a games console type OS (eg: runs in ring0, nopaging), it would be little uses to most dev's here.

But any it may help, first the driver format is a relocatable format, it is first assembled as a obj file from a coff file, then i use a program i have written to output two files one the driver, the other the relocatable for that driver (eg: .dri and .rel).

This mean i can load the driver any where in memory, in my case its is loaded to top of ram, then the size of file plus any buffer etc, is subtracted from TopOf Ram size and now that is top of ram.

Next when you load a driver or module it detects its as such and as well as loading it to top of ram, it fills a module list with info. it also check if it is already loaded and gives a error message if it is.

Now the the driver is layout like this:

Code: Select all

;=========================================================;
; Test module                                    25/08/07 ;
;---------------------------------------------------------;
; By Dex.                                                 ;
;                                                         ;
; Here is a simple Module demo.                           ;
; Assemble like this:                                     ;
; c:\fasm Test.asm Test.obj                               ;
;=========================================================;
format COFF
	jmp   ModRun			 ; jump to the start of program.
    Signature	  db	'MOD1'		 ; We check it's a valid Module file.
    ModID	  db	'DEX5UMOD'	 ; This the ID of the module.
    SizeOfModule  dd	 ModEnd 	 ; This put at end of module.
    ModLoadPtr	  dd	 ModLoad	 ; This is to run code on first load of module.
    ModUnLoadPtr  dd	 ModUnLoad	 ; This is to run code on unload of module.
    ModNumberPtr  dd	 2		 ; This is the number of functions.

ModRun:
	pushad				 ; ************ [STARTUP CODE HERE] ************
	push  ds
	push  es
	mov   ax,18h
	mov   ds,ax
	mov   es,ax

	mov   edi,Functions		 ; this is the interrupt
	mov   al,0			 ; we use to load the DexFunction.inc
	mov   ah,0x0a			 ; with the address to dex4u functions.
	int   40h

	mov   esi,MsgModLoadOK
	call  [PrintString]
	pop   es
	pop   ds
	popad
	ret				; This returns to the CLI/GUI

ModLoad:				; ************ [HERE IS CODE TO CALL FUNCTIONS] ************
	push  ds
	push  es
	push  eax
	mov   ax,18h
	mov   ds,ax
	mov   es,ax
	pop   eax
	cmp   ebx,[ModNumberPtr]
	ja    ModError
	shl   ebx,2
	add   ebx,ModFunctions
	call  dword[ebx]
	jc    ModError
ModOK:
	pop   es
	pop   ds
	clc
	ret


ModError:
	pop   es
	pop   ds
	stc
	ret


ModUnLoad:				; ************ [UNLOAD MOD CODE HERE] ************
	ret

ServiceUnUsed:				; Unused function.
	ret

Service1:				; ************ [FIST FUNCTON CODE HERE] ************
	pushad
	mov   esi,msgService1
	call  [PrintString]
	popad
	ret
Service2:				; ************ [SECOND FUNCTON CODE HERE] ************
	pushad
	mov   esi,msgService2
	call  [PrintString]
	popad
	ret

 ;----------------------------------------------------;
 ; Start of code in module.                           ;
 ;----------------------------------------------------;

ModFunctions:
		  dd	 ServiceUnUsed	; Reserve the first one.
		  dd	 Service1	; Points to first function.
		  dd	 Service2	; Points to second function.
 ;----------------------------------------------------;
 ; Data.                                              ;
 ;----------------------------------------------------;
MsgModLoadOK db 'Test2 module loaded',13,13,0
msgService1  db 'Hello from Service1!a',13,0
msgService2  db 'Hello from Service2!a',13,0
 ;----------------------------------------------------;
 ; BSS goes here.                                     ;
 ;----------------------------------------------------;

align 4 					      ;-----+
Cut  db '2CUT'					      ; These must be here
						   ;-----+
include 'Dex.inc'				      ; Dex inc file
ModEnd:
And the program to use it, may look like this:

Code: Select all

use32
	ORG   0x400000				       ; where our program is loaded to
start1:
	jmp   start				       ; jump to the start of program.
	db    'DEX2'				       ; We check for this, to make shore it a valid Dex4u file.

 ;----------------------------------------------------;
 ; Start of program.                                  ;
 ;----------------------------------------------------;
start:
	mov   ax,18h
	mov   ds,ax
	mov   es,ax
 ;----------------------------------------------------;
 ; Get calltable address.                             ;
 ;----------------------------------------------------;
	mov   edi,Functions			      ; this is the interrupt
	mov   al,0				      ; we use to load the DexFunction.inc
	mov   ah,0x0a				      ; with the address to dex4u functions.
	int   40h
	mov   esi,ModID1
	call  [ModuleFunction]                        ; This is call to get apointer to the driver
	jc    LetsExit
	mov   [mod1],eax

	mov   ebx,1                                   ; Driver function number
	call  [mod1]

	mov   ebx,2
	call  [mod1]


	call  [WaitForKeyPress] 		      ; Wait for key press

LetsExit:
	ret					      ; Exit.

 ;----------------------------------------------------;
 ; calltable include goes here.                       ;
 ;----------------------------------------------------;

mod1  dd 0
mod2  dd 0
ModID1	       db    'DEX5UMOD'       ; This the ID of the module.

include 'Dex.inc'				      ; Dex inc file
Now the key thing here is the ModID which is used to id the driver, so let say we want a sound driver, the id might be some thing like "DEXSOUND" now anyone writing a sound driver for DexOS would use the label "DEXSOUND" for the module ID, no-matter which sound card they are writing a driver for, also ever soundcard would have the same function numbers for the standard sound driver functions(we per define these), plus you can add extra one's after the must have one's.
These driver's are auto load at startup form a .bat file and also they can be loaded at any time or unloaded.

This may seam low tec to a lot of dev's, but i like to keep things simple, it is also very fast.

Note: The above is a simple demo of the drver interface and does nothing, but print a massage.
Post Reply