The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
arch_cpu.h File Reference

the arch part of per-CPU data: a segment base that points at the cpu_t of the core (kernel/cpu/cpu.h). More...

#include "common/stddef.h"
#include "common/stdint.h"

Go to the source code of this file.

Macros

#define ARCH_CPU_MODEL_MAX   49
 the size of the buffer for arch_cpu_model(), with the terminating 0

Enumerations

enum  arch_ipi_t { ARCH_IPI_TLB_FLUSH , ARCH_IPI_RESCHEDULE , ARCH_IPI_STOP }
 the kinds of interrupts one core sends to another More...

Functions

void arch_cpu_set_base (struct cpu *cpu)
 point the per-CPU segment of the core that runs the call at its cpu_t.
void arch_smp_reserve (void)
 keep a page of low memory for the start code of the other cores.
bool arch_smp_prepare (struct cpu *boot)
 get ready to start the other cores: copy the start code to its page and make the page tables it uses.
bool arch_cpu_start (struct cpu *cpu)
 start one core and wait up to 100 ms for it to say it is online.
void arch_smp_finish (bool all_started)
 release what only the start of the cores used.
void arch_cpu_model (char *buffer, size_t size)
 the model name of the CPU, as the CPU gives it (the CPUID brand string on x86), or "unknown".
void arch_cpu_send_ipi (const struct cpu *cpu, arch_ipi_t ipi)
 send an interrupt to another core.

Detailed Description

the arch part of per-CPU data: a segment base that points at the cpu_t of the core (kernel/cpu/cpu.h).

x86_64 uses the GS base, i686 a GDT entry in FS, as in Linux.

Macro Definition Documentation

◆ ARCH_CPU_MODEL_MAX

#define ARCH_CPU_MODEL_MAX   49

the size of the buffer for arch_cpu_model(), with the terminating 0

Enumeration Type Documentation

◆ arch_ipi_t

enum arch_ipi_t

the kinds of interrupts one core sends to another

Enumerator
ARCH_IPI_TLB_FLUSH 
ARCH_IPI_RESCHEDULE 
ARCH_IPI_STOP 

Function Documentation

◆ arch_cpu_set_base()

void arch_cpu_set_base ( struct cpu * cpu)

point the per-CPU segment of the core that runs the call at its cpu_t.

the first field of a cpu_t must point at the cpu_t itself.

Parameters
cputhe data of this core.

◆ arch_smp_reserve()

void arch_smp_reserve ( void )

keep a page of low memory for the start code of the other cores.

call it right after pmm_init, before other allocations can take that memory.

◆ arch_smp_prepare()

bool arch_smp_prepare ( struct cpu * boot)

get ready to start the other cores: copy the start code to its page and make the page tables it uses.

it also sets the hardware id of the boot core in its cpu_t.

Parameters
bootthe cpu_t of the boot core.
Returns
false if the other cores cannot start (no local APIC, no low page or no memory).

◆ arch_cpu_start()

bool arch_cpu_start ( struct cpu * cpu)

start one core and wait up to 100 ms for it to say it is online.

Parameters
cpuits cpu_t, with index, apic_id and idle_stack set.
Returns
true if the core runs.

◆ arch_smp_finish()

void arch_smp_finish ( bool all_started)

release what only the start of the cores used.

Parameters
all_startedfalse if a core did not answer: then the start code and its page tables stay, because that core can still start late.

◆ arch_cpu_model()

void arch_cpu_model ( char * buffer,
size_t size )

the model name of the CPU, as the CPU gives it (the CPUID brand string on x86), or "unknown".

Parameters
bufferreceives the name, terminated by 0.
sizethe size of buffer, at most ARCH_CPU_MODEL_MAX is used.

◆ arch_cpu_send_ipi()

void arch_cpu_send_ipi ( const struct cpu * cpu,
arch_ipi_t ipi )

send an interrupt to another core.

Parameters
cputhe core; it must be online.
ipiwhat the core is to do.