forked from UltraOS/uACPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel_api.h
141 lines (119 loc) · 3.77 KB
/
kernel_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#pragma once
#include <uacpi/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Raw IO API, this is only used for accessing verified data from
* "safe" code (aka not indirectly invoked by the AML interpreter),
* e.g. programming FADT & FACS registers.
* -------------------------------------------------------------------------
*/
uacpi_status uacpi_kernel_raw_memory_read(
uacpi_phys_addr address, uacpi_u8 byte_width, uacpi_u64 *out_value
);
uacpi_status uacpi_kernel_raw_memory_write(
uacpi_phys_addr address, uacpi_u8 byte_width, uacpi_u64 in_value
);
uacpi_status uacpi_kernel_raw_io_read(
uacpi_io_addr address, uacpi_u8 byte_width, uacpi_u64 *out_value
);
uacpi_status uacpi_kernel_raw_io_write(
uacpi_io_addr address, uacpi_u8 byte_width, uacpi_u64 in_value
);
// -------------------------------------------------------------------------
uacpi_status uacpi_kernel_pci_read(
uacpi_pci_address *address, uacpi_size offset,
uacpi_u8 byte_width, uacpi_u64 *value
);
uacpi_status uacpi_kernel_pci_write(
uacpi_pci_address *address, uacpi_size offset,
uacpi_u8 byte_width, uacpi_u64 value
);
/*
* Map a SystemIO address at [base, base + len) and return a kernel-implemented
* handle that can be used for reading and writing the IO range.
*/
uacpi_status uacpi_kernel_io_map(
uacpi_io_addr base, uacpi_size len, uacpi_handle *out_handle
);
void uacpi_kernel_io_unmap(uacpi_handle handle);
/*
* Read/Write the IO range mapped via uacpi_kernel_io_map
* at a 0-based 'offset' within the range.
*/
uacpi_status uacpi_kernel_io_read(
uacpi_handle, uacpi_size offset,
uacpi_u8 byte_width, uacpi_u64 *value
);
uacpi_status uacpi_kernel_io_write(
uacpi_handle, uacpi_size offset,
uacpi_u8 byte_width, uacpi_u64 value
);
void *uacpi_kernel_map(uacpi_phys_addr addr, uacpi_size len);
void uacpi_kernel_unmap(void *addr, uacpi_size len);
void *uacpi_kernel_alloc(uacpi_size size);
void *uacpi_kernel_calloc(uacpi_size count, uacpi_size size);
void uacpi_kernel_free(void *mem);
enum uacpi_log_level {
UACPI_LOG_TRACE = 3,
UACPI_LOG_INFO = 2,
UACPI_LOG_WARN = 1,
UACPI_LOG_ERROR = 0,
};
void uacpi_kernel_log(enum uacpi_log_level, const char*, ...);
void uacpi_kernel_vlog(enum uacpi_log_level, const char*, uacpi_va_list);
/*
* Returns the number of 100 nanosecond ticks, strictly monotonic.
*/
uacpi_u64 uacpi_kernel_get_ticks(void);
/*
* Spin for N microseconds.
*/
void uacpi_kernel_stall(uacpi_u8 usec);
/*
* Sleep for N milliseconds.
*/
void uacpi_kernel_sleep(uacpi_u64 msec);
/*
* Create/free an opaque non-recursive kernel mutex object.
*/
uacpi_handle uacpi_kernel_create_mutex(void);
void uacpi_kernel_free_mutex(uacpi_handle);
/*
* Create/free an opaque kernel (semaphore-like) event object.
*/
uacpi_handle uacpi_kernel_create_event(void);
void uacpi_kernel_free_event(uacpi_handle);
/*
* Try to acquire the mutex with a millisecond timeout.
* A timeout value of 0xFFFF implies infinite wait.
*/
uacpi_bool uacpi_kernel_acquire_mutex(uacpi_handle, uacpi_u16);
void uacpi_kernel_release_mutex(uacpi_handle);
/*
* Try to wait for an event (counter > 0) with a millisecond timeout.
* A timeout value of 0xFFFF implies infinite wait.
*
* The internal counter is decremented by 1 if wait was successful.
*
* A successful wait is indicated by returning UACPI_TRUE.
*/
uacpi_bool uacpi_kernel_wait_for_event(uacpi_handle, uacpi_u16);
/*
* Signal the event object by incrementing its internal counter by 1.
*/
void uacpi_kernel_signal_event(uacpi_handle);
/*
* Reset the event counter to 0.
*/
void uacpi_kernel_reset_event(uacpi_handle);
/*
* Handle a firmware request.
*
* Currently either a Breakpoint or Fatal operators.
*/
uacpi_status uacpi_kernel_handle_firmware_request(uacpi_firmware_request*);
#ifdef __cplusplus
}
#endif