Port-macppc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: [PATCH] Incorrect segment 0 initialization for PMAC G5
On 03/31/2013 02:01 PM, Michael wrote:
Hello,
On Sun, 31 Mar 2013 09:56:45 +0200
Phileas Fogg <phileas-fogg%mail.ru@localhost> wrote:
On 03/31/2013 03:12 AM, Michael wrote:
Patches please! ;)
Will do, first i wanted to get interrupts working else the system is
pretty unusable. At least Ethernet should work properly and then we
could SSH to it :)
I wrote most of the interrupt code, I have a G5 I want to get going and
you just removed the obstacle that kept me from doing so ;)
Hi Michael,
i prepared the first bunch of patches for G5 support.
These patches fix MMU issues on G5.
I tested the patches with NetBSD HEAD.
Please review them and tell me if it's OK.
After applying these patches your NetBSD kernel should boot in virtual
mode and panic in init_interrupt. All patches were tested by me
with netbooting.
Patch description
------------------
POWERMAC_G5_11_2.patch : My kernel config which i used
locore.S.patch : Enable 64bit bridge mode at boot
trap_subr.S.patch : Enable 64bit bridge mode when entering an
exception handler
pmap.c.patch : Disable kernel map in pmap_bootstrap
ofw_rascons.c.patch : Do not use ROM font if kernel option
OFWOEA_WSCONS_NO_ROM_FONT is defined.
I'm having problems with ROM font currently,
my machine hangs, so that's why i added
a new kernel option.
ofwoea_machdep.c.patch : Make OFW code+data mapping machine
independent and map video frame buffer into
pmap_kernel for console.
Also fix ofw_map segments.
The display console can be used only after MMU was enabled.
It's safe to use it before too but you won't see any messages
or you will see some strange things on display. That's OK
because in real mode the machine assumes that all memory is cachable
which is wrong for the video frame buffer and there is no way to fix it
except cache flushing.
In virtual mode i set GUARDED and CACHE-INHIBITED attributes for video
frame buffer addresses and the it works as expected.
For some reason i'm having trouble with ROM font, don't know why but
my machine hangs if i use it. I tried to map it with MMU, it didn't
help. OFWOEA_WSCONS_NO_ROM_FONT disables it.
Thanks.
Regards
--- /dev/null 2013-04-01 16:15:26.000000000 +0000
+++ sys/arch/macppc/conf/POWERMAC_G5_11_2 2013-04-01 16:11:31.000000000
+0000
@@ -0,0 +1,168 @@
+# Lean and mean config file for the POWERMAC G5
+# Author: Sanjay Lal <sanjayl%kymasys.com@localhost>
+
+include "arch/macppc/conf/std.macppc.g5"
+
+options INCLUDE_CONFIG_FILE # embed config file in kernel binary
+maxusers 32
+
+options PMAC_G5
+options ALTIVEC # Include AltiVec support
+
+# Standard system options
+options INSECURE # disable kernel security levels
+
+options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT
+options NTP # NTP phase/frequency locked loop
+options KTRACE # system call tracing via ktrace(1)
+
+options SYSVMSG # System V message queues
+options SYSVSEM # System V semaphores
+#options SEMMNI=10 # number of semaphore identifiers
+#options SEMMNS=60 # number of semaphores in system
+#options SEMUME=10 # max number of undo entries per process
+#options SEMMNU=30 # number of undo structures in system
+options SYSVSHM # System V shared memory
+
+options USERCONF # userconf(4) support
+#options PIPE_SOCKETPAIR # smaller, but slower pipe(2)
+options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel
+
+# Enable experimental buffer queue strategy for better responsiveness under
+# high disk I/O load. Use it with caution - it's not proven to be stable yet.
+#options NEW_BUFQ_STRATEGY
+
+# Diagnostic/debugging support options
+options DIAGNOSTIC # cheap kernel consistency checks
+options DEBUG # expensive debugging checks/support
+options ZS_CONSOLE_ABORT# allow break to get into DDB on serial
+options DDB # in-kernel debugger
+options DDB_ONPANIC=1 # don't go into ddb on panic.
+options DDB_HISTORY_SIZE=512 # enable history editing in DDB
+options TRAP_PANICWAIT
+
+makeoptions DEBUG="-g" # compile full symbol table
+
+# Compatibility options
+options COMPAT_30 # NetBSD 3.0 compatibility.
+options COMPAT_40 # NetBSD 4.0 compatibility.
+options COMPAT_43 # and 4.3BSD
+#options COMPAT_386BSD_MBRPART # recognize old partition ID
+#options TCP_COMPAT_42 # 4.2BSD TCP/IP bug compat. Not recommended.
+options COMPAT_BSDPTY # /dev/[pt]ty?? ptys.
+
+# File systems
+file-system FFS # UFS
+file-system MFS # memory file system
+file-system KERNFS # /kern
+file-system PROCFS # /proc
+file-system NFS # Network File System client
+
+# File system options
+options QUOTA # legacy UFS quotas
+options QUOTA2 # new, in-filesystem UFS quotas
+#options FFS_EI # FFS Endian Independent support
+#options UFS_DIRHASH # UFS Large Directory Hashing - Experimental
+#options NFSSERVER # Network File System server
+#options FFS_NO_SNAPSHOT # ffs snapshots
+#options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
+ # immutable) behave as system flags.
+#options APPLE_UFS # Apple UFS support in FFS
+# Networking options
+#options GATEWAY # packet forwarding
+options INET # IP + ICMP + TCP + UDP
+
+# These options enable verbose messages for several subsystems.
+# Warning, these may compile large string tables into the kernel!
+options PCIVERBOSE # verbose PCI device autoconfig messages
+options MIIVERBOSE # verbose PHY autoconfig messages
+#options PCI_CONFIG_DUMP # verbosely dump PCI config space
+
+# wscons options
+#options WSEMUL_SUN # sun terminal emulation
+options WSEMUL_VT100 # VT100 / VT220 emulation
+options WSDISPLAY_COMPAT_USL # wsconscfg VT handling
+#options WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
+options FONT_GALLANT12x22
+
+# Optional Mac keyboard tweaks
+
+# Tweak the keyboard driver to treat the caps lock key on an ADB
+# keyboard as a control key; requires special remapping because of
+# ADB's strange emulation of a mechanically-locked key.
+#options CAPS_IS_CONTROL
+
+# On Mac laptops, several function keys double as "hot keys"
+# (brightness, volume, eject) when the Fn modifier is held down. Mac
+# OS X likes to reprogram the keyboard controller to send hot key
+# events when Fn is not held down and send function key events when it
+# is. This option transforms the non-keyboard "button" events back
+# into function key events.
+#options FORCE_FUNCTION_KEYS
+
+# Kernel root file system and dump configuration.
+config netbsd root on ? type ?
+#config netbsd root on gem0 type nfs
+#options NFS_BOOT_DHCP,NFS_BOOT_BOOTPARAM
+
+#
+# Device configuration
+#
+
+mainbus* at root
+
+cpu* at mainbus?
+ibmcpc* at mainbus?
+uninorth* at mainbus?
+
+pci* at ibmcpc? bus ?
+pci* at uninorth? bus ?
+pci* at ppb? bus ?
+
+pchb* at pci? dev ? function ? # PCI-Host bridges
+ppb* at pci? dev ? function ? # PCI-PCI bridges
+
+bge* at pci? dev ? function ? # gmac ethernet
+ukphy* at mii? phy ? # generic unknown PHYs
+
+# PCI USB controllers
+ohci* at pci? dev ? function ? # USB Open Host Controller
+ehci* at pci? dev ? function ? # USB Enhanced Host Controller
+
+usb* at ohci? # USB bus support
+uhub* at usb? # USB Hubs
+uhub* at uhub? port ?
+uhidev* at uhub? port ? configuration ? interface ? # USB HID device
+uhid* at uhidev? reportid ? # USB Generic HID
+ukbd* at uhidev? reportid ? # USB Keyboards
+wskbd* at ukbd? console ?
+ums* at uhidev? reportid ? # USB Mice
+wsmouse* at ums?
+
+genfb* at pci? dev ? function ?
+wsdisplay* at genfb? console ?
+
+#pseudo-device crypto # opencrypto framework
+ # (disabled, requires generic softints)
+pseudo-device vnd 4 # disk-like interface to files
+pseudo-device md # memory disk device
+pseudo-device loop # network loopback
+pseudo-device pty # pseudo-terminals
+pseudo-device openfirm # /dev/openfirm
+pseudo-device wsmux # mouse and keyboard multiplexor
+pseudo-device clockctl # user control of clock subsystem
+pseudo-device ksyms # /dev/ksyms
+pseudo-device nsmb # SMB requester
+pseudo-device bpfilter 8 # Berkeley packet filter
+#pseudo-device pf # PF packet filter
+#pseudo-device pflog # PF log if
+
+options OFWOEA_WSCONS_NO_ROM_FONT
+options EXSTORAGE_MAX=24
+
+# Enable the hooks used for initializing the ram-disk.
+options MEMORY_DISK_HOOKS
+options MEMORY_DISK_IS_ROOT # Force root on ram-disk
+options MEMORY_DISK_ROOT_SIZE=5000 # 25000 KiB
+options MEMORY_DISK_RBFLAGS=RB_SINGLE # boot in single-user mode
+options MEMORY_DISK_SERVER=1
Index: sys/arch/macppc/macppc/locore.S
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/macppc/locore.S,v
retrieving revision 1.70
diff -u -r1.70 locore.S
--- sys/arch/macppc/macppc/locore.S 20 Jun 2011 19:56:12 -0000 1.70
+++ sys/arch/macppc/macppc/locore.S 1 Apr 2013 15:21:20 -0000
@@ -52,6 +52,12 @@
#include <powerpc/spr.h>
#include <powerpc/oea/spr.h>
+#if defined (PMAP_OEA64) || defined(PMAP_OEA64_BRIDGE)
+#define MTMSR(r) mtmsrd r
+#else
+#define MTMSR(r) mtmsr r
+#endif /* PMAP_OEA64 || PMAP_OEA64_BRIDGE */
+
/*
* Some instructions gas doesn't understand (yet?)
*/
@@ -86,7 +92,7 @@
bl _C_LABEL(ofwinit) /* init OF */
li 0,0
- mtmsr 0 /* Disable FPU/MMU/exceptions */
+ MTMSR(0) /* Disable FPU/MMU/exceptions */
isync
/* compute end of kernel memory */
Index: sys/arch/powerpc/powerpc/trap_subr.S
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/trap_subr.S,v
retrieving revision 1.75
diff -u -r1.75 trap_subr.S
--- sys/arch/powerpc/powerpc/trap_subr.S 27 Jul 2012 04:17:07 -0000
1.75
+++ sys/arch/powerpc/powerpc/trap_subr.S 1 Apr 2013 15:23:05 -0000
@@ -55,11 +55,20 @@
#define RESTORE_VRSAVE(tf,b)
#endif
-#if defined (PPC_OEA64)
+#if defined (PPC_OEA64) || defined (PPC_OEA64_BRIDGE)
#define RFI rfid
#else
#define RFI rfi
-#endif /* PPC_OEA64 */
+#endif /* PPC_OEA64 || PPC_OEA64_BRIDGE*/
+
+#if defined (PPC_OEA64_BRIDGE)
+#define ENABLE_64BIT_BRIDGE(t0)
\
+ mfmsr t0; \
+ clrldi t0,t0,1; \
+ mtmsrd t0;
+#else
+#define ENABLE_64BIT_BRIDGE(t0)
+#endif /* PPC_OEA64_BRIDGE */
#if defined(PPC_OEA64)
/*
@@ -171,6 +180,7 @@
_C_LABEL(trapcode):
mtsprg1 %r1 /* save SP */
GET_CPUINFO(%r1)
+ ENABLE_64BIT_BRIDGE(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* free r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* free r29 */
streg %r30,(CI_TEMPSAVE+CPUSAVE_R30)(%r1) /* free r30 */
@@ -199,6 +209,7 @@
.globl _C_LABEL(alitrap),_C_LABEL(alisize)
_C_LABEL(alitrap):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -234,6 +245,7 @@
.globl _C_LABEL(dsitrap),_C_LABEL(dsisize)
_C_LABEL(dsitrap):
mtsprg1 %r1
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_DISISAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_DISISAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -397,6 +409,7 @@
.globl _C_LABEL(extint),_C_LABEL(extsize)
_C_LABEL(extint):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -430,6 +443,7 @@
.globl _C_LABEL(decrint),_C_LABEL(decrsize)
_C_LABEL(decrint):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -673,6 +687,7 @@
.globl _C_LABEL(ddblow),_C_LABEL(ddbsize)
_C_LABEL(ddblow):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
mtsprg2 %r29 /* save r29 */
mfcr %r29 /* save CR in r29 */
mfsrr1 %r1
@@ -728,6 +743,7 @@
.globl _C_LABEL(ipkdblow),_C_LABEL(ipkdbsize)
_C_LABEL(ipkdblow):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_IPKDBSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_IPKDBSAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -1020,6 +1036,7 @@
.globl _C_LABEL(sctrap),_C_LABEL(scsize),_C_LABEL(sctrapexit)
_C_LABEL(sctrap):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* save r20 */
@@ -1208,6 +1225,7 @@
.globl _C_LABEL(ddb_trap)
_C_LABEL(ddb_trap):
mtsprg1 %r1
+ ENABLE_64BIT_BRIDGE(%r1)
mfmsr %r3
mtsrr1 %r3
andi. %r3,%r3,~(PSL_EE|PSL_ME)@l
@@ -1248,6 +1266,7 @@
.globl _C_LABEL(ipkdb_trap)
_C_LABEL(ipkdb_trap):
mtsprg1 %r1
+ ENABLE_64BIT_BRIDGE(%r1)
mfmsr %r3
mtsrr1 %r3
andi. %r3,%r3,~(PSL_EE|PSL_ME)@l
Index: sys/arch/powerpc/oea/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/pmap.c,v
retrieving revision 1.88
diff -u -r1.88 pmap.c
--- sys/arch/powerpc/oea/pmap.c 28 Mar 2013 00:22:21 -0000 1.88
+++ sys/arch/powerpc/oea/pmap.c 1 Apr 2013 15:22:23 -0000
@@ -3465,7 +3465,7 @@
sizeof(void *), 0, 0, "pmap_pl", &pmap_pool_uallocator,
IPL_NONE);
-#if defined(PMAP_NEED_MAPKERNEL) || 1
+#if defined(PMAP_NEED_MAPKERNEL)
{
struct pmap *pm = pmap_kernel();
#if defined(PMAP_NEED_FULL_MAPKERNEL)
Index: sys/arch/powerpc/oea/ofw_rascons.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/ofw_rascons.c,v
retrieving revision 1.8
diff -u -r1.8 ofw_rascons.c
--- sys/arch/powerpc/oea/ofw_rascons.c 1 Feb 2012 09:54:03 -0000 1.8
+++ sys/arch/powerpc/oea/ofw_rascons.c 1 Apr 2013 15:21:52 -0000
@@ -98,7 +98,9 @@
wsfont_init();
if (copy_rom_font() == 0) {
+#if !defined(OFWOEA_WSCONS_NO_ROM_FONT)
romfont_loaded = 1;
+#endif /* !OFWOEA_WSCONS_NO_ROM_FONT */
}
/* set up rasops */
Index: sys/arch/powerpc/oea/ofwoea_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/ofwoea_machdep.c,v
retrieving revision 1.31
diff -u -r1.31 ofwoea_machdep.c
--- sys/arch/powerpc/oea/ofwoea_machdep.c 20 Oct 2012 14:42:15 -0000
1.31
+++ sys/arch/powerpc/oea/ofwoea_machdep.c 1 Apr 2013 15:24:18 -0000
@@ -172,6 +172,25 @@
ofwoea_consinit();
+#if defined(PPC_OEA64) || defined (PPC_OEA64_BRIDGE)
+#if defined (PMAC_G5)
+ int32_t width, height, linebytes, fbaddr;
+
+ width = height = -1;
+ if (OF_getprop(console_node, "width", &width, 4) != 4)
+ OF_interpret("screen-width", 0, 1, &width);
+ if (OF_getprop(console_node, "height", &height, 4) != 4)
+ OF_interpret("screen-height", 0, 1, &height);
+ if (OF_getprop(console_node, "linebytes", &linebytes, 4) != 4)
+ linebytes = width;
+ if (OF_getprop(console_node, "address", &fbaddr, 4) != 4)
+ OF_interpret("frame-buffer-adr", 0, 1, &fbaddr);
+
+ printf("Video frame buffer @%x %dx%d\n",
+ fbaddr, width, height);
+#endif /* PMAC_G5 */
+#endif /* PPC_OEA64 || PPC_OEA64_BRIDGE */
+
#if defined(MULTIPROCESSOR) && defined(ofppc)
for (i=1; i < CPU_MAXNUM; i++) {
sprintf(cpupath, "/cpus/@%x", i);
@@ -230,9 +249,36 @@
#if defined(PPC_OEA64) || defined (PPC_OEA64_BRIDGE)
#if defined (PMAC_G5)
/* Mapin 1st 256MB segment 1:1, also map in mem needed to access OFW*/
- if (oeacpufeat & OEACPU_64_BRIDGE)
- pmap_setup_segment0_map(0, 0xff800000, 0x3fc00000, 0x400000,
- 0x0);
+ if (oeacpufeat & OEACPU_64_BRIDGE) {
+ vaddr_t va;
+ paddr_t pa;
+ int i;
+
+ pmap_setup_segment0_map(0, 0x0);
+
+ /* Map OFW code+data */
+
+ for (i = 0; i < ofmaplen / sizeof(struct ofw_translations);
i++) {
+ if (ofmap[i].va < 0xff800000)
+ continue;
+
+ for (va = ofmap[i].va, pa = ofmap[i].pa;
+ va < ofmap[i].va + ofmap[i].len;
+ va += PAGE_SIZE, pa += PAGE_SIZE) {
+ pmap_enter(pmap_kernel(), va, pa, VM_PROT_ALL,
+ VM_PROT_ALL | PMAP_WIRED);
+ }
+ }
+
+ /* Map video frame buffer */
+
+ for (va = fbaddr; va < fbaddr + height * linebytes;
+ va += PAGE_SIZE) {
+ pmap_enter(pmap_kernel(), va, va,
+ VM_PROT_READ | VM_PROT_WRITE,
+ PMAP_NOCACHE | PMAP_WIRED);
+ }
+ }
#elif defined (MAMBO)
/* Mapin 1st 256MB segment 1:1, also map in mem needed to access OFW*/
if (oeacpufeat & OEACPU_64_BRIDGE)
@@ -330,10 +376,11 @@
pmap_pinit(&ofw_pmap);
- ofw_pmap.pm_sr[KERNEL_SR] = KERNEL_SEGMENT;
+ ofw_pmap.pm_sr[0] = KERNELN_SEGMENT(0)|SR_PRKEY;
+ ofw_pmap.pm_sr[KERNEL_SR] = KERNEL_SEGMENT|SR_SUKEY|SR_PRKEY;
#ifdef KERNEL2_SR
- ofw_pmap.pm_sr[KERNEL2_SR] = KERNEL2_SEGMENT;
+ ofw_pmap.pm_sr[KERNEL2_SR] = KERNEL2_SEGMENT|SR_SUKEY|SR_PRKEY;
#endif
for (i = 0; i < n; i++) {
Home |
Main Index |
Thread Index |
Old Index