OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 9:35 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: protected mode isr
PostPosted: Mon Oct 13, 2008 10:15 am 
Offline
Member
Member

Joined: Thu Oct 09, 2008 8:25 am
Posts: 71
Location: Rio de Janeiro - Brazil
Hi, im sing the code neon corrected to go into protected. After i put some apic code referencing vector 1 - keyboard to generate a interrupt, and finally a isr who write on screen.
The code is without error but dont print on the screen. Any ideias?

bits 16
org 0x7c00

jmp main

main:

mov ax, word 0x0000
mov ds, ax

mov ax, word isr
mov [2008], word ax
mov [2010], word 0x8
mov [2012], word 1000111000000000b ; interrupt descriptor
mov [2014], word 0x0000

mov [2016], word 255
mov [2018], word 2000
mov [2020], word 0


mov [528], word 0xffff
mov [530], word 0x0000
mov [532], byte 0x00
mov [533], byte 0x9a
mov [534], byte 0xcf
mov [535], byte 0x00

mov [536], word 0xffff
mov [538], word 0x0000
mov [540], byte 0x00
mov [541], byte 0x92
mov [542], byte 0xcf
mov [543], byte 0x00

mov [1000], word 23
mov [1002], word 520
mov [1004], word 0x0000

cli
lgdt [1000]
mov eax,cr0
or al,0x01
mov cr0,eax

jmp 8:pm

jmp $

bits 32

pm:

mov ax, 8*2
mov ds,ax


lidt [2016]

mov eax, 0x12
mov [0xfec00000], dword eax
mov [0xfec00010], dword 0x00000001 ;apic

mov eax, 0x13
mov [0xfec00000], dword eax ;apic -
mov [0xfec00010], dword 0x00000000

jmp $

isr:

mov [0xb8000], byte 'A'
mov [0xb8001], byte 0x17


Top
 Profile  
 
 Post subject: Re: protected mode isr
PostPosted: Mon Oct 13, 2008 10:34 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Neon also told you to rewrite that code. I can't read this, let alone figure what it does or is meant to do.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: protected mode isr
PostPosted: Mon Oct 13, 2008 1:27 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
I hope that is not the complete code. If it is, it will triple fault when the ISR is called because you are not returning from it.

If this is a hardware interrupt, you need to enable interrupts first (STI instruction). Make sure you have mapped the PIT to a valid int handler first though.

Lastly, if this is a 1st stage boot loader, keep in mind that you are limited to 512 bytes. The assembler wont tell you, so if you go beyond 512 bytes you will run into problems.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject: Re: protected mode isr
PostPosted: Mon Oct 13, 2008 2:01 pm 
Offline
Member
Member

Joined: Thu Oct 09, 2008 8:25 am
Posts: 71
Location: Rio de Janeiro - Brazil
hi, whats PIT?


Top
 Profile  
 
 Post subject: Re: protected mode isr
PostPosted: Mon Oct 13, 2008 2:23 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
http://www.catb.org/~esr/faqs/smart-questions.html
viewtopic.php?f=1&t=16944

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: protected mode isr
PostPosted: Tue Oct 14, 2008 7:36 am 
Offline
Member
Member

Joined: Thu Oct 09, 2008 8:25 am
Posts: 71
Location: Rio de Janeiro - Brazil
why i need to remap pit?
thanks


Top
 Profile  
 
 Post subject: Re: protected mode isr
PostPosted: Tue Oct 14, 2008 7:44 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
I think that was a typo - he meant PIC.

Cheers,
Adam


Top
 Profile  
 
 Post subject: Re: protected mode isr
PostPosted: Tue Oct 14, 2008 4:05 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
Quote:
I think that was a typo - he meant PIC

You are right--I was thinking PIT (Because it uses IRQ 0), but you need to map the PIC. Thanks for the correction :)

Quote:
why i need to remap pit?

If you want hardware exceptions enabled, and the PIC IRQ0 isnt mapped to use a valid IRQ handler defined by you, then almost as soon as you enable hardware interrupts, IRQ 0 will fire and execute invalid code.

Thus, you need to remap the PICs to use a valid base IRQ address in your IDT and define interrupt handlers for them. Search the Wiki or Google...there are alot of good info on the PIC.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 217 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group