1- /* $NetBSD: pmap_bootstrap.c,v 1.110 2025/12/02 02:04:21 thorpej Exp $ */
1+ /* $NetBSD: pmap_bootstrap.c,v 1.111 2025/12/02 02:08:11 thorpej Exp $ */
22
33/*
44 * Copyright (c) 1991, 1993
3636 */
3737
3838#include <sys/cdefs.h>
39- __KERNEL_RCSID (0 , "$NetBSD: pmap_bootstrap.c,v 1.110 2025/12/02 02:04:21 thorpej Exp $" );
39+ __KERNEL_RCSID (0 , "$NetBSD: pmap_bootstrap.c,v 1.111 2025/12/02 02:08:11 thorpej Exp $" );
4040
41- #include "audio.h"
4241#include "opt_ddb.h"
4342#include "opt_kgdb.h"
4443#include "opt_m68k_arch.h"
4544
46- #include "zsc.h"
47-
4845#include <sys/param.h>
4946#include <sys/systm.h>
5047#include <sys/reboot.h>
@@ -65,23 +62,10 @@ __KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.110 2025/12/02 02:04:21 thorpej
6562extern char * etext ;
6663extern char * extiobase ;
6764
68- extern paddr_t avail_start , avail_end ;
6965extern vaddr_t kernel_reloc_offset ;
7066
71- #if NZSC > 0
72- extern int zsinited ;
73- #endif
74-
75- /*
76- * These are used to map the RAM:
77- */
78- int numranges ; /* = 0 == don't use the ranges */
79- u_long low [8 ];
80- u_long high [8 ];
81- u_long last_page ; /* PA of the last physical page */
82- int vidlen ;
83- #define VIDMAPSIZE btoc(vidlen)
84- static vaddr_t newvideoaddr ;
67+ extern int vidlen ;
68+ extern vaddr_t newvideoaddr ;
8569
8670extern void * ROMBase ;
8771
@@ -97,9 +81,6 @@ void *CADDR1, *CADDR2;
9781char * vmmap ;
9882void * msgbufaddr ;
9983
100- paddr_t pmap_bootstrap1 (paddr_t , paddr_t );
101- void bootstrap_mac68k (int );
102-
10384/*
10485 * Bootstrap the VM system.
10586 *
@@ -154,7 +135,7 @@ pmap_bootstrap1(paddr_t nextpa, paddr_t firstpa)
154135 nextpa += PAGE_SIZE ;
155136 kptpa = nextpa ;
156137 nptpages = Sysptsize +
157- (IIOMAPSIZE + ROMMAPSIZE + VIDMAPSIZE + NPTEPG - 1 ) / NPTEPG ;
138+ (IIOMAPSIZE + ROMMAPSIZE + btoc ( vidlen ) + NPTEPG - 1 ) / NPTEPG ;
158139 /*
159140 * New kmem arena is allocated prior to pmap_init(), so we need
160141 * additiona PT pages to account for that allocation, which is based
@@ -418,7 +399,7 @@ pmap_bootstrap1(paddr_t nextpa, paddr_t firstpa)
418399 PG_RW | PG_V | PG_CI ;
419400 newvideoaddr = PTE2VA (pte )
420401 + m68k_page_offset (mac68k_video .mv_phys );
421- epte = & pte [VIDMAPSIZE ];
402+ epte = & pte [btoc ( vidlen ) ];
422403 while (pte < epte ) {
423404 * pte ++ = protopte ;
424405 protopte += PAGE_SIZE ;
@@ -475,149 +456,3 @@ pmap_bootstrap1(paddr_t nextpa, paddr_t firstpa)
475456
476457 return nextpa ;
477458}
478-
479- void
480- pmap_machine_check_bootstrap_allocations (paddr_t nextpa , paddr_t firstpa )
481- {
482- int i ;
483-
484- for (i = 0 ; i < numranges ; i ++ )
485- if (low [i ] <= firstpa && firstpa < high [i ])
486- break ;
487- if (i >= numranges || nextpa > high [i ]) {
488- if (mac68k_machine .do_graybars ) {
489- printf ("Failure in NetBSD boot; " );
490- if (i < numranges )
491- printf ("nextpa=0x%lx, high[%d]=0x%lx.\n" ,
492- nextpa , i , high [i ]);
493- else
494- printf ("can't find kernel RAM segment.\n" );
495- printf ("You're hosed! Try booting with 32-bit " );
496- printf ("addressing enabled in the memory control " );
497- printf ("panel.\n" );
498- printf ("Older machines may need Mode32 to get that " );
499- printf ("option.\n" );
500- }
501- panic ("Cannot work with the current memory mappings." );
502- }
503- }
504-
505- void
506- bootstrap_mac68k (int tc )
507- {
508- #if NZSC > 0
509- extern void zs_init (void );
510- #endif
511- extern int * esym ;
512- paddr_t nextpa ;
513- void * oldROMBase ;
514- char use_bootmem = 0 ;
515- int i ;
516-
517- #ifdef DJMEMCMAX
518- if (mac68k_machine .machineid == MACH_MACC650 ||
519- mac68k_machine .machineid == MACH_MACQ650 ||
520- mac68k_machine .machineid == MACH_MACQ610 ||
521- mac68k_machine .machineid == MACH_MACC610 ||
522- mac68k_machine .machineid == MACH_MACQ800 ) {
523- use_bootmem = 1 ;
524- }
525- #endif
526-
527- if (mac68k_machine .do_graybars )
528- printf ("Bootstrapping NetBSD/mac68k.\n" );
529-
530- oldROMBase = ROMBase ;
531- mac68k_video .mv_phys = mac68k_video .mv_kvaddr ;
532-
533- if ((!use_bootmem ) && (((tc & 0x80000000 ) && (mmutype == MMU_68030 )) ||
534- ((tc & 0x8000 ) && (mmutype == MMU_68040 )))) {
535- if (mac68k_machine .do_graybars )
536- printf ("Getting mapping from MMU.\n" );
537- (void ) get_mapping ();
538- if (mac68k_machine .do_graybars )
539- printf ("Done.\n" );
540- } else {
541- /* MMU not enabled. Fake up ranges. */
542- numranges = 1 ;
543- low [0 ] = 0 ;
544- high [0 ] = mac68k_machine .mach_memsize * (1024 * 1024 );
545- if (mac68k_machine .do_graybars )
546- printf ("Faked range to byte 0x%lx.\n" , high [0 ]);
547- }
548- nextpa = load_addr + m68k_round_page (esym );
549-
550- if (mac68k_machine .do_graybars )
551- printf ("Bootstrapping the pmap system.\n" );
552-
553- vidlen = m68k_round_page (mac68k_video .mv_height *
554- mac68k_video .mv_stride + m68k_page_offset (mac68k_video .mv_phys ));
555-
556- /* Sum up the memory for pmap_bootstrap1(). */
557- vsize_t mem_size = 0 ;
558- for (i = 0 ; i < numranges ; i ++ )
559- mem_size += high [i ] - low [i ];
560- physmem = m68k_btop (mem_size );
561-
562- nextpa = pmap_bootstrap1 (nextpa , load_addr );
563-
564- /*
565- * VM data structures are now initialized, set up data for
566- * the pmap module.
567- *
568- * Note about avail_end: msgbuf is initialized just after
569- * avail_end in machdep.c. Since the last page is used
570- * for rebooting the system (code is copied there and
571- * execution continues from copied code before the MMU
572- * is disabled), the msgbuf will get trounced between
573- * reboots if it's placed in the last physical page.
574- * To work around this, we move avail_end back one more
575- * page so the msgbuf can be preserved.
576- */
577- avail_start = m68k_round_page (nextpa );
578- last_page = high [numranges - 1 ] - m68k_ptob (1 );
579- #if NAUDIO > 0
580- /*
581- * Reduce high by an extra 7 pages which are used by the EASC on some
582- * machines. last_page is unchanged as the last page can still be
583- * safetly used to reboot the system.
584- */
585- high [numranges - 1 ] -= (m68k_round_page (MSGBUFSIZE ) + m68k_ptob (8 ));
586- #else
587- high [numranges - 1 ] -= (m68k_round_page (MSGBUFSIZE ) + m68k_ptob (1 ));
588- #endif
589- avail_end = high [numranges - 1 ];
590-
591- if (mac68k_machine .do_graybars )
592- printf ("Pmap bootstrapped.\n" );
593-
594- if (!vidlen )
595- panic ("Don't know how to relocate video!" );
596-
597- if (mac68k_machine .do_graybars )
598- printf ("Moving ROMBase from %p to %p.\n" , oldROMBase , ROMBase );
599-
600- mrg_fixupROMBase (oldROMBase , ROMBase );
601-
602- if (mac68k_machine .do_graybars )
603- printf ("Video address %p -> %p.\n" ,
604- (void * )mac68k_video .mv_kvaddr , (void * )newvideoaddr );
605-
606- mac68k_set_io_offsets (IOBase );
607-
608- /*
609- * If the serial ports are going (for console or 'echo'), then
610- * we need to make sure the IO change gets propagated properly.
611- * This resets the base addresses for the 8530 (serial) driver.
612- *
613- * WARNING!!! No printfs() (etc) BETWEEN zs_init() and the end
614- * of this function (where we start using the MMU, so the new
615- * address is correct.
616- */
617- #if NZSC > 0
618- if (zsinited != 0 )
619- zs_init ();
620- #endif
621-
622- mac68k_video .mv_kvaddr = newvideoaddr ;
623- }
0 commit comments