PIC reconfiguration - what happens to the orginal INTERUPTs

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
Harish
Posts: 6
Joined: Sat May 18, 2019 7:43 am

PIC reconfiguration - what happens to the orginal INTERUPTs

Post by Harish »

HI,
i have seen and read the code the for PIC reconfiguration on using IDT, it is said that PIC is already configured with interupts
IRQ 0 ‒ system timer
IRQ 1 — keyboard controller
IRQ 3 — serial port COM2
IRQ 4 — serial port COM1
IRQ 5 — line print terminal 2
IRQ 6 — floppy controller
IRQ 7 — line print terminal 1
IRQ 8 — RTC timer
IRQ 12 — mouse controller
IRQ 13 — math co-processor
IRQ 14 — ATA channel 1
IRQ 15 — ATA channel 2
so we reconfigure to start from 32 (0x20) in the code so what happens to the initial 16 interrupts.
i am guessing i am missing some point here and this might be a stupid question.
could any please clarify on this.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PIC reconfiguration - what happens to the orginal INTERU

Post by Octocontrabass »

The PIC is a component that translates from IRQ to interrupt. You can't change which device is using each IRQ, those are physical connections between the hardware and the PICs. What you can change is how the PICs translate from IRQ to interrupt.

When an AT-compatible PC first boots up, this is how the PICs are configured:

IRQ 0 — interrupt 8 (0x8) — system timer
IRQ 1 — interrupt 9 (0x9) — keyboard controller
IRQ 3 — interrupt 11 (0xB) — serial port COM2
IRQ 4 — interrupt 12 (0xC) — serial port COM1
IRQ 5 — interrupt 13 (0xD) — line print terminal 2
IRQ 6 — interrupt 14 (0xE) — floppy controller
IRQ 7 — interrupt 15 (0xF) — line print terminal 1
IRQ 8 — interrupt 112 (0x70) — RTC timer
IRQ 12 — interrupt 116 (0x74) — mouse controller
IRQ 13 — interrupt 117 (0x75) — math co-processor
IRQ 14 — interrupt 118 (0x76) — ATA channel 1
IRQ 15 — interrupt 119 (0x77) — ATA channel 2

When you reprogram the PICs to start at interrupt 32 (0x20), the new mapping will look like this:

IRQ 0 — interrupt 32 (0x20) — system timer
IRQ 1 — interrupt 33 (0x21) — keyboard controller
IRQ 3 — interrupt 35 (0x23) — serial port COM2
IRQ 4 — interrupt 36 (0x24) — serial port COM1
IRQ 5 — interrupt 37 (0x25) — line print terminal 2
IRQ 6 — interrupt 38 (0x26) — floppy controller
IRQ 7 — interrupt 39 (0x27) — line print terminal 1
IRQ 8 — interrupt 40 (0x28) — RTC timer
IRQ 12 — interrupt 44 (0x2C) — mouse controller
IRQ 13 — interrupt 45 (0x2D) — math co-processor
IRQ 14 — interrupt 46 (0x2E) — ATA channel 1
IRQ 15 — interrupt 47 (0x2F) — ATA channel 2

Does that make sense?
Harish
Posts: 6
Joined: Sat May 18, 2019 7:43 am

Re: PIC reconfiguration - what happens to the orginal INTERU

Post by Harish »

yes
thank you
Harish
Posts: 6
Joined: Sat May 18, 2019 7:43 am

Re: PIC reconfiguration - what happens to the orginal INTERU

Post by Harish »

Hi
thank you for your reply.
i had one more doubt what the magical number that we used in the bare bone tutorial.
Also in order for me to load my os in my pc how will my grub know where my os ?
Harish
Posts: 6
Joined: Sat May 18, 2019 7:43 am

Re: PIC reconfiguration - what happens to the orginal INTERU

Post by Harish »

Also how can i acess my harddisk formy os

Thank you for the support .
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PIC reconfiguration - what happens to the orginal INTERU

Post by Octocontrabass »

Harish wrote:what the magical number that we used in the bare bone tutorial.
The bootloader looks for the magic number to see if your kernel is compatible with Multiboot.
Harish wrote:Also in order for me to load my os in my pc how will my grub know where my os ?
GRUB will read grub.cfg to know where to look.
Harish wrote:Also how can i acess my harddisk formy os
You'll need to search the PCI bus for your computer's storage controller, then write a driver for that controller. Most modern computers use AHCI, but older computers use IDE instead.
Harish
Posts: 6
Joined: Sat May 18, 2019 7:43 am

Re: PIC reconfiguration - what happens to the orginal INTERU

Post by Harish »

Thank you for all the help.
User avatar
~
Member
Member
Posts: 1227
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: PIC reconfiguration - what happens to the orginal INTERU

Post by ~ »

Harish wrote:Also how can i acess my harddisk formy os

Thank you for the support .
You could save the whole original configuration to easily exit your kernel like a normal application and restore the state before loading it.

For reading/accessing the hard disks, you need to study how to implement storage devices for 1 whole year for being able to formally implement and test the primitives. You could start with my code, look at the BOOTCFG/ldr/4/LowEST-Kernel-LEVEL-1-2019-01--src/disks/ATA/commands/ directory and for VERY accurate ATA/ATAPI detection (even for old ATA-3 disks from 386 laptops), BOOTCFG/LowEST/x86s/HDD/ATA/utils/atadetec/main16.asm. You can study, reimplement and continue from there for 1 year, por ATA, ATAPI, floppy disks. You will probably need another year for SATA, and another year for USB.

You need to study all aspects, accessing the disks with LBA28, LBA48, bus master with the help of FreeDOS, and of course file systems like FAT in CHS and LBA modes, NTFS, ext3, although for more complex file systems like the ones from Linux and NTFS, you will also need 1 year to reimplement if you work alone.
YouTube:
http://youtube.com/@AltComp126

My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... ip?viasf=1
Harish
Posts: 6
Joined: Sat May 18, 2019 7:43 am

Re: PIC reconfiguration - what happens to the orginal INTERU

Post by Harish »

Thank you
i will look into these topics
this was really helpful
Post Reply