diff options
author | Khalid Aziz <khalid.aziz@hp.com> | 2005-09-19 18:42:36 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2005-09-19 18:42:36 -0400 |
commit | be379124c0a5abfbe57dab2823fe8a71ce797aee (patch) | |
tree | c16b8dce920a001431add24bcd12cc1f12bf824d | |
parent | d8c97d5f3aa348272df2ccb4e224b1cf9a1eb6d7 (diff) |
[IA64] include EFI memory information in /proc/iomem
User mode kexec tools expect to find information about physical
memory in /proc/iomem (as they do on x86) to validate the addresses
that the new kernel will use.
Signed-off-by: Khalid Aziz <khalid.aziz@hp.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r-- | arch/ia64/kernel/efi.c | 87 | ||||
-rw-r--r-- | arch/ia64/kernel/setup.c | 29 |
2 files changed, 116 insertions, 0 deletions
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c index 1291db581721..f72ea6aebcb1 100644 --- a/arch/ia64/kernel/efi.c +++ b/arch/ia64/kernel/efi.c | |||
@@ -923,3 +923,90 @@ efi_memmap_init(unsigned long *s, unsigned long *e) | |||
923 | *s = (u64)kern_memmap; | 923 | *s = (u64)kern_memmap; |
924 | *e = (u64)++k; | 924 | *e = (u64)++k; |
925 | } | 925 | } |
926 | |||
927 | void | ||
928 | efi_initialize_iomem_resources(struct resource *code_resource, | ||
929 | struct resource *data_resource) | ||
930 | { | ||
931 | struct resource *res; | ||
932 | void *efi_map_start, *efi_map_end, *p; | ||
933 | efi_memory_desc_t *md; | ||
934 | u64 efi_desc_size; | ||
935 | char *name; | ||
936 | unsigned long flags; | ||
937 | |||
938 | efi_map_start = __va(ia64_boot_param->efi_memmap); | ||
939 | efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size; | ||
940 | efi_desc_size = ia64_boot_param->efi_memdesc_size; | ||
941 | |||
942 | res = NULL; | ||
943 | |||
944 | for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) { | ||
945 | md = p; | ||
946 | |||
947 | if (md->num_pages == 0) /* should not happen */ | ||
948 | continue; | ||
949 | |||
950 | flags = IORESOURCE_MEM; | ||
951 | switch (md->type) { | ||
952 | |||
953 | case EFI_MEMORY_MAPPED_IO: | ||
954 | case EFI_MEMORY_MAPPED_IO_PORT_SPACE: | ||
955 | continue; | ||
956 | |||
957 | case EFI_LOADER_CODE: | ||
958 | case EFI_LOADER_DATA: | ||
959 | case EFI_BOOT_SERVICES_DATA: | ||
960 | case EFI_BOOT_SERVICES_CODE: | ||
961 | case EFI_CONVENTIONAL_MEMORY: | ||
962 | if (md->attribute & EFI_MEMORY_WP) { | ||
963 | name = "System ROM"; | ||
964 | flags |= IORESOURCE_READONLY; | ||
965 | } else { | ||
966 | name = "System RAM"; | ||
967 | } | ||
968 | break; | ||
969 | |||
970 | case EFI_ACPI_MEMORY_NVS: | ||
971 | name = "ACPI Non-volatile Storage"; | ||
972 | flags |= IORESOURCE_BUSY; | ||
973 | break; | ||
974 | |||
975 | case EFI_UNUSABLE_MEMORY: | ||
976 | name = "reserved"; | ||
977 | flags |= IORESOURCE_BUSY | IORESOURCE_DISABLED; | ||
978 | break; | ||
979 | |||
980 | case EFI_RESERVED_TYPE: | ||
981 | case EFI_RUNTIME_SERVICES_CODE: | ||
982 | case EFI_RUNTIME_SERVICES_DATA: | ||
983 | case EFI_ACPI_RECLAIM_MEMORY: | ||
984 | default: | ||
985 | name = "reserved"; | ||
986 | flags |= IORESOURCE_BUSY; | ||
987 | break; | ||
988 | } | ||
989 | |||
990 | if ((res = kcalloc(1, sizeof(struct resource), GFP_KERNEL)) == NULL) { | ||
991 | printk(KERN_ERR "failed to alocate resource for iomem\n"); | ||
992 | return; | ||
993 | } | ||
994 | |||
995 | res->name = name; | ||
996 | res->start = md->phys_addr; | ||
997 | res->end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1; | ||
998 | res->flags = flags; | ||
999 | |||
1000 | if (insert_resource(&iomem_resource, res) < 0) | ||
1001 | kfree(res); | ||
1002 | else { | ||
1003 | /* | ||
1004 | * We don't know which region contains | ||
1005 | * kernel data so we try it repeatedly and | ||
1006 | * let the resource manager test it. | ||
1007 | */ | ||
1008 | insert_resource(res, code_resource); | ||
1009 | insert_resource(res, data_resource); | ||
1010 | } | ||
1011 | } | ||
1012 | } | ||
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 1658d687b79c..83b37c410ccd 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c | |||
@@ -78,6 +78,19 @@ struct screen_info screen_info; | |||
78 | unsigned long vga_console_iobase; | 78 | unsigned long vga_console_iobase; |
79 | unsigned long vga_console_membase; | 79 | unsigned long vga_console_membase; |
80 | 80 | ||
81 | static struct resource data_resource = { | ||
82 | .name = "Kernel data", | ||
83 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
84 | }; | ||
85 | |||
86 | static struct resource code_resource = { | ||
87 | .name = "Kernel code", | ||
88 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
89 | }; | ||
90 | extern void efi_initialize_iomem_resources(struct resource *, | ||
91 | struct resource *); | ||
92 | extern char _text[], _edata[], _etext[]; | ||
93 | |||
81 | unsigned long ia64_max_cacheline_size; | 94 | unsigned long ia64_max_cacheline_size; |
82 | unsigned long ia64_iobase; /* virtual address for I/O accesses */ | 95 | unsigned long ia64_iobase; /* virtual address for I/O accesses */ |
83 | EXPORT_SYMBOL(ia64_iobase); | 96 | EXPORT_SYMBOL(ia64_iobase); |
@@ -171,6 +184,22 @@ sort_regions (struct rsvd_region *rsvd_region, int max) | |||
171 | } | 184 | } |
172 | } | 185 | } |
173 | 186 | ||
187 | /* | ||
188 | * Request address space for all standard resources | ||
189 | */ | ||
190 | static int __init register_memory(void) | ||
191 | { | ||
192 | code_resource.start = ia64_tpa(_text); | ||
193 | code_resource.end = ia64_tpa(_etext) - 1; | ||
194 | data_resource.start = ia64_tpa(_etext); | ||
195 | data_resource.end = ia64_tpa(_edata) - 1; | ||
196 | efi_initialize_iomem_resources(&code_resource, &data_resource); | ||
197 | |||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | __initcall(register_memory); | ||
202 | |||
174 | /** | 203 | /** |
175 | * reserve_memory - setup reserved memory areas | 204 | * reserve_memory - setup reserved memory areas |
176 | * | 205 | * |