PatchworkOS  69292a3
A non-POSIX operating system.
Loading...
Searching...
No Matches
percpu.h File Reference
#include <kernel/cpu/cpu.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for percpu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  percpu_def_t
 Structure to define a percpu variable. More...
 

Macros

#define PERCPU_ALIGNMENT   64
 The PERCPU_ALIGNMENT constant defines the alignment for per-CPU variables.
 
#define PERCPU   __seg_gs*
 Attribute specifying that the variable is an offset into the GS segment register.
 
#define SELF   ((cpu_t PERCPU)0)
 Macro to access data in the current cpu.
 
#define SELF_PTR(ptr)   ((void*)((uintptr_t)(SELF->self->percpu) + ((uintptr_t)(ptr) - offsetof(cpu_t, percpu))))
 Macro to get a pointer to a percpu variable on the current CPU.
 
#define CPU_PTR(id, ptr)    ((void*)((uintptr_t)(cpu_get_by_id(id)->percpu) + ((uintptr_t)(ptr) - offsetof(cpu_t, percpu))))
 Macro to get a pointer to a percpu variable on a specific CPU.
 
#define PERCPU_DEFINE(type, name, ...)
 Macro to define a percpu variable.
 
#define PERCPU_DEFINE_CTOR(type, name)
 Macro to define a percpu variable with a constructor.
 
#define PERCPU_DEFINE_DTOR(type, name)
 Macro to define a percpu variable with a destructor.
 
#define PERCPU_INIT()
 Initialize all percpu variables within the current modules .percpu section.
 
#define PERCPU_DEINIT()
 Deinitialize all percpu variables within the current modules .percpu section.
 

Typedefs

typedef size_t percpu_t
 The type that the compiler uses to store per-CPU variables.
 

Functions

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.
 
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.