Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/machdep.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
#include <machine/vfp.h> | #include <machine/vfp.h> | ||||
#endif | #endif | ||||
#ifdef FDT | #ifdef FDT | ||||
#include <dev/fdt/fdt_common.h> | #include <dev/fdt/fdt_common.h> | ||||
#include <dev/ofw/openfirm.h> | #include <dev/ofw/openfirm.h> | ||||
#endif | #endif | ||||
#define MAX_DMAP_ENTRIES 64 | |||||
struct direct_map_desc arm64_dmap_desc[MAX_DMAP_ENTRIES]; | |||||
struct pcpu __pcpu[MAXCPU]; | struct pcpu __pcpu[MAXCPU]; | ||||
static struct trapframe proc0_tf; | static struct trapframe proc0_tf; | ||||
vm_paddr_t phys_avail[PHYS_AVAIL_SIZE + 2]; | vm_paddr_t phys_avail[PHYS_AVAIL_SIZE + 2]; | ||||
vm_paddr_t dump_avail[PHYS_AVAIL_SIZE + 2]; | vm_paddr_t dump_avail[PHYS_AVAIL_SIZE + 2]; | ||||
int early_boot = 1; | int early_boot = 1; | ||||
▲ Show 20 Lines • Show All 694 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
initarm(struct arm64_bootparams *abp) | initarm(struct arm64_bootparams *abp) | ||||
{ | { | ||||
struct efi_map_header *efihdr; | struct efi_map_header *efihdr; | ||||
struct pcpu *pcpup; | struct pcpu *pcpup; | ||||
vm_offset_t lastaddr; | vm_offset_t lastaddr; | ||||
caddr_t kmdp; | caddr_t kmdp; | ||||
vm_paddr_t mem_len; | vm_paddr_t mem_len; | ||||
vm_offset_t dmap_address; | |||||
int dmap_cnt; | |||||
int i; | int i; | ||||
/* Set the module data location */ | /* Set the module data location */ | ||||
preload_metadata = (caddr_t)(uintptr_t)(abp->modulep); | preload_metadata = (caddr_t)(uintptr_t)(abp->modulep); | ||||
/* Find the kernel address */ | /* Find the kernel address */ | ||||
kmdp = preload_search_by_type("elf kernel"); | kmdp = preload_search_by_type("elf kernel"); | ||||
if (kmdp == NULL) | if (kmdp == NULL) | ||||
Show All 10 Lines | #endif | ||||
lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); | lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); | ||||
/* Load the physical memory ranges */ | /* Load the physical memory ranges */ | ||||
physmap_idx = 0; | physmap_idx = 0; | ||||
efihdr = (struct efi_map_header *)preload_search_info(kmdp, | efihdr = (struct efi_map_header *)preload_search_info(kmdp, | ||||
MODINFO_METADATA | MODINFOMD_EFI_MAP); | MODINFO_METADATA | MODINFOMD_EFI_MAP); | ||||
add_efi_map_entries(efihdr, physmap, &physmap_idx); | add_efi_map_entries(efihdr, physmap, &physmap_idx); | ||||
/* Print the memory map */ | /* Load the memory map and prepare DMAP descriptor */ | ||||
mem_len = 0; | mem_len = 0; | ||||
for (i = 0; i < physmap_idx; i += 2) { | dmap_address = DMAP_MIN_ADDRESS; | ||||
for (i = 0, dmap_cnt = 0; i < physmap_idx; i += 2, dmap_cnt++) { | |||||
/* The last entry must be zero, so decrease the limit by 1 */ | |||||
if (dmap_cnt >= (MAX_DMAP_ENTRIES - 1)) | |||||
panic("Physmap is too fragmented to fit DMAP"); | |||||
dump_avail[i] = physmap[i]; | dump_avail[i] = physmap[i]; | ||||
dump_avail[i + 1] = physmap[i + 1]; | dump_avail[i + 1] = physmap[i + 1]; | ||||
mem_len += physmap[i + 1] - physmap[i]; | mem_len += physmap[i + 1] - physmap[i]; | ||||
arm64_dmap_desc[dmap_cnt].va_start = dmap_address; | |||||
arm64_dmap_desc[dmap_cnt].va_end = dmap_address + mem_len - 1; | |||||
arm64_dmap_desc[dmap_cnt].pa_start = physmap[i]; | |||||
arm64_dmap_desc[dmap_cnt].pa_end = physmap[i + 1] - 1; | |||||
arm64_dmap_desc[dmap_cnt].flags = DMAP_FLAG_VALID; | |||||
dmap_address += mem_len; | |||||
if (dmap_address > DMAP_MAX_ADDRESS) | |||||
panic("Physmap is too large to fit DMAP"); | |||||
} | } | ||||
dump_avail[i] = 0; | dump_avail[i] = 0; | ||||
dump_avail[i + 1] = 0; | dump_avail[i + 1] = 0; | ||||
/* Set the pcpu data, this is needed by pmap_bootstrap */ | /* Set the pcpu data, this is needed by pmap_bootstrap */ | ||||
pcpup = &__pcpu[0]; | pcpup = &__pcpu[0]; | ||||
pcpu_init(pcpup, 0, sizeof(struct pcpu)); | pcpu_init(pcpup, 0, sizeof(struct pcpu)); | ||||
Show All 34 Lines |