AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
init.c File Reference

The PC platform: its interrupt controllers, its timers, its PCI bus and its real time clock, set up at boot, and the tick. More...

#include <core/kargs.h>
#include <core/system.h>
#include <cpu/io.h>
#include <dev/pci.h>
#include <platform/misc.h>

Go to the source code of this file.

Macros

#define I8254_ADDR   0x40
#define I8254_TYPE   IOADDR_PORT
#define PIC_MASTER   0x20
#define PIC_SLAVE   0xA0
#define PIT_IRQ   0

Functions

static int x86_pc_pic_init (void)
 Sets up the 8259s at the PC's ports.
static void x86_pc_pci_init (void)
 Gives PCI its host bridge.
static int x86_pc_pit_init (void)
 Sets up the PIT at the PC's ports.
static int x86_pc_cmos_init (void)
 Sets up the real time clock at the PC's ports.
uint32_t platform_timer_setup (size_t period_ns, irq_handler_t handler)
 Starts the scheduler's tick: the local APIC's timer if the APIC brings the interrupts, else the PIT.
static void x86_pc_irq_init (void)
 Sets up the interrupts: through the APIC if there's one (and not apic=off), else through the 8259s.
int platform_init (void)

Variables

static struct pci_host x86_pc_pci
static int apic

Detailed Description

The PC platform: its interrupt controllers, its timers, its PCI bus and its real time clock, set up at boot, and the tick.

Definition in file init.c.

Macro Definition Documentation

◆ I8254_ADDR

#define I8254_ADDR   0x40

Definition at line 13 of file init.c.

Referenced by x86_pc_pit_init().

◆ I8254_TYPE

#define I8254_TYPE   IOADDR_PORT

Definition at line 14 of file init.c.

Referenced by x86_pc_pit_init().

◆ PIC_MASTER

#define PIC_MASTER   0x20

Definition at line 17 of file init.c.

Referenced by x86_pc_pic_init().

◆ PIC_SLAVE

#define PIC_SLAVE   0xA0

Definition at line 18 of file init.c.

Referenced by x86_pc_pic_init().

◆ PIT_IRQ

#define PIT_IRQ   0

Definition at line 72 of file init.c.

Referenced by platform_timer_setup().

Function Documentation

◆ platform_init()

◆ platform_timer_setup()

uint32_t platform_timer_setup ( size_t period_ns,
irq_handler_t handler )

Starts the scheduler's tick: the local APIC's timer if the APIC brings the interrupts, else the PIT.

Parameters
period_nsthe tick's period, in ns
handlerthe tick's handler
Returns
the period it really is, in ns

Definition at line 84 of file init.c.

References apic, irq_install(), NULL, PIT_IRQ, platform_timer_setup(), x86_lapic_timer_setup(), and x86_pit_period_set().

Referenced by arch_sched_init(), and platform_timer_setup().

◆ x86_pc_cmos_init()

int x86_pc_cmos_init ( void )
static

Sets up the real time clock at the PC's ports.

Definition at line 63 of file init.c.

References ioaddr::addr, IOADDR_PORT, ioaddr::type, x86_cmos_setup(), and x86_pc_cmos_init().

Referenced by platform_init(), and x86_pc_cmos_init().

◆ x86_pc_irq_init()

void x86_pc_irq_init ( void )
static

Sets up the interrupts: through the APIC if there's one (and not apic=off), else through the 8259s.

The 8259s are remapped either way.

Definition at line 96 of file init.c.

References apic, printk(), x86_apic_setup(), x86_irq_chip_name(), x86_irq_chip_set(), x86_irq_gates_setup(), x86_pc_irq_init(), x86_pc_pic_init(), and x86_pic_chip.

Referenced by platform_init(), and x86_pc_irq_init().

◆ x86_pc_pci_init()

void x86_pc_pci_init ( void )
static

Gives PCI its host bridge.

Definition at line 44 of file init.c.

References pci_host_set(), x86_pc_pci, and x86_pc_pci_init().

Referenced by platform_init(), and x86_pc_pci_init().

◆ x86_pc_pic_init()

int x86_pc_pic_init ( void )
static

Sets up the 8259s at the PC's ports.

Returns 0, or -ENODEV.

Definition at line 21 of file init.c.

References ioaddr::addr, IOADDR_PORT, PIC_MASTER, PIC_SLAVE, ioaddr::type, x86_pc_pic_init(), and x86_pic_setup().

Referenced by x86_pc_irq_init(), and x86_pc_pic_init().

◆ x86_pc_pit_init()

int x86_pc_pit_init ( void )
static

Sets up the PIT at the PC's ports.

Definition at line 52 of file init.c.

References ioaddr::addr, I8254_ADDR, I8254_TYPE, ioaddr::type, x86_pc_pit_init(), and x86_pit_setup().

Referenced by platform_init(), and x86_pc_pit_init().

Variable Documentation

◆ apic

int apic
static

Definition at line 74 of file init.c.

Referenced by platform_init(), platform_timer_setup(), and x86_pc_irq_init().

◆ x86_pc_pci

struct pci_host x86_pc_pci
static
Initial value:
= {
.name = "configuration mechanism #1",
.config = {.type = IOADDR_PORT, .addr = 0xCF8},
.read = pci_conf1_read,
.write = pci_conf1_write,
}
#define IOADDR_PORT
Definition io.h:89
void pci_conf1_write(struct pci_host *host, struct pci_dev *dev, uint16_t reg, uint32_t val)
Writes a 32-bit register of a function's configuration space.
Definition conf1.c:73
uint32_t pci_conf1_read(struct pci_host *host, struct pci_dev *dev, uint16_t reg)
Reads a 32-bit register of a function's configuration space.
Definition conf1.c:55

Definition at line 36 of file init.c.

Referenced by x86_pc_pci_init().