Subject: port-mac68k/3275: Allow custom kernel without nubus
To: None <gnats-bugs@gnats.netbsd.org>
From: Erik Bertelsen <erik@erik-be.uni-c.dk>
List: netbsd-bugs
Date: 03/02/1997 23:20:21
>Number: 3275
>Category: port-mac68k
>Synopsis: Allow custom kernel without nubus
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 2 13:35:00 1997
>Last-Modified:
>Originator: Erik Bertelsen
>Organization:
>Release: NetBSD-current 1 mar 1997
>Environment:
System: NetBSD erik-be.uni-c.dk 1.2C NetBSD 1.2C (ERIKBE) #15: Tue Feb 25 11:01:10 MET 1997 erik@erik-be.uni-c.dk:/sw/NetBSD/src/sys/arch/i386/compile/ERIKBE i386
Really from my Quadra 610, running a custom kernel built from current sources
>Description:
The kernel for NetBSD/mac68k cannot compile (or rather link) when there
is no nubus entry defined in the kernel configuration file.
As has recently been discussed on the mac68k mailing list, this
is intended for allowing custom kernel to be configured just
to contain this computer's actual hardware.
The reason is that the variable tmp_vpages is referenced in arch/
mac68k/mac68k/pmap.c and pmap_bootstrap.c.
It is defined in mac68k/dev/nubus.c which is not used when building
a kernel without nubus support.
In pmap.c, tmp_vpages is referenced (via an ugly local external
declaration) in mac68k_set_pte, which is in turn only called
from nubus.c. This function is called twice in nubus.c, where the
second call may effectively be a no-op.
In pmap_bootstrap.c, tmp_vpages is referenced (via the same
ugly local extern declaration. Here a chunk of kernel virtual
addresses are assigned to this pointer, but only used as mentioned
above. If this memory area does not occupy a well-defined set
of fixed addresses, we could just as well omit the allocation,
if the kernel has no nubus support.
In my patch below, "needs-count" might be replaced with "needs-flag",
but I really don't know when to use which of these...
Also if the local extern declarations of tmp_vpages are retained,
the fix will become much simpler, but I don't really like these
local externs.
Also note that any .c file including mac68k/dev/nubus.h must also
include machine/bus.h. Maybe nubus.h should do this itself ??
regards
Erik Bertelsen
>How-To-Repeat:
Try build a custom NetBSD/mac68k kernel without a nubus
entry.
>Fix:
Index: conf/files.mac68k
===================================================================
RCS file: /home/cvs-base/src/sys/arch/mac68k/conf/files.mac68k,v
retrieving revision 1.1.1.8
diff -c -r1.1.1.8 files.mac68k
*** files.mac68k 1997/02/28 22:23:39 1.1.1.8
--- files.mac68k 1997/02/28 22:47:44
***************
*** 18,24 ****
device nubus { }
attach nubus at mainbus
! file arch/mac68k/dev/nubus.c nubus
device adb
attach adb at obio_norm
--- 18,24 ----
device nubus { }
attach nubus at mainbus
! file arch/mac68k/dev/nubus.c nubus needs-count
device adb
attach adb at obio_norm
Index: dev/nubus.h
===================================================================
RCS file: /home/cvs-base/src/sys/arch/mac68k/dev/nubus.h,v
retrieving revision 1.1.1.3
diff -c -r1.1.1.3 nubus.h
*** nubus.h 1997/02/24 20:41:47 1.1.1.3
--- nubus.h 1997/03/02 15:07:24
***************
*** 241,246 ****
--- 241,248 ----
struct device sc_dev;
};
+ extern vm_offset_t tmp_vpages[];
+
void nubus_get_main_dir __P((nubus_slot *slot, nubus_dir *dir_return));
int nubus_find_rsrc __P((nubus_slot *slot, nubus_dir *dir, u_int8_t rsrcid,
nubus_dirent *dirent_return));
Index: mac68k/pmap.c
===================================================================
RCS file: /home/cvs-base/src/sys/arch/mac68k/mac68k/pmap.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 pmap.c
*** pmap.c 1997/02/03 16:49:52 1.1.1.2
--- pmap.c 1997/03/02 18:16:26
***************
*** 107,112 ****
--- 107,119 ----
#include <machine/cpu.h>
+ #include "nubus.h"
+ #if NNUBUS
+ #include <sys/device.h>
+ #include <machine/bus.h>
+ #include <mac68k/dev/nubus.h>
+ #endif
+
#ifdef PMAPSTATS
struct {
int collectscans;
***************
*** 1030,1041 ****
}
}
void
mac68k_set_pte(va, pge)
vm_offset_t va;
vm_offset_t pge;
{
- extern vm_offset_t tmp_vpages[];
register pt_entry_t *pte;
if (va != tmp_vpages[0])
--- 1037,1048 ----
}
}
+ #if NNUBUS
void
mac68k_set_pte(va, pge)
vm_offset_t va;
vm_offset_t pge;
{
register pt_entry_t *pte;
if (va != tmp_vpages[0])
***************
*** 1044,1049 ****
--- 1051,1057 ----
pte = pmap_pte(pmap_kernel(), va);
*pte = (pt_entry_t) pge;
}
+ #endif /* NNUBUS */
/*
* Insert the given physical page (p) at
Index: mac68k/pmap_bootstrap.c
===================================================================
RCS file: /home/cvs-base/src/sys/arch/mac68k/mac68k/pmap_bootstrap.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 pmap_bootstrap.c
*** pmap_bootstrap.c 1997/01/08 16:31:40 1.1.1.2
--- pmap_bootstrap.c 1997/03/02 18:20:20
***************
*** 57,62 ****
--- 57,68 ----
#include "macrom.h"
+ #include "nubus.h"
+ #if NNUBUS
+ #include <machine/bus.h>
+ #include <mac68k/dev/nubus.h>
+ #endif
+
#define PA2VA(v, t) (t)((u_int)(v) - firstpa)
extern char *etext;
***************
*** 538,544 ****
* Allocate some fixed, special purpose kernel virtual addresses
*/
{
- extern vm_offset_t tmp_vpages[];
vm_offset_t va = virtual_avail;
CADDR1 = (caddr_t)va;
--- 544,549 ----
***************
*** 547,554 ****
--- 552,561 ----
va += NBPG;
vmmap = (caddr_t)va;
va += NBPG;
+ #if NNUBUS
tmp_vpages[0] = va;
va += NBPG;
+ #endif
msgbufp = (struct msgbuf *)va;
va += NBPG;
virtual_avail = reserve_dumppages(va);
>Audit-Trail:
>Unformatted: