Rev 2071 | Rev 2222 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2071 | Rev 2100 | ||
---|---|---|---|
Line 54... | Line 54... | ||
54 | }; |
54 | }; |
55 | 55 | ||
56 | static int rsdp_check(uint8_t *rsdp) { |
56 | static int rsdp_check(uint8_t *rsdp) { |
57 | struct acpi_rsdp *r = (struct acpi_rsdp *) rsdp; |
57 | struct acpi_rsdp *r = (struct acpi_rsdp *) rsdp; |
58 | uint8_t sum = 0; |
58 | uint8_t sum = 0; |
59 | int i; |
59 | unsigned int i; |
60 | 60 | ||
61 | for (i=0; i<20; i++) |
61 | for (i = 0; i < 20; i++) |
62 | sum += rsdp[i]; |
62 | sum += rsdp[i]; |
63 | 63 | ||
64 | if (sum) |
64 | if (sum) |
65 | return 0; /* bad checksum */ |
65 | return 0; /* bad checksum */ |
66 | 66 | ||
67 | if (r->revision == 0) |
67 | if (r->revision == 0) |
68 | return 1; /* ACPI 1.0 */ |
68 | return 1; /* ACPI 1.0 */ |
69 | 69 | ||
70 | for (; i<r->length; i++) |
70 | for (; i < r->length; i++) |
71 | sum += rsdp[i]; |
71 | sum += rsdp[i]; |
72 | 72 | ||
73 | return !sum; |
73 | return !sum; |
74 | 74 | ||
75 | } |
75 | } |
76 | 76 | ||
77 | int acpi_sdt_check(uint8_t *sdt) |
77 | int acpi_sdt_check(uint8_t *sdt) |
78 | { |
78 | { |
79 | struct acpi_sdt_header *h = (struct acpi_sdt_header *) sdt; |
79 | struct acpi_sdt_header *h = (struct acpi_sdt_header *) sdt; |
80 | uint8_t sum = 0; |
80 | uint8_t sum = 0; |
81 | int i; |
81 | unsigned int i; |
82 | 82 | ||
83 | for (i=0; i<h->length; i++) |
83 | for (i = 0; i < h->length; i++) |
84 | sum += sdt[i]; |
84 | sum += sdt[i]; |
85 | 85 | ||
86 | return !sum; |
86 | return !sum; |
87 | } |
87 | } |
88 | 88 | ||
Line 92... | Line 92... | ||
92 | map_structure((uintptr_t) sdt, sdt->length); |
92 | map_structure((uintptr_t) sdt, sdt->length); |
93 | } |
93 | } |
94 | 94 | ||
95 | static void configure_via_rsdt(void) |
95 | static void configure_via_rsdt(void) |
96 | { |
96 | { |
97 | int i, j, cnt = (acpi_rsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(uint32_t); |
97 | unsigned int i, j, cnt = (acpi_rsdt->header.length - sizeof(struct acpi_sdt_header)) / sizeof(uint32_t); |
98 | 98 | ||
99 | for (i=0; i<cnt; i++) { |
99 | for (i = 0; i < cnt; i++) { |
100 | for (j=0; j<sizeof(signature_map)/sizeof(struct acpi_signature_map); j++) { |
100 | for (j = 0; j < sizeof(signature_map) / sizeof(struct acpi_signature_map); j++) { |
101 | struct acpi_sdt_header *h = (struct acpi_sdt_header *) (unative_t) acpi_rsdt->entry[i]; |
101 | struct acpi_sdt_header *h = (struct acpi_sdt_header *) (unative_t) acpi_rsdt->entry[i]; |
102 | 102 | ||
103 | map_sdt(h); |
103 | map_sdt(h); |
104 | if (*((uint32_t *) &h->signature[0])==*((uint32_t *) &signature_map[j].signature[0])) { |
104 | if (*((uint32_t *) &h->signature[0]) == *((uint32_t *) &signature_map[j].signature[0])) { |
105 | if (!acpi_sdt_check((uint8_t *) h)) |
105 | if (!acpi_sdt_check((uint8_t *) h)) |
106 | goto next; |
106 | goto next; |
107 | *signature_map[j].sdt_ptr = h; |
107 | *signature_map[j].sdt_ptr = h; |
108 | printf("%#zx: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description); |
108 | printf("%#zx: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description); |
109 | } |
109 | } |
Line 113... | Line 113... | ||
113 | } |
113 | } |
114 | } |
114 | } |
115 | 115 | ||
116 | static void configure_via_xsdt(void) |
116 | static void configure_via_xsdt(void) |
117 | { |
117 | { |
118 | int i, j, cnt = (acpi_xsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(uint64_t); |
118 | unsigned int i, j, cnt = (acpi_xsdt->header.length - sizeof(struct acpi_sdt_header)) / sizeof(uint64_t); |
119 | 119 | ||
120 | for (i=0; i<cnt; i++) { |
120 | for (i = 0; i < cnt; i++) { |
121 | for (j=0; j<sizeof(signature_map)/sizeof(struct acpi_signature_map); j++) { |
121 | for (j = 0; j < sizeof(signature_map) / sizeof(struct acpi_signature_map); j++) { |
122 | struct acpi_sdt_header *h = (struct acpi_sdt_header *) ((uintptr_t) acpi_rsdt->entry[i]); |
122 | struct acpi_sdt_header *h = (struct acpi_sdt_header *) ((uintptr_t) acpi_rsdt->entry[i]); |
123 | 123 | ||
124 | map_sdt(h); |
124 | map_sdt(h); |
125 | if (*((uint32_t *) &h->signature[0])==*((uint32_t *) &signature_map[j].signature[0])) { |
125 | if (*((uint32_t *) &h->signature[0]) == *((uint32_t *) &signature_map[j].signature[0])) { |
126 | if (!acpi_sdt_check((uint8_t *) h)) |
126 | if (!acpi_sdt_check((uint8_t *) h)) |
127 | goto next; |
127 | goto next; |
128 | *signature_map[j].sdt_ptr = h; |
128 | *signature_map[j].sdt_ptr = h; |
129 | printf("%#zx: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description); |
129 | printf("%#zx: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description); |
130 | } |
130 | } |