ReactOS 0.4.16-dev-1946-g52006dd
io.c
Go to the documentation of this file.
1#include <uacpi/internal/io.h>
8
9#ifndef UACPI_BAREBONES_MODE
10
12{
13 return UACPI_ALIGN_UP(bit_length, 8, uacpi_size) / 8;
14}
15
18)
19{
20 uacpi_u8 remainder = bit_length & 7;
21
22 if (remainder == 0)
23 return;
24
25 data[offset] &= ((1ull << remainder) - 1);
26}
27
29{
30 union {
33 };
36};
37
39{
40 uacpi_size delta = UACPI_MIN(span->length, bits);
41
42 span->index += delta;
43 span->length -= delta;
44
45 return delta;
46}
47
48static void bit_copy(struct bit_span *dst, struct bit_span *src)
49{
50 uacpi_u8 src_shift, dst_shift, bits = 0;
51 uacpi_u16 dst_mask;
52 uacpi_u8 *dst_ptr, *src_ptr;
53 uacpi_u64 dst_count, src_count;
54
55 dst_ptr = dst->data + (dst->index / 8);
56 src_ptr = src->data + (src->index / 8);
57
58 dst_count = dst->length;
59 dst_shift = dst->index & 7;
60
61 src_count = src->length;
62 src_shift = src->index & 7;
63
64 while (dst_count)
65 {
66 bits = 0;
67
68 if (src_count) {
69 bits = *src_ptr >> src_shift;
70
71 if (src_shift && src_count > (uacpi_u32)(8 - src_shift))
72 bits |= *(src_ptr + 1) << (8 - src_shift);
73
74 if (src_count < 8) {
75 bits &= (1 << src_count) - 1;
76 src_count = 0;
77 } else {
78 src_count -= 8;
79 src_ptr++;
80 }
81 }
82
83 dst_mask = (dst_count < 8 ? (1 << dst_count) - 1 : 0xFF) << dst_shift;
84 *dst_ptr = (*dst_ptr & ~dst_mask) | ((bits << dst_shift) & dst_mask);
85
86 if (dst_shift && dst_count > (uacpi_u32)(8 - dst_shift)) {
87 dst_mask >>= 8;
88 *(dst_ptr + 1) &= ~dst_mask;
89 *(dst_ptr + 1) |= (bits >> (8 - dst_shift)) & dst_mask;
90 }
91
92 dst_count = dst_count > 8 ? dst_count - 8 : 0;
93 ++dst_ptr;
94 }
95}
96
99)
100{
101 struct bit_span src_span = {
102 .index = field->bit_index,
103 .length = field->bit_length,
104 .const_data = field->backing->data,
105 };
106 struct bit_span dst_span = {
107 .data = dst,
108 };
109
110 dst_span.length = uacpi_round_up_bits_to_bytes(field->bit_length) * 8;
111 bit_copy(&dst_span, &src_span);
112}
113
115 const uacpi_buffer_field *field, void *dst
116)
117{
118 if (!(field->bit_index & 7)) {
119 uacpi_u8 *src = field->backing->data;
121
123 uacpi_memcpy(dst, src + (field->bit_index / 8), count);
124 cut_misaligned_tail(dst, count - 1, field->bit_length);
125 return;
126 }
127
129}
130
133 const void *src, uacpi_size size
134)
135{
136 struct bit_span src_span = {
137 .length = size * 8,
138 .const_data = src,
139 };
140 struct bit_span dst_span = {
141 .index = field->bit_index,
142 .length = field->bit_length,
143 .data = field->backing->data,
144 };
145
146 bit_copy(&dst_span, &src_span);
147}
148
151 const void *src, uacpi_size size
152)
153{
154 if (!(field->bit_index & 7)) {
155 uacpi_u8 *dst, last_byte, tail_shift;
157
158 dst = field->backing->data;
159 dst += field->bit_index / 8;
161
162 last_byte = dst[count - 1];
163 tail_shift = field->bit_length & 7;
164
166 if (tail_shift) {
167 uacpi_u8 last_shift = 8 - tail_shift;
168 dst[count - 1] = dst[count - 1] << last_shift;
169 dst[count - 1] >>= last_shift;
170 dst[count - 1] |= (last_byte >> tail_shift) << tail_shift;
171 }
172
173 return;
174 }
175
177}
178
182)
183{
185
186 if (field->lock_rule) {
188 g_uacpi_rt_ctx.global_lock_mutex, 0xFFFF
189 );
191 return ret;
192 }
193
194 switch (field->kind) {
197 field->bank_selection, &field->bank_value, sizeof(field->bank_value),
199 );
200 break;
202 break;
205 field->index, &offset, sizeof(offset),
207 );
209 goto out;
210
211 switch (op) {
214 field->data, data.integer, field->access_width_bytes,
216 );
217 break;
220 field->data, data.integer, field->access_width_bytes,
222 );
223 break;
224 default:
226 break;
227 }
228
229 goto out;
230
231 default:
232 uacpi_error("invalid field unit kind %d\n", field->kind);
234 }
235
237 goto out;
238
240
241out:
242 if (field->lock_rule)
243 uacpi_release_aml_mutex(g_uacpi_rt_ctx.global_lock_mutex);
244 return ret;
245}
246
247#define OPREGION_IO_U64(x) (union uacpi_opregion_io_data) { .integer = x }
248
249#define SERIAL_HEADER_SIZE 2
250#define IPMI_DATA_SIZE 64
251
255)
256{
257 switch (space) {
260 break;
262 *out_size = 26;
263 break;
265 *out_size = 256;
266 break;
269 uacpi_size size_for_protocol = SERIAL_HEADER_SIZE;
270
271 switch (field->attributes) {
273 break; // + 0
276 size_for_protocol += 1;
277 break;
278
281 size_for_protocol += 2;
282 break;
283
285 size_for_protocol += field->access_length;
286 break;
287
292 size_for_protocol += 255;
293 break;
294
295 default:
297 "unsupported field@%p access attribute %d\n",
298 field, field->attributes
299 );
301 }
302
303 *out_size = size_for_protocol;
304 break;
305 }
306 default:
308 }
309
310 return UACPI_STATUS_OK;
311}
312
315 uacpi_region_op op, uacpi_data_view *wtr_response,
316 uacpi_bool *did_handle
317)
318{
322 uacpi_u64 in_out;
323 uacpi_data_view wtr_buffer;
324
325 *did_handle = UACPI_FALSE;
326
328 return ret;
329
332 );
333 if (uacpi_unlikely(obj == UACPI_NULL)) {
336 field->region, "attempted access to deleted", ret
337 );
338 goto out_handled;
339 }
340 region = obj->op_region;
341
342 switch (region->space) {
344 if (op == UACPI_REGION_OP_WRITE) {
346 &in_out, buf.const_data, sizeof(in_out), buf.length
347 );
348 }
349
352 goto out_handled;
353
355 uacpi_memcpy_zerout(buf.data, &in_out, buf.length, sizeof(in_out));
356 goto out_handled;
362 field->region, "attempted to read from a write-only", ret
363 );
364 goto out_handled;
365 }
370 goto do_wtr;
371 default:
372 return ret;
373 }
374
375do_wtr:
376 ret = wtr_buffer_size(field, region->space, &wtr_buffer.length);
378 goto out_handled;
379
380 wtr_buffer.data = uacpi_kernel_alloc(wtr_buffer.length);
381 if (uacpi_unlikely(wtr_buffer.data == UACPI_NULL)) {
383 goto out_handled;
384 }
385
387 wtr_buffer.data, buf.const_data, wtr_buffer.length, buf.length
388 );
390 field, field->byte_offset,
391 op, (union uacpi_opregion_io_data) {
392 .buffer = wtr_buffer,
393 }
394 );
396 uacpi_free(wtr_buffer.data, wtr_buffer.length);
397 goto out_handled;
398 }
399
400 if (wtr_response != UACPI_NULL)
401 *wtr_response = wtr_buffer;
402
403out_handled:
404 *did_handle = UACPI_TRUE;
405 return ret;
406}
407
410)
411{
413 uacpi_size reads_to_do;
415 uacpi_u32 byte_offset = field->byte_offset;
416 uacpi_u32 bits_left = field->bit_length;
417 uacpi_u8 width_access_bits = field->access_width_bytes * 8;
418
419 struct bit_span src_span = {
420 .data = (uacpi_u8*)&out,
421 .index = field->bit_offset_within_first_byte,
422 };
423 struct bit_span dst_span = {
424 .data = dst,
425 .index = 0,
426 .length = size * 8
427 };
428
429 reads_to_do = UACPI_ALIGN_UP(
430 field->bit_offset_within_first_byte + field->bit_length,
431 width_access_bits,
433 );
434 reads_to_do /= width_access_bits;
435
436 while (reads_to_do-- > 0) {
437 src_span.length = UACPI_MIN(
438 bits_left, width_access_bits - src_span.index
439 );
440
442 field, byte_offset, UACPI_REGION_OP_READ,
444 );
446 return ret;
447
448 bit_copy(&dst_span, &src_span);
449 bits_left -= src_span.length;
450 src_span.index = 0;
451
452 bit_span_offset(&dst_span, src_span.length);
453 byte_offset += field->access_width_bytes;
454 }
455
456 return UACPI_STATUS_OK;
457}
458
461 uacpi_data_view *wtr_response
462)
463{
465 uacpi_u32 field_byte_length;
466 uacpi_bool did_handle;
467
470 .data = dst,
471 .length = size,
473 wtr_response, &did_handle
474 );
475 if (did_handle)
476 return ret;
477
478 field_byte_length = uacpi_round_up_bits_to_bytes(field->bit_length);
479
480 /*
481 * Very simple fast case:
482 * - Bit offset within first byte is 0
483 * AND
484 * - Field size is <= access width
485 */
486 if (field->bit_offset_within_first_byte == 0 &&
487 field_byte_length <= field->access_width_bytes)
488 {
490
492 field, field->byte_offset, UACPI_REGION_OP_READ,
494 );
496 return ret;
497
498 uacpi_memcpy_zerout(dst, &out, size, field_byte_length);
499 if (size >= field_byte_length)
500 cut_misaligned_tail(dst, field_byte_length - 1, field->bit_length);
501
502 return UACPI_STATUS_OK;
503 }
504
505 // Slow case
507}
508
511)
512{
514 uacpi_u32 bits_left, byte_offset = field->byte_offset;
515 uacpi_u8 width_access_bits = field->access_width_bytes * 8;
517
518 struct bit_span src_span = {
519 .const_data = src,
520 .index = 0,
521 .length = size * 8
522 };
523 struct bit_span dst_span = {
524 .data = (uacpi_u8*)&in,
525 .index = field->bit_offset_within_first_byte,
526 };
527
528 bits_left = field->bit_length;
529
530 while (bits_left) {
531 in = 0;
532 dst_span.length = UACPI_MIN(
533 width_access_bits - dst_span.index, bits_left
534 );
535
536 if (dst_span.index != 0 || dst_span.length < width_access_bits) {
537 switch (field->update_rule) {
540 field, byte_offset, UACPI_REGION_OP_READ,
542 );
544 return ret;
545 break;
547 in = ~in;
548 break;
550 break;
551 default:
552 uacpi_error("invalid field@%p update rule %d\n",
553 field, field->update_rule);
555 }
556 }
557
558 bit_copy(&dst_span, &src_span);
559 bit_span_offset(&src_span, dst_span.length);
560
562 field, byte_offset, UACPI_REGION_OP_WRITE,
564 );
566 return ret;
567
568 bits_left -= dst_span.length;
569 dst_span.index = 0;
570 byte_offset += field->access_width_bytes;
571 }
572
573 return UACPI_STATUS_OK;
574}
575
578 uacpi_data_view *wtr_response
579)
580{
582 uacpi_bool did_handle;
583
586 .const_data = src,
587 .length = size,
589 wtr_response, &did_handle
590 );
591 if (did_handle)
592 return ret;
593
595}
596
598 struct uacpi_field_unit *field, uacpi_object_type *out_type
599)
600{
602
604 goto out_basic_field;
605
608 );
611
612 if (uacpi_is_buffer_access_address_space(obj->op_region->space)) {
613 *out_type = UACPI_OBJECT_BUFFER;
614 return UACPI_STATUS_OK;
615 }
616
617out_basic_field:
618 if (field->bit_length > (g_uacpi_rt_ctx.is_rev1 ? 32u : 64u))
619 *out_type = UACPI_OBJECT_BUFFER;
620 else
621 *out_type = UACPI_OBJECT_INTEGER;
622
623 return UACPI_STATUS_OK;
624}
625
627 struct uacpi_field_unit *field, uacpi_size *out_length
628)
629{
631
633 goto out_basic_field;
634
637 );
640
641 if (uacpi_is_buffer_access_address_space(obj->op_region->space)) {
642 /*
643 * Bit length is protocol specific, the data will be returned
644 * via the write-then-read response buffer.
645 */
646 *out_length = 0;
647 return UACPI_STATUS_OK;
648 }
649
650out_basic_field:
651 *out_length = field->bit_length;
652 return UACPI_STATUS_OK;
653}
654
655static uacpi_u8 gas_get_access_bit_width(const struct acpi_gas *gas)
656{
657 /*
658 * Same algorithm as ACPICA.
659 *
660 * The reason we do this is apparently GAS bit offset being non-zero means
661 * that it's an APEI register, as opposed to FADT, which needs special
662 * handling. In the case of a FADT register we want to ignore the specified
663 * access size.
664 */
665 uacpi_u8 access_bit_width;
666
667 if (gas->register_bit_offset == 0 &&
668 UACPI_IS_POWER_OF_TWO(gas->register_bit_width, uacpi_u8) &&
669 UACPI_IS_ALIGNED(gas->register_bit_width, 8, uacpi_u8)) {
670 access_bit_width = gas->register_bit_width;
671 } else if (gas->access_size) {
672 access_bit_width = gas->access_size * 8;
673 } else {
674 uacpi_u8 msb;
675
677 (gas->register_bit_offset + gas->register_bit_width) - 1
678 );
679 access_bit_width = 1 << msb;
680
681 if (access_bit_width <= 8) {
682 access_bit_width = 8;
683 } else {
684 /*
685 * Keep backing off to previous power of two until we find one
686 * that is aligned to the address specified in GAS.
687 */
688 while (!UACPI_IS_ALIGNED(
689 gas->address, access_bit_width / 8, uacpi_u64
690 ))
691 access_bit_width /= 2;
692 }
693 }
694
695 return UACPI_MIN(
696 access_bit_width,
697 gas->address_space_id == UACPI_ADDRESS_SPACE_SYSTEM_IO ? 32 : 64
698 );
699}
700
702 const struct acpi_gas *gas, uacpi_u8 *access_bit_width,
703 uacpi_u8 *bit_width
704)
705{
706 uacpi_size total_width, aligned_width;
707
708 if (uacpi_unlikely(gas == UACPI_NULL))
710
711 if (!gas->address)
713
714 if (gas->address_space_id != UACPI_ADDRESS_SPACE_SYSTEM_IO &&
715 gas->address_space_id != UACPI_ADDRESS_SPACE_SYSTEM_MEMORY) {
716 uacpi_warn("unsupported GAS address space '%s' (%d)\n",
717 uacpi_address_space_to_string(gas->address_space_id),
718 gas->address_space_id);
720 }
721
722 if (gas->access_size > 4) {
723 uacpi_warn("unsupported GAS access size %d\n",
724 gas->access_size);
726 }
727
728 *access_bit_width = gas_get_access_bit_width(gas);
729
730 total_width = gas->register_bit_offset + gas->register_bit_width;
731 aligned_width = UACPI_ALIGN_UP(total_width, *access_bit_width, uacpi_size);
732
733 if (uacpi_unlikely(aligned_width > 64)) {
735 "GAS register total width is too large: %zu\n", total_width
736 );
738 }
739
740 *bit_width = total_width;
741 return UACPI_STATUS_OK;
742}
743
744/*
745 * Apparently both reading and writing GAS works differently from operation
746 * region in that bit offsets are not respected when writing the data.
747 *
748 * Let's follow ACPICA's approach here so that we don't accidentally
749 * break any quirky hardware.
750 */
752 const uacpi_mapped_gas *gas, uacpi_u64 *out_value
753)
754{
756 uacpi_u8 access_byte_width;
757 uacpi_u8 bit_offset, bits_left, index = 0;
758 uacpi_u64 data, mask = 0xFFFFFFFFFFFFFFFF;
759 uacpi_size offset = 0;
760
761 bit_offset = gas->bit_offset;
762 bits_left = gas->total_bit_width;
763
764 access_byte_width = gas->access_bit_width / 8;
765
766 if (access_byte_width < 8)
767 mask = ~(mask << gas->access_bit_width);
768
769 *out_value = 0;
770
771 while (bits_left) {
772 if (bit_offset >= gas->access_bit_width) {
773 data = 0;
774 bit_offset -= gas->access_bit_width;
775 } else {
776 ret = gas->read(gas->mapping, offset, access_byte_width, &data);
778 return ret;
779 }
780
781 *out_value |= (data & mask) << (index * gas->access_bit_width);
782 bits_left -= UACPI_MIN(bits_left, gas->access_bit_width);
783 ++index;
784 offset += access_byte_width;
785 }
786
787 return UACPI_STATUS_OK;
788}
789
791 const uacpi_mapped_gas *gas, uacpi_u64 in_value
792)
793{
795 uacpi_u8 access_byte_width;
796 uacpi_u8 bit_offset, bits_left, index = 0;
797 uacpi_u64 data, mask = 0xFFFFFFFFFFFFFFFF;
798 uacpi_size offset = 0;
799
800 bit_offset = gas->bit_offset;
801 bits_left = gas->total_bit_width;
802 access_byte_width = gas->access_bit_width / 8;
803
804 if (access_byte_width < 8)
805 mask = ~(mask << gas->access_bit_width);
806
807 while (bits_left) {
808 data = (in_value >> (index * gas->access_bit_width)) & mask;
809
810 if (bit_offset >= gas->access_bit_width) {
811 bit_offset -= gas->access_bit_width;
812 } else {
813 ret = gas->write(gas->mapping, offset, access_byte_width, data);
815 return ret;
816 }
817
818 bits_left -= UACPI_MIN(bits_left, gas->access_bit_width);
819 ++index;
820 offset += access_byte_width;
821 }
822
823 return UACPI_STATUS_OK;
824}
825
827{
829 uacpi_kernel_io_unmap(io_handle);
830}
831
833 const struct acpi_gas *gas, uacpi_mapped_gas *out_mapped
834)
835{
837 uacpi_u8 access_bit_width, total_width;
838
839 ret = gas_validate(gas, &access_bit_width, &total_width);
840 if (ret != UACPI_STATUS_OK)
841 return ret;
842
843 if (gas->address_space_id == UACPI_ADDRESS_SPACE_SYSTEM_MEMORY) {
844 out_mapped->mapping = uacpi_kernel_map(gas->address, total_width / 8);
845 if (uacpi_unlikely(out_mapped->mapping == UACPI_NULL))
847
848 out_mapped->read = uacpi_system_memory_read;
849 out_mapped->write = uacpi_system_memory_write;
850 out_mapped->unmap = uacpi_kernel_unmap;
851 } else { // IO, validated by gas_validate above
852 ret = uacpi_kernel_io_map(gas->address, total_width / 8, &out_mapped->mapping);
854 return ret;
855
856 out_mapped->read = uacpi_system_io_read;
857 out_mapped->write = uacpi_system_io_write;
858 out_mapped->unmap = unmap_gas_io;
859 }
860
861 out_mapped->access_bit_width = access_bit_width;
862 out_mapped->total_bit_width = total_width;
863 out_mapped->bit_offset = gas->register_bit_offset;
864
865 return UACPI_STATUS_OK;
866}
867
869 const struct acpi_gas *gas, uacpi_mapped_gas **out_mapped
870)
871{
874
878
881 uacpi_free(mapping, sizeof(*mapping));
882 return ret;
883 }
884
885 *out_mapped = mapping;
886 return ret;
887}
888
890{
891 gas->unmap(gas->mapping, gas->access_bit_width / 8);
892}
893
895{
897 uacpi_free(gas, sizeof(*gas));
898}
899
900uacpi_status uacpi_gas_read(const struct acpi_gas *gas, uacpi_u64 *out_value)
901{
904
907 return ret;
908
909 ret = uacpi_gas_read_mapped(&mapping, out_value);
911
912 return ret;
913}
914
915uacpi_status uacpi_gas_write(const struct acpi_gas *gas, uacpi_u64 in_value)
916{
919
922 return ret;
923
924 ret = uacpi_gas_write_mapped(&mapping, in_value);
926
927 return ret;
928}
929
932)
933{
935
936 switch (width) {
937 case 1:
938 *out = *(volatile uacpi_u8*)ptr;
939 break;
940 case 2:
941 *out = *(volatile uacpi_u16*)ptr;
942 break;
943 case 4:
944 *out = *(volatile uacpi_u32*)ptr;
945 break;
946 case 8:
947 *out = *(volatile uacpi_u64*)ptr;
948 break;
949 default:
951 }
952
953 return UACPI_STATUS_OK;
954}
955
958)
959{
961
962 switch (width) {
963 case 1:
964 *(volatile uacpi_u8*)ptr = in;
965 break;
966 case 2:
967 *(volatile uacpi_u16*)ptr = in;
968 break;
969 case 4:
970 *(volatile uacpi_u32*)ptr = in;
971 break;
972 case 8:
973 *(volatile uacpi_u64*)ptr = in;
974 break;
975 default:
977 }
978
979 return UACPI_STATUS_OK;
980}
981
987};
988
991)
992{
994 union integer_data data = {
995 .qword = 0,
996 };
997
998 switch (width) {
999 case 1:
1001 break;
1002 case 2:
1004 break;
1005 case 4:
1007 break;
1008 default:
1010 "invalid SystemIO read %p@%zu width=%d\n",
1012 );
1014 }
1015
1017 *out = data.qword;
1018 return ret;
1019}
1020
1023)
1024{
1026
1027 switch (width) {
1028 case 1:
1030 break;
1031 case 2:
1033 break;
1034 case 4:
1036 break;
1037 default:
1039 "invalid SystemIO write %p@%zu width=%d\n",
1041 );
1043 }
1044
1045 return ret;
1046}
1047
1050)
1051{
1053 union integer_data data = {
1054 .qword = 0,
1055 };
1056
1057 switch (width) {
1058 case 1:
1060 break;
1061 case 2:
1063 break;
1064 case 4:
1066 break;
1067 default:
1069 "invalid PCI_Config read %p@%zu width=%d\n",
1071 );
1073 }
1074
1076 *out = data.qword;
1077 return ret;
1078}
1079
1082)
1083{
1085
1086 switch (width) {
1087 case 1:
1089 break;
1090 case 2:
1092 break;
1093 case 4:
1095 break;
1096 default:
1098 "invalid PCI_Config write %p@%zu width=%d\n",
1100 );
1102 }
1103
1104 return ret;
1105}
1106
1107#endif // !UACPI_BAREBONES_MODE
#define index(s, c)
Definition: various.h:29
uacpi_status uacpi_acquire_aml_mutex(uacpi_mutex *, uacpi_u16 timeout)
Definition: mutex.c:201
uacpi_status uacpi_release_aml_mutex(uacpi_mutex *)
Definition: mutex.c:241
UINT op
Definition: effect.c:236
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:17
#define UACPI_UNUSED(x)
Definition: helpers.h:7
#define uacpi_error(...)
Definition: log.h:21
#define uacpi_warn(...)
Definition: log.h:20
uacpi_object * uacpi_namespace_node_get_object_typed(const uacpi_namespace_node *node, uacpi_object_type_bits type_mask)
Definition: namespace.c:654
#define UACPI_ALIGN_UP(x, val, type)
Definition: stdlib.h:106
#define UACPI_IS_POWER_OF_TWO(x, type)
Definition: stdlib.h:114
#define UACPI_IS_ALIGNED(x, val, type)
Definition: stdlib.h:112
#define uacpi_memcpy
Definition: stdlib.h:34
#define uacpi_free(mem, _)
Definition: stdlib.h:96
uacpi_u8 uacpi_bit_scan_backward(uacpi_u64)
Definition: stdlib.c:154
void uacpi_memcpy_zerout(void *dst, const void *src, uacpi_size dst_size, uacpi_size src_size)
Definition: stdlib.c:112
#define UACPI_MIN(x, y)
Definition: stdlib.h:102
@ UACPI_UPDATE_RULE_PRESERVE
Definition: types.h:198
@ UACPI_UPDATE_RULE_WRITE_AS_ZEROES
Definition: types.h:200
@ UACPI_UPDATE_RULE_WRITE_AS_ONES
Definition: types.h:199
@ UACPI_FIELD_UNIT_KIND_NORMAL
Definition: types.h:204
@ UACPI_FIELD_UNIT_KIND_BANK
Definition: types.h:206
@ UACPI_FIELD_UNIT_KIND_INDEX
Definition: types.h:205
#define UACPI_FALLTHROUGH
Definition: compiler.h:70
#define uacpi_unlikely(expr)
Definition: compiler.h:58
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
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_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_NOT_FOUND
Definition: status.h:17
@ UACPI_STATUS_UNIMPLEMENTED
Definition: status.h:19
@ UACPI_STATUS_OUT_OF_MEMORY
Definition: status.h:13
@ UACPI_STATUS_AML_INCOMPATIBLE_OBJECT_TYPE
Definition: status.h:38
@ UACPI_STATUS_MAPPING_FAILED
Definition: status.h:12
@ UACPI_STATUS_OK
Definition: status.h:11
const uacpi_char * uacpi_address_space_to_string(uacpi_address_space space)
Definition: types.c:11
@ UACPI_OBJECT_OPERATION_REGION_BIT
Definition: types.h:138
@ UACPI_ACCESS_ATTRIBUTE_WORD
Definition: types.h:472
@ UACPI_ACCESS_ATTRIBUTE_PROCESS_CALL
Definition: types.h:475
@ UACPI_ACCESS_ATTRIBUTE_BLOCK_PROCESS_CALL
Definition: types.h:476
@ UACPI_ACCESS_ATTRIBUTE_BYTE
Definition: types.h:471
@ UACPI_ACCESS_ATTRIBUTE_QUICK
Definition: types.h:469
@ UACPI_ACCESS_ATTRIBUTE_SEND_RECEIVE
Definition: types.h:470
@ UACPI_ACCESS_ATTRIBUTE_RAW_BYTES
Definition: types.h:477
@ UACPI_ACCESS_ATTRIBUTE_BLOCK
Definition: types.h:473
@ UACPI_ACCESS_ATTRIBUTE_RAW_PROCESS_BYTES
Definition: types.h:478
@ UACPI_ACCESS_ATTRIBUTE_BYTES
Definition: types.h:474
uacpi_object_type
Definition: types.h:104
@ UACPI_OBJECT_BUFFER
Definition: types.h:108
@ UACPI_OBJECT_INTEGER
Definition: types.h:106
uacpi_region_op
Definition: types.h:367
@ UACPI_REGION_OP_WRITE
Definition: types.h:375
@ UACPI_REGION_OP_READ
Definition: types.h:374
uacpi_address_space
Definition: types.h:36
@ UACPI_ADDRESS_SPACE_IPMI
Definition: types.h:44
@ UACPI_ADDRESS_SPACE_PRM
Definition: types.h:48
@ UACPI_ADDRESS_SPACE_SYSTEM_MEMORY
Definition: types.h:37
@ UACPI_ADDRESS_SPACE_GENERAL_PURPOSE_IO
Definition: types.h:45
@ UACPI_ADDRESS_SPACE_FFIXEDHW
Definition: types.h:49
@ UACPI_ADDRESS_SPACE_GENERIC_SERIAL_BUS
Definition: types.h:46
@ UACPI_ADDRESS_SPACE_SYSTEM_IO
Definition: types.h:38
@ UACPI_ADDRESS_SPACE_SMBUS
Definition: types.h:41
static uacpi_size bit_span_offset(struct bit_span *span, uacpi_size bits)
Definition: io.c:38
#define IPMI_DATA_SIZE
Definition: io.c:250
static void bit_copy(struct bit_span *dst, struct bit_span *src)
Definition: io.c:48
uacpi_status uacpi_pci_write(uacpi_handle handle, uacpi_size offset, uacpi_u8 width, uacpi_u64 in)
Definition: io.c:1080
static uacpi_status access_field_unit(uacpi_field_unit *field, uacpi_u32 offset, uacpi_region_op op, union uacpi_opregion_io_data data)
Definition: io.c:179
uacpi_size uacpi_round_up_bits_to_bytes(uacpi_size bit_length)
Definition: io.c:11
uacpi_status uacpi_map_gas(const struct acpi_gas *gas, uacpi_mapped_gas **out_mapped)
Definition: io.c:868
uacpi_status uacpi_pci_read(uacpi_handle handle, uacpi_size offset, uacpi_u8 width, uacpi_u64 *out)
Definition: io.c:1048
static void do_misaligned_buffer_read(const uacpi_buffer_field *field, uacpi_u8 *dst)
Definition: io.c:97
static uacpi_status wtr_buffer_size(uacpi_field_unit *field, uacpi_address_space space, uacpi_size *out_size)
Definition: io.c:252
#define SERIAL_HEADER_SIZE
Definition: io.c:249
void uacpi_write_buffer_field(uacpi_buffer_field *field, const void *src, uacpi_size size)
Definition: io.c:149
uacpi_status uacpi_field_unit_get_bit_length(struct uacpi_field_unit *field, uacpi_size *out_length)
Definition: io.c:626
void uacpi_unmap_gas(uacpi_mapped_gas *gas)
Definition: io.c:894
static uacpi_status write_generic_field_unit(uacpi_field_unit *field, const void *src, uacpi_size size)
Definition: io.c:509
static void cut_misaligned_tail(uacpi_u8 *data, uacpi_size offset, uacpi_u32 bit_length)
Definition: io.c:16
uacpi_status uacpi_system_io_write(uacpi_handle handle, uacpi_size offset, uacpi_u8 width, uacpi_u64 in)
Definition: io.c:1021
static uacpi_status do_read_misaligned_field_unit(uacpi_field_unit *field, uacpi_u8 *dst, uacpi_size size)
Definition: io.c:408
uacpi_status uacpi_gas_write_mapped(const uacpi_mapped_gas *gas, uacpi_u64 in_value)
Definition: io.c:790
#define OPREGION_IO_U64(x)
Definition: io.c:247
void uacpi_read_buffer_field(const uacpi_buffer_field *field, void *dst)
Definition: io.c:114
static void do_write_misaligned_buffer_field(uacpi_buffer_field *field, const void *src, uacpi_size size)
Definition: io.c:131
uacpi_status uacpi_system_memory_read(void *ptr, uacpi_size offset, uacpi_u8 width, uacpi_u64 *out)
Definition: io.c:930
void uacpi_unmap_gas_nofree(uacpi_mapped_gas *gas)
Definition: io.c:889
uacpi_status uacpi_field_unit_get_read_type(struct uacpi_field_unit *field, uacpi_object_type *out_type)
Definition: io.c:597
uacpi_status uacpi_system_io_read(uacpi_handle handle, uacpi_size offset, uacpi_u8 width, uacpi_u64 *out)
Definition: io.c:989
uacpi_status uacpi_gas_write(const struct acpi_gas *gas, uacpi_u64 in_value)
Definition: io.c:915
uacpi_status uacpi_map_gas_noalloc(const struct acpi_gas *gas, uacpi_mapped_gas *out_mapped)
Definition: io.c:832
static void unmap_gas_io(uacpi_handle io_handle, uacpi_size size)
Definition: io.c:826
uacpi_status uacpi_system_memory_write(void *ptr, uacpi_size offset, uacpi_u8 width, uacpi_u64 in)
Definition: io.c:956
uacpi_status uacpi_read_field_unit(uacpi_field_unit *field, void *dst, uacpi_size size, uacpi_data_view *wtr_response)
Definition: io.c:459
static uacpi_u8 gas_get_access_bit_width(const struct acpi_gas *gas)
Definition: io.c:655
uacpi_status uacpi_gas_read(const struct acpi_gas *gas, uacpi_u64 *out_value)
Definition: io.c:900
static uacpi_status gas_validate(const struct acpi_gas *gas, uacpi_u8 *access_bit_width, uacpi_u8 *bit_width)
Definition: io.c:701
uacpi_status uacpi_gas_read_mapped(const uacpi_mapped_gas *gas, uacpi_u64 *out_value)
Definition: io.c:751
uacpi_status uacpi_write_field_unit(uacpi_field_unit *field, const void *src, uacpi_size size, uacpi_data_view *wtr_response)
Definition: io.c:576
static uacpi_status handle_special_field(uacpi_field_unit *field, uacpi_data_view buf, uacpi_region_op op, uacpi_data_view *wtr_response, uacpi_bool *did_handle)
Definition: io.c:313
return ret
Definition: mutex.c:146
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei width
Definition: gl.h:1546
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
GLenum GLenum GLvoid GLvoid GLvoid * span
Definition: glext.h:5664
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint in
Definition: glext.h:9616
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLenum GLenum dst
Definition: glext.h:6340
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
void uacpi_trace_region_error(uacpi_namespace_node *node, uacpi_char *message, uacpi_status ret)
Definition: opregion.c:25
uacpi_bool uacpi_is_buffer_access_address_space(uacpi_address_space space)
Definition: opregion.c:828
uacpi_status uacpi_dispatch_opregion_io(uacpi_field_unit *field, uacpi_u32 offset, uacpi_region_op op, union uacpi_opregion_io_data data)
Definition: opregion.c:848
#define UACPI_PTR_ADD(ptr, value)
Definition: utilities.h:23
uacpi_status uacpi_kernel_io_map(uacpi_io_addr base, uacpi_size len, uacpi_handle *out_handle)
Definition: uacpiosl.c:165
uacpi_status uacpi_kernel_pci_write16(uacpi_handle device, uacpi_size offset, uacpi_u16 value)
Definition: uacpiosl.c:285
uacpi_status uacpi_kernel_pci_read8(uacpi_handle device, uacpi_size offset, uacpi_u8 *value)
Definition: uacpiosl.c:257
void * uacpi_kernel_alloc(uacpi_size size)
Definition: uacpiosl.c:111
uacpi_status uacpi_kernel_io_write8(uacpi_handle, uacpi_size offset, uacpi_u8 in_value)
Definition: uacpiosl.c:320
uacpi_status uacpi_kernel_pci_read16(uacpi_handle device, uacpi_size offset, uacpi_u16 *value)
Definition: uacpiosl.c:264
uacpi_status uacpi_kernel_io_read32(uacpi_handle, uacpi_size offset, uacpi_u32 *out_value)
Definition: uacpiosl.c:313
uacpi_status uacpi_kernel_pci_read32(uacpi_handle device, uacpi_size offset, uacpi_u32 *value)
Definition: uacpiosl.c:271
uacpi_status uacpi_kernel_io_write32(uacpi_handle, uacpi_size offset, uacpi_u32 in_value)
Definition: uacpiosl.c:334
uacpi_status uacpi_kernel_io_read8(uacpi_handle, uacpi_size offset, uacpi_u8 *out_value)
Definition: uacpiosl.c:299
uacpi_status uacpi_kernel_pci_write8(uacpi_handle device, uacpi_size offset, uacpi_u8 value)
Definition: uacpiosl.c:278
void uacpi_kernel_unmap(void *addr, uacpi_size len)
Definition: uacpiosl.c:198
uacpi_status uacpi_kernel_io_write16(uacpi_handle, uacpi_size offset, uacpi_u16 in_value)
Definition: uacpiosl.c:327
uacpi_status uacpi_kernel_io_read16(uacpi_handle, uacpi_size offset, uacpi_u16 *out_value)
Definition: uacpiosl.c:306
void * uacpi_kernel_map(uacpi_phys_addr addr, uacpi_size len)
Definition: uacpiosl.c:191
void uacpi_kernel_io_unmap(uacpi_handle handle)
Definition: uacpiosl.c:171
uacpi_status uacpi_kernel_pci_write32(uacpi_handle device, uacpi_size offset, uacpi_u32 value)
Definition: uacpiosl.c:292
double __cdecl remainder(double, double)
Definition: remainder.c:75
static PVOID ptr
Definition: dispmode.c:27
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
Definition: io.c:29
uacpi_u64 index
Definition: io.c:34
uacpi_u64 length
Definition: io.c:35
uacpi_u8 * data
Definition: io.c:31
const uacpi_u8 * const_data
Definition: io.c:32
Definition: parser.c:44
uacpi_size length
Definition: types.h:99
void * data
Definition: types.h:96
uacpi_u8 access_bit_width
Definition: io.h:11
uacpi_u8 total_bit_width
Definition: io.h:12
uacpi_handle mapping
Definition: io.h:10
void(* unmap)(uacpi_handle, uacpi_size)
Definition: io.h:22
uacpi_status(* write)(uacpi_handle, uacpi_size offset, uacpi_u8 width, uacpi_u64 in)
Definition: io.h:18
uacpi_u8 bit_offset
Definition: io.h:13
uacpi_status(* read)(uacpi_handle, uacpi_size offset, uacpi_u8 width, uacpi_u64 *out)
Definition: io.h:15
uacpi_u16 space
Definition: types.h:120
uacpi_u32 dword
Definition: io.c:985
uacpi_u8 byte
Definition: io.c:983
uacpi_u64 qword
Definition: io.c:986
uacpi_u16 word
Definition: io.c:984
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383