0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/kernel.h>
0012 #include <linux/slab.h>
0013 #include <linux/string.h>
0014 #include <generated/utsrelease.h>
0015 #include <linux/mm.h>
0016
0017 #include <asm/console.h>
0018 #include <asm/hwrpb.h>
0019 #include <asm/io.h>
0020
0021 #include <stdarg.h>
0022
0023 #include "ksize.h"
0024
0025 extern unsigned long switch_to_osf_pal(unsigned long nr,
0026 struct pcb_struct *pcb_va, struct pcb_struct *pcb_pa,
0027 unsigned long *vptb);
0028
0029 extern void move_stack(unsigned long new_stack);
0030
0031 struct hwrpb_struct *hwrpb = INIT_HWRPB;
0032 static struct pcb_struct pcb_va[1];
0033
0034
0035
0036
0037
0038
0039
0040 static inline void *
0041 find_pa(unsigned long *vptb, void *ptr)
0042 {
0043 unsigned long address = (unsigned long) ptr;
0044 unsigned long result;
0045
0046 result = vptb[address >> 13];
0047 result >>= 32;
0048 result <<= 13;
0049 result |= address & 0x1fff;
0050 return (void *) result;
0051 }
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 #define VPTB ((unsigned long *) 0x200000000)
0065 #define L1 ((unsigned long *) 0x200802000)
0066
0067 void
0068 pal_init(void)
0069 {
0070 unsigned long i, rev;
0071 struct percpu_struct * percpu;
0072 struct pcb_struct * pcb_pa;
0073
0074
0075 pcb_va->ksp = 0;
0076 pcb_va->usp = 0;
0077 pcb_va->ptbr = L1[1] >> 32;
0078 pcb_va->asn = 0;
0079 pcb_va->pcc = 0;
0080 pcb_va->unique = 0;
0081 pcb_va->flags = 1;
0082 pcb_va->res1 = 0;
0083 pcb_va->res2 = 0;
0084 pcb_pa = find_pa(VPTB, pcb_va);
0085
0086
0087
0088
0089
0090
0091
0092
0093 srm_printk("Switching to OSF PAL-code .. ");
0094
0095 i = switch_to_osf_pal(2, pcb_va, pcb_pa, VPTB);
0096 if (i) {
0097 srm_printk("failed, code %ld\n", i);
0098 __halt();
0099 }
0100
0101 percpu = (struct percpu_struct *)
0102 (INIT_HWRPB->processor_offset + (unsigned long) INIT_HWRPB);
0103 rev = percpu->pal_revision = percpu->palcode_avail[2];
0104
0105 srm_printk("Ok (rev %lx)\n", rev);
0106
0107 tbia();
0108 }
0109
0110 static inline void
0111 load(unsigned long dst, unsigned long src, unsigned long count)
0112 {
0113 memcpy((void *)dst, (void *)src, count);
0114 }
0115
0116
0117
0118
0119 static inline void
0120 runkernel(void)
0121 {
0122 __asm__ __volatile__(
0123 "bis %0,%0,$27\n\t"
0124 "jmp ($27)"
0125 :
0126 : "r" (START_ADDR));
0127 }
0128
0129 extern char _end;
0130 #define KERNEL_ORIGIN \
0131 ((((unsigned long)&_end) + 511) & ~511)
0132
0133 void
0134 start_kernel(void)
0135 {
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 static long nbytes;
0149 static char envval[256] __attribute__((aligned(8)));
0150 static unsigned long initrd_start;
0151
0152 srm_printk("Linux/AXP bootp loader for Linux " UTS_RELEASE "\n");
0153 if (INIT_HWRPB->pagesize != 8192) {
0154 srm_printk("Expected 8kB pages, got %ldkB\n",
0155 INIT_HWRPB->pagesize >> 10);
0156 return;
0157 }
0158 if (INIT_HWRPB->vptb != (unsigned long) VPTB) {
0159 srm_printk("Expected vptb at %p, got %p\n",
0160 VPTB, (void *)INIT_HWRPB->vptb);
0161 return;
0162 }
0163 pal_init();
0164
0165
0166
0167 initrd_start = ((START_ADDR + 5*KERNEL_SIZE + PAGE_SIZE) |
0168 (PAGE_SIZE-1)) + 1;
0169 #ifdef INITRD_IMAGE_SIZE
0170 srm_printk("Initrd positioned at %#lx\n", initrd_start);
0171 #endif
0172
0173
0174
0175
0176
0177 move_stack(initrd_start - PAGE_SIZE);
0178
0179 nbytes = callback_getenv(ENV_BOOTED_OSFLAGS, envval, sizeof(envval));
0180 if (nbytes < 0 || nbytes >= sizeof(envval)) {
0181 nbytes = 0;
0182 }
0183 envval[nbytes] = '\0';
0184 srm_printk("Loading the kernel...'%s'\n", envval);
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200 #ifdef INITRD_IMAGE_SIZE
0201 load(initrd_start, KERNEL_ORIGIN+KERNEL_SIZE, INITRD_IMAGE_SIZE);
0202 #endif
0203 load(START_ADDR+(4*KERNEL_SIZE), KERNEL_ORIGIN, KERNEL_SIZE);
0204 load(START_ADDR, START_ADDR+(4*KERNEL_SIZE), KERNEL_SIZE);
0205
0206 memset((char*)ZERO_PGE, 0, PAGE_SIZE);
0207 strcpy((char*)ZERO_PGE, envval);
0208 #ifdef INITRD_IMAGE_SIZE
0209 ((long *)(ZERO_PGE+256))[0] = initrd_start;
0210 ((long *)(ZERO_PGE+256))[1] = INITRD_IMAGE_SIZE;
0211 #endif
0212
0213 runkernel();
0214 }