@@ -40,12 +40,14 @@ int main(void)
printf("starting sieve\n");
test_sieve("static", static_data, STATIC_SIZE);
- setup_vm();
- test_sieve("mapped", static_data, STATIC_SIZE);
- for (i = 0; i < 3; ++i) {
- v = malloc(VSIZE);
- test_sieve("virtual", v, VSIZE);
- free(v);
+ if (vm_available()) {
+ setup_vm();
+ test_sieve("mapped", static_data, STATIC_SIZE);
+ for (i = 0; i < 3; ++i) {
+ v = malloc(VSIZE);
+ test_sieve("virtual", v, VSIZE);
+ free(v);
+ }
}
return 0;
@@ -3,7 +3,6 @@
#include <asm/pgtable.h>
-bool vm_available(void);
bool mmu_enabled(void);
void mmu_enable(pgd_t *pgtable);
void mmu_disable(void);
@@ -23,7 +23,7 @@
static pgd_t *identity_pgd;
-bool vm_available(void)
+bool vm_available(void) /* weak override */
{
return cpu_has_radix;
}
@@ -206,10 +206,17 @@ void init_alloc_vpage(void *top)
spin_unlock(&lock);
}
+bool __attribute__((__weak__)) vm_available(void)
+{
+ return true;
+}
+
void __setup_vm(void *opaque)
{
phys_addr_t base, top;
+ assert_msg(vm_available(), "Virtual memory not available. Must check vm_available() before calling setup_vm()");
+
if (alloc_ops == &vmalloc_ops)
return;
@@ -17,6 +17,8 @@ extern void setup_vm(void);
/* As above, plus passes an opaque value to setup_mmu(). */
extern void __setup_vm(void *opaque);
+/* common/ tests must check availability before calling setup_vm() */
+extern bool vm_available(void);
/* Set up paging */
extern void *setup_mmu(phys_addr_t top, void *opaque);
/* Walk the page table and resolve the virtual address to a physical address */