Os programmering

2

Comments

  • hmmm
    i can see what you mean (both), and now i have tryede a little crontroller programmering. and i can see why it isen't used that much, (i have found a example of it : http://www.wagemakers.be/english/doc/vga , and http://www.codebreakers-journal.com/content/view/117/103/ .)
    and about protected mode, i will first know how the code will have to be, before i chance the mode. but i will of cause have to chance.
    But the next thing i wanna ask about, is how to make your own int, (the reason why i ask here is that you know it, and i dont want to seach google, for the **** time,)

    thanks for answering

    Kmt

  • One should only use what is needed when programming. Because most
    applications interface with the OS, there is useually no reason
    to do controller programming unless you yourself are developing an OS.

    I still recommend going into protected mode first, before continuing
    on. Protected mode uses a different addressing system then real mode
    does, with added priviledge levels.

    You do seem like you are jumping far ahead of yourself. This will
    hurt in the long one, depending on how complex your OS will be.

    Nontheless, if you want to continue, Protected Mode has absolutley
    no interrupts when you switch, so you will need to remap all interrupts.
    This requires reprogramming the Programmable Interrupt Controller (PIC),
    with your new Interrupt Vector Table (IVT).

    Note that I said "absolutley no interrupts". That is, if any interrupt
    (Even those provoked by a timer, for example) will triple fault the CPU
    in protected mode until you remap your own table.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • hmmmmm ./.....
    the thing i asked about was if you know hot to set up the IVT , (and with that i meant if you coud make a source code, since i lean more from that.)
    ...
    and the code, i am not finish :), but i am workin on it. and, sure i will switch to pmode, else i cant use much grapich, and even if i could, i will not be able to make a os without

    Kmt :)



    ... by the way, should we not create a new thred, using a new name, this is getting to long
  • [code]
    the thing i asked about was if you know hot to set up the IVT , (and with that i meant if you coud make a source code, since i lean more from that.)
    [/code]

    I CAN, but it will be a while. Remember there are 256 entry's? o.0

    Also, setting up the ENTIRE IVT requires first setting up IRQs, ISRs, which involve remapping the PICs for hardware interrupts, followed by writing routines hat can set and get vector tables so that we can add our own software interrupts.

    I recommend NOT worrying about the IVT overall for now--That will build itself up through time as you add to it.

    I DO recommend remapping the PICs now, and trapping hardware exceptions (so you can output useful information instead of triple fault. ak, BSOD)

    [b]Let me know at what you first want to proceed with--IRQs, IRSs, or remapping the PICs, and I will find a tutorial for you.[/b]

    [code]
    and the code, i am not finish :), but i am workin on it. and, sure i will switch to pmode, else i cant use much grapich, and even if i could, i will not be able to make a os without
    [/code]
    Perhaps I should show you my low level C DOS Graphical Pong game using real mode interrupts :/ :-)

    Both of these statements--again--are incorrect.

    [code]
    ... by the way, should we not create a new thred, using a new name, this is getting to long
    [/code]

    Go for it:-)

    Displaying the thread in linear view doesn't make it look that bad.
  • [b]Setting up the IDT[/b]

    The IDT is an array of 256 interrupt descriptors. Each descriptor contains
    information, such as the base address, of a function to call.

    Each descriptor follows the format:
    [code]
    struc IDT_Entry:
    m_baseLow: resw 0 ; address of handler
    m_selector: resw 0 ; code selector (Usually 0x8, same with GDT)
    m_reserved: resb 0
    m_DPL: resb 0 ; Descriptor Protection Level
    m_BaseHi resw 0 ; high base address
    endstruc
    [/code]
    Remember that this is an array of 256 descriptors--so you will need to
    create the array of 256 IDT_Entrys.

    Next up, is the IDT Pointer, which is used by the processor to point
    to the IDT:
    [code]
    IDT_Ptr:
    dw 0 ; size of IDT (Sizeof IDT_Entry * 256)
    dd 0 ; base address of IDT (The address of our IDT_Entry array)
    [/code]

    The IDT descriptors are easy to fill out. [b]m_baseLow[/b] takes the
    [b]lower 2 bytes[/b] of your interrupt routine, and [b]m_baseHi[/b] takes
    [b]the upper 2 bytes[/b] of the same address.

    [b]m_selector[/b] should always be 0x8, and [b]m_reserved[/b] should
    always be 0. The [b]DPL[/b] is usually 0x8E. I want to keep this post
    short, so I wont explain why here.

    The actual address is an address to an interrupt routine. Such as:
    [code]
    ; Here is our interrupt table.

    ; Will be called whenever int 0x0 is fired.
    _irq0:
    cli
    push 0
    push 32
    jmp IRQ_Stub ; do something here
    [/code]

    Great! So now, we have the interrupt table, and the IDT set up
    to point to the interrupt routines. All we need now is to load the IDT
    into the processor:
    [code]
    LoadIDT:
    lidt [IDT_Ptr]
    ret
    [/code]

    Thats all there is to it ;-)

    Of course, this does not touch on the PICs.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • well....
    I didnt understood alle, but i found some help (the link)
    i have searched for the pmode entrance, and found a greate tutorial, it has also the IDT and .....
    the link is http://www.programmersheaven.com/download/15817/download.aspx
    :)
    you new tutorial (mt2002), is good (10, prepare the kernel).
    and by the way, the a20 gate, is it that who make the 32bit crontrol, or is it pmode ???


    Kmt



  • : you new tutorial (mt2002), is good (10, prepare the kernel).

    Thanks!:-)

    : and by the way, the a20 gate, is it that who make the 32bit
    : crontrol, or is it pmode ???

    I'm not sure what you are asking... The current a20 code should work in both real mode and pmode. (The one from my tutorial, anyway.)

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • : I'm not sure what you are asking... The current a20 code should work
    : in both real mode and pmode. (The one from my tutorial, anyway.)
    well...
    what is it that makes 32 bit, (eax .....) possebel, is it a20 gate or the entry of pmode ?

    (pmode = 32 bit, or is it a20 gate ?)
    i have tryed to make a subruine to write a string, but it Wont work,...
    :(
    (it is attached)
    Kmt

  • PMode=32 bit, a20 has nothing to do with PMode directly.

    The code you posted is still in real mode, not PMode...

    Your code says that you ran the code inside of DEBUG. Does this mean that you assembled the code and tried to run it inside DEBUG? If so, hat will not work for alot of reasons. DEBUG only deals with DOS programs, which use DOS interrupts and routines. In Kernel Land, There is NO DOS! It also assumes your program begins at offset 0x100, which may not be true. Not to mention, it does not know 32 bit.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • that is right, but, if you copy it from 0000:0100, to floppy, then it can work.
    but the problem is that i Cant make the computer, print a sting.
    i have tryede alle things that came in my mind.
    can you not check it, and answer me whats wrong ? (last post)

    Kmt
  • : that is right, but, if you copy it from 0000:0100, to floppy, then
    : it can work.

    No no no no. It's location on disk is irrilavent. DOS requires every address offset from 0x100 in memory because DOS places the IVT within the first 100 bytes.

    I hope this program is not your bootloader, as it [b]will not boot[/b].

    : but the problem is that i Cant make the computer, print a sting.
    : i have tryede alle things that came in my mind.
    : can you not check it, and answer me whats wrong ? (last post)
    :
    : Kmt
    :

    Are you testing your program in DOS DEBUG? You are attempting to directly access video memory--which DOS DEBUG does NOT allow.

    You can save it as a *.COM (through DEBUG), run it as stand alone and it should be okay. It's still not going to work for an OS though.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • well that is what i do
    i do it , this way: (after the code) w 100 0 0 1
    and run it though boch
    = work
    but How in the hell.. do i get the subrutine to work
    kmt

  • : well that is what i do
    : i do it , this way: (after the code) w 100 0 0 1
    : and run it though boch
    : = work
    : but How in the hell.. do i get the subrutine to work
    : kmt
    :
    :

    Again: [b]If this your bootloader, it WILL NOT work.[/b] Note that I said WILL NOT, not MIGHT NOT.

    Ugh I should not be doing this...
    [code]
    ; my test program, i use debug.exe (windows) to do it. runded under windows.

    ; jump to start
    jmp 113 ; 0100

    ; Now SI=Address of string;
    ; AX and ES point to 0xb800

    xor ax,ax ; 0102
    mov ds,ax ; 0104

    lodsb ; 0106
    or al,al ; 0107
    je 112 ; 0109
    mov ah,01 ; blue on black ; 010b
    mov word ptr [di], ax ; 010d
    inc di ; 010f
    jmp 102 ; 0110

    ret ; 0112

    ; start of routine--------------------------

    ; go back in same text mode (DOS starts in text mode 3)
    mov ax,0003 ; 0113
    int 10 ; 0116

    mov si,129 ; 0118 SI=Address of string
    mov ax,b800 ; 011b
    mov es,ax ; 011e AX and ES=video memory start
    call 102 ; 0120

    xor ax,ax ; 0123
    int 16 ; 0125
    int 20 ; 0127
    db "hej",00 ; hej is danish, (it means hi) ;0129
    cli ; 012d
    hlt ; 012e

    ; end: 012f
    [/code]

    The problem is that you set the address of the string into SI before calling the routine:
    [code]
    [red]mov si,129 ; 0118 SI=Address of string[/red]
    mov ax,b800 ; 011b
    mov es,ax ; 011e AX and ES=video memory start
    call 102 ; 0120
    [/code]

    However your routine [b]does not use SI! It uses DI:[/b]
    [code]
    ; Now SI=Address of string;
    ; AX and ES point to 0xb800

    xor ax,ax ; 0102
    mov ds,ax ; 0104

    lodsb ; 0106
    or al,al ; 0107
    je 112 ; 0109
    mov ah,01 ; blue on black ; 010b
    mov word ptr [di], ax ; 010d
    inc di ; 010f
    jmp 102 ; 0110

    ret ; 0112
    [/code]

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • Thansk much
    i know what you are saying, about debug.( but i have an other code, it is attached, and you can try it, just copy alle to debug, with a formatede disk.)
    the reason why i down use you subrutine.. is that i dont understand how mine not are.


    Kmt
  • : Thansk much
    : i know what you are saying, about debug.( but i have an other code,
    : it is attached, and you can try it, just copy alle to debug, with a
    : formatede disk.)

    Okay, then:-)

    : the reason why i down use you subrutine.. is that i dont understand
    : how mine not are.

    Im not sure what you mean here...

    The code I posted was the same routine you uploaded, just with added comments by me.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories