MOS Source Code
Loading...
Searching...
No Matches
limine.h
Go to the documentation of this file.
1/* BSD Zero Clause License */
2
3/* Copyright (C) 2022-2024 mintsuki and contributors.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef LIMINE_H
18#define LIMINE_H 1
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <stdint.h>
25
26/* Misc */
27
28#ifdef LIMINE_NO_POINTERS
29# define LIMINE_PTR(TYPE) uint64_t
30#else
31# define LIMINE_PTR(TYPE) TYPE
32#endif
33
34#ifdef __GNUC__
35# define LIMINE_DEPRECATED __attribute__((__deprecated__))
36# define LIMINE_DEPRECATED_IGNORE_START \
37 _Pragma("GCC diagnostic push") \
38 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
39# define LIMINE_DEPRECATED_IGNORE_END \
40 _Pragma("GCC diagnostic pop")
41#else
42# define LIMINE_DEPRECATED
43# define LIMINE_DEPRECATED_IGNORE_START
44# define LIMINE_DEPRECATED_IGNORE_END
45#endif
46
47#define LIMINE_REQUESTS_START_MARKER \
48 uint64_t limine_requests_start_marker[4] = { 0xf6b8f4b39de7d1ae, 0xfab91a6940fcb9cf, \
49 0x785c6ed015d3e316, 0x181e920a7852b9d9 };
50#define LIMINE_REQUESTS_END_MARKER \
51 uint64_t limine_requests_end_marker[2] = { 0xadc0e0531bb10d03, 0x9572709f31764c62 };
52
53#define LIMINE_REQUESTS_DELIMITER LIMINE_REQUESTS_END_MARKER
54
55#define LIMINE_BASE_REVISION(N) \
56 uint64_t limine_base_revision[3] = { 0xf9562b2d5c95a6c8, 0x6a7b384944536bdc, (N) };
57
58#define LIMINE_BASE_REVISION_SUPPORTED (limine_base_revision[2] == 0)
59
60#define LIMINE_COMMON_MAGIC 0xc7b1dd30df4c8b88, 0x0a82e883a194f07b
61
68
69#define LIMINE_MEDIA_TYPE_GENERIC 0
70#define LIMINE_MEDIA_TYPE_OPTICAL 1
71#define LIMINE_MEDIA_TYPE_TFTP 2
72
89
90/* Boot info */
91
92#define LIMINE_BOOTLOADER_INFO_REQUEST { LIMINE_COMMON_MAGIC, 0xf55038d8e2a1202f, 0x279426fcf5f59740 }
93
99
105
106/* Stack size */
107
108#define LIMINE_STACK_SIZE_REQUEST { LIMINE_COMMON_MAGIC, 0x224ef0460a8e8926, 0xe1cb0fc25f46ea3d }
109
113
120
121/* HHDM */
122
123#define LIMINE_HHDM_REQUEST { LIMINE_COMMON_MAGIC, 0x48dcf1cb8ad2b852, 0x63984e959a98244b }
124
129
135
136/* Framebuffer */
137
138#define LIMINE_FRAMEBUFFER_REQUEST { LIMINE_COMMON_MAGIC, 0x9d5827dcd881dd75, 0xa3148604f6fab11b }
139
140#define LIMINE_FRAMEBUFFER_RGB 1
141
155
176
182
188
189/* Terminal */
190
191#define LIMINE_TERMINAL_REQUEST { LIMINE_COMMON_MAGIC, 0xc8ac59310c2b0844, 0xa68d0c7265d38878 }
192
193#define LIMINE_TERMINAL_CB_DEC 10
194#define LIMINE_TERMINAL_CB_BELL 20
195#define LIMINE_TERMINAL_CB_PRIVATE_ID 30
196#define LIMINE_TERMINAL_CB_STATUS_REPORT 40
197#define LIMINE_TERMINAL_CB_POS_REPORT 50
198#define LIMINE_TERMINAL_CB_KBD_LEDS 60
199#define LIMINE_TERMINAL_CB_MODE 70
200#define LIMINE_TERMINAL_CB_LINUX 80
201
202#define LIMINE_TERMINAL_CTX_SIZE ((uint64_t)(-1))
203#define LIMINE_TERMINAL_CTX_SAVE ((uint64_t)(-2))
204#define LIMINE_TERMINAL_CTX_RESTORE ((uint64_t)(-3))
205#define LIMINE_TERMINAL_FULL_REFRESH ((uint64_t)(-4))
206
207/* Response revision 1 */
208#define LIMINE_TERMINAL_OOB_OUTPUT_GET ((uint64_t)(-10))
209#define LIMINE_TERMINAL_OOB_OUTPUT_SET ((uint64_t)(-11))
210
211#define LIMINE_TERMINAL_OOB_OUTPUT_OCRNL (1 << 0)
212#define LIMINE_TERMINAL_OOB_OUTPUT_OFDEL (1 << 1)
213#define LIMINE_TERMINAL_OOB_OUTPUT_OFILL (1 << 2)
214#define LIMINE_TERMINAL_OOB_OUTPUT_OLCUC (1 << 3)
215#define LIMINE_TERMINAL_OOB_OUTPUT_ONLCR (1 << 4)
216#define LIMINE_TERMINAL_OOB_OUTPUT_ONLRET (1 << 5)
217#define LIMINE_TERMINAL_OOB_OUTPUT_ONOCR (1 << 6)
218#define LIMINE_TERMINAL_OOB_OUTPUT_OPOST (1 << 7)
219
221
223
224typedef void (*limine_terminal_write)(struct limine_terminal *, const char *, uint64_t);
226
232
239
246
248
249/* Paging mode */
250
251#define LIMINE_PAGING_MODE_REQUEST { LIMINE_COMMON_MAGIC, 0x95c1a0edab0944cb, 0xa4e5cb3842f7488a }
252
253#if defined (__x86_64__) || defined (__i386__)
254#define LIMINE_PAGING_MODE_X86_64_4LVL 0
255#define LIMINE_PAGING_MODE_X86_64_5LVL 1
256#define LIMINE_PAGING_MODE_MAX LIMINE_PAGING_MODE_X86_64_5LVL
257#define LIMINE_PAGING_MODE_DEFAULT LIMINE_PAGING_MODE_X86_64_4LVL
258#elif defined (__aarch64__)
259#define LIMINE_PAGING_MODE_AARCH64_4LVL 0
260#define LIMINE_PAGING_MODE_AARCH64_5LVL 1
261#define LIMINE_PAGING_MODE_MAX LIMINE_PAGING_MODE_AARCH64_5LVL
262#define LIMINE_PAGING_MODE_DEFAULT LIMINE_PAGING_MODE_AARCH64_4LVL
263#elif defined (__riscv) && (__riscv_xlen == 64)
264#define LIMINE_PAGING_MODE_RISCV_SV39 0
265#define LIMINE_PAGING_MODE_RISCV_SV48 1
266#define LIMINE_PAGING_MODE_RISCV_SV57 2
267#define LIMINE_PAGING_MODE_MAX LIMINE_PAGING_MODE_RISCV_SV57
268#define LIMINE_PAGING_MODE_DEFAULT LIMINE_PAGING_MODE_RISCV_SV48
269#else
270#error Unknown architecture
271#endif
272
278
286
287/* 5-level paging */
288
289#define LIMINE_5_LEVEL_PAGING_REQUEST { LIMINE_COMMON_MAGIC, 0x94469551da9b3192, 0xebe5e86db7382888 }
290
292
296
302
304
305/* SMP */
306
307#define LIMINE_SMP_REQUEST { LIMINE_COMMON_MAGIC, 0x95a67b819a1b857e, 0xa0b61b723b6a73e0 }
308
309struct limine_smp_info;
310
311typedef void (*limine_goto_address)(struct limine_smp_info *);
312
313#if defined (__x86_64__) || defined (__i386__)
314
315#define LIMINE_SMP_X2APIC (1 << 0)
316
317struct limine_smp_info {
318 uint32_t processor_id;
319 uint32_t lapic_id;
320 uint64_t reserved;
321 LIMINE_PTR(limine_goto_address) goto_address;
322 uint64_t extra_argument;
323};
324
325struct limine_smp_response {
326 uint64_t revision;
327 uint32_t flags;
328 uint32_t bsp_lapic_id;
329 uint64_t cpu_count;
330 LIMINE_PTR(struct limine_smp_info **) cpus;
331};
332
333#elif defined (__aarch64__)
334
335struct limine_smp_info {
336 uint32_t processor_id;
337 uint32_t gic_iface_no;
338 uint64_t mpidr;
339 uint64_t reserved;
340 LIMINE_PTR(limine_goto_address) goto_address;
341 uint64_t extra_argument;
342};
343
344struct limine_smp_response {
345 uint64_t revision;
346 uint64_t flags;
347 uint64_t bsp_mpidr;
348 uint64_t cpu_count;
349 LIMINE_PTR(struct limine_smp_info **) cpus;
350};
351
352#elif defined (__riscv) && (__riscv_xlen == 64)
353
354struct limine_smp_info {
355 uint64_t processor_id;
356 uint64_t hartid;
357 uint64_t reserved;
358 LIMINE_PTR(limine_goto_address) goto_address;
359 uint64_t extra_argument;
360};
361
362struct limine_smp_response {
363 uint64_t revision;
364 uint64_t flags;
365 uint64_t bsp_hartid;
366 uint64_t cpu_count;
367 LIMINE_PTR(struct limine_smp_info **) cpus;
368};
369
370#else
371#error Unknown architecture
372#endif
373
375 uint64_t id[4];
377 LIMINE_PTR(struct limine_smp_response *) response;
379};
380
381/* Memory map */
382
383#define LIMINE_MEMMAP_REQUEST { LIMINE_COMMON_MAGIC, 0x67cf3d9d378a806f, 0xe304acdfc50c3c62 }
384
385#define LIMINE_MEMMAP_USABLE 0
386#define LIMINE_MEMMAP_RESERVED 1
387#define LIMINE_MEMMAP_ACPI_RECLAIMABLE 2
388#define LIMINE_MEMMAP_ACPI_NVS 3
389#define LIMINE_MEMMAP_BAD_MEMORY 4
390#define LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE 5
391#define LIMINE_MEMMAP_KERNEL_AND_MODULES 6
392#define LIMINE_MEMMAP_FRAMEBUFFER 7
393
399
405
411
412/* Entry point */
413
414#define LIMINE_ENTRY_POINT_REQUEST { LIMINE_COMMON_MAGIC, 0x13d86c035a1cd3e1, 0x2b0caa89d8f3026a }
415
417
421
428
429/* Kernel File */
430
431#define LIMINE_KERNEL_FILE_REQUEST { LIMINE_COMMON_MAGIC, 0xad97e90e83f1ed67, 0x31eb5d1c5ff23b69 }
432
437
443
444/* Module */
445
446#define LIMINE_MODULE_REQUEST { LIMINE_COMMON_MAGIC, 0x3e7e279702be32af, 0xca1c4f3bd1280cee }
447
448#define LIMINE_INTERNAL_MODULE_REQUIRED (1 << 0)
449#define LIMINE_INTERNAL_MODULE_COMPRESSED (1 << 1)
450
456
462
472
473/* RSDP */
474
475#define LIMINE_RSDP_REQUEST { LIMINE_COMMON_MAGIC, 0xc5e77b6b397e7b43, 0x27637845accdcf3c }
476
481
487
488/* SMBIOS */
489
490#define LIMINE_SMBIOS_REQUEST { LIMINE_COMMON_MAGIC, 0x9e9046f11e095391, 0xaa4a520fefbde5ee }
491
497
503
504/* EFI system table */
505
506#define LIMINE_EFI_SYSTEM_TABLE_REQUEST { LIMINE_COMMON_MAGIC, 0x5ceba5163eaaf6d6, 0x0a6981610cf65fcc }
507
512
518
519/* EFI memory map */
520
521#define LIMINE_EFI_MEMMAP_REQUEST { LIMINE_COMMON_MAGIC, 0x7df62a431d6872d5, 0xa4fcdfb3e57306c8 }
522
530
536
537/* Boot time */
538
539#define LIMINE_BOOT_TIME_REQUEST { LIMINE_COMMON_MAGIC, 0x502746e184c088aa, 0xfbc5ec83e6327893 }
540
545
551
552/* Kernel address */
553
554#define LIMINE_KERNEL_ADDRESS_REQUEST { LIMINE_COMMON_MAGIC, 0x71ba76863cc55f63, 0xb2644a48c516a487 }
555
561
567
568/* Device Tree Blob */
569
570#define LIMINE_DTB_REQUEST { LIMINE_COMMON_MAGIC, 0xb40ddb48fb54bac7, 0x545081493f81ffb7 }
571
576
582
583#ifdef __cplusplus
584}
585#endif
586
587#endif
MOSAPI void(1, 2) fatal_abort(const char *fmt
#define LIMINE_DEPRECATED_IGNORE_END
Definition limine.h:44
void(* limine_entry_point)(void)
Definition limine.h:416
#define LIMINE_DEPRECATED_IGNORE_START
Definition limine.h:43
void(* limine_terminal_callback)(struct limine_terminal *, uint64_t, uint64_t, uint64_t, uint64_t)
Definition limine.h:225
void(* limine_terminal_write)(struct limine_terminal *, const char *, uint64_t)
Definition limine.h:224
void(* limine_goto_address)(struct limine_smp_info *)
Definition limine.h:311
#define LIMINE_PTR(TYPE)
Definition limine.h:31
#define LIMINE_DEPRECATED
Definition limine.h:42
#define uint64_t
unsigned short uint16_t
Definition pb_syshdr.h:22
unsigned int uint32_t
Definition pb_syshdr.h:24
unsigned long long uint64_t
Definition pb_syshdr.h:26
unsigned char uint8_t
Definition pb_syshdr.h:20
signed long long int64_t
Definition pb_syshdr.h:25
struct limine_5_level_paging_response * response
Definition limine.h:300
struct limine_boot_time_response * response
Definition limine.h:549
struct limine_bootloader_info_response * response
Definition limine.h:103
struct limine_dtb_response * response
Definition limine.h:580
uint64_t revision
Definition limine.h:579
uint64_t revision
Definition limine.h:573
struct limine_efi_memmap_response * response
Definition limine.h:534
struct limine_efi_system_table_response * response
Definition limine.h:516
Definition limine.h:422
limine_entry_point entry
Definition limine.h:426
uint64_t revision
Definition limine.h:424
struct limine_entry_point_response * response
Definition limine.h:425
Definition limine.h:418
uint64_t revision
Definition limine.h:419
char * cmdline
Definition limine.h:78
struct limine_uuid gpt_part_uuid
Definition limine.h:86
uint32_t partition_index
Definition limine.h:83
uint32_t media_type
Definition limine.h:79
char * path
Definition limine.h:77
struct limine_uuid gpt_disk_uuid
Definition limine.h:85
struct limine_uuid part_uuid
Definition limine.h:87
uint32_t unused
Definition limine.h:80
uint32_t mbr_disk_id
Definition limine.h:84
void * address
Definition limine.h:75
uint64_t revision
Definition limine.h:74
uint32_t tftp_port
Definition limine.h:82
uint32_t tftp_ip
Definition limine.h:81
uint64_t size
Definition limine.h:76
struct limine_framebuffer_response * response
Definition limine.h:186
struct limine_framebuffer ** framebuffers
Definition limine.h:180
uint8_t green_mask_shift
Definition limine.h:166
uint8_t green_mask_size
Definition limine.h:165
uint64_t mode_count
Definition limine.h:173
uint8_t red_mask_size
Definition limine.h:163
uint64_t height
Definition limine.h:159
uint64_t pitch
Definition limine.h:160
uint8_t memory_model
Definition limine.h:162
uint64_t edid_size
Definition limine.h:170
struct limine_video_mode ** modes
Definition limine.h:174
uint64_t width
Definition limine.h:158
uint8_t blue_mask_shift
Definition limine.h:168
uint8_t unused[7]
Definition limine.h:169
uint8_t red_mask_shift
Definition limine.h:164
uint8_t blue_mask_size
Definition limine.h:167
uint64_t revision
Definition limine.h:132
struct limine_hhdm_response * response
Definition limine.h:133
uint64_t revision
Definition limine.h:126
const char * path
Definition limine.h:452
const char * cmdline
Definition limine.h:453
struct limine_kernel_address_response * response
Definition limine.h:565
struct limine_kernel_file_response * response
Definition limine.h:441
struct limine_file * kernel_file
Definition limine.h:435
Definition limine.h:394
uint64_t type
Definition limine.h:397
uint64_t length
Definition limine.h:396
uint64_t base
Definition limine.h:395
struct limine_memmap_response * response
Definition limine.h:409
struct limine_memmap_entry ** entries
Definition limine.h:403
uint64_t internal_module_count
Definition limine.h:469
struct limine_internal_module ** internal_modules
Definition limine.h:470
struct limine_module_response * response
Definition limine.h:466
struct limine_file ** modules
Definition limine.h:460
uint64_t module_count
Definition limine.h:459
struct limine_paging_mode_response * response
Definition limine.h:282
struct limine_rsdp_response * response
Definition limine.h:485
uint64_t revision
Definition limine.h:484
uint64_t revision
Definition limine.h:478
struct limine_smbios_response * response
Definition limine.h:501
struct limine_smp_response * response
Definition limine.h:377
uint64_t flags
Definition limine.h:378
uint64_t revision
Definition limine.h:376
struct limine_stack_size_response * response
Definition limine.h:117
limine_terminal_callback callback
Definition limine.h:244
struct limine_terminal_response * response
Definition limine.h:243
limine_terminal_write write
Definition limine.h:237
struct limine_terminal ** terminals
Definition limine.h:236
uint64_t rows
Definition limine.h:229
uint64_t columns
Definition limine.h:228
struct limine_framebuffer * framebuffer
Definition limine.h:230
uint32_t a
Definition limine.h:63
uint16_t b
Definition limine.h:64
uint8_t d[8]
Definition limine.h:66
uint16_t c
Definition limine.h:65
uint8_t green_mask_shift
Definition limine.h:151
uint8_t green_mask_size
Definition limine.h:150
uint8_t red_mask_size
Definition limine.h:148
uint64_t height
Definition limine.h:145
uint16_t bpp
Definition limine.h:146
uint64_t pitch
Definition limine.h:143
uint8_t memory_model
Definition limine.h:147
uint64_t width
Definition limine.h:144
uint8_t blue_mask_shift
Definition limine.h:153
uint8_t red_mask_shift
Definition limine.h:149
uint8_t blue_mask_size
Definition limine.h:152