kernel: remove hard-coded defines in earm
earm-wide defines don't play nice with multiple BSPs. Co-Authored-By: Benjamin Dauphin <benjamin.dauphin@live.fr> Co-Authored-By: Gilles Henaux <gill.henaux@gmail.com>
This commit is contained in:
@@ -3,8 +3,4 @@
|
||||
#ifndef _ARM_MEMORY_H
|
||||
#define _ARM_MEMORY_H
|
||||
|
||||
/* omap */
|
||||
#define PHYS_MEM_BEGIN 0x80000000
|
||||
#define PHYS_MEM_END 0xbfffffff
|
||||
|
||||
#endif /* _ARM_MEMORY_H */
|
||||
|
||||
@@ -33,6 +33,7 @@ struct tss_s {
|
||||
} __attribute__((packed));
|
||||
int tss_init(unsigned cpu, void * kernel_stack);
|
||||
|
||||
void get_phys_mem_map(phys_bytes *start, phys_bytes *end);
|
||||
void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len);
|
||||
phys_bytes alloc_lowest(kinfo_t *cbi, phys_bytes len);
|
||||
void vm_enable_paging(void);
|
||||
|
||||
@@ -78,6 +78,9 @@ static phys_bytes createpde(
|
||||
phys_bytes offset;
|
||||
int pde;
|
||||
|
||||
phys_bytes phys_start, phys_end;
|
||||
get_phys_mem_map(&phys_start, &phys_end);
|
||||
|
||||
assert(free_pde_idx >= 0 && free_pde_idx < nfreepdes);
|
||||
pde = freepdes[free_pde_idx];
|
||||
assert(pde >= 0 && pde < 4096);
|
||||
@@ -101,7 +104,7 @@ static phys_bytes createpde(
|
||||
pdeval = pr->p_seg.p_ttbr_v[ARM_VM_PDE(linaddr)];
|
||||
} else {
|
||||
/* Requested address is physical. Make up the PDE entry. */
|
||||
assert (linaddr >= PHYS_MEM_BEGIN && linaddr <= PHYS_MEM_END);
|
||||
assert (linaddr >= phys_start && linaddr <= phys_end);
|
||||
|
||||
/* memory */
|
||||
pdeval = (linaddr & ARM_VM_SECTION_MASK)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <arm/armreg.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <minix/board.h>
|
||||
#include <minix/type.h>
|
||||
|
||||
/* These are set/computed in kernel.lds. */
|
||||
@@ -21,6 +22,17 @@ static phys_bytes kern_kernlen = (phys_bytes) &_kern_size;
|
||||
/* page directory we can use to map things */
|
||||
static u32_t pagedir[4096] __aligned(16384);
|
||||
|
||||
void get_phys_mem_map(phys_bytes *start, phys_bytes *end)
|
||||
{
|
||||
*start = 0x0;
|
||||
*end = 0x0;
|
||||
|
||||
if (BOARD_IS_BB(machine.board_id) || BOARD_IS_BBXM(machine.board_id)) {
|
||||
*start = 0x80000000;
|
||||
*end = 0xbfffffff;
|
||||
}
|
||||
}
|
||||
|
||||
void print_memmap(kinfo_t *cbi)
|
||||
{
|
||||
int m;
|
||||
@@ -160,6 +172,9 @@ void pg_identity(kinfo_t *cbi)
|
||||
uint32_t i;
|
||||
phys_bytes phys;
|
||||
|
||||
phys_bytes phys_start, phys_end;
|
||||
get_phys_mem_map(&phys_start, &phys_end);
|
||||
|
||||
/* We map memory that does not correspond to physical memory
|
||||
* as non-cacheable. Make sure we know what it is.
|
||||
*/
|
||||
@@ -173,7 +188,7 @@ void pg_identity(kinfo_t *cbi)
|
||||
|
||||
phys = i * ARM_SECTION_SIZE;
|
||||
/* mark mormal memory as cacheable. TODO: fix hard coded values */
|
||||
if (phys >= PHYS_MEM_BEGIN && phys <= PHYS_MEM_END) {
|
||||
if (phys >= phys_start && phys <= phys_end) {
|
||||
pagedir[i] = phys | flags | ARM_VM_SECTION_CACHED;
|
||||
} else {
|
||||
pagedir[i] = phys | flags | ARM_VM_SECTION_DEVICE;
|
||||
|
||||
@@ -45,6 +45,16 @@ extern u32_t _end;
|
||||
extern char _kern_unpaged_edata;
|
||||
extern char _kern_unpaged_end;
|
||||
|
||||
/*
|
||||
* During low level init many things are not supposed to work
|
||||
* serial being one of them. We therefore can't rely on the
|
||||
* serial to debug. POORMANS_FAILURE_NOTIFICATION can be used
|
||||
* before we setup our own vector table and will result in calling
|
||||
* the bootloader's debugging methods that will hopefully show some
|
||||
* information like the currnet PC at on the serial.
|
||||
*/
|
||||
#define POORMANS_FAILURE_NOTIFICATION asm volatile("svc #00\n")
|
||||
|
||||
/**
|
||||
*
|
||||
* The following function combines a few things together
|
||||
@@ -179,10 +189,6 @@ int overlaps(multiboot_module_t *mod, int n, int cmp_mod)
|
||||
|
||||
/* XXX: hard-coded stuff for modules */
|
||||
#define MB_MODS_NR NR_BOOT_MODULES
|
||||
#define MB_MODS_BASE 0x82000000
|
||||
#define MB_MODS_ALIGN 0x00800000 /* 8 MB */
|
||||
#define MB_MMAP_START 0x80000000
|
||||
#define MB_MMAP_SIZE 0x10000000 /* 256 MB */
|
||||
|
||||
multiboot_module_t mb_modlist[MB_MODS_NR];
|
||||
multiboot_memory_map_t mb_memmap;
|
||||
@@ -195,10 +201,23 @@ void setup_mbi(multiboot_info_t *mbi, char *bootargs)
|
||||
mbi->mi_mods_count = MB_MODS_NR;
|
||||
mbi->mods_addr = (u32_t)&mb_modlist;
|
||||
|
||||
phys_bytes mb_mods_base;
|
||||
phys_bytes mb_mods_align = 0x00800000;
|
||||
phys_bytes mb_mmap_start;
|
||||
phys_bytes mb_mmap_size;
|
||||
|
||||
if (BOARD_IS_BB(machine.board_id) || BOARD_IS_BBXM(machine.board_id)) {
|
||||
mb_mods_base = 0x82000000;
|
||||
mb_mmap_start = 0x80000000;
|
||||
mb_mmap_size = 0x10000000; /* 256 MB */
|
||||
}
|
||||
else
|
||||
POORMANS_FAILURE_NOTIFICATION;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < MB_MODS_NR; ++i) {
|
||||
mb_modlist[i].mod_start = MB_MODS_BASE + i * MB_MODS_ALIGN;
|
||||
mb_modlist[i].mod_end = mb_modlist[i].mod_start + MB_MODS_ALIGN
|
||||
mb_modlist[i].mod_start = mb_mods_base + i * mb_mods_align;
|
||||
mb_modlist[i].mod_end = mb_modlist[i].mod_start + mb_mods_align
|
||||
- ARM_PAGE_SIZE;
|
||||
mb_modlist[i].cmdline = 0;
|
||||
}
|
||||
@@ -210,8 +229,8 @@ void setup_mbi(multiboot_info_t *mbi, char *bootargs)
|
||||
mbi->mmap_length = sizeof(mb_memmap);
|
||||
|
||||
mb_memmap.size = sizeof(multiboot_memory_map_t);
|
||||
mb_memmap.mm_base_addr = MB_MMAP_START;
|
||||
mb_memmap.mm_length = MB_MMAP_SIZE;
|
||||
mb_memmap.mm_base_addr = mb_mmap_start;
|
||||
mb_memmap.mm_length = mb_mmap_size;
|
||||
mb_memmap.type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
}
|
||||
|
||||
@@ -340,16 +359,6 @@ void get_parameters(kinfo_t *cbi, char *bootargs)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* During low level init many things are not supposed to work
|
||||
* serial being one of them. We therefore can't rely on the
|
||||
* serial to debug. POORMANS_FAILURE_NOTIFICATION can be used
|
||||
* before we setup our own vector table and will result in calling
|
||||
* the bootloader's debugging methods that will hopefully show some
|
||||
* information like the currnet PC at on the serial.
|
||||
*/
|
||||
#define POORMANS_FAILURE_NOTIFICATION asm volatile("svc #00\n")
|
||||
|
||||
/* use the passed cmdline argument to determine the machine id */
|
||||
void set_machine_id(char *cmdline)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user