Skip to content

Commit 38b8f5f

Browse files
committed
Add __HAVE_NEW_PMAP_68K glue:
- mac68k_init(): Use pmap_protect() to write-protect the kernel text (with a comment explaining why we do this here). - Add a machine_bootmap[] with entries for IOBase, ROMBase, and VIDBase. In bootstrap_mac68k(), patch up machine_bootmap[] with run-time computed values.
1 parent aa25902 commit 38b8f5f

1 file changed

Lines changed: 58 additions & 2 deletions

File tree

sys/arch/mac68k/mac68k/machdep.c

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: machdep.c,v 1.374 2025/12/02 02:26:18 thorpej Exp $ */
1+
/* $NetBSD: machdep.c,v 1.375 2025/12/02 02:32:36 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
7474
*/
7575

7676
#include <sys/cdefs.h>
77-
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.374 2025/12/02 02:26:18 thorpej Exp $");
77+
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.375 2025/12/02 02:32:36 thorpej Exp $");
7878

7979
#include "opt_adb.h"
8080
#include "opt_compat_netbsd.h"
@@ -274,6 +274,19 @@ mac68k_init(void)
274274
VM_FREELIST_DEFAULT);
275275
}
276276

277+
#ifdef __HAVE_NEW_PMAP_68K
278+
/*
279+
* We mapped the kernel text read/write in pmap_bootstrap1() to
280+
* deal with the vectors and Mac ROM variable region. Go ahead
281+
* and write-protect &start - &etext here.
282+
*/
283+
extern char start[], etext[];
284+
pmap_protect(pmap_kernel(), m68k_round_page((vaddr_t)start),
285+
m68k_trunc_page((vaddr_t)etext),
286+
UVM_PROT_READ | UVM_PROT_EXEC);
287+
pmap_update(pmap_kernel());
288+
#endif /* __HAVE_NEW_PMAP_68K */
289+
277290
/*
278291
* Initialize the I/O mem extent map.
279292
* Note: we don't have to check the return value since
@@ -2676,6 +2689,30 @@ pmap_machine_check_bootstrap_allocations(paddr_t nextpa, paddr_t firstpa)
26762689
}
26772690
}
26782691

2692+
#ifdef __HAVE_NEW_PMAP_68K
2693+
#define PMBM_IOBase 0
2694+
#define PMBM_ROMBase 1
2695+
#define PMBM_VIDBase 2
2696+
struct pmap_bootmap machine_bootmap[] = {
2697+
{ .pmbm_vaddr_ptr = (vaddr_t *)&IOBase,
2698+
.pmbm_paddr = 0, /* initialized below */
2699+
.pmbm_size = m68k_ptob(IIOMAPSIZE),
2700+
.pmbm_flags = PMBM_F_CI },
2701+
2702+
{ .pmbm_vaddr_ptr = (vaddr_t *)&ROMBase,
2703+
.pmbm_paddr = 0, /* initialized below */
2704+
.pmbm_size = m68k_ptob(ROMMAPSIZE),
2705+
.pmbm_flags = PMBM_F_RO },
2706+
2707+
{ .pmbm_vaddr_ptr = &newvideoaddr,
2708+
.pmbm_paddr = 0, /* initialized below */
2709+
.pmbm_size = 0, /* initialized below */
2710+
.pmbm_flags = PMBM_F_CI },
2711+
2712+
{ .pmbm_vaddr = -1 },
2713+
};
2714+
#endif /* __HAVE_NEW_PMAP_68K */
2715+
26792716
void bootstrap_mac68k(int);
26802717

26812718
void __attribute__((no_instrument_function))
@@ -2736,8 +2773,27 @@ bootstrap_mac68k(int tc)
27362773
mem_size += high[i] - low[i];
27372774
physmem = m68k_btop(mem_size);
27382775

2776+
#ifdef __HAVE_NEW_PMAP_68K
2777+
/* Initialize machine_bootmap[] for pmap_bootstrap1(). */
2778+
machine_bootmap[PMBM_IOBase].pmbm_paddr = (paddr_t)IOBase;
2779+
machine_bootmap[PMBM_ROMBase].pmbm_paddr = (paddr_t)ROMBase;
2780+
machine_bootmap[PMBM_VIDBase].pmbm_paddr =
2781+
m68k_trunc_page(mac68k_video.mv_phys);
2782+
machine_bootmap[PMBM_VIDBase].pmbm_size = vidlen;
2783+
#endif
2784+
27392785
nextpa = pmap_bootstrap1(nextpa, load_addr);
27402786

2787+
#ifdef __HAVE_NEW_PMAP_68K
2788+
/*
2789+
* machine_bootmap[] deals in whole pages; fixup newvideoaddr to
2790+
* include the page offset.
2791+
*/
2792+
if (vidlen) {
2793+
newvideoaddr += m68k_page_offset(mac68k_video.mv_phys);
2794+
}
2795+
#endif
2796+
27412797
/*
27422798
* VM data structures are now initialized, set up data for
27432799
* the pmap module.

0 commit comments

Comments
 (0)