2 * arch/alpha/boot/main.c
4 * Copyright (C) 1994, 1995 Linus Torvalds
6 * This file is the bootloader for the Linux/AXP kernel
8 #include <linux/kernel.h>
9 #include <linux/slab.h>
10 #include <linux/string.h>
11 #include <generated/utsrelease.h>
14 #include <asm/console.h>
15 #include <asm/hwrpb.h>
16 #include <asm/pgtable.h>
22 extern unsigned long switch_to_osf_pal(unsigned long nr
,
23 struct pcb_struct
* pcb_va
, struct pcb_struct
* pcb_pa
,
25 struct hwrpb_struct
*hwrpb
= INIT_HWRPB
;
26 static struct pcb_struct pcb_va
[1];
29 * Find a physical address of a virtual object..
31 * This is easy using the virtual page table address.
35 find_pa(unsigned long *vptb
, void *ptr
)
37 unsigned long address
= (unsigned long) ptr
;
40 result
= vptb
[address
>> 13];
43 result
|= address
& 0x1fff;
44 return (void *) result
;
48 * This function moves into OSF/1 pal-code, and has a temporary
49 * PCB for that. The kernel proper should replace this PCB with
50 * the real one as soon as possible.
52 * The page table muckery in here depends on the fact that the boot
53 * code has the L1 page table identity-map itself in the second PTE
54 * in the L1 page table. Thus the L1-page is virtually addressable
55 * itself (through three levels) at virtual address 0x200802000.
58 #define VPTB ((unsigned long *) 0x200000000)
59 #define L1 ((unsigned long *) 0x200802000)
65 struct percpu_struct
* percpu
;
66 struct pcb_struct
* pcb_pa
;
68 /* Create the dummy PCB. */
71 pcb_va
->ptbr
= L1
[1] >> 32;
78 pcb_pa
= find_pa(VPTB
, pcb_va
);
82 * a1 = return address, but we give the asm the vaddr of the PCB
83 * a2 = physical addr of PCB
84 * a3 = new virtual page table pointer
85 * a4 = KSP (but the asm sets it)
87 srm_printk("Switching to OSF PAL-code .. ");
89 i
= switch_to_osf_pal(2, pcb_va
, pcb_pa
, VPTB
);
91 srm_printk("failed, code %ld\n", i
);
95 percpu
= (struct percpu_struct
*)
96 (INIT_HWRPB
->processor_offset
+ (unsigned long) INIT_HWRPB
);
97 rev
= percpu
->pal_revision
= percpu
->palcode_avail
[2];
99 srm_printk("Ok (rev %lx)\n", rev
);
101 tbia(); /* do it directly in case we are SMP */
104 static inline long openboot(void)
109 result
= callback_getenv(ENV_BOOTED_DEV
, bootdev
, 255);
112 return callback_open(bootdev
, result
& 255);
115 static inline long close(long dev
)
117 return callback_close(dev
);
120 static inline long load(long dev
, unsigned long addr
, unsigned long count
)
124 long result
, boot_size
= &_end
- (char *) BOOT_ADDR
;
126 result
= callback_getenv(ENV_BOOTED_FILE
, bootfile
, 255);
130 bootfile
[result
] = '\0';
132 srm_printk("Boot file specification (%s) not implemented\n",
134 return callback_read(dev
, count
, (void *)addr
, boot_size
/512 + 1);
140 static void runkernel(void)
142 __asm__
__volatile__(
146 : /* no outputs: it doesn't even return */
148 "r" (PAGE_SIZE
+ INIT_STACK
));
151 void start_kernel(void)
158 srm_printk("Linux/AXP bootloader for Linux " UTS_RELEASE
"\n");
159 if (INIT_HWRPB
->pagesize
!= 8192) {
160 srm_printk("Expected 8kB pages, got %ldkB\n", INIT_HWRPB
->pagesize
>> 10);
166 srm_printk("Unable to open boot device: %016lx\n", dev
);
170 srm_printk("Loading vmlinux ...");
171 i
= load(dev
, START_ADDR
, KERNEL_SIZE
);
173 if (i
!= KERNEL_SIZE
) {
174 srm_printk("Failed (%lx)\n", i
);
178 nbytes
= callback_getenv(ENV_BOOTED_OSFLAGS
, envval
, sizeof(envval
));
182 envval
[nbytes
] = '\0';
183 strcpy((char*)ZERO_PGE
, envval
);
185 srm_printk(" Ok\nNow booting the kernel\n");
187 for (i
= 0 ; i
< 0x100000000 ; i
++)