Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
ioapic.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <sys/kassert.h>
#include <sys/kdebug.h>
#include <sys/cdefs.h>
#include <machine/amd64.h>
#include <machine/pmap.h>
#include <machine/trap.h>
Include dependency graph for ioapic.c:

Go to the source code of this file.

Macros

#define IOAPICBASE   0xFEC00000
 
#define IOAPICID   0x00 /* IOAPIC ID */
 
#define IOAPICVER   0x01 /* IOAPIC Version */
 
#define IOAPICARB   0x02 /* IOAPIC Arbitration ID */
 
#define IOREDTBL0   0x10
 
#define IOREDTBL23   0x3E
 
#define IOREDTBL_LEN   24
 
#define IOREDTBL_MASK   0x00010000
 
#define IOREDTBL_LOGICAL   0x00000800
 

Functions

uint32_t IOAPIC_Read (uint32_t reg)
 
void IOAPIC_Write (uint32_t reg, uint32_t val)
 
void IOAPIC_Init ()
 
void IOAPIC_Enable (int irq)
 
void IOAPIC_Disable (int irq)
 
static void Debug_IOAPIC (int argc, const char *argv[])
 
 REGISTER_DBGCMD (ioapic, "IOAPIC Dump", Debug_IOAPIC)
 

Macro Definition Documentation

◆ IOAPICARB

#define IOAPICARB   0x02 /* IOAPIC Arbitration ID */

Definition at line 20 of file ioapic.c.

◆ IOAPICBASE

#define IOAPICBASE   0xFEC00000

Definition at line 16 of file ioapic.c.

◆ IOAPICID

#define IOAPICID   0x00 /* IOAPIC ID */

Definition at line 18 of file ioapic.c.

◆ IOAPICVER

#define IOAPICVER   0x01 /* IOAPIC Version */

Definition at line 19 of file ioapic.c.

◆ IOREDTBL0

#define IOREDTBL0   0x10

Definition at line 21 of file ioapic.c.

◆ IOREDTBL23

#define IOREDTBL23   0x3E

Definition at line 22 of file ioapic.c.

◆ IOREDTBL_LEN

#define IOREDTBL_LEN   24

Definition at line 24 of file ioapic.c.

◆ IOREDTBL_LOGICAL

#define IOREDTBL_LOGICAL   0x00000800

Definition at line 27 of file ioapic.c.

◆ IOREDTBL_MASK

#define IOREDTBL_MASK   0x00010000

Definition at line 26 of file ioapic.c.

Function Documentation

◆ Debug_IOAPIC()

static void Debug_IOAPIC ( int  argc,
const char *  argv[] 
)
static

Definition at line 84 of file ioapic.c.

85{
86 int i;
87
88 kprintf("IOAPIC ID: %08x\n", IOAPIC_Read(IOAPICID));
89 kprintf("IOAPIC VERSION: %08x\n", IOAPIC_Read(IOAPICVER));
90
91 for (i = 0; i < IOREDTBL_LEN; i++)
92 {
93 uint32_t irqInfo = IOAPIC_Read(IOREDTBL0 + 2*i);
94 uint32_t cpuInfo = IOAPIC_Read(IOREDTBL0 + 2*i + 1);
95 kprintf("%02x: %08x %08x\n", i, irqInfo, cpuInfo);
96 }
97}
#define IOAPICID
Definition: ioapic.c:18
uint32_t IOAPIC_Read(uint32_t reg)
Definition: ioapic.c:30
#define IOREDTBL0
Definition: ioapic.c:21
#define IOAPICVER
Definition: ioapic.c:19
#define IOREDTBL_LEN
Definition: ioapic.c:24
int kprintf(const char *fmt,...)
Definition: printf.c:210
unsigned int uint32_t
Definition: types.h:12
Here is the call graph for this function:

◆ IOAPIC_Disable()

void IOAPIC_Disable ( int  irq)

Definition at line 77 of file ioapic.c.

78{
81}
void IOAPIC_Write(uint32_t reg, uint32_t val)
Definition: ioapic.c:42
#define IOREDTBL_MASK
Definition: ioapic.c:26
static uint8_t irq
Definition: sercons.c:38
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IOAPIC_Enable()

void IOAPIC_Enable ( int  irq)

Definition at line 70 of file ioapic.c.

71{
74}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IOAPIC_Init()

void IOAPIC_Init ( )

Definition at line 54 of file ioapic.c.

55{
56 int i;
57 uint32_t id = (IOAPIC_Read(IOAPICID) >> 24) & 0x0F;
58 uint32_t maxInts = (IOAPIC_Read(IOAPICVER) >> 16) & 0xFF;
59
60 kprintf("IOAPIC: ID:%d Max Interrupts: %d\n", id, maxInts);
61
62 for (i = 0; i < IOREDTBL_LEN; i++)
63 {
65 IOAPIC_Write(IOREDTBL0 + 2*i + 1, 0);
66 }
67}
#define T_IRQ_BASE
Definition: trap.h:28
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IOAPIC_Read()

uint32_t IOAPIC_Read ( uint32_t  reg)

Definition at line 30 of file ioapic.c.

31{
32 uint32_t volatile *addr = (uint32_t volatile *)DMPA2VA(IOAPICBASE);
33 uint32_t volatile *cmd = (uint32_t volatile *)DMPA2VA(IOAPICBASE + 0x10);
34
35 ASSERT(reg <= 0xFF);
36
37 *addr = reg;
38 return *cmd;
39}
#define IOAPICBASE
Definition: ioapic.c:16
#define ASSERT(_x)
Definition: kassert.h:8
uint64_t addr
Definition: multiboot.h:1
#define DMPA2VA(pa)
Definition: pmap.h:48
Here is the caller graph for this function:

◆ IOAPIC_Write()

void IOAPIC_Write ( uint32_t  reg,
uint32_t  val 
)

Definition at line 42 of file ioapic.c.

43{
44 uint32_t volatile *addr = (uint32_t volatile *)DMPA2VA(IOAPICBASE);
45 uint32_t volatile *cmd = (uint32_t volatile *)DMPA2VA(IOAPICBASE + 0x10);
46
47 ASSERT(reg <= 0xFF);
48
49 *addr = reg;
50 *cmd = val;
51}
Here is the caller graph for this function:

◆ REGISTER_DBGCMD()

REGISTER_DBGCMD ( ioapic  ,
"IOAPIC Dump"  ,
Debug_IOAPIC   
)