nckernel  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
8259 Programmable Interrupt Controller

PIC 를 초기화 한다. More...

Functions

void pic_init (void)
 PIC 초기화 More...
 
void timer_init (unsigned long frequency)
 타이머 초기화 More...
 

Detailed Description

PIC 를 초기화 한다.

Date
2011-7-22
Author
Sung-jae Park nices.nosp@m.j@ni.nosp@m.cesj..nosp@m.com

8259 Programmable Interrupt Controller 는 Timer, Keyboard 등과 같은 기본 외부 장치 들의 인터럽트를 제어하는 장치다. 이 장치 제어를 통해 CPU 로 전 달되는 Interrupt 의 방식을 변경하고 CPU 가 알맞은 Interrupt handler 를 IDT 에서 찾을 수 있게 한다.

아래 그림 처럼 두개의 PIC 가 Cascading 되어서 Interrupt 를 처리한다.

8259.png
Programmable Interrupt Controller (Block Diagram)
pic_interrupts.png
PIC Interrupts

PIC 를 통해 전달되는 Interrupt 들은 IRQ Remapping 을 통해 IDT 의 0x20 이 후 부터 하나씩 Mapping 시킨다.

x86 의 인터럽트 콘트롤러를 초기화 한다. x86 의 클럭은 초당 1193180 튄다. 1193180 / 100을 한 값을 divisor 값으로 설정해주면, 1 초에 100번 timer 인터럽트가 발생하게 된다. 즉 10 밀리초에 한번씩 인터럽트 핸들러를 실행 시킬 수 있게 된다.

Function Documentation

void pic_init ( void  )

PIC 초기화

Master 8259 PIC, Edge trigger, Cascade mode (ICW4)

Start at interrupt vector 0x20

#IR2 pin has a slave

Not SP, Non-buffered mode, normal EOI for x86

Slave 8259 PIC, Edge trigger, cascade mode (ICW4)

Start at interrupt vector 0x28

Slave 8259 has been linked to master's #IR2 pin

Not SP, Non-buffered mode, normal EOI for x86

Definition at line 40 of file pic.c.

References outb(), PIC_FIRST_COMMAND, PIC_FIRST_INTERRUPT_MASK, PIC_SECOND_COMMAND, and PIC_SECOND_INTERRUPT_MASK.

Referenced by arch_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void timer_init ( unsigned long  frequency)

타이머 초기화

Parameters
[in]frequency초당 인터럽트 발생 횟수

Definition at line 63 of file pic.c.

References CLOCK, outb(), TIMER_COUNTER_DIVISOR, and TIMER_MODE_CONTROL.

Referenced by arch_init().

Here is the call graph for this function:

Here is the caller graph for this function: