OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Dec 12, 2017 4:09 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: RTC interruption
PostPosted: Mon Oct 09, 2017 8:19 pm 
Offline

Joined: Wed Aug 30, 2017 9:04 pm
Posts: 6
I am trying to set rtc interruptions, but it is not working(triple fault).
I have already setted PIC1 and PIC2 and their interruption masks.

This is the code that sets the rtc interruptions:
Code:
/*          Ports
*        PIC1   PIC2
*Command 0x20   0xA0
*Data    0x21   0xA1
*/


asm volatile ( "cli" );

uint8_t rate = 0x05;
outb(0x70, 0x8B);
char prev = inb(0x71);
outb(0x70, 0x8B);
outb(0x71, prev | 0x40);

outb(0x70, 0x8A);
prev = inb(0x71);
outb(0x70, 0x8A);
outb(0x71, (prev & 0xF0) | rate );
outb(0x70, 0x0C);
inb(0x71);

// PIC 2
/* 0xFE is 11111110 - enables IRQ0 (rtc)*/
uint8_t prevIrq = inb(0xA1);
outb(0xA1 , 0xFE & prevIrq );
     
// PIC 1
/* 0xFB is 11111011 - enables IRQ2 (rtc)*/
prevIrq = inb(0x21);   
outb(0x21 , 0xFB & prevIrq );     

asm volatile ( "sti" );


This is the rtc interruption handler:
Code:
/*          Ports
*        PIC1   PIC2
*Command 0x20   0xA0
*Data    0x21   0xA1
*/

outb(0xA1, 0x20);
outb(0x20, 0x20);
/*
do something
*/


Top
 Profile  
 
 Post subject: Re: RTC interruption
PostPosted: Mon Oct 09, 2017 11:41 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3027
Location: Chichester, UK
No "RTI" instruction?


Top
 Profile  
 
 Post subject: Re: RTC interruption
PostPosted: Tue Oct 10, 2017 9:59 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 1200
pedrodemargomes wrote:
I am trying to set rtc interruptions, but it is not working(triple fault).

Have you figured out where in your code the triple fault occurs?

pedrodemargomes wrote:
Code:
outb(0xA1, 0x20);

I don't think this line of code does what you want.


Top
 Profile  
 
 Post subject: Re: RTC interruption
PostPosted: Tue Oct 10, 2017 6:21 pm 
Offline

Joined: Wed Aug 30, 2017 9:04 pm
Posts: 6
Octocontrabass wrote:
pedrodemargomes wrote:
I am trying to set rtc interruptions, but it is not working(triple fault).

Have you figured out where in your code the triple fault occurs?

Yes, it occurs at the first rtc interruption.

Octocontrabass wrote:
Code:
outb(0xA1, 0x20);

I don't think this line of code does what you want.

It supossed to be 0xA0, i fixed that :D .
But the problem is that the program does not get there, it fails before that.

I will let my git repository here:
https://gitlab.com/pedrodemargomes/BootTeste_OS


Top
 Profile  
 
 Post subject: Re: RTC interruption
PostPosted: Tue Oct 10, 2017 6:38 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8169
Location: At his keyboard!
Hi,

pedrodemargomes wrote:
I am trying to set rtc interruptions, but it is not working(triple fault).


In that case it's probably a problem with your GDT, IDT or stack (and not a problem with any of the code you posted). You should be able to get some information about what caused the triple fault from an emulator's logs (e.g. if the first exception was a general protection fault or page fault, etc).

pedrodemargomes wrote:
I will let my git repository here:
https://gitlab.com/pedrodemargomes/BootTeste_OS


I couldn't find any source code there.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: RTC interruption
PostPosted: Wed Oct 11, 2017 5:51 am 
Offline

Joined: Wed Aug 30, 2017 9:04 pm
Posts: 6
Brendan wrote:
Hi,

pedrodemargomes wrote:
I am trying to set rtc interruptions, but it is not working(triple fault).


In that case it's probably a problem with your GDT, IDT or stack (and not a problem with any of the code you posted). You should be able to get some information about what caused the triple fault from an emulator's logs (e.g. if the first exception was a general protection fault or page fault, etc).

pedrodemargomes wrote:
I will let my git repository here:
https://gitlab.com/pedrodemargomes/BootTeste_OS


I couldn't find any source code there.


Cheers,

Brendan


Sorry, i forgot to change the permissions :D, now it is right.
I could not find any usefull information in the log files about the the faults :( .


Top
 Profile  
 
 Post subject: Re: RTC interruption
PostPosted: Wed Oct 11, 2017 12:23 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 110
Where in your code do you set up the IDT entry for your RTC Interrupt handler? I see you set up an entry for the keyboard at IDT[0x21] to handle IRQ1. To handle IRQ8 (RTC) you would need an IDT entry at IDT[0x28] with the way you set up the PICs and then point it at your rtc_handler function.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Haoud, Yahoo [Bot] and 19 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