OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 10:57 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: help,stumbling on APIC learning.
PostPosted: Tue Apr 13, 2010 2:55 pm 
Offline

Joined: Sun Apr 11, 2010 9:29 am
Posts: 2
:lol: Hello!everyone,i'm a newbie around OS dev and hardware , i'm have been confused on this so much : how does those irqs resides in IOAPIC(any tables?),and is there somehow something relationships between the both. My questions stem from the following windows driver snippet. i'm so sorroy for the chinese comments. I commented those lines in which i can't figure out:

Code:
// 搜索IOAPIC获得键盘中断,或者设置这个值。
// Description:
//lookup IOAPIC to grab keyboard interrupt.

P2C_U8 p2cSeachOrSetIrq1(P2C_U8 new_ch)
{
    // 选择寄存器。选择寄存器虽然是32位的寄存器,但是只使用
    // 低8位,其他的位都被保留。
P2C_U8 *io_reg_sel;

    // 窗口寄存器,用来读写被选择寄存器选择的值,是32位的。
P2C_U32 *io_win;
P2C_U32 ch,ch1;

    // 定义一个物理地址,这个地址为0xfec00000。正是IOAPIC
    // 寄存器组在Windows上的开始地址
PHYSICAL_ADDRESS phys ;
PVOID paddr;
RtlZeroMemory(&phys,sizeof(PHYSICAL_ADDRESS));
phys.u.LowPart = 0xfec00000;

    // 物理地址是不能直接读写的。MmMapIoSpace把物理地址映射
    // 为系统空间的虚拟地址。0x14是这片空间的长度。
paddr = MmMapIoSpace(phys, 0x14, MmNonCached);

    // 如果映射失败了就返回0.
if (!MmIsAddressValid(paddr))
  return 0;

    // 选择寄存器的偏移为0
io_reg_sel = (P2C_U8 *)paddr;
    // 窗口寄存器的偏移为0x10.
io_win = (P2C_U32 *)((P2C_U8 *)(paddr) + 0x10);

    // 选择第0x12,刚好是irq1的项
   //here, why select 0x12 into i/o select register,why  irq1(keyboard interrupt) corresponds   to the index 0x12

*io_reg_sel = 0x12;
ch = *io_win;  //vector?

    // 如果new_ch不为0,我们就设置新值。并返回旧值。
    if(new_ch != 0)
    { //here,two line bitwise operations,i don't understand what's the meaning of  at all
        ch1 = *io_win;
        ch1 &= 0xffffff00;
        ch1 |= (P2C_U32)new_ch;
        *io_win = ch1;
        KdPrint(("p2cSeachOrSetIrq1: set %2x to irq1.\r\n",(P2C_U8)new_ch));
    }

    // 窗口寄存器里读出的值是32位的,但是我们只需要
    // 一个字节就可以了。这个字节就是中断向量的值。
    // 一会我们要修改这个值。
    ch &= 0xff;
MmUnmapIoSpace(paddr, 0x14);
    KdPrint(("p2cSeachOrSetIrq1: the old vec of irq1 is %2x.\r\n",(P2C_U8)ch));
return (P2C_U8)ch;
}


than all you! :D


Last edited by supperchao on Wed Apr 14, 2010 1:01 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: help,stumbling on APIC learning.
PostPosted: Tue Apr 13, 2010 3:36 pm 
Offline
Member
Member

Joined: Sat Nov 21, 2009 5:11 pm
Posts: 852
Each redirection entry occupies two registers starting at 0x10. Therefore, entry 1 is at 0x12. However, not all systems have ISA IRQ 1 connected to IO APIC pin 1.

On ACPI systems, each ISA IRQ corresponds to the same numbered pin on the IO APIC whose Global System Interrupt base is 0. So, ISA IRQ number equals the GSI number.


Top
 Profile  
 
 Post subject: Re: help,stumbling on APIC learning.
PostPosted: Wed Apr 14, 2010 1:18 am 
Offline

Joined: Sun Apr 11, 2010 9:29 am
Posts: 2
[quote="Gigasoft"]Each redirection entry occupies two registers starting at 0x10. Therefore, entry 1 is at 0x12.[quote]
:) :) ,
Hello ....
1.I understand this superficially and literally above, could you describe this subject more in detail and make me a full knowledge.

2. The following bitwise operations. what's the ues for?

Code:
    // 如果new_ch不为0,我们就设置新值。并返回旧值。
    if(new_ch != 0)
    { //here,two line bitwise operations,i don't understand what's the meaning of  at all
        ch1 = *io_win;
        ch1 &= 0xffffff00;
        ch1 |= (P2C_U32)new_ch;
        *io_win = ch1;
        KdPrint(("p2cSeachOrSetIrq1: set %2x to irq1.\r\n",(P2C_U8)new_ch));
    }
 


thank everyone in advance!!


Top
 Profile  
 
 Post subject: Re: help,stumbling on APIC learning.
PostPosted: Wed Apr 14, 2010 2:06 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
supperchao wrote:
1.I understand this superficially and literally above, could you describe this subject more in detail and make me a full knowledge.


IOAPIC

Quote:
2. The following bitwise operations. what's the ues for?


Masking out the LSB of *io_win.

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 120 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