Interrupt Inaccessible Code Segment

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.
Post Reply
Geometrian
Member
Member
Posts: 77
Joined: Tue Nov 20, 2012 4:45 pm
Contact:

Interrupt Inaccessible Code Segment

Post by Geometrian »

Hi,

I am trying to get interrupts working. In Bochs, however, I am getting the following:

Code: Select all

00089733886i[BIOS ] Booting from 0000:7c00
00089886116e[CPU0 ] interrupt(): not accessable or not code segment cs=0x0008
00089886116e[CPU0 ] interrupt(): not accessable or not code segment cs=0x0008
00089886116e[CPU0 ] interrupt(): not accessable or not code segment cs=0x0008
00089886116i[CPU0 ] CPU is in protected mode (active)
00089886116i[CPU0 ] CS.d_b = 32 bit
00089886116i[CPU0 ] SS.d_b = 32 bit
00089886116i[CPU0 ] EFER   = 0x00000000
00089886116i[CPU0 ] | RAX=0000000000000000  RBX=000000000000aa55
00089886116i[CPU0 ] | RCX=0000000000000019  RDX=00000000000a105d
00089886116i[CPU0 ] | RSP=000000000008ffd0  RBP=000000000008ffe8
00089886116i[CPU0 ] | RSI=0000000000007da3  RDI=0000000000000530
00089886116i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00089886116i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00089886116i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00089886116i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00089886116i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF af PF cf
00089886116i[CPU0 ] | SEG selector     base    limit G D
00089886116i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00089886116i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 ffffffff 1 1
00089886116i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00089886116i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00089886116i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00089886116i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00089886116i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00089886116i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00089886116i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00089886116i[CPU0 ] | RIP=0000000000001ce6 (0000000000001ce6)
00089886116i[CPU0 ] | CR0=0x60000011 CR2=0x0000000000000000
00089886116i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00089886116i[CPU0 ] 0x0000000000001ce6>> int 0x13 : CD13
00089886116e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
According to the Wiki, this implies that the IDT is corrupt. However, I am not sure that is the problem--in the output above, CS does indeed seem to be 0x0008; furthermore, I issue a test interrupt immediately after loading the IDT.

Thanks,
rdos
Member
Member
Posts: 3306
Joined: Wed Oct 01, 2008 1:55 pm

Re: Interrupt Inaccessible Code Segment

Post by rdos »

Why do you issue int 0x13 in protected mode, and have you setup a interrupt handler for it?
Geometrian
Member
Member
Posts: 77
Joined: Tue Nov 20, 2012 4:45 pm
Contact:

Re: Interrupt Inaccessible Code Segment

Post by Geometrian »

rdos wrote:Why do you issue int 0x13 in protected mode, and have you setup a interrupt handler for it?
The 0x13 is just a random number; I'm not trying to accomplish anything using the interrupt yet.

I have set up a handler in the IDT, using almost exactly the same code as described here: http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html.
Geometrian
Member
Member
Posts: 77
Joined: Tue Nov 20, 2012 4:45 pm
Contact:

Re: Interrupt Inaccessible Code Segment

Post by Geometrian »

I think I found the problem. The GDT was being allocated on the stack. When the IDT was set immediately after, it munged the GDT.

The solution was to move the GDT and IDT to be global variables.

Thanks,
Post Reply