Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F141183120
D20347.id57686.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D20347.id57686.diff
View Options
Index: sys/dev/efidev/efirt.c
===================================================================
--- sys/dev/efidev/efirt.c
+++ sys/dev/efidev/efirt.c
@@ -60,6 +60,7 @@
static struct efi_systbl *efi_systbl;
static eventhandler_tag efi_shutdown_tag;
+static struct efi_map_header *efihdr = NULL;
/*
* The following pointers point to tables in the EFI runtime service data pages.
* Care should be taken to make sure that we've properly entered the EFI runtime
@@ -133,6 +134,52 @@
return (false);
}
+static bool
+efi_get_memory_map(void)
+{
+ caddr_t kmdp;
+
+ if (efihdr != NULL)
+ return (true);
+
+ kmdp = preload_search_by_type("elf kernel");
+ if (kmdp == NULL)
+ kmdp = preload_search_by_type("elf64 kernel");
+ efihdr = (struct efi_map_header *)preload_search_info(kmdp,
+ MODINFO_METADATA | MODINFOMD_EFI_MAP);
+ if (efihdr == NULL)
+ return (false);
+
+ return (true);
+}
+
+uint64_t
+efi_memory_attribute(vm_paddr_t pa)
+{
+ struct efi_md *map, *p;
+ size_t efisz;
+ int i, ndesc;
+
+ if (!efi_get_memory_map())
+ return (0);
+
+ efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf;
+ map = (struct efi_md *)((uint8_t *)efihdr + efisz);
+ if (efihdr->descriptor_size == 0)
+ return (0);
+ ndesc = efihdr->memory_size / efihdr->descriptor_size;
+
+ for (i = 0, p = map; i < ndesc; i++, p = efi_next_descriptor(p,
+ efihdr->descriptor_size)) {
+ if (pa >= p->md_phys &&
+ pa < (p->md_phys + p->md_pages * PAGE_SIZE)) {
+ return (p->md_attr);
+ }
+ }
+
+ return (0);
+}
+
static void
efi_shutdown_final(void *dummy __unused, int howto)
{
@@ -149,10 +196,8 @@
static int
efi_init(void)
{
- struct efi_map_header *efihdr;
struct efi_md *map;
struct efi_rt *rtdm;
- caddr_t kmdp;
size_t efisz;
int ndesc, rt_disabled;
@@ -182,12 +227,7 @@
printf("EFI config table is not present\n");
}
- kmdp = preload_search_by_type("elf kernel");
- if (kmdp == NULL)
- kmdp = preload_search_by_type("elf64 kernel");
- efihdr = (struct efi_map_header *)preload_search_info(kmdp,
- MODINFO_METADATA | MODINFOMD_EFI_MAP);
- if (efihdr == NULL) {
+ if (!efi_get_memory_map()) {
if (bootverbose)
printf("EFI map is not present\n");
return (0);
@@ -234,6 +274,13 @@
}
#endif
+ if (bootverbose)
+ printf("EFI RT Signature: %lx, Revision=%x, Size=%x, CRC32=%x\n",
+ efi_runtime->rt_hdr.th_sig,
+ efi_runtime->rt_hdr.th_rev,
+ efi_runtime->rt_hdr.th_hdrsz,
+ efi_runtime->rt_hdr.th_crc32);
+
/*
* We use SHUTDOWN_PRI_LAST - 1 to trigger after IPMI, but before ACPI.
*/
Index: sys/sys/efi.h
===================================================================
--- sys/sys/efi.h
+++ sys/sys/efi.h
@@ -192,6 +192,7 @@
int efi_var_nextname(size_t *namesize, uint16_t *name, struct uuid *vendor);
int efi_var_set(uint16_t *name, struct uuid *vendor, uint32_t attrib,
size_t datasize, void *data);
+uint64_t efi_memory_attribute(vm_paddr_t pa);
#endif /* _KERNEL */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 3, 12:51 AM (12 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27465545
Default Alt Text
D20347.id57686.diff (2 KB)
Attached To
Mode
D20347: efirt: Add efi_memory_attribute
Attached
Detach File
Event Timeline
Log In to Comment