flat assembler
Message board for the users of flat assembler.

Index > OS Construction > making some drivers for my os

Author
Thread Post new topic Reply to topic
urielka



Joined: 16 Nov 2003
Posts: 17
Location: israel
urielka 12 Jun 2004, 18:20
i know how to build a "driver" for screen text mode using the memory buffer
but how i build driver for:
1.getting in the floppy(for now later to hdd and cd/dvd) write sec,delete and so
2.get scan code from keyboard(for now later the pos of mouse)
3.mange memory and later Vmem of fdd/hdd/cd

all this driver must be writen on 32bit PMode so i can`t use bios int
and how does i make my own int, writening them on .inc file(if yes how like a label?)?
10x
Very Happy
Post 12 Jun 2004, 18:20
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 12 Jun 2004, 18:32
Post 12 Jun 2004, 18:32
View user's profile Send private message Visit poster's website Reply with quote
urielka



Joined: 16 Nov 2003
Posts: 17
Location: israel
urielka 12 Jun 2004, 18:44
at least for the keyboard scan can you give my a example for driver that well comment and no complex(no multi press etc.)
Post 12 Jun 2004, 18:44
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
urielka



Joined: 16 Nov 2003
Posts: 17
Location: israel
urielka 12 Jun 2004, 19:43
how i know if a key has been pressed by an irq? but how i implent it on my os which instruct do that,the keyboard irg is irq1 and function 1
and for getting the key i use
in al,60h
but i need to do that only if a key press not all the time
so it will be like this
if there an irq the
in al,60h
but how i know that an irq was sent please help me and 10x
Post 12 Jun 2004, 19:43
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
Gomer73



Joined: 29 Nov 2003
Posts: 151
Gomer73 12 Jun 2004, 21:17
IRQ1 would be interuupt 9 unless you change this with your PIC(interrupt controller)
Since you have to create your own IDT for protected mode, you would know how to program where this code resides.
At the end of your interrupt you also need to do the following to enable interrupts:

mov al,20h
out 20h,al
Post 12 Jun 2004, 21:17
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 12 Jun 2004, 21:29
the Allegro graphics library has (or had? unless it's moved to 100% win32) a pretty good keyboard handler in C, showed how to do a lot of things... should be easy to find with google, I think the author is Shawn/Sean Hargreaves, something like that anyway - it should be in the top5 google hits anyway.
Post 12 Jun 2004, 21:29
View user's profile Send private message Visit poster's website Reply with quote
urielka



Joined: 16 Nov 2003
Posts: 17
Location: israel
urielka 12 Jun 2004, 22:05
not in PMode for now how i know if it sends my an irq like that(if the irq need to be 9(key press))?
code:
mov al,20h
out 20h,al
readagain:
in al,20h
cmp al,09h
jz readkey
jnz readagain
readkey:
in al,60h
ret
Post 12 Jun 2004, 22:05
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 12 Jun 2004, 23:06
Post 12 Jun 2004, 23:06
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 13 Jun 2004, 04:21
In the case of the keyboard the IRQ will come only when a key is in buffer / has been pressed .
Well on some other minor occasions like ACK of keyboard commands but you can ignore that for now

That is the whole idea of hardware IRQ's : to come and signal that you have some urgent job to do Very Happy
Exactly for you to avoid "busy waiting" == waiting in a loop for an event to occur or probing hardware.

Indeed you have a lot to read... as OS development is for guys who want to understand everything / and I mean every little aspect in hardware and low level ASM or C programming...

Waiting for us to tutor you steep-by-stepp is going to make you slowdown about 10000years or so... but will eventually get you there... the Quesion is: It will be you walking the path...or it will be us walking it for you (again) ?
Post 13 Jun 2004, 04:21
View user's profile Send private message Visit poster's website Reply with quote
urielka



Joined: 16 Nov 2003
Posts: 17
Location: israel
urielka 13 Jun 2004, 07:29
i don`t want you to tell me what i do exactly i only want the instruc for this i did a lot of my code by my self (i am working on a new ver and read alot of things to understand what i need to know)
and i know that i need to get from the irq the number 09h
from port 20h
so
i did like this
in al,20h
and this don`t work
it only work on
in ax,20h
but why shold i use ax the answer shold bee a byte and ax is a word(16bit)
so where the real answer sotres in al or ah(al and ah parts of ax right? al=8 lower bits ah=8higher bits)
i understood that u can`t tell me how to build an os step by step because it`s the same like you can`t pee for my i know i need to learing and that is what i am tring to do so please help me
10x
Post 13 Jun 2004, 07:29
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
urielka



Joined: 16 Nov 2003
Posts: 17
Location: israel
urielka 13 Jun 2004, 09:55
why this code is not working
keypress:
in eax, 64h
and eax, 1
jne keypress
in al,60h

