PatchworkOS  69292a3
A non-POSIX operating system.
Loading...
Searching...
No Matches
percpu.c File Reference
#include <kernel/cpu/percpu.h>
#include <kernel/cpu/cpu.h>
#include <kernel/log/panic.h>
#include <kernel/mem/vmm.h>
#include <kernel/sync/lock.h>
#include <string.h>
Include dependency graph for percpu.c:

Go to the source code of this file.

Data Structures

struct  percpu_section_t
 

Macros

#define PERCPU_MAX_SECTIONS   128
 

Functions

static BITMAP_CREATE_ZERO (allocated, CONFIG_PERCPU_SIZE/PERCPU_ALIGNMENT)
 
static PERCPU_DEFINE (uint64_t, pcpu_generation)
 
static PERCPU_DEFINE (uint64_t, pcpu_ack)
 
void percpu_init (cpu_t *cpu)
 Initialize the percpu system.
 
percpu_t percpu_alloc (size_t size)
 Allocates a percpu variable.
 
void percpu_free (percpu_t ptr, size_t size)
 Frees a percpu variable.
 
static void percpu_run_ctors (percpu_section_t *section)
 
static void percpu_run_dtors (percpu_section_t *section)
 
void percpu_update (void)
 Update percpu sections on the current CPU.
 
void percpu_section_init (percpu_def_t *start, percpu_def_t *end)
 Register a percpu section and run constructors.
 
void percpu_section_deinit (percpu_def_t *start, percpu_def_t *end)
 Unregister a percpu section and run destructors.
 

Variables

static percpu_section_t sections [PERCPU_MAX_SECTIONS]
 We cant do memory allocation during early boot so we have to statically allocate the percpu sections.
 
static size_t sectionCount = 0
 
static uint64_t globalGeneration = 0
 
static uint64_t globalAck = 0
 
static lock_t lock = LOCK_CREATE()
 

Macro Definition Documentation

◆ PERCPU_MAX_SECTIONS

#define PERCPU_MAX_SECTIONS   128

Definition at line 9 of file percpu.c.

Function Documentation

◆ BITMAP_CREATE_ZERO()

static BITMAP_CREATE_ZERO ( allocated  ,
CONFIG_PERCPU_SIZE PERCPU_ALIGNMENT 
)
static

◆ PERCPU_DEFINE() [1/2]

static PERCPU_DEFINE ( uint64_t  ,
pcpu_generation   
)
static

◆ PERCPU_DEFINE() [2/2]

static PERCPU_DEFINE ( uint64_t  ,
pcpu_ack   
)
static

◆ percpu_run_ctors()

static void percpu_run_ctors ( percpu_section_t section)
static

Definition at line 77 of file percpu.c.

Here is the caller graph for this function:

◆ percpu_run_dtors()

static void percpu_run_dtors ( percpu_section_t section)
static

Definition at line 88 of file percpu.c.

Here is the caller graph for this function:

Variable Documentation

◆ sections

We cant do memory allocation during early boot so we have to statically allocate the percpu sections.

Definition at line 22 of file percpu.c.

◆ sectionCount

size_t sectionCount = 0
static

Definition at line 23 of file percpu.c.

◆ globalGeneration

uint64_t globalGeneration = 0
static

Definition at line 25 of file percpu.c.

◆ globalAck

uint64_t globalAck = 0
static

Definition at line 26 of file percpu.c.

◆ lock

lock_t lock = LOCK_CREATE()
static

Definition at line 31 of file percpu.c.