Howdy, Stranger!

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

Categories

LIDT in Protected mode causes wierd behavior on my PC

eikedehlingeikedehling Member Posts: 123
Hi readers ....


I'm making an (Protected Mode) OS, and i does run pretty well ... at least i thought ...

I developed it using BOCHS 1.3, NASM, DJGPP ... sometimes i used an old PC to test it on real hardware ... bvut not quite often. Now, it is some time ago that i teste on a real PC, and - Damn - it does real wierd things, but not the things i want it to do ... Now i have tested all parts, and debugged each single instrucxtion, and i foud out, that the wierd stuff starts after i issued an 'lidt' during kernel initialisation. Under BOCHS everething works perfect, just as expected... On my Real PC, somehow the IRQ's seem to have different INT numbers ... and i can't do a task-switch when i do 'lidt' before it (not always true: it's rather impredictable ... and that sucks hard.) I do initialse the PIC, but somehow it seems to have a different effect on my 486, than under BOCHS ... I checked the complete IDT, it is OK.

My question: is there any (obvious) reason why this might go wrong ??

If think you got it, or you want to see the source code, to get an answer, please mail me (eikedehling@hotmail.com)

Thanx, Eike.

SUSE LINUX 7.3 PRO - The world starts behind windows

Comments

  • DariusDarius Member Posts: 1,666
    : Hi readers ....
    :
    :
    : I'm making an (Protected Mode) OS, and i does run pretty well ... at least i thought ...
    :
    : I developed it using BOCHS 1.3, NASM, DJGPP ... sometimes i used an old PC to test it on real hardware ... bvut not quite often. Now, it is some time ago that i teste on a real PC, and - Damn - it does real wierd things, but not the things i want it to do ... Now i have tested all parts, and debugged each single instrucxtion, and i foud out, that the wierd stuff starts after i issued an 'lidt' during kernel initialisation. Under BOCHS everething works perfect, just as expected... On my Real PC, somehow the IRQ's seem to have different INT numbers ... and i can't do a task-switch when i do 'lidt' before it (not always true: it's rather impredictable ... and that sucks hard.) I do initialse the PIC, but somehow it seems to have a different effect on my 486, than under BOCHS ... I checked the complete IDT, it is OK.
    :
    : My question: is there any (obvious) reason why this might go wrong ??
    :
    : If think you got it, or you want to see the source code, to get an answer, please mail me (eikedehling@hotmail.com)
    :
    : Thanx, Eike.
    :
    : SUSE LINUX 7.3 PRO - The world starts behind windows
    :

    You need to reprogram the PIC to put the IRQs at the locations you want. If you have done that then I'm not sure what them problem is yet.

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

  • blipblip Member Posts: 756
    Here's some remapping code incase you don't have any:
    [code]
    ; reprogram 8259-compatible interrupt controllers to use INT 20h through
    ; INT 2Fh for the 16 hardware interrupts. Code from Josh McDonald's OS/2000
    ; and from Linux.
    mov al,0x11 ; put both 8259s in init mode
    out 0x20,al
    out 0xA0,al
    mov al,0x20 ; IRQ0-IRQ7 -> interrupts 0x20-0x27
    out 0x21,al
    add al,8
    out 0xA1,al ; IRQ8-IRQ15 -> interrupts 0x28-0x2F
    mov al,4
    out 0x21,al
    mov al,2
    out 0xA1,al
    mov al,1
    out 0x21,al
    out 0xA1,al
    ; enable IRQs at these chips [ints still disabled at CPU]
    mov al,0xFE ; IRQ0 [timer]
    out 0x21,al
    mov al,0xFF ; none
    out 0xA1,al
    [/code]
  • eikedehlingeikedehling Member Posts: 123
    : : Hi readers ....
    : :
    : :
    : : I'm making an (Protected Mode) OS, and i does run pretty well ... at least i thought ...
    : :
    : : I developed it using BOCHS 1.3, NASM, DJGPP ... sometimes i used an old PC to test it on real hardware ... bvut not quite often. Now, it is some time ago that i teste on a real PC, and - Damn - it does real wierd things, but not the things i want it to do ... Now i have tested all parts, and debugged each single instrucxtion, and i foud out, that the wierd stuff starts after i issued an 'lidt' during kernel initialisation. Under BOCHS everething works perfect, just as expected... On my Real PC, somehow the IRQ's seem to have different INT numbers ... and i can't do a task-switch when i do 'lidt' before it (not always true: it's rather impredictable ... and that sucks hard.) I do initialse the PIC, but somehow it seems to have a different effect on my 486, than under BOCHS ... I checked the complete IDT, it is OK.
    : :
    : : My question: is there any (obvious) reason why this might go wrong ??
    : :
    : : If think you got it, or you want to see the source code, to get an answer, please mail me (eikedehling@hotmail.com)
    : :
    : : Thanx, Eike.
    : :
    : : SUSE LINUX 7.3 PRO - The world starts behind windows
    : :
    :
    : You need to reprogram the PIC to put the IRQs at the locations you want. If you have done that then I'm not sure what them problem is yet.
    :
    : "We can't do nothing and think someone else will make it right."
    : -Kyoto Now, Bad Religion
    :

    Thanx, but i am already doing exactly that ... And that does work (at least on BOCHS, itn even appears in BOCHS-debuf-log as PIC programming ...) So that is not the solution ...

    My best guess is, that in the 'mess' of assembly/C miced code (about 250 KB at the moment) somwhere the stack sometimes gets corrupted (during task-switches, and other unpredictable stuff) , and that that messes up my interrupts. Sometimes, the PC even generates a stack-error (BOCHS does not, there it works fine :)

    Anyhow: Thanx for your help.

    SUSE LINUX 7.3 PRO - The world starts behind windows

  • eikedehlingeikedehling Member Posts: 123
    See my reply ...

    Thanx anyhow.


    : Here's some remapping code incase you don't have any:
    : [code]
    : ; reprogram 8259-compatible interrupt controllers to use INT 20h through
    : ; INT 2Fh for the 16 hardware interrupts. Code from Josh McDonald's OS/2000
    : ; and from Linux.
    : mov al,0x11 ; put both 8259s in init mode
    : out 0x20,al
    : out 0xA0,al
    : mov al,0x20 ; IRQ0-IRQ7 -> interrupts 0x20-0x27
    : out 0x21,al
    : add al,8
    : out 0xA1,al ; IRQ8-IRQ15 -> interrupts 0x28-0x2F
    : mov al,4
    : out 0x21,al
    : mov al,2
    : out 0xA1,al
    : mov al,1
    : out 0x21,al
    : out 0xA1,al
    : ; enable IRQs at these chips [ints still disabled at CPU]
    : mov al,0xFE ; IRQ0 [timer]
    : out 0x21,al
    : mov al,0xFF ; none
    : out 0xA1,al
    : [/code]
    :


    SUSE LINUX 7.3 PRO - The world starts behind windows

  • Shawn CarterShawn Carter Member Posts: 0

    ____ ( http://forcoder.org ) free video tutorials and ebooks about // Swift, Visual Basic .NET, MATLAB, PL/SQL, Assembly, Scratch, C#, Java, Objective-C, Delphi, JavaScript, PHP, Perl, Visual Basic, Python, C++, Go, C, Ruby, R Julia, Apex, D, Scala, ML, Logo, Transact-SQL, Erlang, Fortran, FoxPro, Bash, SAS, Dart, F#, Scheme, Clojure, Awk, Lua, Kotlin, Ada, Crystal, Alice, Lisp, VBScript, LabVIEW, COBOL, Prolog, Rust, Hack, ABAP // _____________

Sign In or Register to comment.