You are not logged in.


  • Index
  •  » Main
  •  » My first module/driver loaded!

#1 2005-08-25 19:28:53

bubach
Administrator
From: Trollhättan, Sweden
Registered: 2005-02-15
Posts: 367
PM  Website

My first module/driver loaded!

Hi, I thought that I would let you know that I'm still working hard on the OS, and yesterday I loaded the first
module/driver or whatever to call it. It just printed some status about itself on the screen from it's init function, like current CS, DS etc..
I'm going to debug my add_interrupt function now, to see if it can add it's own interrupt with some test functions. big_smile
I'm going to post a nice screenshot of my testdriver in a day or two.

When it all works ok, I can start porting bit's of the OS to this driver interface and continue on the VFS/FAT12 part so i don't need to include all drivers as binarys directly after the kernel.. tongue

/ Christoffer

Offline

 

#2 2005-08-25 20:18:07

Dex4u
Active member
Registered: 2005-02-19
Posts: 132
PM

Re: My first module/driver loaded!

Great to hear your making progress, look forward to the shots wink .
For Dex4u driver/module i am thinking about a using a something like "djca" made
http://dex.7.forumer.com/viewtopic.php? … mp;start=0

Keep us informed.

Offline

 

#3 2005-08-26 04:05:41

smiddy
Active member
Registered: 2005-02-15
Posts: 183
PM

Re: My first module/driver loaded!

Excellent, here's my code, should be similar:

ASM code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AddISRToIDT - Adds an ISR to the IDT, then reloads the IDT.
;;
;; Assumptions: User has already turned off interrupts.
;;
;; Input:   ESI = Address of ISR
;;          EAX = The number of the IRQ to load
;;
;; Output:  EDI = Address of previous ISR (not functioning yet)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

AddISRToIDT:

    mov ebx,eax             ; Copy EAX into EBX
    mov eax,8               ; Place 8 into EAX
    mul ebx                 ; Multiply EAX by EBX to get offset of IRQ in IDT
    mov ebx,eax             ; Copy EAX into EBX
    mov eax,IDTISRStart     ; Load address of starting IRQ in IDT
    add eax,ebx             ; Add offset of IRQ into EAX
    mov ecx,esi             ; Place address of ISR into ECX
    mov [ds:eax],cx         ; Copy lower 16 bits into IDT entry
    shr ecx,16              ; Move upper 16 bits into CX
    mov [ds:eax + 6],cx     ; Copy upper 16 bits into IDT entry
    
    ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AddExceptionToIDT - Adds an exception ISR to the IDT, then reloads the IDT.
;;
;; Assumptions: User has already turned off interrupts.
;;
;; Input:   ESI = Address of ISR
;;          EAX = The number of the Exception to load
;;
;; Output:  EDI = Address of previous ISR (not functioning yet)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

AddExceptionToIDT:

    mov ebx,eax             ; Copy EAX into EBX
    mov eax,8               ; Place 8 into EAX
    mul ebx                 ; Multiply EAX by EBX to get offset of IRQ in IDT
    mov ebx,eax             ; Copy EAX into EBX
    mov eax,IDT             ; Load address of starting IRQ in IDT
    add eax,ebx             ; Add offset of IRQ into EAX
    mov ecx,esi             ; Place address of ISR into ECX
    mov [ds:eax],cx         ; Copy lower 16 bits into IDT entry
    shr ecx,16              ; Move upper 16 bits into CX
    mov [ds:eax + 6],cx     ; Copy upper 16 bits into IDT entry
    
    ret

Hopefully this will give you some ideas, if you aren't already using something similar.

Good job, I can't wait to see what is happening with your OS.

I'm running at a turtle's pace since I'm moving. I'll keep looking at the sites so I can comment and such on the fly.

Keep us posted!


- [color=red]s[/color][color=blue]m[/color][color=red]i[/color][color=blue]d[/color][color=red]d[/color][color=blue]y[/color]

Offline

 

#4 2005-08-26 10:06:29

bubach
Administrator
From: Trollhättan, Sweden
Registered: 2005-02-15
Posts: 367
PM  Website

Re: My first module/driver loaded!

Yeah, my code is similar, but I also have the selector part as input, since BOS is more or less segmented..

Offline

 

#5 2005-08-26 14:46:48

Dex4u
Active member
Registered: 2005-02-19
Posts: 132
PM

Re: My first module/driver loaded!

Nice code smiddy and well commentated smile .

Offline

 

#6 2005-08-26 21:38:42

smiddy
Active member
Registered: 2005-02-15
Posts: 183
PM

Re: My first module/driver loaded!

bubach wrote:

Yeah, my code is similar, but I also have the selector part as input, since BOS is more or less segmented..

The selector is probably a good idea, it removes the assumption. I'll consider that myself.

Dex4u wrote:

Nice code smiddy and well commentated smile.

Thanks, I've been relooking at everything in my rebuild and commenting where it needs it, for clarity.


- [color=red]s[/color][color=blue]m[/color][color=red]i[/color][color=blue]d[/color][color=red]d[/color][color=blue]y[/color]

Offline

 

 

Board footer

Powered by PunBB
BOS homepage © Copyright 2005 Christoffer Bubach
Strict XHTML and valid CSS.