linux/arch/sparc/kernel/head.S
<<
>>
Prefs
   1/* $Id: head.S,v 1.105 2001/08/12 09:08:56 davem Exp $
   2 * head.S: The initial boot code for the Sparc port of Linux.
   3 *
   4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   5 * Copyright (C) 1995,1999 Pete Zaitcev   (zaitcev@yahoo.com)
   6 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
   7 * Copyright (C) 1997 Jakub Jelinek   (jj@sunsite.mff.cuni.cz)
   8 * Copyright (C) 1997 Michael A. Griffith (grif@acm.org)
   9 *
  10 * CompactPCI platform by Eric Brower, 1999.
  11 */
  12
  13#include <linux/version.h>
  14#include <linux/init.h>
  15
  16#include <asm/head.h>
  17#include <asm/asi.h>
  18#include <asm/contregs.h>
  19#include <asm/ptrace.h>
  20#include <asm/psr.h>
  21#include <asm/page.h>
  22#include <asm/kdebug.h>
  23#include <asm/winmacro.h>
  24#include <asm/thread_info.h>    /* TI_UWINMASK */
  25#include <asm/errno.h>
  26#include <asm/pgtsrmmu.h>       /* SRMMU_PGDIR_SHIFT */
  27
  28        .data
  29/* 
  30 * The following are used with the prom_vector node-ops to figure out
  31 * the cpu-type 
  32 */
  33
  34        .align 4
  35        .globl  cputyp
  36cputyp:
  37        .word   1
  38
  39        .align 4
  40        .globl cputypval
  41cputypval:
  42        .asciz "sun4c"
  43        .ascii "     "
  44
  45cputypvalend:
  46cputypvallen = cputypvar - cputypval
  47
  48        .align 4
  49/*
  50 * Sun people can't spell worth damn. "compatability" indeed.
  51 * At least we *know* we can't spell, and use a spell-checker.
  52 */
  53
  54/* Uh, actually Linus it is I who cannot spell. Too much murky
  55 * Sparc assembly will do this to ya.
  56 */
  57cputypvar:
  58        .asciz "compatability"
  59
  60/* Tested on SS-5, SS-10. Probably someone at Sun applied a spell-checker. */
  61        .align 4
  62cputypvar_sun4m:
  63        .asciz "compatible"
  64
  65        .align 4
  66
  67#ifndef CONFIG_SUN4
  68sun4_notsup:
  69        .asciz  "Sparc-Linux sun4 needs a specially compiled kernel, turn CONFIG_SUN4 on.\n\n"
  70        .align 4
  71#else
  72sun4cdm_notsup:
  73        .asciz  "Kernel compiled with CONFIG_SUN4 cannot run on SUN4C/SUN4M/SUN4D\nTurn CONFIG_SUN4 off.\n\n"
  74        .align 4
  75#endif
  76
  77sun4e_notsup:
  78        .asciz  "Sparc-Linux sun4e support does not exist\n\n"
  79        .align 4
  80
  81#ifndef CONFIG_SUNOS_EMUL
  82#undef SUNOS_SYSCALL_TRAP
  83#define SUNOS_SYSCALL_TRAP SUNOS_NO_SYSCALL_TRAP
  84#endif
  85
  86        /* The Sparc trap table, bootloader gives us control at _start. */
  87        .text
  88        .globl  start, _stext, _start, __stext
  89        .globl  trapbase
  90_start:   /* danger danger */
  91__stext:
  92_stext:
  93start:
  94trapbase:
  95#ifdef CONFIG_SMP
  96trapbase_cpu0:
  97#endif
  98/* We get control passed to us here at t_zero. */
  99t_zero: b gokernel; nop; nop; nop;
 100t_tflt: SPARC_TFAULT                        /* Inst. Access Exception        */
 101t_bins: TRAP_ENTRY(0x2, bad_instruction)    /* Illegal Instruction           */
 102t_pins: TRAP_ENTRY(0x3, priv_instruction)   /* Privileged Instruction        */
 103t_fpd:  TRAP_ENTRY(0x4, fpd_trap_handler)   /* Floating Point Disabled       */
 104t_wovf: WINDOW_SPILL                        /* Window Overflow               */
 105t_wunf: WINDOW_FILL                         /* Window Underflow              */
 106t_mna:  TRAP_ENTRY(0x7, mna_handler)        /* Memory Address Not Aligned    */
 107t_fpe:  TRAP_ENTRY(0x8, fpe_trap_handler)   /* Floating Point Exception      */
 108t_dflt: SPARC_DFAULT                        /* Data Miss Exception           */
 109t_tio:  TRAP_ENTRY(0xa, do_tag_overflow)    /* Tagged Instruction Ovrflw     */
 110t_wpt:  TRAP_ENTRY(0xb, do_watchpoint)      /* Watchpoint Detected           */
 111t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
 112t_irq1: TRAP_ENTRY_INTERRUPT(1)             /* IRQ Software/SBUS Level 1     */
 113t_irq2: TRAP_ENTRY_INTERRUPT(2)             /* IRQ SBUS Level 2              */
 114t_irq3: TRAP_ENTRY_INTERRUPT(3)             /* IRQ SCSI/DMA/SBUS Level 3     */
 115t_irq4: TRAP_ENTRY_INTERRUPT(4)             /* IRQ Software Level 4          */
 116t_irq5: TRAP_ENTRY_INTERRUPT(5)             /* IRQ SBUS/Ethernet Level 5     */
 117t_irq6: TRAP_ENTRY_INTERRUPT(6)             /* IRQ Software Level 6          */
 118t_irq7: TRAP_ENTRY_INTERRUPT(7)             /* IRQ Video/SBUS Level 5        */
 119t_irq8: TRAP_ENTRY_INTERRUPT(8)             /* IRQ SBUS Level 6              */
 120t_irq9: TRAP_ENTRY_INTERRUPT(9)             /* IRQ SBUS Level 7              */
 121t_irq10:TRAP_ENTRY_INTERRUPT(10)            /* IRQ Timer #1 (one we use)     */
 122t_irq11:TRAP_ENTRY_INTERRUPT(11)            /* IRQ Floppy Intr.              */
 123t_irq12:TRAP_ENTRY_INTERRUPT(12)            /* IRQ Zilog serial chip         */
 124t_irq13:TRAP_ENTRY_INTERRUPT(13)            /* IRQ Audio Intr.               */
 125t_irq14:TRAP_ENTRY_INTERRUPT(14)            /* IRQ Timer #2                  */
 126        .globl  t_nmi
 127#ifndef CONFIG_SMP
 128t_nmi:  NMI_TRAP                            /* Level 15 (NMI)                */
 129#else
 130t_nmi:  TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
 131#endif
 132t_racc: TRAP_ENTRY(0x20, do_reg_access)     /* General Register Access Error */
 133t_iacce:BAD_TRAP(0x21)                      /* Instr Access Error            */
 134t_bad22:BAD_TRAP(0x22) BAD_TRAP(0x23)
 135t_cpdis:TRAP_ENTRY(0x24, do_cp_disabled)    /* Co-Processor Disabled         */
 136t_uflsh:SKIP_TRAP(0x25, unimp_flush)        /* Unimplemented FLUSH inst.     */
 137t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
 138t_cpexc:TRAP_ENTRY(0x28, do_cp_exception)   /* Co-Processor Exception        */
 139t_dacce:SPARC_DFAULT                        /* Data Access Error             */
 140t_hwdz: TRAP_ENTRY(0x2a, do_hw_divzero)     /* Division by zero, you lose... */
 141t_dserr:BAD_TRAP(0x2b)                      /* Data Store Error              */
 142t_daccm:BAD_TRAP(0x2c)                      /* Data Access MMU-Miss          */
 143t_bad2d:BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
 144t_bad32:BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
 145t_bad37:BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
 146t_iaccm:BAD_TRAP(0x3c)                      /* Instr Access MMU-Miss         */
 147t_bad3d:BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40) BAD_TRAP(0x41)
 148t_bad42:BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45) BAD_TRAP(0x46)
 149t_bad47:BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a) BAD_TRAP(0x4b)
 150t_bad4c:BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f) BAD_TRAP(0x50)
 151t_bad51:BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
 152t_bad56:BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
 153t_bad5b:BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
 154t_bad60:BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
 155t_bad65:BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
 156t_bad6a:BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
 157t_bad6f:BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
 158t_bad74:BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
 159t_bad79:BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
 160t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f)
 161t_sunos:SUNOS_SYSCALL_TRAP                  /* SunOS System Call             */
 162t_sbkpt:BREAKPOINT_TRAP                     /* Software Breakpoint/KGDB      */
 163t_divz: TRAP_ENTRY(0x82, do_hw_divzero)     /* Divide by zero trap           */
 164t_flwin:TRAP_ENTRY(0x83, do_flush_windows)  /* Flush Windows Trap            */
 165t_clwin:BAD_TRAP(0x84)                      /* Clean Windows Trap            */
 166t_rchk: BAD_TRAP(0x85)                      /* Range Check                   */
 167t_funal:BAD_TRAP(0x86)                      /* Fix Unaligned Access Trap     */
 168t_iovf: BAD_TRAP(0x87)                      /* Integer Overflow Trap         */
 169t_slowl:SOLARIS_SYSCALL_TRAP                /* Slowaris System Call          */
 170t_netbs:NETBSD_SYSCALL_TRAP                 /* Net-B.S. System Call          */
 171t_bad8a:BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) BAD_TRAP(0x8d) BAD_TRAP(0x8e)
 172t_bad8f:BAD_TRAP(0x8f)
 173t_linux:LINUX_SYSCALL_TRAP                  /* Linux System Call             */
 174t_bad91:BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94) BAD_TRAP(0x95)
 175t_bad96:BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99) BAD_TRAP(0x9a)
 176t_bad9b:BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e) BAD_TRAP(0x9f)
 177t_getcc:GETCC_TRAP                          /* Get Condition Codes           */
 178t_setcc:SETCC_TRAP                          /* Set Condition Codes           */
 179t_getpsr:GETPSR_TRAP                        /* Get PSR Register              */
 180t_bada3:BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
 181t_slowi:INDIRECT_SOLARIS_SYSCALL(156)
 182t_bada8:BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
 183t_badac:BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
 184t_badb1:BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
 185t_badb6:BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
 186t_badbb:BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
 187t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
 188t_badc5:BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
 189t_badca:BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
 190t_badcf:BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
 191t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
 192t_badd9:BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
 193t_badde:BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
 194t_bade3:BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
 195t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
 196t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
 197t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
 198t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
 199t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd)
 200dbtrap: BAD_TRAP(0xfe)                      /* Debugger/PROM breakpoint #1   */
 201dbtrap2:BAD_TRAP(0xff)                      /* Debugger/PROM breakpoint #2   */ 
 202
 203        .globl  end_traptable
 204end_traptable:
 205
 206#ifdef CONFIG_SMP
 207        /* Trap tables for the other cpus. */
 208        .globl  trapbase_cpu1, trapbase_cpu2, trapbase_cpu3
 209trapbase_cpu1:
 210        BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
 211        TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
 212        WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
 213        TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
 214        TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
 215        BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
 216        TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
 217        TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
 218        TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
 219        TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
 220        TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
 221        TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
 222        TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
 223        TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
 224        TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
 225        BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
 226        BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
 227        SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
 228        BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
 229        BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
 230        BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
 231        BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
 232        BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
 233        BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
 234        BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
 235        BAD_TRAP(0x50)
 236        BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
 237        BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
 238        BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
 239        BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
 240        BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
 241        BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
 242        BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
 243        BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
 244        BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
 245        BAD_TRAP(0x7e) BAD_TRAP(0x7f)
 246        SUNOS_SYSCALL_TRAP 
 247        BREAKPOINT_TRAP
 248        TRAP_ENTRY(0x82, do_hw_divzero)
 249        TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
 250        BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
 251        NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
 252        BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
 253        LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
 254        BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
 255        BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
 256        BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
 257        BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
 258        INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
 259        BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
 260        BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
 261        BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
 262        BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
 263        BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
 264        BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
 265        BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
 266        BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
 267        BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
 268        BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
 269        BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
 270        BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
 271        BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
 272        BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
 273        BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
 274        BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
 275        BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
 276
 277trapbase_cpu2:
 278        BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
 279        TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
 280        WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
 281        TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
 282        TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
 283        BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
 284        TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
 285        TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
 286        TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
 287        TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
 288        TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
 289        TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
 290        TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
 291        TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
 292        TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
 293        BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
 294        BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
 295        SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
 296        BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
 297        BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
 298        BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
 299        BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
 300        BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
 301        BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
 302        BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
 303        BAD_TRAP(0x50)
 304        BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
 305        BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
 306        BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
 307        BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
 308        BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
 309        BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
 310        BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
 311        BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
 312        BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
 313        BAD_TRAP(0x7e) BAD_TRAP(0x7f)
 314        SUNOS_SYSCALL_TRAP 
 315        BREAKPOINT_TRAP
 316        TRAP_ENTRY(0x82, do_hw_divzero)
 317        TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
 318        BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
 319        NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
 320        BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
 321        LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
 322        BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
 323        BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
 324        BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
 325        BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
 326        INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
 327        BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
 328        BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
 329        BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
 330        BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
 331        BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
 332        BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
 333        BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
 334        BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
 335        BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
 336        BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
 337        BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
 338        BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
 339        BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
 340        BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
 341        BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
 342        BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
 343        BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
 344
 345trapbase_cpu3:
 346        BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
 347        TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
 348        WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
 349        TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
 350        TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
 351        BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
 352        TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
 353        TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
 354        TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
 355        TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
 356        TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
 357        TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
 358        TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
 359        TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
 360        TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
 361        BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
 362        BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
 363        SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
 364        BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
 365        BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
 366        BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
 367        BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
 368        BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
 369        BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
 370        BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
 371        BAD_TRAP(0x50)
 372        BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
 373        BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
 374        BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
 375        BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
 376        BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
 377        BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
 378        BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
 379        BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
 380        BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
 381        BAD_TRAP(0x7e) BAD_TRAP(0x7f)
 382        SUNOS_SYSCALL_TRAP  
 383        BREAKPOINT_TRAP
 384        TRAP_ENTRY(0x82, do_hw_divzero)
 385        TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
 386        BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
 387        NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
 388        BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
 389        LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
 390        BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
 391        BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
 392        BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
 393        BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
 394        INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
 395        BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
 396        BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
 397        BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
 398        BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
 399        BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
 400        BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
 401        BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
 402        BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
 403        BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
 404        BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
 405        BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
 406        BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
 407        BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
 408        BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
 409        BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
 410        BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
 411        BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
 412
 413#endif
 414        .align PAGE_SIZE
 415
 416/* This was the only reasonable way I could think of to properly align
 417 * these page-table data structures.
 418 */
 419        .globl pg0, pg1, pg2, pg3
 420        .globl empty_bad_page
 421        .globl empty_bad_page_table
 422        .globl empty_zero_page
 423        .globl swapper_pg_dir
 424swapper_pg_dir:         .skip PAGE_SIZE
 425pg0:                    .skip PAGE_SIZE
 426pg1:                    .skip PAGE_SIZE
 427pg2:                    .skip PAGE_SIZE
 428pg3:                    .skip PAGE_SIZE
 429empty_bad_page:         .skip PAGE_SIZE
 430empty_bad_page_table:   .skip PAGE_SIZE
 431empty_zero_page:        .skip PAGE_SIZE
 432
 433        .global root_flags
 434        .global ram_flags
 435        .global root_dev
 436        .global sparc_ramdisk_image
 437        .global sparc_ramdisk_size
 438
 439/* This stuff has to be in sync with SILO and other potential boot loaders
 440 * Fields should be kept upward compatible and whenever any change is made,
 441 * HdrS version should be incremented.
 442 */
 443        .ascii  "HdrS"
 444        .word   LINUX_VERSION_CODE
 445        .half   0x0203          /* HdrS version */
 446root_flags:
 447        .half   1
 448root_dev:
 449        .half   0
 450ram_flags:
 451        .half   0
 452sparc_ramdisk_image:
 453        .word   0
 454sparc_ramdisk_size:
 455        .word   0
 456        .word   reboot_command
 457        .word   0, 0, 0
 458        .word   _end
 459
 460/* Cool, here we go. Pick up the romvec pointer in %o0 and stash it in
 461 * %g7 and at prom_vector_p. And also quickly check whether we are on
 462 * a v0, v2, or v3 prom.
 463 */
 464gokernel:
 465                /* Ok, it's nice to know, as early as possible, if we
 466                 * are already mapped where we expect to be in virtual
 467                 * memory.  The Solaris /boot elf format bootloader
 468                 * will peek into our elf header and load us where
 469                 * we want to be, otherwise we have to re-map.
 470                 *
 471                 * Some boot loaders don't place the jmp'rs address
 472                 * in %o7, so we do a pc-relative call to a local
 473                 * label, then see what %o7 has.
 474                 */
 475
 476                mov     %o7, %g4                ! Save %o7
 477
 478                /* Jump to it, and pray... */
 479current_pc:
 480                call    1f
 481                 nop
 482
 4831:
 484                mov     %o7, %g3
 485
 486                tst     %o0
 487                be      no_sun4u_here
 488                 mov    %g4, %o7                /* Previous %o7. */
 489        
 490                mov     %o0, %l0                ! stash away romvec
 491                mov     %o0, %g7                ! put it here too
 492                mov     %o1, %l1                ! stash away debug_vec too
 493
 494                /* Ok, let's check out our run time program counter. */
 495                set     current_pc, %g5
 496                cmp     %g3, %g5
 497                be      already_mapped
 498                 nop 
 499
 500                /* %l6 will hold the offset we have to subtract
 501                 * from absolute symbols in order to access areas
 502                 * in our own image.  If already mapped this is
 503                 * just plain zero, else it is KERNBASE.
 504                 */
 505                set     KERNBASE, %l6
 506                b       copy_prom_lvl14
 507                 nop
 508
 509already_mapped:
 510                mov     0, %l6
 511
 512                /* Copy over the Prom's level 14 clock handler. */
 513copy_prom_lvl14:
 514#if 1
 515                /* DJHR
 516                 * preserve our linked/calculated instructions
 517                 */
 518                set     lvl14_save, %g1
 519                set     t_irq14, %g3
 520                sub     %g1, %l6, %g1           ! translate to physical
 521                sub     %g3, %l6, %g3           ! translate to physical
 522                ldd     [%g3], %g4
 523                std     %g4, [%g1]
 524                ldd     [%g3+8], %g4
 525                std     %g4, [%g1+8]
 526#endif
 527                rd      %tbr, %g1
 528                andn    %g1, 0xfff, %g1         ! proms trap table base
 529                or      %g0, (0x1e<<4), %g2     ! offset to lvl14 intr
 530                or      %g1, %g2, %g2
 531                set     t_irq14, %g3
 532                sub     %g3, %l6, %g3
 533                ldd     [%g2], %g4
 534                std     %g4, [%g3]
 535                ldd     [%g2 + 0x8], %g4
 536                std     %g4, [%g3 + 0x8]        ! Copy proms handler
 537
 538/* Must determine whether we are on a sun4c MMU, SRMMU, or SUN4/400 MUTANT
 539 * MMU so we can remap ourselves properly.  DON'T TOUCH %l0 thru %l5 in these
 540 * remapping routines, we need their values afterwards!
 541 */
 542                /* Now check whether we are already mapped, if we
 543                 * are we can skip all this garbage coming up.
 544                 */
 545copy_prom_done:
 546                cmp     %l6, 0
 547                be      go_to_highmem           ! this will be a nop then
 548                 nop
 549
 550                set     LOAD_ADDR, %g6
 551                cmp     %g7, %g6
 552                bne     remap_not_a_sun4        ! This is not a Sun4
 553                 nop
 554
 555                or      %g0, 0x1, %g1
 556                lduba   [%g1] ASI_CONTROL, %g1  ! Only safe to try on Sun4.
 557                subcc   %g1, 0x24, %g0          ! Is this a mutant Sun4/400???
 558                be      sun4_mutant_remap       ! Ugh, it is...
 559                 nop
 560
 561                b       sun4_normal_remap       ! regular sun4, 2 level mmu
 562                 nop
 563
 564remap_not_a_sun4:
 565                lda     [%g0] ASI_M_MMUREGS, %g1 ! same as ASI_PTE on sun4c
 566                and     %g1, 0x1, %g1           ! Test SRMMU Enable bit ;-)
 567                cmp     %g1, 0x0
 568                be      sun4c_remap             ! A sun4c MMU or normal Sun4
 569                 nop
 570srmmu_remap:
 571                /* First, check for a viking (TI) module. */
 572                set     0x40000000, %g2
 573                rd      %psr, %g3
 574                and     %g2, %g3, %g3
 575                subcc   %g3, 0x0, %g0
 576                bz      srmmu_nviking
 577                 nop
 578
 579                /* Figure out what kind of viking we are on.
 580                 * We need to know if we have to play with the
 581                 * AC bit and disable traps or not.
 582                 */
 583
 584                /* I've only seen MicroSparc's on SparcClassics with this
 585                 * bit set.
 586                 */
 587                set     0x800, %g2
 588                lda     [%g0] ASI_M_MMUREGS, %g3        ! peek in the control reg
 589                and     %g2, %g3, %g3
 590                subcc   %g3, 0x0, %g0
 591                bnz     srmmu_nviking                   ! is in mbus mode
 592                 nop
 593                
 594                rd      %psr, %g3                       ! DO NOT TOUCH %g3
 595                andn    %g3, PSR_ET, %g2
 596                wr      %g2, 0x0, %psr
 597                WRITE_PAUSE
 598                
 599                /* Get context table pointer, then convert to
 600                 * a physical address, which is 36 bits.
 601                 */
 602                set     AC_M_CTPR, %g4
 603                lda     [%g4] ASI_M_MMUREGS, %g4
 604                sll     %g4, 0x4, %g4                   ! We use this below
 605                                                        ! DO NOT TOUCH %g4
 606
 607                /* Set the AC bit in the Viking's MMU control reg. */
 608                lda     [%g0] ASI_M_MMUREGS, %g5        ! DO NOT TOUCH %g5
 609                set     0x8000, %g6                     ! AC bit mask
 610                or      %g5, %g6, %g6                   ! Or it in...
 611                sta     %g6, [%g0] ASI_M_MMUREGS        ! Close your eyes...
 612
 613                /* Grrr, why does it seem like every other load/store
 614                 * on the sun4m is in some ASI space...
 615                 * Fine with me, let's get the pointer to the level 1
 616                 * page table directory and fetch its entry.
 617                 */
 618                lda     [%g4] ASI_M_BYPASS, %o1         ! This is a level 1 ptr
 619                srl     %o1, 0x4, %o1                   ! Clear low 4 bits
 620                sll     %o1, 0x8, %o1                   ! Make physical
 621                
 622                /* Ok, pull in the PTD. */
 623                lda     [%o1] ASI_M_BYPASS, %o2         ! This is the 0x0 16MB pgd
 624
 625                /* Calculate to KERNBASE entry. */
 626                add     %o1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %o3           
 627
 628                /* Poke the entry into the calculated address. */
 629                sta     %o2, [%o3] ASI_M_BYPASS
 630
 631                /* I don't get it Sun, if you engineered all these
 632                 * boot loaders and the PROM (thank you for the debugging
 633                 * features btw) why did you not have them load kernel
 634                 * images up in high address space, since this is necessary
 635                 * for ABI compliance anyways?  Does this low-mapping provide
 636                 * enhanced interoperability?
 637                 *
 638                 * "The PROM is the computer."
 639                 */
 640
 641                /* Ok, restore the MMU control register we saved in %g5 */
 642                sta     %g5, [%g0] ASI_M_MMUREGS        ! POW... ouch
 643
 644                /* Turn traps back on.  We saved it in %g3 earlier. */
 645                wr      %g3, 0x0, %psr                  ! tick tock, tick tock
 646
 647                /* Now we burn precious CPU cycles due to bad engineering. */
 648                WRITE_PAUSE
 649
 650                /* Wow, all that just to move a 32-bit value from one
 651                 * place to another...  Jump to high memory.
 652                 */
 653                b       go_to_highmem
 654                 nop
 655
 656                /* This works on viking's in Mbus mode and all
 657                 * other MBUS modules.  It is virtually the same as
 658                 * the above madness sans turning traps off and flipping
 659                 * the AC bit.
 660                 */
 661srmmu_nviking:
 662                set     AC_M_CTPR, %g1
 663                lda     [%g1] ASI_M_MMUREGS, %g1        ! get ctx table ptr
 664                sll     %g1, 0x4, %g1                   ! make physical addr
 665                lda     [%g1] ASI_M_BYPASS, %g1         ! ptr to level 1 pg_table
 666                srl     %g1, 0x4, %g1
 667                sll     %g1, 0x8, %g1                   ! make phys addr for l1 tbl
 668
 669                lda     [%g1] ASI_M_BYPASS, %g2         ! get level1 entry for 0x0
 670                add     %g1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %g3
 671                sta     %g2, [%g3] ASI_M_BYPASS         ! place at KERNBASE entry
 672                b       go_to_highmem
 673                 nop                                    ! wheee....
 674
 675                /* This remaps the kernel on Sun4/4xx machines
 676                 * that have the Sun Mutant Three Level MMU.
 677                 * It's like a platypus, Sun didn't have the
 678                 * SRMMU in conception so they kludged the three
 679                 * level logic in the regular Sun4 MMU probably.
 680                 *
 681                 * Basically, you take each entry in the top level
 682                 * directory that maps the low 3MB starting at
 683                 * address zero and put the mapping in the KERNBASE
 684                 * slots.  These top level pgd's are called regmaps.
 685                 */
 686sun4_mutant_remap:
 687                or      %g0, %g0, %g3           ! source base
 688                sethi   %hi(KERNBASE), %g4      ! destination base
 689                or      %g4, %lo(KERNBASE), %g4
 690                sethi   %hi(0x300000), %g5
 691                or      %g5, %lo(0x300000), %g5 ! upper bound 3MB
 692                or      %g0, 0x1, %l6
 693                sll     %l6, 24, %l6            ! Regmap mapping size
 694                add     %g3, 0x2, %g3           ! Base magic
 695                add     %g4, 0x2, %g4           ! Base magic
 696
 697                /* Main remapping loop on Sun4-Mutant-MMU.
 698                 * "I am not an animal..." -Famous Mutant Person
 699                 */
 700sun4_mutant_loop:
 701                lduha   [%g3] ASI_REGMAP, %g2   ! Get lower entry
 702                stha    %g2, [%g4] ASI_REGMAP   ! Store in high entry
 703                add     %g4, %l6, %g4           ! Move up high memory ptr
 704                subcc   %g3, %g5, %g0           ! Reached our limit?
 705                blu     sun4_mutant_loop        ! Nope, loop again
 706                 add    %g3, %l6, %g3           ! delay, Move up low ptr
 707                b       go_to_highmem           ! Jump to high memory.
 708                 nop
 709
 710                /* The following is for non-4/4xx sun4 MMU's. */
 711sun4_normal_remap:
 712                mov     0, %g3                  ! source base
 713                set     KERNBASE, %g4           ! destination base
 714                set     0x300000, %g5           ! upper bound 3MB
 715                mov     1, %l6
 716                sll     %l6, 18, %l6            ! sun4 mmu segmap size
 717sun4_normal_loop:
 718                lduha   [%g3] ASI_SEGMAP, %g6   ! load phys_seg
 719                stha    %g6, [%g4] ASI_SEGMAP   ! stort new virt mapping
 720                add     %g3, %l6, %g3           ! increment source pointer
 721                subcc   %g3, %g5, %g0           ! reached limit?
 722                blu     sun4_normal_loop        ! nope, loop again
 723                 add    %g4, %l6, %g4           ! delay, increment dest ptr
 724                b       go_to_highmem
 725                 nop
 726
 727                /* The following works for Sun4c MMU's */
 728sun4c_remap:
 729                mov     0, %g3                  ! source base
 730                set     KERNBASE, %g4           ! destination base
 731                set     0x300000, %g5           ! upper bound 3MB
 732                mov     1, %l6
 733                sll     %l6, 18, %l6            ! sun4c mmu segmap size
 734sun4c_remap_loop:
 735                lda     [%g3] ASI_SEGMAP, %g6   ! load phys_seg
 736                sta     %g6, [%g4] ASI_SEGMAP   ! store new virt mapping
 737                add     %g3, %l6, %g3           ! Increment source ptr
 738                subcc   %g3, %g5, %g0           ! Reached limit?
 739                bl      sun4c_remap_loop        ! Nope, loop again
 740                 add    %g4, %l6, %g4           ! delay, Increment dest ptr
 741
 742/* Now do a non-relative jump so that PC is in high-memory */
 743go_to_highmem:
 744                set     execute_in_high_mem, %g1
 745                jmpl    %g1, %g0
 746                 nop
 747
 748/* The code above should be at beginning and we have to take care about
 749 * short jumps, as branching to .text.init section from .text is usually
 750 * impossible */
 751                __INIT
 752/* Acquire boot time privileged register values, this will help debugging.
 753 * I figure out and store nwindows and nwindowsm1 later on.
 754 */
 755execute_in_high_mem:
 756                mov     %l0, %o0                ! put back romvec
 757                mov     %l1, %o1                ! and debug_vec
 758
 759                sethi   %hi(prom_vector_p), %g1
 760                st      %o0, [%g1 + %lo(prom_vector_p)]
 761
 762                sethi   %hi(linux_dbvec), %g1
 763                st      %o1, [%g1 + %lo(linux_dbvec)]
 764
 765                ld      [%o0 + 0x4], %o3
 766                and     %o3, 0x3, %o5                   ! get the version
 767
 768                cmp     %o3, 0x2                        ! a v2 prom?
 769                be      found_version
 770                 nop
 771
 772                /* paul@sfe.com.au */
 773                cmp     %o3, 0x3                        ! a v3 prom?
 774                be      found_version
 775                 nop
 776
 777/* Old sun4's pass our load address into %o0 instead of the prom
 778 * pointer. On sun4's you have to hard code the romvec pointer into
 779 * your code. Sun probably still does that because they don't even
 780 * trust their own "OpenBoot" specifications.
 781 */
 782                set     LOAD_ADDR, %g6
 783                cmp     %o0, %g6                ! an old sun4?
 784                be      sun4_init
 785                 nop
 786
 787found_version:
 788#ifdef CONFIG_SUN4
 789/* For people who try sun4 kernels, even if Configure.help advises them. */
 790                ld      [%g7 + 0x68], %o1
 791                set     sun4cdm_notsup, %o0
 792                call    %o1
 793                 nop
 794                b       halt_me
 795                 nop
 796#endif
 797/* Get the machine type via the mysterious romvec node operations. */
 798
 799                add     %g7, 0x1c, %l1          
 800                ld      [%l1], %l0
 801                ld      [%l0], %l0
 802                call    %l0
 803                 or     %g0, %g0, %o0           ! next_node(0) = first_node
 804                or      %o0, %g0, %g6
 805
 806                sethi   %hi(cputypvar), %o1     ! First node has cpu-arch
 807                or      %o1, %lo(cputypvar), %o1
 808                sethi   %hi(cputypval), %o2     ! information, the string
 809                or      %o2, %lo(cputypval), %o2
 810                ld      [%l1], %l0              ! 'compatibility' tells
 811                ld      [%l0 + 0xc], %l0        ! that we want 'sun4x' where
 812                call    %l0                     ! x is one of '', 'c', 'm',
 813                 nop                            ! 'd' or 'e'. %o2 holds pointer
 814                                                ! to a buf where above string
 815                                                ! will get stored by the prom.
 816
 817                subcc   %o0, %g0, %g0
 818                bpos    got_prop                ! Got the property
 819                 nop
 820
 821                or      %g6, %g0, %o0
 822                sethi   %hi(cputypvar_sun4m), %o1
 823                or      %o1, %lo(cputypvar_sun4m), %o1
 824                sethi   %hi(cputypval), %o2
 825                or      %o2, %lo(cputypval), %o2
 826                ld      [%l1], %l0
 827                ld      [%l0 + 0xc], %l0
 828                call    %l0
 829                 nop
 830
 831got_prop:
 832                set     cputypval, %o2
 833                ldub    [%o2 + 0x4], %l1
 834
 835                cmp     %l1, ' '
 836                be      1f
 837                 cmp    %l1, 'c'
 838                be      1f
 839                 cmp    %l1, 'm'
 840                be      1f
 841                 cmp    %l1, 's'
 842                be      1f
 843                 cmp    %l1, 'd'
 844                be      1f
 845                 cmp    %l1, 'e'
 846                be      no_sun4e_here           ! Could be a sun4e.
 847                 nop
 848                b       no_sun4u_here           ! AIEEE, a V9 sun4u... Get our BIG BROTHER kernel :))
 849                 nop
 850
 8511:              set     cputypval, %l1
 852                ldub    [%l1 + 0x4], %l1
 853                cmp     %l1, 'm'                ! Test for sun4d, sun4e ?
 854                be      sun4m_init
 855                 cmp    %l1, 's'                ! Treat sun4s as sun4m
 856                be      sun4m_init
 857                 cmp    %l1, 'd'                ! Let us see how the beast will die
 858                be      sun4d_init
 859                 nop
 860
 861                /* Jump into mmu context zero. */
 862                set     AC_CONTEXT, %g1
 863                stba    %g0, [%g1] ASI_CONTROL
 864
 865                b       sun4c_continue_boot
 866                 nop
 867
 868/* CPUID in bootbus can be found at PA 0xff0140000 */
 869#define SUN4D_BOOTBUS_CPUID     0xf0140000
 870
 871sun4d_init:
 872        /* Need to patch call to handler_irq */
 873        set     patch_handler_irq, %g4
 874        set     sun4d_handler_irq, %g5
 875        sethi   %hi(0x40000000), %g3            ! call
 876        sub     %g5, %g4, %g5
 877        srl     %g5, 2, %g5
 878        or      %g5, %g3, %g5
 879        st      %g5, [%g4]
 880
 881#ifdef CONFIG_SMP
 882        /* Get our CPU id out of bootbus */
 883        set     SUN4D_BOOTBUS_CPUID, %g3
 884        lduba   [%g3] ASI_M_CTL, %g3
 885        and     %g3, 0xf8, %g3
 886        srl     %g3, 3, %g4
 887        sta     %g4, [%g0] ASI_M_VIKING_TMP1
 888        sethi   %hi(boot_cpu_id), %g5
 889        stb     %g4, [%g5 + %lo(boot_cpu_id)]
 890        sll     %g4, 2, %g4
 891        sethi   %hi(boot_cpu_id4), %g5
 892        stb     %g4, [%g5 + %lo(boot_cpu_id4)]
 893#endif
 894
 895        /* Fall through to sun4m_init */
 896
 897sun4m_init:
 898        /* XXX Fucking Cypress... */
 899        lda     [%g0] ASI_M_MMUREGS, %g5
 900        srl     %g5, 28, %g4
 901
 902        cmp     %g4, 1
 903        bne     1f
 904         srl    %g5, 24, %g4
 905
 906        and     %g4, 0xf, %g4
 907        cmp     %g4, 7          /* This would be a HyperSparc. */
 908
 909        bne     2f
 910         nop
 911
 9121:
 913
 914#define PATCH_IT(dst, src)      \
 915        set     (dst), %g5;     \
 916        set     (src), %g4;     \
 917        ld      [%g4], %g3;     \
 918        st      %g3, [%g5];     \
 919        ld      [%g4+0x4], %g3; \
 920        st      %g3, [%g5+0x4];
 921
 922        /* Signed multiply. */
 923        PATCH_IT(.mul, .mul_patch)
 924        PATCH_IT(.mul+0x08, .mul_patch+0x08)
 925
 926        /* Signed remainder. */
 927        PATCH_IT(.rem, .rem_patch)
 928        PATCH_IT(.rem+0x08, .rem_patch+0x08)
 929        PATCH_IT(.rem+0x10, .rem_patch+0x10)
 930        PATCH_IT(.rem+0x18, .rem_patch+0x18)
 931        PATCH_IT(.rem+0x20, .rem_patch+0x20)
 932        PATCH_IT(.rem+0x28, .rem_patch+0x28)
 933
 934        /* Signed division. */
 935        PATCH_IT(.div, .div_patch)
 936        PATCH_IT(.div+0x08, .div_patch+0x08)
 937        PATCH_IT(.div+0x10, .div_patch+0x10)
 938        PATCH_IT(.div+0x18, .div_patch+0x18)
 939        PATCH_IT(.div+0x20, .div_patch+0x20)
 940
 941        /* Unsigned multiply. */
 942        PATCH_IT(.umul, .umul_patch)
 943        PATCH_IT(.umul+0x08, .umul_patch+0x08)
 944
 945        /* Unsigned remainder. */
 946        PATCH_IT(.urem, .urem_patch)
 947        PATCH_IT(.urem+0x08, .urem_patch+0x08)
 948        PATCH_IT(.urem+0x10, .urem_patch+0x10)
 949        PATCH_IT(.urem+0x18, .urem_patch+0x18)
 950
 951        /* Unsigned division. */
 952        PATCH_IT(.udiv, .udiv_patch)
 953        PATCH_IT(.udiv+0x08, .udiv_patch+0x08)
 954        PATCH_IT(.udiv+0x10, .udiv_patch+0x10)
 955
 956#undef PATCH_IT
 957
 958/* Ok, the PROM could have done funny things and apple cider could still
 959 * be sitting in the fault status/address registers.  Read them all to
 960 * clear them so we don't get magic faults later on.
 961 */
 962/* This sucks, apparently this makes Vikings call prom panic, will fix later */
 9632:
 964                rd      %psr, %o1
 965                srl     %o1, 28, %o1            ! Get a type of the CPU
 966
 967                subcc   %o1, 4, %g0             ! TI: Viking or MicroSPARC
 968                be      sun4c_continue_boot
 969                 nop
 970
 971                set     AC_M_SFSR, %o0
 972                lda     [%o0] ASI_M_MMUREGS, %g0
 973                set     AC_M_SFAR, %o0
 974                lda     [%o0] ASI_M_MMUREGS, %g0
 975
 976                /* Fujitsu MicroSPARC-II has no asynchronous flavors of FARs */
 977                subcc   %o1, 0, %g0
 978                be      sun4c_continue_boot
 979                 nop
 980
 981                set     AC_M_AFSR, %o0
 982                lda     [%o0] ASI_M_MMUREGS, %g0
 983                set     AC_M_AFAR, %o0
 984                lda     [%o0] ASI_M_MMUREGS, %g0
 985                 nop
 986
 987
 988sun4c_continue_boot:
 989
 990
 991/* Aieee, now set PC and nPC, enable traps, give ourselves a stack and it's
 992 * show-time!
 993 */
 994
 995                sethi   %hi(cputyp), %o0
 996                st      %g4, [%o0 + %lo(cputyp)]
 997
 998                /* Turn on Supervisor, EnableFloating, and all the PIL bits.
 999                 * Also puts us in register window zero with traps off.
1000                 */
1001                set     (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
1002                wr      %g2, 0x0, %psr
1003                WRITE_PAUSE
1004
1005                /* I want a kernel stack NOW! */
1006                set     init_thread_union, %g1
1007                set     (THREAD_SIZE - STACKFRAME_SZ), %g2
1008                add     %g1, %g2, %sp
1009                mov     0, %fp                  /* And for good luck */
1010
1011                /* Zero out our BSS section. */
1012                set     __bss_start , %o0       ! First address of BSS
1013                set     end , %o1               ! Last address of BSS
1014                add     %o0, 0x1, %o0
10151:      
1016                stb     %g0, [%o0]
1017                subcc   %o0, %o1, %g0
1018                bl      1b
1019                 add    %o0, 0x1, %o0
1020
1021                /* Initialize the uwinmask value for init task just in case.
1022                 * But first make current_set[boot_cpu_id] point to something useful.
1023                 */
1024                set     init_thread_union, %g6
1025                set     current_set, %g2
1026#ifdef CONFIG_SMP
1027                sethi   %hi(boot_cpu_id4), %g3
1028                ldub    [%g3 + %lo(boot_cpu_id4)], %g3
1029                st      %g6, [%g2]
1030                add     %g2, %g3, %g2
1031#endif
1032                st      %g6, [%g2]
1033
1034                st      %g0, [%g6 + TI_UWINMASK]
1035
1036/* Compute NWINDOWS and stash it away. Now uses %wim trick explained
1037 * in the V8 manual. Ok, this method seems to work, Sparc is cool...
1038 * No, it doesn't work, have to play the save/readCWP/restore trick.
1039 */
1040
1041                wr      %g0, 0x0, %wim                  ! so we do not get a trap
1042                WRITE_PAUSE
1043
1044                save
1045
1046                rd      %psr, %g3
1047
1048                restore
1049
1050                and     %g3, 0x1f, %g3
1051                add     %g3, 0x1, %g3
1052
1053                mov     2, %g1
1054                wr      %g1, 0x0, %wim                  ! make window 1 invalid
1055                WRITE_PAUSE
1056
1057                cmp     %g3, 0x7
1058                bne     2f
1059                 nop
1060
1061                /* Adjust our window handling routines to
1062                 * do things correctly on 7 window Sparcs.
1063                 */
1064
1065#define         PATCH_INSN(src, dest) \
1066                set     src, %g5; \
1067                set     dest, %g2; \
1068                ld      [%g5], %g4; \
1069                st      %g4, [%g2];
1070        
1071                /* Patch for window spills... */
1072                PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
1073                PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
1074                PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
1075
1076                /* Patch for window fills... */
1077                PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
1078                PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
1079
1080                /* Patch for trap entry setup... */
1081                PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
1082                PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
1083                PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
1084                PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
1085                PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
1086                PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
1087
1088                /* Patch for returning from traps... */
1089                PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
1090                PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
1091                PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
1092                PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
1093                PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
1094
1095                /* Patch for killing user windows from the register file. */
1096                PATCH_INSN(kuw_patch1_7win, kuw_patch1)
1097
1098                /* Now patch the kernel window flush sequences.
1099                 * This saves 2 traps on every switch and fork.
1100                 */
1101                set     0x01000000, %g4
1102                set     flush_patch_one, %g5
1103                st      %g4, [%g5 + 0x18]
1104                st      %g4, [%g5 + 0x1c]
1105                set     flush_patch_two, %g5
1106                st      %g4, [%g5 + 0x18]
1107                st      %g4, [%g5 + 0x1c]
1108                set     flush_patch_three, %g5
1109                st      %g4, [%g5 + 0x18]
1110                st      %g4, [%g5 + 0x1c]
1111                set     flush_patch_four, %g5
1112                st      %g4, [%g5 + 0x18]
1113                st      %g4, [%g5 + 0x1c]
1114                set     flush_patch_exception, %g5
1115                st      %g4, [%g5 + 0x18]
1116                st      %g4, [%g5 + 0x1c]
1117                set     flush_patch_switch, %g5
1118                st      %g4, [%g5 + 0x18]
1119                st      %g4, [%g5 + 0x1c]
1120
11212:              
1122                sethi   %hi(nwindows), %g4
1123                st      %g3, [%g4 + %lo(nwindows)]      ! store final value
1124                sub     %g3, 0x1, %g3
1125                sethi   %hi(nwindowsm1), %g4
1126                st      %g3, [%g4 + %lo(nwindowsm1)]
1127
1128                /* Here we go, start using Linux's trap table... */
1129                set     trapbase, %g3
1130                wr      %g3, 0x0, %tbr
1131                WRITE_PAUSE
1132
1133                /* Finally, turn on traps so that we can call c-code. */
1134                rd      %psr, %g3
1135                wr      %g3, 0x0, %psr
1136                WRITE_PAUSE
1137
1138                wr      %g3, PSR_ET, %psr
1139                WRITE_PAUSE
1140
1141                /* First we call prom_init() to set up PROMLIB, then
1142                 * off to start_kernel().
1143                 */
1144
1145                sethi   %hi(prom_vector_p), %g5
1146                ld      [%g5 + %lo(prom_vector_p)], %o0
1147                call    prom_init
1148                 nop
1149
1150                call    start_kernel
1151                 nop
1152        
1153                /* We should not get here. */
1154                call    halt_me
1155                 nop
1156
1157sun4_init:
1158#ifdef CONFIG_SUN4
1159/* There, happy now Adrian? */
1160                set     cputypval, %o2          ! Let everyone know we
1161                set     ' ', %o0                        ! are a "sun4 " architecture
1162                stb     %o0, [%o2 + 0x4]                
1163
1164                b got_prop 
1165                 nop
1166#else
1167                sethi   %hi(SUN4_PROM_VECTOR+0x84), %o1
1168                ld      [%o1 + %lo(SUN4_PROM_VECTOR+0x84)], %o1
1169                set     sun4_notsup, %o0
1170                call    %o1     /* printf */
1171                 nop
1172                sethi   %hi(SUN4_PROM_VECTOR+0xc4), %o1
1173                ld      [%o1 + %lo(SUN4_PROM_VECTOR+0xc4)], %o1
1174                call    %o1     /* exittomon */
1175                 nop
11761:              ba      1b                      ! Cannot exit into KMON
1177                 nop
1178#endif
1179no_sun4e_here:
1180                ld      [%g7 + 0x68], %o1
1181                set     sun4e_notsup, %o0
1182                call    %o1
1183                 nop
1184                b       halt_me
1185                 nop
1186
1187                __INITDATA
1188
1189sun4u_1:
1190                .asciz "finddevice"
1191                .align  4
1192sun4u_2:
1193                .asciz "/chosen"
1194                .align  4
1195sun4u_3:
1196                .asciz "getprop"
1197                .align  4
1198sun4u_4:
1199                .asciz "stdout"
1200                .align  4
1201sun4u_5:
1202                .asciz "write"
1203                .align  4
1204sun4u_6:
1205                .asciz  "\n\rOn sun4u you have to use UltraLinux (64bit) kernel\n\rand not a 32bit sun4[cdem] version\n\r\n\r"
1206sun4u_6e:
1207                .align  4
1208sun4u_7:
1209                .asciz "exit"
1210                .align  8
1211sun4u_a1:
1212                .word   0, sun4u_1, 0, 1, 0, 1, 0, sun4u_2, 0
1213sun4u_r1:
1214                .word   0
1215sun4u_a2:
1216                .word   0, sun4u_3, 0, 4, 0, 1, 0
1217sun4u_i2:
1218                .word   0, 0, sun4u_4, 0, sun4u_1, 0, 8, 0
1219sun4u_r2:
1220                .word   0
1221sun4u_a3:
1222                .word   0, sun4u_5, 0, 3, 0, 1, 0
1223sun4u_i3:
1224                .word   0, 0, sun4u_6, 0, sun4u_6e - sun4u_6 - 1, 0
1225sun4u_r3:
1226                .word   0
1227sun4u_a4:
1228                .word   0, sun4u_7, 0, 0, 0, 0
1229sun4u_r4:
1230
1231                __INIT
1232no_sun4u_here:
1233                set     sun4u_a1, %o0
1234                set     current_pc, %l2
1235                cmp     %l2, %g3
1236                be      1f
1237                 mov    %o4, %l0
1238                sub     %g3, %l2, %l6
1239                add     %o0, %l6, %o0
1240                mov     %o0, %l4
1241                mov     sun4u_r4 - sun4u_a1, %l3
1242                ld      [%l4], %l5
12432:
1244                add     %l4, 4, %l4
1245                cmp     %l5, %l2
1246                add     %l5, %l6, %l5
1247                bgeu,a  3f
1248                 st     %l5, [%l4 - 4]
12493:
1250                subcc   %l3, 4, %l3
1251                bne     2b
1252                 ld     [%l4], %l5
12531:
1254                call    %l0
1255                 mov    %o0, %l1
1256
1257                ld      [%l1 + (sun4u_r1 - sun4u_a1)], %o1
1258                add     %l1, (sun4u_a2 - sun4u_a1), %o0
1259                call    %l0
1260                 st     %o1, [%o0 + (sun4u_i2 - sun4u_a2)]
1261
1262                ld      [%l1 + (sun4u_1 - sun4u_a1)], %o1
1263                add     %l1, (sun4u_a3 - sun4u_a1), %o0
1264                call    %l0
1265                st      %o1, [%o0 + (sun4u_i3 - sun4u_a3)]
1266
1267                call    %l0
1268                 add    %l1, (sun4u_a4 - sun4u_a1), %o0
1269
1270                /* Not reached */
1271halt_me:
1272                ld      [%g7 + 0x74], %o0
1273                call    %o0                     ! Get us out of here...
1274                 nop                            ! Apparently Solaris is better.
1275
1276/* Ok, now we continue in the .data/.text sections */
1277
1278        .data
1279        .align 4
1280
1281/*
1282 * Fill up the prom vector, note in particular the kind first element,
1283 * no joke. I don't need all of them in here as the entire prom vector
1284 * gets initialized in c-code so all routines can use it.
1285 */
1286
1287        .globl  prom_vector_p
1288prom_vector_p:
1289                .word 0
1290
1291/* We calculate the following at boot time, window fills/spills and trap entry
1292 * code uses these to keep track of the register windows.
1293 */
1294
1295        .align 4
1296        .globl  nwindows
1297        .globl  nwindowsm1
1298nwindows:
1299        .word   8
1300nwindowsm1:
1301        .word   7
1302
1303/* Boot time debugger vector value.  We need this later on. */
1304
1305        .align 4
1306        .globl  linux_dbvec
1307linux_dbvec:
1308        .word   0
1309        .word   0
1310
1311        .align 8
1312
1313        .globl  lvl14_save
1314lvl14_save:
1315        .word   0
1316        .word   0
1317        .word   0
1318        .word   0
1319        .word   t_irq14
1320
1321        .section        ".fixup",#alloc,#execinstr
1322        .globl  __ret_efault
1323__ret_efault:
1324        ret
1325         restore %g0, -EFAULT, %o0
1326