[SOLVED]Initializing paging stops the IRQ and ISR handler...
[SOLVED]Initializing paging stops the IRQ and ISR handler...
While i was rewriting my kernel, cause it get too heavy and without a lot of things necessaries for a kernel i have encountered with a problem. I'm working in the paging, it works correctly, i can start all i want(multitasking, user mode, timer...), but, when i enable paging, all the IRQs stop sending data and the ISR handler stops working... I have heap working... Any idea why this is caused ?
Last edited by Almamu on Thu Nov 18, 2010 8:32 am, edited 1 time in total.
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: Initializing paging stops the IRQ and ISR handler...
The GDT is loaded as a virtual address, not a physical one. If you turn on paging and the GDT moves, you need to give the processor the GDT's new address. I would think that the system would triple fault if that was the mistake, but I suppose it could simply hang if you had the kernel wait for interrupts.
Re: Initializing paging stops the IRQ and ISR handler...
Ok, so i should resend the GDT and IDT to CPU, thats right ?NickJohnson wrote:The GDT is loaded as a virtual address, not a physical one. If you turn on paging and the GDT moves, you need to give the processor the GDT's new address. I would think that the system would triple fault if that was the mistake, but I suppose it could simply hang if you had the kernel wait for interrupts.
EDIT: I cant do this cause im using an interrupt to detect any page fault...
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: Initializing paging stops the IRQ and ISR handler...
Well, did the locations of the GDT and IDT change when you turned on paging? I'm not sure that the GDT and IDT addresses are the problem, it's just a guess. The existence of a page fault handler should have no affect on whether you can reload the GDT and IDT.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Initializing paging stops the IRQ and ISR handler...
I expect interrupts to be off - otherwise there's nothing that *prevents* IRQs (rather they should cause crashes because the tables are no longer where the processor thinks they are)
Re: Initializing paging stops the IRQ and ISR handler...
Ok, now seems to work(atleast with the syscalls_ functions, they use interrupts...)but now my keyboard handler doesn't seems to work. It works before i initialise paging, but when i initialize it the drivers stops working, thats my code:Combuster wrote:I expect interrupts to be off - otherwise there's nothing that *prevents* IRQs (rather they should cause crashes because the tables are no longer where the processor thinks they are)
Code: Select all
unsigned char keymap[128] =
{
0, 27, '1', '2', '3', '4', '5', '6', '7', '8',
'9', '0', '-', '=', '\b',
'\t',
'q', 'w', 'e', 'r',
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
0,
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
'\'', '`', 0,
'\\', 'z', 'x', 'c', 'v', 'b', 'n',
'm', ',', '.', '/', 0,
'*',
0,
' ',
0,
0,
0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0,
0,
0,
0,
'-',
0,
0,
0,
'+',
0,
0,
0,
0,
0,
0, 0, 0,
0,
0,
0,
};
// Read keyboard buffer
unsigned char keyboard_data(){
unsigned char scancode;
scancode = inb(0x60);
return scancode;
}
static void keyboard_handler(registers_t *regs)
{
unsigned char scancode;
scancode = keyboard_data();
// Write the data to the screen
monitor_put(keymap[scancode]);
}
// Keyboard in IRQ1
void init_keyboard()
{
register_interrupt_handler(IRQ1, &keyboard_handler);
}
P.D: I know that i should scan for shift, caps, num lock, control... keys press, but atm i only want to prin a character to the screen readed from the keyboard...
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Initializing paging stops the IRQ and ISR handler...
Syscalls are not hardware interrupts.
Also, how come this question turns out to be in the FAQ? I somehow doubt you checked it.
Also, how come this question turns out to be in the FAQ? I somehow doubt you checked it.
Re: Initializing paging stops the IRQ and ISR handler...
If you read the problem comes up when i start paging, and not when i initialize the PIT, i can receive ISRs but no IRQs, so "When I try to enable the PIT, the keyboard doesn't work anymore" and "I'm not receiving any IRQ" are not my problems, as you know, the IRQs works when no paging is enabled... This is my IRQ remap, maybe this is wrong:Combuster wrote:Syscalls are not hardware interrupts.
Also, how come this question turns out to be in the FAQ? I somehow doubt you checked it.
Code: Select all
outb(0x20, 0x11);
outb(0xA0, 0x11);
outb(0x21, 0x20);
outb(0xA1, 0x28);
outb(0x21, 0x04);
outb(0xA1, 0x02);
outb(0x21, 0x01);
outb(0xA1, 0x01);
outb(0x21, 0x0);
outb(0xA1, 0x0);
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Initializing paging stops the IRQ and ISR handler...
You (summarized) wrote:i can receive ISRs but no IRQs, so "I'm not receiving any IRQ" are not my problems
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: Initializing paging stops the IRQ and ISR handler...
Hi:
An "interrupt" can be triggered in one of three ways: "software interrupts" are caused by executing a specific instruction which triggers an interrupt. "External", or "hardware" interrupts are raised by devices on the chipset, and they are known as "IRQs". "Exceptions" are internally generated interrupts which the processor raises when it needs to trap into the system software.
All three types of interrupts all eventually trap into the kernel. The kernel sets up "handler" functions for each type of interrupt it knows, whether generated by software, generated internally, or signaled externally. These "handlers" are known as "ISRs", which when expanded means: "Interrupt Service Routines". Interrupts trap into the kernel and the CPU vectors into some table or other and enters an ISR.
So you can't "receive" an ISR. You get an interrupt, and the CPU vectors and enters the kernel, and your kernel directs it to one or more ISRs. Just thought you should know so you could word your problem better, seeing as not doing so hasn't worked out too well for you so far.
An "interrupt" can be triggered in one of three ways: "software interrupts" are caused by executing a specific instruction which triggers an interrupt. "External", or "hardware" interrupts are raised by devices on the chipset, and they are known as "IRQs". "Exceptions" are internally generated interrupts which the processor raises when it needs to trap into the system software.
All three types of interrupts all eventually trap into the kernel. The kernel sets up "handler" functions for each type of interrupt it knows, whether generated by software, generated internally, or signaled externally. These "handlers" are known as "ISRs", which when expanded means: "Interrupt Service Routines". Interrupts trap into the kernel and the CPU vectors into some table or other and enters an ISR.
So you can't "receive" an ISR. You get an interrupt, and the CPU vectors and enters the kernel, and your kernel directs it to one or more ISRs. Just thought you should know so you could word your problem better, seeing as not doing so hasn't worked out too well for you so far.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Re: Initializing paging stops the IRQ and ISR handler...
Im talking when paging is enabled, if i disable it i can recevie IRQs and ISRs and handle them.Combuster wrote:You (summarized) wrote:i can receive ISRs but no IRQs, so "I'm not receiving any IRQ" are not my problems
EDIT: Seems that now i can receive interrupts before switching to user mode...
usermode:
Code: Select all
cli
mov $0x23, ax
mov ax, ds
mov ax, es
mov ax, fs
mov ax, gs
mov esp, eax
pushl $0x23
pushl esp
pushf
pushl $0x1B
push $1f
iret
Code: Select all
set_kernel_stack(current_task->kernel_stack+KERNEL_STACK_SIZE);
usermode();
Code: Select all
cli
mov $0x23, ax
mov ax, ds
mov ax, es
mov ax, fs
mov ax, gs
mov esp, eax
pushl $0x23
pushl esp
pushf
pushl $0x1B
push $1f
sti
ret
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: [SOLVED]Initializing paging stops the IRQ and ISR handle
You have a real problem there.
Why are you mixing intel syntax and ATT syntax - half that code is not doing what you think it does, such as setting ESP to the value in GS
Why are you mixing intel syntax and ATT syntax - half that code is not doing what you think it does, such as setting ESP to the value in GS
Re: [SOLVED]Initializing paging stops the IRQ and ISR handle
Ok, so, how do you think that this code should look ?Combuster wrote:You have a real problem there.
Why are you mixing intel syntax and ATT syntax - half that code is not doing what you think it does, such as setting ESP to the value in GS
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: [SOLVED]Initializing paging stops the IRQ and ISR handle
Since you asked, it should look like it was written by someone who knew what he was doing.Almamu wrote:Ok, so, how do you think that this code should look ?Combuster wrote:You have a real problem there.
Why are you mixing intel syntax and ATT syntax - half that code is not doing what you think it does, such as setting ESP to the value in GS
Seriously, I pointed out an error, including example. What more did you expect? Us writing your OS?