1#pragma once
2
3#include <uacpi/types.h>
4#include <uacpi/utilities.h>
5#include <uacpi/internal/log.h>
6#include <uacpi/internal/stdlib.h>
7
8static inline uacpi_phys_addr uacpi_truncate_phys_addr_with_warn(uacpi_u64 large_addr)
9{
10 if (sizeof(uacpi_phys_addr) < 8 && large_addr > 0xFFFFFFFF) {
11 uacpi_warn(
12 "truncating a physical address 0x%"UACPI_PRIX64
13 " outside of address space\n", UACPI_FMT64(large_addr)
14 );
15 }
16
17 return (uacpi_phys_addr)large_addr;
18}
19
20#define UACPI_PTR_TO_VIRT_ADDR(ptr) ((uacpi_virt_addr)(ptr))
21#define UACPI_VIRT_ADDR_TO_PTR(vaddr) ((void*)(vaddr))
22
23#define UACPI_PTR_ADD(ptr, value) ((void*)(((uacpi_u8*)(ptr)) + value))
24
25/*
26 * Target buffer must have a length of at least 8 bytes.
27 */
28void uacpi_eisa_id_to_string(uacpi_u32, uacpi_char *out_string);
29
30enum uacpi_base {
31 UACPI_BASE_AUTO,
32 UACPI_BASE_OCT = 8,
33 UACPI_BASE_DEC = 10,
34 UACPI_BASE_HEX = 16,
35};
36uacpi_status uacpi_string_to_integer(
37 const uacpi_char *str, uacpi_size max_chars, enum uacpi_base base,
38 uacpi_u64 *out_value
39);
40
41uacpi_bool uacpi_is_valid_nameseg(uacpi_u8 *nameseg);
42
43void uacpi_free_dynamic_string(const uacpi_char *str);
44