Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Unexpected
Post
by Unexpected » Wed Dec 18, 2002 3:06 pm
Tom, my PIC is intialized and outportb(0x20, 0x20) is before IRET
But here is another problem...
In ASM file:
Code: Select all
EXTERN _KBD_Handler
GLOBAL _IRQ1_Handler
_IRQ1_Handler:
PUSHA
CALL _KBD_Handler
POPA
IRET
In C file:
Code: Select all
...
extern void IRQ1_Handler();
...
void KBD_Handler()
{
Print("KBD_Test\n");
ScanCode = inportb(0x60);
KBD_BufAdd(ScanCode);
outportb(0x20, 0x20);
}
So if I pressing a key two times, then must print to screen two "KBD_Test" messages...
But prints only one?
Whats the problem?
jrfritz
Post
by jrfritz » Wed Dec 18, 2002 3:13 pm
Does it print the text over itself?
or are you using my Print() C++ function?
Also try printing the ASCII non shifted value of inportb.
whyme_t
Post
by whyme_t » Wed Dec 18, 2002 3:17 pm
Unexpected wrote:
If no then why?
Because for irq's 0-7 you must send
end of interrupt to master pic.
Code: Select all
//send EOI (0x20) to port 0x20
outportb(0x20, 0x20);
And for irq's 8-15 you must send EOI to both pics.
Code: Select all
//send EOI (0x20) to port (0xA0) and to port(0x20)
outportb(0xA0, 0x20);
outportb(0x20, 0x20);
If you don't send EOI, you will not receive any further interrupts.
In addition to this, the keyboard will not trigger another interrupt until you read the scancode from port 0x60.
whyme_t
Post
by whyme_t » Wed Dec 18, 2002 3:20 pm
Unexpected, try disabling interrupts as you enter your isr, and enable them before you leave.
Unexpected
Post
by Unexpected » Wed Dec 18, 2002 3:21 pm
I'm using my own Print function and it work correctly
I think error is somewhere in handlers and asm mixing with C...
jrfritz
Post
by jrfritz » Wed Dec 18, 2002 3:37 pm
I don't mean to be rude, but this is like two people fighing over the same thread...i'm going to start a new one.
Unexpected
Post
by Unexpected » Wed Dec 18, 2002 3:55 pm
Sorry Tom, I just want to clear up with interrupts...
jrfritz
Post
by jrfritz » Wed Dec 18, 2002 4:06 pm
It's ok...keep posting here...I already have a new thread.
Slasher
Post
by Slasher » Thu Dec 19, 2002 2:26 pm
hi,
if you are not using paging, then their is no need to map anything!
also what is the selector you placed in the SS register?
has to be one thai spans the whole address space if you are going to put 0xffffffff in ESP.
jrfritz
Post
by jrfritz » Thu Dec 19, 2002 2:28 pm
0x10 is what I put into AX, then put ax into ss.
hanoi
Post
by hanoi » Wed Dec 25, 2002 3:11 pm
hey
I have also some problems with my IDT
-Code-
C:
typedef struct {
unsigned short int Offset1;
unsigned short int Segment;
unsigned short int t;
unsigned short int Offset2;
} intdes;
typedef struct
{
unsigned short limit;
intdes *lIDT;
} IDTR;
typedef union
{
void *p;
unsigned short a;
unsigned short b;
} part;
extern void unhandled();
void setVector(int nr, void *function);
void LIDT();
void STI();
intdes IDT[256];
IDTR sysreg;
for(i=0; i <256; i++)
{
setVector(i, (void *)(unhandled));
}
LIDT();
asm("sti");
void setVector(int nr, void *function)
{
intdes n;
part p;
p.p = function;
n.Offset1 = p.a;
n.Offset2 = p.b;
n.Segment = 0x8;
n.t = 0x8e00;
IDT[nr] = n;
return;
}
void LIDT()
{
sysreg.limit = 1024;
sysreg.lIDT = IDT;
asm volatile ("lidt _sysreg");
return;
}
asm:
[extern _unhandled]
_unhandled:
iret
-Code-
problem: 31d exception(14)
thank you
hanoi
Post
by hanoi » Wed Dec 25, 2002 3:13 pm
ahya, the __attribute__ ((packed)) doesn't change anything
thanks
hanoi
Post
by hanoi » Wed Dec 25, 2002 3:14 pm
if paging isn't switched on, i get 3rd(13)
hanoi
Post
by hanoi » Thu Dec 26, 2002 3:39 am
i have changed now:
void LIDT()
{
unsigned int x[2];
x[0]=((256*sizeof(intdes))-1)<<16;
x[1]= (unsigned int)IDT;
__asm__ __volatile__ ("lidt (%0)"::"d"((int)((unsigned char*)x)+2):"memory");
return;
}
now i got:
-3rd(12)(stack error) when i set stack to 0x7BFF (code is at 0x100000)
-3rd(13)(general protection fault) when i set stack to 0x9FFFF; bochs says:
00001024150i[CPU ] WARNING: Encountered an unknown instruction (signalling illegal instruction):
00001024182i[CPU ] BxError: instruction with op1=0xfe
00001024182i[CPU ] nnn was 4
00001024182i[CPU ] WARNING: Encountered an unknown instruction (signalling illegal instruction):
00001024182p[CPU ] >>PANIC<< exception(): 3rd (13) exception with no resolution
00001024182i[SYS ] Last time is 1040895234
00001024182i[CPU ] protected mode
00001024182i[CPU ] CS.d_b = 32 bit
00001024182i[CPU ] SS.d_b = 32 bit
00001024182i[CPU ] | EAX=0009fff7 EBX=00000007 ECX=000017fa EDX=0009ffd1
00001024182i[CPU ] | ESP=00007be5 EBP=000a16f2 ESI=000207d8 EDI=001107d8
00001024182i[CPU ] | IOPL=0 NV UP DI NG NZ AC PO CY
00001024182i[CPU ] | SEG selector base limit G D
00001024182i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00001024182i[CPU ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001024182i[CPU ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001024182i[CPU ] | FS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00001024182i[CPU ] | GS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00001024182i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001024182i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00001024182i[CPU ] | EIP=0000004c (0000004c)
00001024182i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0x00000000
00001024182i[CPU ] | CR3=0x00300000 CR4=0x00000000 strange, isn't it?
hanoi
Post
by hanoi » Thu Dec 26, 2002 3:40 am
i mean the EIP of course