ret
and then i use cmp to find which key has been pressed
it`s not in PMode but whichout int functions
Post 13 Jun 2004, 09:55
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 13 Jun 2004, 12:23
I use the following code in RetroForth/Native to read a keypress and get a byte value (returned in EAX)

Code:
key:
       xor eax,eax           ;  clear eax
.a:      in al,64h          ;  Is any data waiting?
       test al,1                     ;  Is character = ASCII 0?
    jz .a                 ;  Yes? Try again
        in al,60h          ;  Otherwise, read scancode
        xor edx,edx              ;  edx: 0=make, 1=break
        test al,80h              ;  Is character = HEX 80h?
        jz .b                     ;  Skip the next line
        inc edx                        ;  Update edx
.b:      and al,7Fh                ;  Filters to handle
        cmp al,39h              ;  the ignored keys
   ja .a                 ;  We just try another key
        mov ecx,[board]           ;  Load the keymap
        mov al,[ecx+eax]  ;  Get the key ASCII char
     or al,al                      ;  Is is = 0?
        js .shift                      ;  No, use CAPITALS
        jz .a                    ;  Ignore 0's
        or dl,dl                      ;  Filter for break code
        jnz .a                      ;  Ignore break code
          ret
.shift:  mov ecx,[edx*4 + .shifts] ;  Load the CAPITAL keymap
        mov [board],ecx                   ;  Store into BOARD pointer
        jmp .a                   ;  And try again
.shifts dd shift,alpha
variable board, alpha
alpha:
  db 0,27,"1234567890-=",8              ;00-0E
  db 9,"qwertyuiop[]",10                ;0F-1C
  db 0,"asdfghjkl;'`"                   ;1D-29
  db -1,"\zxcvbnm,./",-1,"*",0,32,-2    ;2A-3A
shift:
  db 0,27,"!@#$%^&*()_+",8              ;00-0E
  db 9,"QWERTYUIOP{}",10                ;0F-1C
  db 0,'ASDFGHJKL:"~'                   ;1D-29
  db -1,"|ZXCVBNM<>?",-1,"*",0,32,-2    ;2A-3A
    

_________________
Charles Childers, Programmer
Post 13 Jun 2004, 12:23
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 13 Jun 2004, 16:26
don't forget that shifts, sys request and pause are handled little bit differently than with single code
Post 13 Jun 2004, 16:26
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
urielka



Joined: 16 Nov 2003
Posts: 17
Location: israel
urielka 13 Jun 2004, 20:32
it now work but........it`s slow(until it know that i press w) on vmware And stucks
my kernel:
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;main
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
mov ax,1000h
mov ds,ax
mov es,ax
start:
mov si,msg
call outputscr
call key
cmp al,11h
jz ver
jmp $
;-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;drivers
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
outputscr: ;21
lodsb ;22
or al,al ;23
jz short ends ;24
mov ah,0x0E ;25
mov bx,0x0007 ;26
int 0x10 ;27
jmp outputscr ;28
ends: ;29
retn ;30
key:
xor eax,eax ; clear eax
.a: in al,64h ; Is any data waiting?
test al,1 ; Is character = ASCII 0?
jz .a ; Yes? Try again
in al,60h ; Otherwise, read scancode
ret

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;38procedures
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ver: ;40
mov si,msgg ;41
call outputscr ;42
ret ;43
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;45strings and vars
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
msg db "press w to get the ver",13,10,0 ;47
msgg db "woody os ver 0.01a",13,10,0 ;48
times 32768-($-$$)-2 db 0 ;49
my boot(lowos boot):
org 0x7C00 ; Unsere Startadresse

; -----------------------------------------
; Unser Bootloader
; -----------------------------------------

start:
; Erst brauchen wir einen Stack.
cli ; Keine Interrupts!
mov ax, 0x9000 ; Stackadresse
mov ss, ax ; SS = 9000 (unser Stack)
mov sp, 0 ; SP = 0000 (der Stackpointer)
sti ; Interrupts zulassen

; Bootlaufwerk aus DL speichern
mov [bootdrv], dl

;Lade unseren Kernel
call load

;Springe zu diesem Kernel
mov ax, 0x1000 ; Die Adresse des Programms
mov es, ax ; Segmentregister updaten
mov ds, ax
push ax
mov ax, 0
push ax
retf

; ----------------------------------------------
; Funktionen und Variablen
; ----------------------------------------------

bootdrv db 0 ;Das Bootlaufwerk
loadmsg db "Loading...",13,10,0

; Einen String ausgeben:
putstr:
lodsb ; Byte laden
or al,al
jz short putstrd ; 0-Byte? -> Ende!

mov ah,0x0E ; Funktion 0x0E
mov bx,0x0007 ; Attribut-Byte (wird nicht benötigt)
int 0x10 ; schreiben
jmp putstr ; Nächstes Byte
putstrd:
retn

; Lade den Kernel vom Bootlaufwerk
load:

; Diskdrive reset (Interrupt 13h, 0)
push ds ; Sichere DS
mov ax, 0 ; Die gewünschte Funktion (reset)
mov dl, [bootdrv] ; Dieses Laufwerk ist gewünscht
int 13h ; Den Interrupt ausführen
pop ds ; DS wiederherstellen
jc load ; Geht nicht? -> Noch mal!

load1:
mov ax,0x1000 ; ES:BX = 10000
mov es,ax
mov bx, 0

; Sektoren lesen (Interrupt 13h, 2)
mov ah, 2 ; Funktion 2 (Lesen)
mov al, 5 ; Lese 5 Sektoren
mov cx, 2 ; Cylinder=0, Sector=2
mov dx, 0 ; Head=0, Laufwerk=0
int 13h ; ES:BX = Daten vom Laufwerk
jc load1 ; Fehler? Noch mal!
mov si,loadmsg
call putstr ; Meldung ausgeben
retn

times 512-($-$$)-2 db 0 ; Dateilänge: 512 Bytes
dw 0AA55h ; Bootsignatur
all the thing compiled by nasm of course
Post 13 Jun 2004, 20:32
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.