ReactOS 0.4.17-dev-683-g0dafdc5
tables.c
Go to the documentation of this file.
6
9)
11 table_array, struct uacpi_installed_table, static
12)
13
14static struct table_array tables;
15static uacpi_bool early_table_access;
16static uacpi_bool fadt_available;
17static uacpi_table_installation_handler installation_handler;
18
19#ifndef UACPI_BAREBONES_MODE
20
21static uacpi_handle table_mutex;
22
24{
25 return early_table_access ||
27}
28
29#define ENSURE_TABLES_ONLINE() \
30 do { \
31 if (!early_table_access) \
32 UACPI_ENSURE_INIT_LEVEL_AT_LEAST( \
33 UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED \
34 ); \
35 } while (0)
36
37#else
38
40{
41 return early_table_access;
42}
43
44/*
45 * Use a dummy function instead of a macro to prevent the following error:
46 * error: statement with no effect [-Werror=unused-value]
47 */
48static inline uacpi_status dummy_mutex_acquire_release(uacpi_handle mtx)
49{
50 UACPI_UNUSED(mtx);
51 return UACPI_STATUS_OK;
52}
53
54#define table_mutex UACPI_NULL
55#define uacpi_acquire_native_mutex_may_be_null dummy_mutex_acquire_release
56#define uacpi_release_native_mutex_may_be_null dummy_mutex_acquire_release
57
58#define ENSURE_TABLES_ONLINE() \
59 do { \
60 if (!early_table_access) \
61 return UACPI_STATUS_INIT_LEVEL_MISMATCH; \
62 } while (0)
63
64#endif // !UACPI_BAREBONES_MODE
65
68 const uacpi_char *expected_signature, uacpi_table *out_table
69);
71 void *virt, enum uacpi_table_origin origin, uacpi_table *out_table
72);
73
74UACPI_PACKED(struct uacpi_rxsdt {
75 struct acpi_sdt_hdr hdr;
76 uacpi_u8 ptr_bytes[];
77})
78
79static void dump_table_header(
80 uacpi_phys_addr phys_addr, void *hdr
81)
82{
83 struct acpi_sdt_hdr *sdt = hdr;
84
87 "FACS 0x%016"UACPI_PRIX64" %08X", UACPI_FMT64(phys_addr),
88 sdt->length
89 );
90 return;
91 }
92
94 struct acpi_rsdp *rsdp = hdr;
95
97 "RSDP 0x%016"UACPI_PRIX64" %08X v%02X (%6.6s)",
98 UACPI_FMT64(phys_addr), rsdp->revision >= 2 ? rsdp->length : 20,
99 rsdp->revision, rsdp->oemid
100 );
101 return;
102 }
103
105 "%.4s 0x%016"UACPI_PRIX64" %08X v%02X (%6.6s %8.8s)",
106 sdt->signature, UACPI_FMT64(phys_addr), sdt->length, sdt->revision,
107 sdt->oemid, sdt->oem_table_id
108 );
109}
110
112 uacpi_size entry_size)
113{
114 struct uacpi_rxsdt *rxsdt;
115 uacpi_size i, entry_bytes, map_len = sizeof(*rxsdt);
116 uacpi_phys_addr entry_addr;
118
119 rxsdt = uacpi_kernel_map(rxsdt_addr, map_len);
120 if (rxsdt == UACPI_MAP_FAILED)
122
123 dump_table_header(rxsdt_addr, rxsdt);
124
126 entry_size == 8 ? ACPI_XSDT_SIGNATURE : ACPI_RSDT_SIGNATURE);
128 goto error_out;
129
130 map_len = rxsdt->hdr.length;
131 uacpi_kernel_unmap(rxsdt, sizeof(*rxsdt));
132
133 if (uacpi_unlikely(map_len < (sizeof(*rxsdt) + entry_size)))
135
136 // Make sure length is aligned to entry size so we don't OOB
137 entry_bytes = map_len - sizeof(*rxsdt);
138 entry_bytes &= ~(entry_size - 1);
139
140 rxsdt = uacpi_kernel_map(rxsdt_addr, map_len);
141 if (uacpi_unlikely(rxsdt == UACPI_MAP_FAILED))
143
144 ret = uacpi_verify_table_checksum(rxsdt, map_len, UACPI_NULL);
146 goto error_out;
147
148 for (i = 0; i < entry_bytes; i += entry_size) {
149 uacpi_u64 entry_phys_addr_large = 0;
150 uacpi_memcpy(&entry_phys_addr_large, &rxsdt->ptr_bytes[i], entry_size);
151
152 if (!entry_phys_addr_large)
153 continue;
154
155 entry_addr = uacpi_truncate_phys_addr_with_warn(entry_phys_addr_large);
158 );
161 goto error_out;
162 }
163
165
166error_out:
167 uacpi_kernel_unmap(rxsdt, map_len);
168 return ret;
169}
170
172{
174 uacpi_phys_addr rsdp_phys;
175 struct acpi_rsdp *rsdp;
176 uacpi_phys_addr rxsdt;
177 uacpi_size rxsdt_entry_size;
178
179 g_uacpi_rt_ctx.is_rev1 = UACPI_TRUE;
180
181 ret = uacpi_kernel_get_rsdp(&rsdp_phys);
183 return ret;
184
185 rsdp = uacpi_kernel_map(rsdp_phys, sizeof(struct acpi_rsdp));
186 if (rsdp == UACPI_MAP_FAILED)
188
189 dump_table_header(rsdp_phys, rsdp);
190
191 if (rsdp->revision > 1 && rsdp->xsdt_addr &&
193 {
194 rxsdt = uacpi_truncate_phys_addr_with_warn(rsdp->xsdt_addr);
195 rxsdt_entry_size = 8;
196 } else {
197 rxsdt = (uacpi_phys_addr)rsdp->rsdt_addr;
198 rxsdt_entry_size = 4;
199 }
200
201 uacpi_kernel_unmap(rsdp, sizeof(struct acpi_rsdp));
202
203 if (!rxsdt) {
204 uacpi_error("both RSDT & XSDT tables are NULL!");
206 }
207
208 return initialize_from_rxsdt(rxsdt, rxsdt_entry_size);
209}
210
212{
213 return table_array_size(&tables);
214}
215
218)
219{
221 uacpi_virt_addr buffer_addr, aligned_buffer_addr;
222
223#ifndef UACPI_BAREBONES_MODE
225#endif
226 if (uacpi_unlikely(early_table_access))
228
230
232 aligned_buffer_addr = UACPI_ALIGN_UP(
233 buffer_addr, UACPI_POINTER_SIZE, uacpi_virt_addr
234 );
235 if (buffer_addr != aligned_buffer_addr) {
236 uacpi_size stripped_bytes;
237
238 stripped_bytes = aligned_buffer_addr - buffer_addr;
240 "fixed up misaligned early tables buffer (%zu bytes stripped)",
241 stripped_bytes
242 );
243
244 buffer_size -= UACPI_MIN(stripped_bytes, buffer_size);
245 temporary_buffer = UACPI_VIRT_ADDR_TO_PTR(aligned_buffer_addr);
246 }
247
250
251 tables.dynamic_storage = temporary_buffer;
252 tables.dynamic_capacity = buffer_size / sizeof(struct uacpi_installed_table);
253 early_table_access = UACPI_TRUE;
254
258
259 return ret;
260}
261
262#ifndef UACPI_BAREBONES_MODE
264 void *user, struct uacpi_installed_table *tbl, uacpi_size idx
265)
266{
268
269 if (uacpi_unlikely(tbl->reference_count != 0)) {
271 "table "UACPI_PRI_TBL_HDR" (%zu) still has %d early reference(s)!",
273 );
274 }
275
277}
278
280{
281 if (early_table_access) {
282 uacpi_size num_tables;
283
285
286 // Reallocate the user buffer into a normal heap array
287 num_tables = table_array_size(&tables);
288 if (num_tables > table_array_inline_capacity(&tables)) {
289 void *new_buf;
290
291 /*
292 * Allocate a new buffer with size equal to exactly the number of
293 * dynamic tables (that live in the user provided temporary buffer).
294 */
295 num_tables -= table_array_inline_capacity(&tables);
296 new_buf = uacpi_kernel_alloc(
297 sizeof(struct uacpi_installed_table) * num_tables
298 );
299 if (uacpi_unlikely(new_buf == UACPI_NULL))
301
302 uacpi_memcpy(new_buf, tables.dynamic_storage,
303 sizeof(struct uacpi_installed_table) * num_tables);
304 tables.dynamic_storage = new_buf;
305 tables.dynamic_capacity = num_tables;
306 } else {
307 /*
308 * User-provided temporary buffer was not used at all, just remove
309 * any references to it.
310 */
311 tables.dynamic_storage = UACPI_NULL;
312 tables.dynamic_capacity = 0;
313 }
314
315 early_table_access = UACPI_FALSE;
316 } else {
318
321 return ret;
322 }
323
325 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
326 uacpi_table tbl;
327
328 if (fadt->x_firmware_ctrl) {
330
332 fadt->x_firmware_ctrl, UACPI_TABLE_ORIGIN_FIRMWARE_PHYSICAL,
334 );
337 return ret;
338
339 g_uacpi_rt_ctx.facs = tbl.ptr;
340 }
341 }
342
343 table_mutex = uacpi_kernel_create_mutex();
344 if (uacpi_unlikely(table_mutex == UACPI_NULL))
346
347 return UACPI_STATUS_OK;
348}
349#endif // !UACPI_BAREBONES_MODE
350
352{
354
355 for (i = 0; i < table_array_size(&tables); ++i) {
356 struct uacpi_installed_table *tbl = table_array_at(&tables, i);
357
358 switch (tbl->origin) {
359#ifndef UACPI_BAREBONES_MODE
361 uacpi_free(tbl->ptr, tbl->hdr.length);
362 break;
363#endif
366 if (tbl->reference_count != 0)
367 uacpi_kernel_unmap(tbl->ptr, tbl->hdr.length);
368 break;
369 default:
370 break;
371 }
372 }
373
374 if (early_table_access) {
375 uacpi_memzero(&tables, sizeof(tables));
376 early_table_access = UACPI_FALSE;
377 } else {
378 table_array_clear(&tables);
379 }
380
381 installation_handler = UACPI_NULL;
382 fadt_available = UACPI_FALSE;
383
384#ifndef UACPI_BAREBONES_MODE
385 if (table_mutex)
386 uacpi_kernel_free_mutex(table_mutex);
387
388 table_mutex = UACPI_NULL;
389#endif
390}
391
394)
395{
397
400 return ret;
401
402 if (installation_handler != UACPI_NULL && handler != UACPI_NULL)
403 goto out;
404
405 installation_handler = handler;
406
407out:
409 return ret;
410}
411
412static uacpi_status initialize_fadt(const void*);
413
415{
417 uacpi_u8 csum = 0;
419
420 for (i = 0; i < size; ++i)
421 csum += bytes[i];
422
423 return csum;
424}
425
427 void *table, uacpi_size size, uacpi_u8 *out_flags
428)
429{
432
434 if (out_flags != UACPI_NULL)
435 *out_flags |= UACPI_TABLE_CSUM_CHECKED;
436
437 if (uacpi_unlikely(csum != 0)) {
439 struct acpi_sdt_hdr *hdr = table;
440
441 if (out_flags != UACPI_NULL)
442 *out_flags |= UACPI_TABLE_CSUM_BAD;
443
446 lvl = UACPI_LOG_ERROR;
447 }
448
450 lvl, "invalid table "UACPI_PRI_TBL_HDR" checksum %d!",
452 );
453 }
454
455 return ret;
456}
457
459{
462}
463
464uacpi_bool uacpi_signatures_match(const void *const lhs, const void *const rhs)
465{
466 return uacpi_memcmp(lhs, rhs, sizeof(uacpi_object_name)) == 0;
467}
468
470{
472
475 struct acpi_sdt_hdr *hdr = table;
476
479 lvl = UACPI_LOG_ERROR;
480 }
481
483 lvl,
484 "invalid table "UACPI_PRI_TBL_HDR" signature (expected '%.4s')",
486 );
487 }
488
489 return ret;
490}
491
493 struct uacpi_installed_table **out_tbl, uacpi_size *out_idx
494)
495{
496 struct uacpi_installed_table *tbl;
497
498 if (early_table_access &&
499 table_array_size(&tables) == table_array_capacity(&tables)) {
500 uacpi_warn("early table access buffer capacity exhausted!");
502 }
503
504 tbl = table_array_alloc(&tables);
505 if (uacpi_unlikely(tbl == UACPI_NULL))
507
508 *out_tbl = tbl;
509 *out_idx = table_array_size(&tables) - 1;
510 return UACPI_STATUS_OK;
511}
512
514 uacpi_phys_addr phys_addr, struct acpi_sdt_hdr *out_hdr
515)
516{
517 void *virt;
518
519 virt = uacpi_kernel_map(phys_addr, sizeof(*out_hdr));
520 if (uacpi_unlikely(virt == UACPI_MAP_FAILED))
522
523 uacpi_memcpy(out_hdr, virt, sizeof(*out_hdr));
524
525 uacpi_kernel_unmap(virt, sizeof(*out_hdr));
526 return UACPI_STATUS_OK;
527}
528
530{
531 switch (tbl->reference_count) {
532 case 0: {
534
537
540 break;
541
542 tbl->ptr = uacpi_kernel_map(tbl->phys_addr, tbl->hdr.length);
545
546 if (!(tbl->flags & UACPI_TABLE_CSUM_CHECKED)) {
548 tbl->ptr, tbl->hdr.length, &tbl->flags
549 );
551 uacpi_kernel_unmap(tbl->ptr, tbl->hdr.length);
552 tbl->ptr = UACPI_NULL;
553 return ret;
554 }
555 }
556 break;
557 }
558 case 0xFFFF - 1:
560 "too many references for "UACPI_PRI_TBL_HDR
561 ", mapping permanently", UACPI_FMT_TBL_HDR(&tbl->hdr)
562 );
563 break;
564 default:
565 break;
566 }
567
568 if (uacpi_likely(tbl->reference_count != 0xFFFF))
569 tbl->reference_count++;
570 return UACPI_STATUS_OK;
571}
572
574{
575 switch (tbl->reference_count) {
576 case 0:
578 "tried to unref table "UACPI_PRI_TBL_HDR" with no references",
580 );
582 case 1:
585 break;
586
587 uacpi_kernel_unmap(tbl->ptr, tbl->hdr.length);
588 tbl->ptr = UACPI_NULL;
589 break;
590 case 0xFFFF:
591 /*
592 * Consider the reference count (overflow) of 0xFFFF to be a permanently
593 * mapped table as we don't know the actual number of references.
594 */
595 return UACPI_STATUS_OK;
596 default:
597 break;
598 }
599
600 tbl->reference_count--;
601 return UACPI_STATUS_OK;
602}
603
606)
607{
608 struct uacpi_installed_table *tbl;
609
610 tbl = table_array_at(&tables, idx);
611
612 out_info->idx = idx;
613 out_info->size = tbl->hdr.length;
615 out_info->signature, tbl->hdr.signature,
616 sizeof(out_info->signature)
617 );
618 out_info->origin = tbl->origin;
619 out_info->flags = tbl->flags;
620 out_info->reference_count = tbl->reference_count;
621
622 if (out_info->origin & (UACPI_TABLE_ORIGIN_HOST_VIRTUAL |
624 out_info->virt_addr = tbl->ptr;
625 } else {
626 out_info->phys_addr = tbl->phys_addr;
627 }
628}
629
632)
633{
635
637
640 return ret;
641
642 if (uacpi_unlikely(table_array_size(&tables) <= idx)) {
644 "requested invalid table index %zu (%zu tables installed)",
645 idx, table_array_size(&tables)
646 );
648 goto out;
649 }
650
652
653out:
655 return ret;
656}
657
660)
661{
663 uacpi_size num_tables, i = 0;
665
667
668 for (;;) {
671 return ret;
672
673 // Number of tables may have increased while we were in the callback
674 num_tables = table_array_size(&tables);
675 if (i >= num_tables) {
677 return ret;
678 }
679
681
684 return ret;
685
687 break;
688
689 i++;
690 }
691
692 return UACPI_STATUS_OK;
693}
694
696 struct acpi_sdt_hdr *hdr, uacpi_phys_addr phys_addr, void *virt_addr,
697 enum uacpi_table_origin origin, uacpi_table *out_table
698)
699{
702 uacpi_bool is_fadt;
704 uacpi_u8 flags = 0;
705
706 is_fadt = uacpi_signatures_match(hdr->signature, ACPI_FADT_SIGNATURE);
707
708 /*
709 * FACS is the only(?) table without a checksum because it has OSPM
710 * writable fields. Don't try to validate it here.
711 */
714 } else if (uacpi_check_flag(UACPI_FLAG_PROACTIVE_TBL_CSUM) || is_fadt ||
715 out_table != UACPI_NULL) {
716 void *mapping = virt_addr;
717
718 // We may already have a valid mapping, reuse it if we do
719 if (mapping == UACPI_NULL)
723
726 if (is_fadt)
728 }
729
730 if (virt_addr == UACPI_NULL)
732
734 return ret;
735 }
736
738 g_uacpi_rt_ctx.is_rev1 = hdr->revision < 2;
739
740 ret = table_alloc(&table, &idx);
742 return ret;
743
744 dump_table_header(phys_addr, hdr);
745
746 uacpi_memcpy(&table->hdr, hdr, sizeof(*hdr));
747 table->reference_count = 0;
748 table->phys_addr = phys_addr;
749 table->ptr = virt_addr;
750 table->flags = flags;
751 table->origin = origin;
752
753 if (out_table == UACPI_NULL)
754 return UACPI_STATUS_OK;
755
756 table->reference_count++;
757 out_table->ptr = virt_addr;
758 out_table->index = idx;
759 return UACPI_STATUS_OK;
760}
761
764 uacpi_table *out_table
765)
766{
768
769 switch (disposition) {
774 out_table
775 );
776 return ret;
782 out_table
783 );
784 default:
785 uacpi_error("invalid table installation disposition %d", disposition);
787 }
788}
789
792 const uacpi_char *expected_signature, uacpi_table *out_table
793)
794{
795 struct acpi_sdt_hdr hdr;
796 void *virt = UACPI_NULL;
798
801 return ret;
802
803 if (uacpi_unlikely(hdr.length < sizeof(struct acpi_sdt_hdr))) {
805 "bogus table '%.4s' (0x%016"UACPI_PRIX64") size: %u bytes",
806 hdr.signature, UACPI_FMT64(phys), hdr.length
807 );
808 }
809
810 if (expected_signature != UACPI_NULL) {
811 ret = uacpi_check_table_signature(&hdr, expected_signature);
813 return ret;
814 }
815
816 if (installation_handler != UACPI_NULL || out_table != UACPI_NULL) {
817 virt = uacpi_kernel_map(phys, hdr.length);
818 if (uacpi_unlikely(virt == UACPI_MAP_FAILED))
820 }
821
823 installation_handler != UACPI_NULL) {
824 uacpi_u64 override;
826
827 disposition = installation_handler(virt, &override);
828
829 switch (disposition) {
831 break;
834 "table '%.4s' (0x%016"UACPI_PRIX64") installation denied "
835 "by host", hdr.signature, UACPI_FMT64(phys)
836 );
838 goto out;
839
840 default:
842 "table '%.4s' (0x%016"UACPI_PRIX64") installation "
843 "overridden by host", hdr.signature, UACPI_FMT64(phys)
844 );
845
846 ret = handle_table_override(disposition, override, out_table);
849
850 goto out;
851 }
852 }
853
854 ret = verify_and_install_table(&hdr, phys, virt, origin, out_table);
855out:
856 // We don't unmap only in this case
857 if (ret == UACPI_STATUS_OK && out_table != UACPI_NULL)
858 return ret;
859
860 if (virt != UACPI_NULL)
861 uacpi_kernel_unmap(virt, hdr.length);
862 return UACPI_STATUS_OK;
863}
864
867)
868{
870
873 return ret;
874
876 phys, origin, UACPI_NULL, out_table
877 );
879
880 return ret;
881}
882
884 void *virt, enum uacpi_table_origin origin, uacpi_table *out_table
885)
886{
887 struct acpi_sdt_hdr *hdr = virt;
888
889 if (uacpi_unlikely(hdr->length < sizeof(struct acpi_sdt_hdr))) {
890 uacpi_error("invalid table '%.4s' (%p) size: %u",
891 hdr->signature, virt, hdr->length);
893 }
894
895#ifndef UACPI_BAREBONES_MODE
897 installation_handler != UACPI_NULL) {
898 uacpi_u64 override;
900
901 disposition = installation_handler(virt, &override);
902
903 switch (disposition) {
905 break;
908 "table "UACPI_PRI_TBL_HDR" installation denied by host",
910 );
911 return UACPI_STATUS_DENIED;
912
913 default: {
916 "table "UACPI_PRI_TBL_HDR" installation overridden by host",
918 );
919
920 ret = handle_table_override(disposition, override, out_table);
923
924 return ret;
925 }
926 }
927 }
928#endif
929
931 hdr, 0, virt, origin, out_table
932 );
933}
934
936 void *virt, enum uacpi_table_origin origin, uacpi_table *out_table
937)
938{
940
943 return ret;
944
946
948 return ret;
949}
950
952{
954
956 virt, UACPI_TABLE_ORIGIN_HOST_VIRTUAL, out_table
957 );
958}
959
962)
963{
965
968 );
969}
970
973)
974{
977 struct uacpi_installed_table *tbl;
979
981
984 return ret;
985
986 for (idx = base_idx; idx < table_array_size(&tables); ++idx) {
987 tbl = table_array_at(&tables, idx);
988
990 continue;
991
992 dec = cb(user, tbl, idx);
994 break;
995 }
996
998 return ret;
999}
1000
1004};
1005
1007 union {
1010 };
1011
1016};
1017
1019 void *user, struct uacpi_installed_table *tbl, uacpi_size idx
1020)
1021{
1022 struct table_search_ctx *ctx = user;
1025
1026 switch (ctx->search_type) {
1027 case SEARCH_TYPE_BY_ID: {
1028 const uacpi_table_identifiers *id = ctx->id;
1029
1030 if (!uacpi_signatures_match(&id->signature, tbl->hdr.signature))
1032 if (id->oemid[0] != '\0' &&
1033 uacpi_memcmp(id->oemid, tbl->hdr.oemid, sizeof(id->oemid)) != 0)
1035
1036 if (id->oem_table_id[0] != '\0' &&
1037 uacpi_memcmp(id->oem_table_id, tbl->hdr.oem_table_id,
1038 sizeof(id->oem_table_id)) != 0)
1040
1041 break;
1042 }
1043
1044 case SEARCH_TYPE_MATCH:
1045 if (!ctx->match_cb(tbl))
1047 break;
1048
1049 default:
1052 }
1053
1054 // Match, but we were asked for an nth table
1055 if (ctx->to_skip) {
1056 ctx->to_skip--;
1058 }
1059
1060 ret = table_ref_unlocked(tbl);
1062 out_table = ctx->out_table;
1063 out_table->ptr = tbl->ptr;
1064 out_table->index = idx;
1065 ctx->status = ret;
1067 }
1068
1069 /*
1070 * Don't abort nor propagate bad checksums, just pretend this table never
1071 * existed and go on with the search.
1072 */
1075
1076 ctx->status = ret;
1078}
1079
1080#ifndef UACPI_BAREBONES_MODE
1083)
1084{
1086 struct table_search_ctx ctx = { 0 };
1087
1088 ctx.match_cb = cb;
1089 ctx.search_type = SEARCH_TYPE_MATCH;
1090 ctx.out_table = out_table;
1091 ctx.status = UACPI_STATUS_NOT_FOUND;
1092
1095 return ret;
1096
1097 return ctx.status;
1098}
1099#endif
1100
1104)
1105{
1107 struct table_search_ctx ctx = { 0 };
1108
1109 ctx.id = id;
1110 ctx.out_table = out_table;
1111 ctx.search_type = SEARCH_TYPE_BY_ID;
1112 ctx.to_skip = nth;
1113 ctx.status = UACPI_STATUS_NOT_FOUND;
1114
1117 return ret;
1118
1119 return ctx.status;
1120}
1121
1123 const uacpi_char *signature_string, uacpi_size idx, uacpi_size nth,
1125)
1126{
1127 struct uacpi_table_identifiers id = { 0 };
1128
1130
1131 id.signature.text[0] = signature_string[0];
1132 id.signature.text[1] = signature_string[1];
1133 id.signature.text[2] = signature_string[2];
1134 id.signature.text[3] = signature_string[3];
1135
1136 return find_table(idx, nth, &id, out_table);
1137}
1138
1140 const uacpi_char *signature, uacpi_size idx, uacpi_table *out_table
1141)
1142{
1143 return find_table_by_signature(signature, idx, 0, out_table);
1144}
1145
1147 const uacpi_char *signature, uacpi_size nth, uacpi_table *out_table
1148)
1149{
1150 return find_table_by_signature(signature, 0, nth, out_table);
1151}
1152
1154 const uacpi_char *signature_string, struct uacpi_table *out_table
1155)
1156{
1157 return find_table_by_signature(signature_string, 0, 0, out_table);
1158}
1159
1161 uacpi_table *in_out_table
1162)
1163{
1164 struct uacpi_table_identifiers id = { 0 };
1165
1167
1168 if (uacpi_unlikely(in_out_table->ptr == UACPI_NULL))
1170
1171 uacpi_memcpy(&id.signature, in_out_table->hdr->signature,
1172 sizeof(id.signature));
1173 uacpi_table_unref(in_out_table);
1174
1175 return find_table(in_out_table->index + 1, 0, &id, in_out_table);
1176}
1177
1179 const uacpi_table_identifiers *id, uacpi_table *out_table
1180)
1181{
1183
1184 return find_table(0, 0, id, out_table);
1185}
1186
1187#define TABLE_CTL_SET_FLAGS (1 << 0)
1188#define TABLE_CTL_CLEAR_FLAGS (1 << 1)
1189#define TABLE_CTL_VALIDATE_SET_FLAGS (1 << 2)
1190#define TABLE_CTL_VALIDATE_CLEAR_FLAGS (1 << 3)
1191#define TABLE_CTL_GET (1 << 4)
1192#define TABLE_CTL_PUT (1 << 5)
1193
1196
1201
1202 void *out_tbl;
1203};
1204
1206{
1208 struct uacpi_installed_table *tbl;
1209
1211
1214 return ret;
1215
1216 if (uacpi_unlikely(table_array_size(&tables) <= idx)) {
1218 "requested invalid table index %zu (%zu tables installed)",
1219 idx, table_array_size(&tables)
1220 );
1222 goto out;
1223 }
1224
1225 tbl = table_array_at(&tables, idx);
1228
1230 uacpi_u8 mask = req->expect_set;
1231
1232 if (uacpi_unlikely((tbl->flags & mask) != mask)) {
1234 "unexpected table '%.4s' flags %02X, expected %02X to be set",
1235 tbl->hdr.signature, tbl->flags, mask
1236 );
1238 goto out;
1239 }
1240 }
1241
1243 uacpi_u8 mask = req->expect_clear;
1244
1245 if (uacpi_unlikely((tbl->flags & mask) != 0)) {
1247 "unexpected table '%.4s' flags %02X, expected %02X "
1248 "to be clear", tbl->hdr.signature, tbl->flags, mask
1249 );
1251 goto out;
1252 }
1253 }
1254
1255 if (req->type & TABLE_CTL_GET) {
1256 ret = table_ref_unlocked(tbl);
1258 goto out;
1259
1260 req->out_tbl = tbl->ptr;
1261 }
1262
1263 if (req->type & TABLE_CTL_PUT) {
1266 goto out;
1267 }
1268
1269 if (req->type & TABLE_CTL_SET_FLAGS)
1270 tbl->flags |= req->set;
1271 if (req->type & TABLE_CTL_CLEAR_FLAGS)
1272 tbl->flags &= ~req->clear;
1273
1274out:
1276 return ret;
1277}
1278
1279#ifndef UACPI_BAREBONES_MODE
1282)
1283{
1285 struct table_ctl_request req = {
1288 .set = UACPI_TABLE_LOADED,
1289 .expect_clear = UACPI_TABLE_LOADED,
1290 };
1291
1292 ret = table_ctl(idx, &req);
1294 return ret;
1295
1296 ret = uacpi_execute_table(req.out_tbl, cause);
1297
1298 req.type = TABLE_CTL_PUT;
1299 table_ctl(idx, &req);
1300 return ret;
1301}
1302
1304{
1306}
1307
1309{
1310 struct table_ctl_request req = {
1312 };
1313
1314 table_ctl(idx, &req);
1315}
1316#endif // !UACPI_BAREBONES_MODE
1317
1319{
1321 struct table_ctl_request req = {
1323 };
1324
1325 ret = table_ctl(idx, &req);
1327 return ret;
1328
1329 out_table->ptr = req.out_tbl;
1330 out_table->index = idx;
1331 return UACPI_STATUS_OK;
1332}
1333
1335{
1336 struct table_ctl_request req = {
1338 };
1339
1340 return table_ctl(index, &req);
1341}
1342
1344{
1345 return uacpi_table_ref_by_index(tbl->index);
1346}
1347
1349{
1350 struct table_ctl_request req = {
1352 };
1353
1354 return table_ctl(index, &req);
1355}
1356
1358{
1359 return uacpi_table_unref_by_index(tbl->index);
1360}
1361
1363 116, 132, 244, 244, 268, 276
1364};
1365
1366static void fadt_ensure_correct_revision(struct acpi_fadt *fadt)
1367{
1368 uacpi_size current_rev, rev;
1369
1370 current_rev = fadt->hdr.revision;
1371
1372 for (rev = 0; rev < UACPI_ARRAY_SIZE(fadt_version_sizes); ++rev) {
1373 if (fadt->hdr.length <= fadt_version_sizes[rev])
1374 break;
1375 }
1376
1379 "FADT revision (%zu) is likely greater than the last "
1380 "supported, reducing to %zu", current_rev, rev
1381 );
1382 fadt->hdr.revision = rev;
1383 return;
1384 }
1385
1386 rev++;
1387
1388 if (current_rev != rev && !(rev == 3 && current_rev == 4)) {
1389 uacpi_warn(
1390 "FADT length %u doesn't match expected for revision %zu, "
1391 "assuming version %zu", fadt->hdr.length, current_rev,
1392 rev
1393 );
1394 fadt->hdr.revision = rev;
1395 }
1396}
1397
1399 struct acpi_gas *gas, uacpi_u64 address, uacpi_u8 byte_size
1400)
1401{
1402 gas->address = address;
1403 gas->address_space_id = UACPI_ADDRESS_SPACE_SYSTEM_IO;
1404 gas->register_bit_width = UACPI_MIN(255, byte_size * 8);
1405 gas->register_bit_offset = 0;
1406 gas->access_size = 0;
1407}
1408
1409
1413};
1414
1415#define fadt_offset(field) uacpi_offsetof(struct acpi_fadt, field)
1416
1417/*
1418 * We convert all the legacy registers into GAS format and write them into
1419 * the x_* fields for convenience and faster access at runtime.
1420 */
1422 {
1423 .offset = fadt_offset(pm1a_evt_blk),
1424 .xoffset = fadt_offset(x_pm1a_evt_blk),
1425 .length_offset = fadt_offset(pm1_evt_len),
1426 },
1427 {
1428 .offset = fadt_offset(pm1b_evt_blk),
1429 .xoffset = fadt_offset(x_pm1b_evt_blk),
1430 .length_offset = fadt_offset(pm1_evt_len),
1431 },
1432 {
1433 .offset = fadt_offset(pm1a_cnt_blk),
1434 .xoffset = fadt_offset(x_pm1a_cnt_blk),
1435 .length_offset = fadt_offset(pm1_cnt_len),
1436 },
1437 {
1438 .offset = fadt_offset(pm1b_cnt_blk),
1439 .xoffset = fadt_offset(x_pm1b_cnt_blk),
1440 .length_offset = fadt_offset(pm1_cnt_len),
1441 },
1442 {
1443 .offset = fadt_offset(pm2_cnt_blk),
1444 .xoffset = fadt_offset(x_pm2_cnt_blk),
1445 .length_offset = fadt_offset(pm2_cnt_len),
1446 },
1447 {
1448 .offset = fadt_offset(pm_tmr_blk),
1449 .xoffset = fadt_offset(x_pm_tmr_blk),
1450 .length_offset = fadt_offset(pm_tmr_len),
1451 },
1452 {
1453 .offset = fadt_offset(gpe0_blk),
1454 .xoffset = fadt_offset(x_gpe0_blk),
1455 .length_offset = fadt_offset(gpe0_blk_len),
1456 },
1457 {
1458 .offset = fadt_offset(gpe1_blk),
1459 .xoffset = fadt_offset(x_gpe1_blk),
1460 .length_offset = fadt_offset(gpe1_blk_len),
1461 },
1462};
1463
1465{
1466 return ((uacpi_u8*)&g_uacpi_rt_ctx.fadt) + offset;
1467}
1468
1470{
1471 uacpi_size i;
1472 struct register_description *desc;
1473 struct acpi_gas *gas;
1474 uacpi_u32 legacy_addr;
1476
1477 for (i = 0; i < UACPI_ARRAY_SIZE(fadt_registers); ++i) {
1478 desc = &fadt_registers[i];
1479
1480 legacy_addr = *(uacpi_u32*)fadt_relative(desc->offset);
1481 length = *(uacpi_u8*)fadt_relative(desc->length_offset);
1482 gas = fadt_relative(desc->xoffset);
1483
1484 if (gas->address)
1485 continue;
1486
1487 gas_init_system_io(gas, legacy_addr, length);
1488 }
1489}
1490
1491#ifndef UACPI_BAREBONES_MODE
1493 struct acpi_gas *src, struct acpi_gas *dst0, struct acpi_gas *dst1
1494)
1495{
1496 uacpi_size byte_length;
1497
1498 if (src->address == 0)
1499 return;
1500
1501 byte_length = src->register_bit_width / 8;
1502 byte_length /= 2;
1503
1504 gas_init_system_io(dst0, src->address, byte_length);
1505 gas_init_system_io(dst1, src->address + byte_length, byte_length);
1506}
1507
1508static void split_event_blocks(void)
1509{
1511 &g_uacpi_rt_ctx.fadt.x_pm1a_evt_blk,
1512 &g_uacpi_rt_ctx.pm1a_status_blk,
1513 &g_uacpi_rt_ctx.pm1a_enable_blk
1514 );
1516 &g_uacpi_rt_ctx.fadt.x_pm1b_evt_blk,
1517 &g_uacpi_rt_ctx.pm1b_status_blk,
1518 &g_uacpi_rt_ctx.pm1b_enable_blk
1519 );
1520}
1521#endif // !UACPI_BAREBONES_MODE
1522
1523static uacpi_status initialize_fadt(const void *virt)
1524{
1526 struct acpi_fadt *fadt = &g_uacpi_rt_ctx.fadt;
1527 const struct acpi_sdt_hdr *hdr = virt;
1528
1529 /*
1530 * Here we (roughly) follow ACPICA initialization sequence to make sure we
1531 * handle potential BIOS quirks with garbage inside FADT correctly.
1532 */
1533
1534 uacpi_memcpy(fadt, hdr, UACPI_MIN(sizeof(*fadt), hdr->length));
1535
1536#ifndef UACPI_REDUCED_HARDWARE
1537 g_uacpi_rt_ctx.is_hardware_reduced = fadt->flags & ACPI_HW_REDUCED_ACPI;
1538#endif
1539
1541
1542 /*
1543 * These are reserved prior to version 3, so zero them out to work around
1544 * BIOS implementations that might dirty these.
1545 */
1546 if (fadt->hdr.revision <= 2) {
1547 fadt->preferred_pm_profile = 0;
1548 fadt->pstate_cnt = 0;
1549 fadt->cst_cnt = 0;
1550 fadt->iapc_boot_arch = 0;
1551 }
1552
1553 if (!fadt->x_dsdt)
1554 fadt->x_dsdt = fadt->dsdt;
1555
1556 if (fadt->x_dsdt) {
1560 );
1563 return ret;
1564 }
1565
1566 /*
1567 * Unconditionally use 32 bit FACS if it exists, as 64 bit FACS is known
1568 * to cause issues on some firmware:
1569 * https://bugzilla.kernel.org/show_bug.cgi?id=74021
1570 *
1571 * Note that we don't install it here as FACS needs permanent mapping, which
1572 * we might not be able to obtain at this point in case of early table
1573 * access.
1574 */
1575 if (fadt->firmware_ctrl)
1576 fadt->x_firmware_ctrl = fadt->firmware_ctrl;
1577
1580#ifndef UACPI_BAREBONES_MODE
1582#endif
1583 }
1584
1585 fadt_available = true;
1586 return UACPI_STATUS_OK;
1587}
1588
1589uacpi_status uacpi_table_fadt(struct acpi_fadt **out_fadt)
1590{
1592
1593 if (!fadt_available)
1595
1596 *out_fadt = &g_uacpi_rt_ctx.fadt;
1597 return UACPI_STATUS_OK;
1598}
1599
1601 struct acpi_sdt_hdr *hdr, size_t hdr_size,
1603)
1604{
1605 void *cursor;
1606 size_t bytes_left;
1607
1608 cursor = UACPI_PTR_ADD(hdr, hdr_size);
1609 bytes_left = hdr->length - hdr_size;
1610
1611 if (uacpi_unlikely(bytes_left > hdr->length))
1613
1614 while (bytes_left > sizeof(struct acpi_entry_hdr)) {
1615 struct acpi_entry_hdr *subtable_hdr = cursor;
1616
1617 if (uacpi_unlikely(subtable_hdr->length > bytes_left ||
1618 subtable_hdr->length < sizeof(*subtable_hdr))) {
1620 "corrupted '%.4s' subtable length: %u (%zu bytes left)",
1621 hdr->signature, subtable_hdr->length, bytes_left
1622 );
1624 }
1625
1626 switch (cb(user, subtable_hdr)) {
1628 break;
1630 return UACPI_STATUS_OK;
1631 default:
1633 }
1634
1635 cursor = UACPI_PTR_ADD(cursor, subtable_hdr->length);
1636 bytes_left -= subtable_hdr->length;
1637 }
1638
1639 if (uacpi_unlikely(bytes_left != 0)) {
1640 uacpi_warn(
1641 "found %zu stray bytes in table '%.4s'",
1642 bytes_left, hdr->signature
1643 );
1644 }
1645
1646 return UACPI_STATUS_OK;
1647}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
ios_base &_STLP_CALL dec(ios_base &__s)
Definition: _ios_base.h:321
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
int rev
Definition: sort.c:17
void user(int argc, const char *argv[])
Definition: cmds.c:1350
static uacpi_status uacpi_acquire_native_mutex_may_be_null(uacpi_handle mtx)
Definition: mutex.h:34
static uacpi_status uacpi_release_native_mutex_may_be_null(uacpi_handle mtx)
Definition: mutex.h:44
unsigned int idx
Definition: utils.c:41
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
#define ACPI_FACS_SIGNATURE
Definition: acpi.h:18
#define ACPI_RSDP_SIGNATURE
Definition: acpi.h:13
#define ACPI_XSDT_SIGNATURE
Definition: acpi.h:15
#define ACPI_DSDT_SIGNATURE
Definition: acpi.h:23
#define ACPI_HW_REDUCED_ACPI
Definition: acpi.h:728
#define ACPI_FADT_SIGNATURE
Definition: acpi.h:17
#define ACPI_RSDT_SIGNATURE
Definition: acpi.h:14
#define UACPI_ENSURE_INIT_LEVEL_IS(lvl)
Definition: context.h:141
static uacpi_bool uacpi_check_flag(uacpi_u64 flag)
Definition: context.h:90
static uacpi_bool uacpi_is_hardware_reduced(void)
Definition: context.h:100
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:17
#define UACPI_ARRAY_SIZE(arr)
Definition: helpers.h:5
#define UACPI_UNUSED(x)
Definition: helpers.h:7
#define uacpi_trace(...)
Definition: log.h:33
#define uacpi_info(...)
Definition: log.h:34
void uacpi_logger_initialize(void)
Definition: uacpi.c:36
#define uacpi_error(...)
Definition: log.h:36
#define uacpi_warn(...)
Definition: log.h:35
#define uacpi_log_lvl(lvl, fmt,...)
Definition: log.h:22
#define uacpi_memzero(ptr, size)
Definition: stdlib.h:99
#define UACPI_ALIGN_UP(x, val, type)
Definition: stdlib.h:106
#define uacpi_memcmp
Definition: stdlib.h:61
#define uacpi_memcpy
Definition: stdlib.h:34
#define uacpi_free(mem, _)
Definition: stdlib.h:96
#define UACPI_MIN(x, y)
Definition: stdlib.h:102
uacpi_log_level
Definition: log.h:7
@ UACPI_LOG_ERROR
Definition: log.h:35
@ UACPI_LOG_WARN
Definition: log.h:29
#define uacpi_likely(expr)
Definition: compiler.h:89
#define uacpi_unlikely(expr)
Definition: compiler.h:88
#define UACPI_PACKED(decl)
Definition: compiler.h:36
#define UACPI_STATIC_TABLE_ARRAY_LEN
Definition: config.h:175
#define UACPI_PRIX64
Definition: types.h:61
size_t uacpi_size
Definition: types.h:37
uint32_t uacpi_u32
Definition: types.h:21
bool uacpi_bool
Definition: types.h:31
#define UACPI_FALSE
Definition: types.h:30
uint64_t uacpi_u64
Definition: types.h:22
char uacpi_char
Definition: types.h:44
uint16_t uacpi_u16
Definition: types.h:20
#define UACPI_NULL
Definition: types.h:33
uint8_t uacpi_u8
Definition: types.h:19
#define UACPI_FMT64(val)
Definition: types.h:62
uacpi_uintptr uacpi_virt_addr
Definition: types.h:36
#define UACPI_TRUE
Definition: types.h:29
#define uacpi_likely_success(expr)
Definition: status.h:53
#define uacpi_unlikely_error(expr)
Definition: status.h:49
uacpi_status
Definition: status.h:10
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_STATUS_INTERNAL_ERROR
Definition: status.h:21
@ UACPI_STATUS_NOT_FOUND
Definition: status.h:17
@ UACPI_STATUS_OUT_OF_MEMORY
Definition: status.h:13
@ UACPI_STATUS_OVERRIDDEN
Definition: status.h:30
@ UACPI_STATUS_INVALID_TABLE_LENGTH
Definition: status.h:16
@ UACPI_STATUS_INVALID_SIGNATURE
Definition: status.h:15
@ UACPI_STATUS_ALREADY_EXISTS
Definition: status.h:20
@ UACPI_STATUS_MAPPING_FAILED
Definition: status.h:12
@ UACPI_STATUS_OK
Definition: status.h:11
@ UACPI_STATUS_DENIED
Definition: status.h:31
@ UACPI_STATUS_INIT_LEVEL_MISMATCH
Definition: status.h:23
@ UACPI_STATUS_BAD_CHECKSUM
Definition: status.h:14
uacpi_iteration_decision
Definition: types.h:28
@ UACPI_ITERATION_DECISION_BREAK
Definition: types.h:30
@ UACPI_ITERATION_DECISION_CONTINUE
Definition: types.h:29
uacpi_u64 uacpi_phys_addr
Definition: types.h:17
@ UACPI_INIT_LEVEL_EARLY
Definition: types.h:66
@ UACPI_INIT_LEVEL_SUBSYSTEM_INITIALIZED
Definition: types.h:72
@ UACPI_ADDRESS_SPACE_SYSTEM_IO
Definition: types.h:44
return ret
Definition: mutex.c:147
uacpi_status uacpi_verify_table_checksum(void *table, uacpi_size size, uacpi_u8 *out_flags)
Definition: tables.c:426
uacpi_status uacpi_table_get_by_index(uacpi_size idx, uacpi_table *out_table)
Definition: tables.c:1318
static uacpi_status initialize_from_rxsdt(uacpi_phys_addr rxsdt_addr, uacpi_size entry_size)
Definition: tables.c:111
static uacpi_u8 table_checksum(void *table, uacpi_size size)
Definition: tables.c:414
static uacpi_status verify_and_install_table(struct acpi_sdt_hdr *hdr, uacpi_phys_addr phys_addr, void *virt_addr, enum uacpi_table_origin origin, uacpi_table *out_table)
Definition: tables.c:695
uacpi_status uacpi_table_fadt(struct acpi_fadt **out_fadt)
Definition: tables.c:1589
#define TABLE_CTL_GET
Definition: tables.c:1191
uacpi_status uacpi_table_ref_by_index(uacpi_size index)
Definition: tables.c:1334
#define TABLE_CTL_VALIDATE_CLEAR_FLAGS
Definition: tables.c:1190
#define TABLE_CTL_VALIDATE_SET_FLAGS
Definition: tables.c:1189
static uacpi_status find_table_by_signature(const uacpi_char *signature_string, uacpi_size idx, uacpi_size nth, uacpi_table *out_table)
Definition: tables.c:1122
#define ENSURE_TABLES_ONLINE()
Definition: tables.c:29
static void gas_init_system_io(struct acpi_gas *gas, uacpi_u64 address, uacpi_u8 byte_size)
Definition: tables.c:1398
uacpi_status uacpi_table_find(const uacpi_table_identifiers *id, uacpi_table *out_table)
Definition: tables.c:1178
static uacpi_status initialize_fadt(const void *)
Definition: tables.c:1523
static bool skip_due_to_bad_csum(struct uacpi_installed_table *tbl)
Definition: tables.c:458
uacpi_u16 fadt_version_sizes[]
Definition: tables.c:1362
uacpi_bool uacpi_signatures_match(const void *const lhs, const void *const rhs)
Definition: tables.c:464
static uacpi_status table_install_with_origin_unlocked(void *virt, enum uacpi_table_origin origin, uacpi_table *out_table)
Definition: tables.c:883
uacpi_status uacpi_table_find_next_with_same_signature(uacpi_table *in_out_table)
Definition: tables.c:1160
static void table_info_by_index_unchecked(uacpi_size idx, uacpi_table_info *out_info)
Definition: tables.c:604
#define TABLE_CTL_PUT
Definition: tables.c:1192
uacpi_status uacpi_for_each_table(uacpi_table_iteration_callback cb, void *user)
Definition: tables.c:658
static uacpi_iteration_decision warn_if_early_referenced(void *user, struct uacpi_installed_table *tbl, uacpi_size idx)
Definition: tables.c:263
uacpi_status uacpi_table_load_with_cause(uacpi_size idx, enum uacpi_table_load_cause cause)
Definition: tables.c:1280
uacpi_status uacpi_table_install_with_origin(void *virt, enum uacpi_table_origin origin, uacpi_table *out_table)
Definition: tables.c:935
void uacpi_deinitialize_tables(void)
Definition: tables.c:351
static uacpi_status handle_table_override(uacpi_table_installation_disposition disposition, uacpi_u64 address, uacpi_table *out_table)
Definition: tables.c:762
#define TABLE_CTL_CLEAR_FLAGS
Definition: tables.c:1188
#define TABLE_CTL_SET_FLAGS
Definition: tables.c:1187
uacpi_status uacpi_table_unref(uacpi_table *tbl)
Definition: tables.c:1357
uacpi_status uacpi_table_info_get_by_index(uacpi_size idx, uacpi_table_info *out_info)
Definition: tables.c:630
uacpi_status uacpi_table_install(void *virt, uacpi_table *out_table)
Definition: tables.c:951
uacpi_status uacpi_for_each_installed_table(uacpi_size base_idx, uacpi_installed_table_iteration_callback cb, void *user)
Definition: tables.c:971
static uacpi_status table_ctl(uacpi_size idx, struct table_ctl_request *req)
Definition: tables.c:1205
uacpi_status uacpi_initialize_tables(void)
Definition: tables.c:279
static uacpi_status table_unref_unlocked(struct uacpi_installed_table *tbl)
Definition: tables.c:573
static uacpi_iteration_decision do_search_tables(void *user, struct uacpi_installed_table *tbl, uacpi_size idx)
Definition: tables.c:1018
uacpi_status uacpi_table_load(uacpi_size idx)
Definition: tables.c:1303
static uacpi_status table_alloc(struct uacpi_installed_table **out_tbl, uacpi_size *out_idx)
Definition: tables.c:492
static void * fadt_relative(uacpi_size offset)
Definition: tables.c:1464
static void convert_registers_to_gas(void)
Definition: tables.c:1469
uacpi_status uacpi_table_find_by_signature(const uacpi_char *signature_string, struct uacpi_table *out_table)
Definition: tables.c:1153
uacpi_status uacpi_table_ref(uacpi_table *tbl)
Definition: tables.c:1343
static struct register_description fadt_registers[]
Definition: tables.c:1421
uacpi_status uacpi_table_match(uacpi_size base_idx, uacpi_table_match_callback cb, uacpi_table *out_table)
Definition: tables.c:1081
static uacpi_status get_external_table_header(uacpi_phys_addr phys_addr, struct acpi_sdt_hdr *out_hdr)
Definition: tables.c:513
uacpi_status uacpi_table_unref_by_index(uacpi_size index)
Definition: tables.c:1348
uacpi_size uacpi_table_count(void)
Definition: tables.c:211
uacpi_status uacpi_for_each_subtable(struct acpi_sdt_hdr *hdr, size_t hdr_size, uacpi_subtable_iteration_callback cb, void *user)
Definition: tables.c:1600
static uacpi_status find_table(uacpi_size idx, uacpi_size nth, const uacpi_table_identifiers *id, uacpi_table *out_table)
Definition: tables.c:1101
uacpi_status uacpi_check_table_signature(void *table, const uacpi_char *expect)
Definition: tables.c:469
static uacpi_status initialize_from_rsdp(void)
Definition: tables.c:171
uacpi_status uacpi_table_install_physical(uacpi_phys_addr addr, uacpi_table *out_table)
Definition: tables.c:960
static void fadt_ensure_correct_revision(struct acpi_fadt *fadt)
Definition: tables.c:1366
uacpi_status uacpi_table_find_by_signature_at(const uacpi_char *signature, uacpi_size idx, uacpi_table *out_table)
Definition: tables.c:1139
static uacpi_status table_install_physical_with_origin_unlocked(uacpi_phys_addr phys, enum uacpi_table_origin origin, const uacpi_char *expected_signature, uacpi_table *out_table)
Definition: tables.c:790
static uacpi_status table_ref_unlocked(struct uacpi_installed_table *tbl)
Definition: tables.c:529
search_type
Definition: tables.c:1001
@ SEARCH_TYPE_MATCH
Definition: tables.c:1003
@ SEARCH_TYPE_BY_ID
Definition: tables.c:1002
#define fadt_offset(field)
Definition: tables.c:1415
static void split_event_blocks(void)
Definition: tables.c:1508
uacpi_status uacpi_set_table_installation_handler(uacpi_table_installation_handler handler)
Definition: tables.c:392
void uacpi_table_mark_as_loaded(uacpi_size idx)
Definition: tables.c:1308
uacpi_status uacpi_table_install_physical_with_origin(uacpi_phys_addr phys, enum uacpi_table_origin origin, uacpi_table *out_table)
Definition: tables.c:865
static void split_one_block(struct acpi_gas *src, struct acpi_gas *dst0, struct acpi_gas *dst1)
Definition: tables.c:1492
uacpi_status uacpi_setup_early_table_access(void *temporary_buffer, uacpi_size buffer_size)
Definition: tables.c:216
uacpi_status uacpi_table_find_nth_by_signature(const uacpi_char *signature, uacpi_size nth, uacpi_table *out_table)
Definition: tables.c:1146
struct nls_table * tables
Definition: nls_base.c:22
#define DYNAMIC_ARRAY_WITH_INLINE_STORAGE_IMPL(name, type, prefix)
#define DYNAMIC_ARRAY_WITH_INLINE_STORAGE(name, type, inline_capacity)
Definition: dynamic_array.h:7
GLuint address
Definition: glext.h:9393
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLuint index
Definition: glext.h:6031
GLenum GLint GLuint mask
Definition: glext.h:6028
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
GLuint id
Definition: glext.h:5910
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const char cursor[]
Definition: icontest.c:13
#define UACPI_PRI_TBL_HDR
Definition: tables.h:58
uacpi_iteration_decision(* uacpi_installed_table_iteration_callback)(void *user, struct uacpi_installed_table *tbl, uacpi_size idx)
Definition: tables.h:45
#define UACPI_FMT_TBL_HDR(hdr)
Definition: tables.h:59
uacpi_bool(* uacpi_table_match_callback)(struct uacpi_installed_table *tbl)
Definition: tables.h:52
static uacpi_phys_addr uacpi_truncate_phys_addr_with_warn(uacpi_u64 large_addr)
Definition: utilities.h:8
#define UACPI_PTR_TO_VIRT_ADDR(ptr)
Definition: utilities.h:20
#define UACPI_VIRT_ADDR_TO_PTR(vaddr)
Definition: utilities.h:21
#define UACPI_PTR_ADD(ptr, value)
Definition: utilities.h:23
uacpi_status uacpi_execute_table(void *, enum uacpi_table_load_cause cause)
Definition: interpreter.c:1612
uacpi_table_load_cause
Definition: interpreter.h:9
@ UACPI_TABLE_LOAD_CAUSE_HOST
Definition: interpreter.h:13
voidpf uLong int origin
Definition: ioapi.h:144
char hdr[14]
Definition: iptest.cpp:33
void * uacpi_kernel_alloc(uacpi_size size)
Definition: uacpiosl.c:111
uacpi_handle uacpi_kernel_create_mutex(void)
Definition: uacpiosl.c:139
void uacpi_kernel_free_mutex(uacpi_handle)
Definition: uacpiosl.c:146
#define UACPI_MAP_FAILED
Definition: kernel_api.h:13
void uacpi_kernel_unmap(void *addr, uacpi_size len)
Definition: uacpiosl.c:198
void * uacpi_kernel_map(uacpi_phys_addr addr, uacpi_size len)
Definition: uacpiosl.c:191
uacpi_status uacpi_kernel_get_rsdp(uacpi_phys_addr *out_rsdp_address)
Definition: uacpiosl.c:204
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
Definition: ffs.h:52
uacpi_size offset
Definition: tables.c:1411
uacpi_size xoffset
Definition: tables.c:1411
uacpi_size length_offset
Definition: tables.c:1412
uacpi_u8 expect_clear
Definition: tables.c:1198
void * out_tbl
Definition: tables.c:1202
uacpi_u8 type
Definition: tables.c:1195
uacpi_u8 clear
Definition: tables.c:1200
uacpi_u8 expect_set
Definition: tables.c:1197
uacpi_u8 set
Definition: tables.c:1199
const uacpi_table_identifiers * id
Definition: tables.c:1008
uacpi_status status
Definition: tables.c:1015
uacpi_table * out_table
Definition: tables.c:1012
uacpi_u8 search_type
Definition: tables.c:1013
uacpi_size to_skip
Definition: tables.c:1014
uacpi_table_match_callback match_cb
Definition: tables.c:1009
uacpi_phys_addr phys_addr
Definition: tables.h:10
uacpi_u16 reference_count
Definition: tables.h:14
uacpi_u8 flags
Definition: tables.h:16
struct acpi_sdt_hdr hdr
Definition: tables.h:11
uacpi_u8 origin
Definition: tables.h:17
uacpi_char signature[4]
Definition: tables.h:232
uacpi_u16 reference_count
Definition: tables.h:267
uacpi_u8 origin
Definition: tables.h:237
void * virt_addr
Definition: tables.h:226
uacpi_phys_addr phys_addr
Definition: tables.h:217
uacpi_size size
Definition: tables.h:210
uacpi_size idx
Definition: tables.h:205
uacpi_u8 flags
Definition: tables.h:262
void * ptr
Definition: tables.h:28
struct acpi_sdt_hdr * hdr
Definition: tables.h:29
uacpi_size index
Definition: tables.h:33
uacpi_iteration_decision(* uacpi_subtable_iteration_callback)(uacpi_handle, struct acpi_entry_hdr *)
Definition: tables.h:298
#define UACPI_TABLE_CSUM_BAD
Definition: tables.h:257
uacpi_table_installation_disposition
Definition: tables.h:139
@ UACPI_TABLE_INSTALLATION_DISPOSITON_DENY
Definition: tables.h:148
@ UACPI_TABLE_INSTALLATION_DISPOSITON_PHYSICAL_OVERRIDE
Definition: tables.h:160
@ UACPI_TABLE_INSTALLATION_DISPOSITON_VIRTUAL_OVERRIDE
Definition: tables.h:154
@ UACPI_TABLE_INSTALLATION_DISPOSITON_ALLOW
Definition: tables.h:141
uacpi_table_installation_disposition(* uacpi_table_installation_handler)(struct acpi_sdt_hdr *hdr, uacpi_u64 *out_override_address)
Definition: tables.h:164
#define UACPI_TABLE_CSUM_CHECKED
Definition: tables.h:249
uacpi_iteration_decision(* uacpi_table_iteration_callback)(uacpi_handle, uacpi_table_info *info)
Definition: tables.h:271
#define UACPI_TABLE_LOADED
Definition: tables.h:243
uacpi_table_origin
Definition: tables.h:176
@ UACPI_TABLE_ORIGIN_HOST_VIRTUAL
Definition: tables.h:198
@ UACPI_TABLE_ORIGIN_HOST_PHYSICAL
Definition: tables.h:193
@ UACPI_TABLE_ORIGIN_FIRMWARE_PHYSICAL
Definition: tables.h:181
@ UACPI_TABLE_ORIGIN_FIRMWARE_VIRTUAL
Definition: tables.h:188
uacpi_bool uacpi_table_subsystem_available(void)
#define UACPI_FLAG_BAD_CSUM_FATAL
Definition: uacpi.h:75
#define UACPI_FLAG_BAD_XSDT
Definition: uacpi.h:86
#define UACPI_FLAG_PROACTIVE_TBL_CSUM
Definition: uacpi.h:107
#define UACPI_FLAG_BAD_TBL_SIGNATURE_FATAL
Definition: uacpi.h:81
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383