Inline several functions which are simple or have a single caller, to save a bit of space.

This commit is contained in:
Lionel Debroux 2022-09-15 22:08:39 +02:00
parent edf6b5576d
commit df1fddcddb
4 changed files with 20 additions and 25 deletions

View File

@ -305,17 +305,6 @@ static bool parse_fadt(uintptr_t fadt_addr)
// Public Functions
//------------------------------------------------------------------------------
int acpi_checksum(const void *data, int length)
{
uint8_t sum = 0;
uint8_t *ptr = (uint8_t *)data;
while (length--) {
sum += *ptr++;
}
return sum;
}
void acpi_init(void)
{
acpi_config.rsdp_addr = find_rsdp();

View File

@ -63,7 +63,16 @@ extern acpi_t acpi_config;
/**
* ACPI Table Checksum Function
*/
int acpi_checksum(const void *data, int length);
static inline int acpi_checksum(const void *data, int length)
{
uint8_t sum = 0;
uint8_t *ptr = (uint8_t *)data;
while (length--) {
sum += *ptr++;
}
return sum;
}
/**
* Look for specific ACPI Tables Addresses (RSDP, MADT, ...)

View File

@ -12,15 +12,3 @@
//------------------------------------------------------------------------------
int local_bytes_used = 0;
//------------------------------------------------------------------------------
// Public Functions
//------------------------------------------------------------------------------
int allocate_local_flag(void)
{
if (local_bytes_used == LOCALS_SIZE) {
return -1;
}
return local_bytes_used += sizeof(bool);
}

View File

@ -24,13 +24,22 @@ typedef struct __attribute__((packed)) {
uint8_t spacing[AP_STACK_SIZE - sizeof(bool)];
} local_flag_t;
/**
* Allocates an array of thread-local flags, one per CPU core, and returns
* a ID number that identifies the allocated array. Returns -1 if there is
* insufficient thread local storage remaining to allocate a new array of
* flags.
*/
int allocate_local_flag(void);
static inline int allocate_local_flag(void)
{
extern int local_bytes_used;
if (local_bytes_used == LOCALS_SIZE) {
return -1;
}
return local_bytes_used += sizeof(bool);
}
/**
* Returns a pointer to the previously allocated array of thread-local flags