aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/hp/sim/boot
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ia64/hp/sim/boot
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/ia64/hp/sim/boot')
-rw-r--r--arch/ia64/hp/sim/boot/Makefile37
-rw-r--r--arch/ia64/hp/sim/boot/boot_head.S144
-rw-r--r--arch/ia64/hp/sim/boot/bootloader.c176
-rw-r--r--arch/ia64/hp/sim/boot/bootloader.lds65
-rw-r--r--arch/ia64/hp/sim/boot/fw-emu.c398
-rw-r--r--arch/ia64/hp/sim/boot/ssc.h35
6 files changed, 855 insertions, 0 deletions
diff --git a/arch/ia64/hp/sim/boot/Makefile b/arch/ia64/hp/sim/boot/Makefile
new file mode 100644
index 00000000000..df6e9968c84
--- /dev/null
+++ b/arch/ia64/hp/sim/boot/Makefile
@@ -0,0 +1,37 @@
1#
2# ia64/boot/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive
6# for more details.
7#
8# Copyright (C) 1998, 2003 by David Mosberger-Tang <davidm@hpl.hp.com>
9#
10
11targets-$(CONFIG_IA64_HP_SIM) += bootloader
12targets := vmlinux.bin vmlinux.gz $(targets-y)
13
14quiet_cmd_cptotop = LN $@
15 cmd_cptotop = ln -f $< $@
16
17vmlinux.gz: $(obj)/vmlinux.gz $(addprefix $(obj)/,$(targets-y))
18 $(call cmd,cptotop)
19 @echo ' Kernel: $@ is ready'
20
21boot: bootloader
22
23bootloader: $(obj)/bootloader
24 $(call cmd,cptotop)
25
26$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
27 $(call if_changed,gzip)
28
29$(obj)/vmlinux.bin: vmlinux FORCE
30 $(call if_changed,objcopy)
31
32
33LDFLAGS_bootloader = -static -T
34
35$(obj)/bootloader: $(src)/bootloader.lds $(obj)/bootloader.o $(obj)/boot_head.o $(obj)/fw-emu.o \
36 lib/lib.a arch/ia64/lib/lib.a FORCE
37 $(call if_changed,ld)
diff --git a/arch/ia64/hp/sim/boot/boot_head.S b/arch/ia64/hp/sim/boot/boot_head.S
new file mode 100644
index 00000000000..9364199e563
--- /dev/null
+++ b/arch/ia64/hp/sim/boot/boot_head.S
@@ -0,0 +1,144 @@
1/*
2 * Copyright (C) 1998-2003 Hewlett-Packard Co
3 * David Mosberger-Tang <davidm@hpl.hp.com>
4 */
5
6#include <asm/asmmacro.h>
7
8 .bss
9 .align 16
10stack_mem:
11 .skip 16834
12
13 .text
14
15/* This needs to be defined because lib/string.c:strlcat() calls it in case of error... */
16GLOBAL_ENTRY(printk)
17 break 0
18END(printk)
19
20GLOBAL_ENTRY(_start)
21 .prologue
22 .save rp, r0
23 .body
24 movl gp = __gp
25 movl sp = stack_mem
26 bsw.1
27 br.call.sptk.many rp=start_bootloader
28END(_start)
29
30/*
31 * Set a break point on this function so that symbols are available to set breakpoints in
32 * the kernel being debugged.
33 */
34GLOBAL_ENTRY(debug_break)
35 br.ret.sptk.many b0
36END(debug_break)
37
38GLOBAL_ENTRY(ssc)
39 .regstk 5,0,0,0
40 mov r15=in4
41 break 0x80001
42 br.ret.sptk.many b0
43END(ssc)
44
45GLOBAL_ENTRY(jmp_to_kernel)
46 .regstk 2,0,0,0
47 mov r28=in0
48 mov b7=in1
49 br.sptk.few b7
50END(jmp_to_kernel)
51
52
53GLOBAL_ENTRY(pal_emulator_static)
54 mov r8=-1
55 mov r9=256
56 ;;
57 cmp.gtu p6,p7=r9,r28 /* r28 <= 255? */
58(p6) br.cond.sptk.few static
59 ;;
60 mov r9=512
61 ;;
62 cmp.gtu p6,p7=r9,r28
63(p6) br.cond.sptk.few stacked
64 ;;
65static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */
66(p7) br.cond.sptk.few 1f
67 ;;
68 mov r8=0 /* status = 0 */
69 movl r9=0x100000000 /* tc.base */
70 movl r10=0x0000000200000003 /* count[0], count[1] */
71 movl r11=0x1000000000002000 /* stride[0], stride[1] */
72 br.cond.sptk.few rp
731: cmp.eq p6,p7=14,r28 /* PAL_FREQ_RATIOS */
74(p7) br.cond.sptk.few 1f
75 mov r8=0 /* status = 0 */
76 movl r9 =0x100000064 /* proc_ratio (1/100) */
77 movl r10=0x100000100 /* bus_ratio<<32 (1/256) */
78 movl r11=0x100000064 /* itc_ratio<<32 (1/100) */
79 ;;
801: cmp.eq p6,p7=19,r28 /* PAL_RSE_INFO */
81(p7) br.cond.sptk.few 1f
82 mov r8=0 /* status = 0 */
83 mov r9=96 /* num phys stacked */
84 mov r10=0 /* hints */
85 mov r11=0
86 br.cond.sptk.few rp
871: cmp.eq p6,p7=1,r28 /* PAL_CACHE_FLUSH */
88(p7) br.cond.sptk.few 1f
89 mov r9=ar.lc
90 movl r8=524288 /* flush 512k million cache lines (16MB) */
91 ;;
92 mov ar.lc=r8
93 movl r8=0xe000000000000000
94 ;;
95.loop: fc r8
96 add r8=32,r8
97 br.cloop.sptk.few .loop
98 sync.i
99 ;;
100 srlz.i
101 ;;
102 mov ar.lc=r9
103 mov r8=r0
104 ;;
1051: cmp.eq p6,p7=15,r28 /* PAL_PERF_MON_INFO */
106(p7) br.cond.sptk.few 1f
107 mov r8=0 /* status = 0 */
108 movl r9 =0x08122f04 /* generic=4 width=47 retired=8 cycles=18 */
109 mov r10=0 /* reserved */
110 mov r11=0 /* reserved */
111 mov r16=0xffff /* implemented PMC */
112 mov r17=0x3ffff /* implemented PMD */
113 add r18=8,r29 /* second index */
114 ;;
115 st8 [r29]=r16,16 /* store implemented PMC */
116 st8 [r18]=r0,16 /* clear remaining bits */
117 ;;
118 st8 [r29]=r0,16 /* clear remaining bits */
119 st8 [r18]=r0,16 /* clear remaining bits */
120 ;;
121 st8 [r29]=r17,16 /* store implemented PMD */
122 st8 [r18]=r0,16 /* clear remaining bits */
123 mov r16=0xf0 /* cycles count capable PMC */
124 ;;
125 st8 [r29]=r0,16 /* clear remaining bits */
126 st8 [r18]=r0,16 /* clear remaining bits */
127 mov r17=0xf0 /* retired bundles capable PMC */
128 ;;
129 st8 [r29]=r16,16 /* store cycles capable */
130 st8 [r18]=r0,16 /* clear remaining bits */
131 ;;
132 st8 [r29]=r0,16 /* clear remaining bits */
133 st8 [r18]=r0,16 /* clear remaining bits */
134 ;;
135 st8 [r29]=r17,16 /* store retired bundle capable */
136 st8 [r18]=r0,16 /* clear remaining bits */
137 ;;
138 st8 [r29]=r0,16 /* clear remaining bits */
139 st8 [r18]=r0,16 /* clear remaining bits */
140 ;;
1411: br.cond.sptk.few rp
142stacked:
143 br.ret.sptk.few rp
144END(pal_emulator_static)
diff --git a/arch/ia64/hp/sim/boot/bootloader.c b/arch/ia64/hp/sim/boot/bootloader.c
new file mode 100644
index 00000000000..51a7b7b4dd0
--- /dev/null
+++ b/arch/ia64/hp/sim/boot/bootloader.c
@@ -0,0 +1,176 @@
1/*
2 * arch/ia64/hp/sim/boot/bootloader.c
3 *
4 * Loads an ELF kernel.
5 *
6 * Copyright (C) 1998-2003 Hewlett-Packard Co
7 * David Mosberger-Tang <davidm@hpl.hp.com>
8 * Stephane Eranian <eranian@hpl.hp.com>
9 *
10 * 01/07/99 S.Eranian modified to pass command line arguments to kernel
11 */
12struct task_struct; /* forward declaration for elf.h */
13
14#include <linux/config.h>
15#include <linux/elf.h>
16#include <linux/init.h>
17#include <linux/kernel.h>
18
19#include <asm/elf.h>
20#include <asm/intrinsics.h>
21#include <asm/pal.h>
22#include <asm/pgtable.h>
23#include <asm/sal.h>
24#include <asm/system.h>
25
26#include "ssc.h"
27
28struct disk_req {
29 unsigned long addr;
30 unsigned len;
31};
32
33struct disk_stat {
34 int fd;
35 unsigned count;
36};
37
38extern void jmp_to_kernel (unsigned long bp, unsigned long e_entry);
39extern struct ia64_boot_param *sys_fw_init (const char *args, int arglen);
40extern void debug_break (void);
41
42static void
43cons_write (const char *buf)
44{
45 unsigned long ch;
46
47 while ((ch = *buf++) != '\0') {
48 ssc(ch, 0, 0, 0, SSC_PUTCHAR);
49 if (ch == '\n')
50 ssc('\r', 0, 0, 0, SSC_PUTCHAR);
51 }
52}
53
54#define MAX_ARGS 32
55
56void
57start_bootloader (void)
58{
59 static char mem[4096];
60 static char buffer[1024];
61 unsigned long off;
62 int fd, i;
63 struct disk_req req;
64 struct disk_stat stat;
65 struct elfhdr *elf;
66 struct elf_phdr *elf_phdr; /* program header */
67 unsigned long e_entry, e_phoff, e_phnum;
68 register struct ia64_boot_param *bp;
69 char *kpath, *args;
70 long arglen = 0;
71
72 ssc(0, 0, 0, 0, SSC_CONSOLE_INIT);
73
74 /*
75 * S.Eranian: extract the commandline argument from the simulator
76 *
77 * The expected format is as follows:
78 *
79 * kernelname args...
80 *
81 * Both are optional but you can't have the second one without the first.
82 */
83 arglen = ssc((long) buffer, 0, 0, 0, SSC_GET_ARGS);
84
85 kpath = "vmlinux";
86 args = buffer;
87 if (arglen > 0) {
88 kpath = buffer;
89 while (*args != ' ' && *args != '\0')
90 ++args, --arglen;
91 if (*args == ' ')
92 *args++ = '\0', --arglen;
93 }
94
95 if (arglen <= 0) {
96 args = "";
97 arglen = 1;
98 }
99
100 fd = ssc((long) kpath, 1, 0, 0, SSC_OPEN);
101
102 if (fd < 0) {
103 cons_write(kpath);
104 cons_write(": file not found, reboot now\n");
105 for(;;);
106 }
107 stat.fd = fd;
108 off = 0;
109
110 req.len = sizeof(mem);
111 req.addr = (long) mem;
112 ssc(fd, 1, (long) &req, off, SSC_READ);
113 ssc((long) &stat, 0, 0, 0, SSC_WAIT_COMPLETION);
114
115 elf = (struct elfhdr *) mem;
116 if (elf->e_ident[0] == 0x7f && strncmp(elf->e_ident + 1, "ELF", 3) != 0) {
117 cons_write("not an ELF file\n");
118 return;
119 }
120 if (elf->e_type != ET_EXEC) {
121 cons_write("not an ELF executable\n");
122 return;
123 }
124 if (!elf_check_arch(elf)) {
125 cons_write("kernel not for this processor\n");
126 return;
127 }
128
129 e_entry = elf->e_entry;
130 e_phnum = elf->e_phnum;
131 e_phoff = elf->e_phoff;
132
133 cons_write("loading ");
134 cons_write(kpath);
135 cons_write("...\n");
136
137 for (i = 0; i < e_phnum; ++i) {
138 req.len = sizeof(*elf_phdr);
139 req.addr = (long) mem;
140 ssc(fd, 1, (long) &req, e_phoff, SSC_READ);
141 ssc((long) &stat, 0, 0, 0, SSC_WAIT_COMPLETION);
142 if (stat.count != sizeof(*elf_phdr)) {
143 cons_write("failed to read phdr\n");
144 return;
145 }
146 e_phoff += sizeof(*elf_phdr);
147
148 elf_phdr = (struct elf_phdr *) mem;
149
150 if (elf_phdr->p_type != PT_LOAD)
151 continue;
152
153 req.len = elf_phdr->p_filesz;
154 req.addr = __pa(elf_phdr->p_paddr);
155 ssc(fd, 1, (long) &req, elf_phdr->p_offset, SSC_READ);
156 ssc((long) &stat, 0, 0, 0, SSC_WAIT_COMPLETION);
157 memset((char *)__pa(elf_phdr->p_paddr) + elf_phdr->p_filesz, 0,
158 elf_phdr->p_memsz - elf_phdr->p_filesz);
159 }
160 ssc(fd, 0, 0, 0, SSC_CLOSE);
161
162 cons_write("starting kernel...\n");
163
164 /* fake an I/O base address: */
165 ia64_setreg(_IA64_REG_AR_KR0, 0xffffc000000UL);
166
167 bp = sys_fw_init(args, arglen);
168
169 ssc(0, (long) kpath, 0, 0, SSC_LOAD_SYMBOLS);
170
171 debug_break();
172 jmp_to_kernel((unsigned long) bp, e_entry);
173
174 cons_write("kernel returned!\n");
175 ssc(-1, 0, 0, 0, SSC_EXIT);
176}
diff --git a/arch/ia64/hp/sim/boot/bootloader.lds b/arch/ia64/hp/sim/boot/bootloader.lds
new file mode 100644
index 00000000000..69ae5853103
--- /dev/null
+++ b/arch/ia64/hp/sim/boot/bootloader.lds
@@ -0,0 +1,65 @@
1OUTPUT_FORMAT("elf64-ia64-little")
2OUTPUT_ARCH(ia64)
3ENTRY(_start)
4SECTIONS
5{
6 /* Read-only sections, merged into text segment: */
7 . = 0x100000;
8
9 _text = .;
10 .text : { *(__ivt_section) *(.text) }
11 _etext = .;
12
13 /* Global data */
14 _data = .;
15 .rodata : { *(.rodata) *(.rodata.*) }
16 .data : { *(.data) *(.gnu.linkonce.d*) CONSTRUCTORS }
17 __gp = ALIGN (8) + 0x200000;
18 .got : { *(.got.plt) *(.got) }
19 /* We want the small data sections together, so single-instruction offsets
20 can access them all, and initialized data all before uninitialized, so
21 we can shorten the on-disk segment size. */
22 .sdata : { *(.sdata) }
23 _edata = .;
24
25 _bss = .;
26 .sbss : { *(.sbss) *(.scommon) }
27 .bss : { *(.bss) *(COMMON) }
28 . = ALIGN(64 / 8);
29 _end = . ;
30
31 /* Stabs debugging sections. */
32 .stab 0 : { *(.stab) }
33 .stabstr 0 : { *(.stabstr) }
34 .stab.excl 0 : { *(.stab.excl) }
35 .stab.exclstr 0 : { *(.stab.exclstr) }
36 .stab.index 0 : { *(.stab.index) }
37 .stab.indexstr 0 : { *(.stab.indexstr) }
38 .comment 0 : { *(.comment) }
39 /* DWARF debug sections.
40 Symbols in the DWARF debugging sections are relative to the beginning
41 of the section so we begin them at 0. */
42 /* DWARF 1 */
43 .debug 0 : { *(.debug) }
44 .line 0 : { *(.line) }
45 /* GNU DWARF 1 extensions */
46 .debug_srcinfo 0 : { *(.debug_srcinfo) }
47 .debug_sfnames 0 : { *(.debug_sfnames) }
48 /* DWARF 1.1 and DWARF 2 */
49 .debug_aranges 0 : { *(.debug_aranges) }
50 .debug_pubnames 0 : { *(.debug_pubnames) }
51 /* DWARF 2 */
52 .debug_info 0 : { *(.debug_info) }
53 .debug_abbrev 0 : { *(.debug_abbrev) }
54 .debug_line 0 : { *(.debug_line) }
55 .debug_frame 0 : { *(.debug_frame) }
56 .debug_str 0 : { *(.debug_str) }
57 .debug_loc 0 : { *(.debug_loc) }
58 .debug_macinfo 0 : { *(.debug_macinfo) }
59 /* SGI/MIPS DWARF 2 extensions */
60 .debug_weaknames 0 : { *(.debug_weaknames) }
61 .debug_funcnames 0 : { *(.debug_funcnames) }
62 .debug_typenames 0 : { *(.debug_typenames) }
63 .debug_varnames 0 : { *(.debug_varnames) }
64 /* These must appear regardless of . */
65}
diff --git a/arch/ia64/hp/sim/boot/fw-emu.c b/arch/ia64/hp/sim/boot/fw-emu.c
new file mode 100644
index 00000000000..5c46928e3dc
--- /dev/null
+++ b/arch/ia64/hp/sim/boot/fw-emu.c
@@ -0,0 +1,398 @@
1/*
2 * PAL & SAL emulation.
3 *
4 * Copyright (C) 1998-2001 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 */
7#include <linux/config.h>
8
9#ifdef CONFIG_PCI
10# include <linux/pci.h>
11#endif
12
13#include <linux/efi.h>
14#include <asm/io.h>
15#include <asm/pal.h>
16#include <asm/sal.h>
17
18#include "ssc.h"
19
20#define MB (1024*1024UL)
21
22#define SIMPLE_MEMMAP 1
23
24#if SIMPLE_MEMMAP
25# define NUM_MEM_DESCS 4
26#else
27# define NUM_MEM_DESCS 16
28#endif
29
30static char fw_mem[( sizeof(struct ia64_boot_param)
31 + sizeof(efi_system_table_t)
32 + sizeof(efi_runtime_services_t)
33 + 1*sizeof(efi_config_table_t)
34 + sizeof(struct ia64_sal_systab)
35 + sizeof(struct ia64_sal_desc_entry_point)
36 + NUM_MEM_DESCS*(sizeof(efi_memory_desc_t))
37 + 1024)] __attribute__ ((aligned (8)));
38
39#define SECS_PER_HOUR (60 * 60)
40#define SECS_PER_DAY (SECS_PER_HOUR * 24)
41
42/* Compute the `struct tm' representation of *T,
43 offset OFFSET seconds east of UTC,
44 and store year, yday, mon, mday, wday, hour, min, sec into *TP.
45 Return nonzero if successful. */
46int
47offtime (unsigned long t, efi_time_t *tp)
48{
49 const unsigned short int __mon_yday[2][13] =
50 {
51 /* Normal years. */
52 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
53 /* Leap years. */
54 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
55 };
56 long int days, rem, y;
57 const unsigned short int *ip;
58
59 days = t / SECS_PER_DAY;
60 rem = t % SECS_PER_DAY;
61 while (rem < 0) {
62 rem += SECS_PER_DAY;
63 --days;
64 }
65 while (rem >= SECS_PER_DAY) {
66 rem -= SECS_PER_DAY;
67 ++days;
68 }
69 tp->hour = rem / SECS_PER_HOUR;
70 rem %= SECS_PER_HOUR;
71 tp->minute = rem / 60;
72 tp->second = rem % 60;
73 /* January 1, 1970 was a Thursday. */
74 y = 1970;
75
76# define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
77# define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
78# define __isleap(year) \
79 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
80
81 while (days < 0 || days >= (__isleap (y) ? 366 : 365)) {
82 /* Guess a corrected year, assuming 365 days per year. */
83 long int yg = y + days / 365 - (days % 365 < 0);
84
85 /* Adjust DAYS and Y to match the guessed year. */
86 days -= ((yg - y) * 365 + LEAPS_THRU_END_OF (yg - 1)
87 - LEAPS_THRU_END_OF (y - 1));
88 y = yg;
89 }
90 tp->year = y;
91 ip = __mon_yday[__isleap(y)];
92 for (y = 11; days < (long int) ip[y]; --y)
93 continue;
94 days -= ip[y];
95 tp->month = y + 1;
96 tp->day = days + 1;
97 return 1;
98}
99
100extern void pal_emulator_static (void);
101
102/* Macro to emulate SAL call using legacy IN and OUT calls to CF8, CFC etc.. */
103
104#define BUILD_CMD(addr) ((0x80000000 | (addr)) & ~3)
105
106#define REG_OFFSET(addr) (0x00000000000000FF & (addr))
107#define DEVICE_FUNCTION(addr) (0x000000000000FF00 & (addr))
108#define BUS_NUMBER(addr) (0x0000000000FF0000 & (addr))
109
110static efi_status_t
111fw_efi_get_time (efi_time_t *tm, efi_time_cap_t *tc)
112{
113#if defined(CONFIG_IA64_HP_SIM) || defined(CONFIG_IA64_GENERIC)
114 struct {
115 int tv_sec; /* must be 32bits to work */
116 int tv_usec;
117 } tv32bits;
118
119 ssc((unsigned long) &tv32bits, 0, 0, 0, SSC_GET_TOD);
120
121 memset(tm, 0, sizeof(*tm));
122 offtime(tv32bits.tv_sec, tm);
123
124 if (tc)
125 memset(tc, 0, sizeof(*tc));
126#else
127# error Not implemented yet...
128#endif
129 return EFI_SUCCESS;
130}
131
132static void
133efi_reset_system (int reset_type, efi_status_t status, unsigned long data_size, efi_char16_t *data)
134{
135#if defined(CONFIG_IA64_HP_SIM) || defined(CONFIG_IA64_GENERIC)
136 ssc(status, 0, 0, 0, SSC_EXIT);
137#else
138# error Not implemented yet...
139#endif
140}
141
142static efi_status_t
143efi_unimplemented (void)
144{
145 return EFI_UNSUPPORTED;
146}
147
148static struct sal_ret_values
149sal_emulator (long index, unsigned long in1, unsigned long in2,
150 unsigned long in3, unsigned long in4, unsigned long in5,
151 unsigned long in6, unsigned long in7)
152{
153 long r9 = 0;
154 long r10 = 0;
155 long r11 = 0;
156 long status;
157
158 /*
159 * Don't do a "switch" here since that gives us code that
160 * isn't self-relocatable.
161 */
162 status = 0;
163 if (index == SAL_FREQ_BASE) {
164 switch (in1) {
165 case SAL_FREQ_BASE_PLATFORM:
166 r9 = 200000000;
167 break;
168
169 case SAL_FREQ_BASE_INTERVAL_TIMER:
170 /*
171 * Is this supposed to be the cr.itc frequency
172 * or something platform specific? The SAL
173 * doc ain't exactly clear on this...
174 */
175 r9 = 700000000;
176 break;
177
178 case SAL_FREQ_BASE_REALTIME_CLOCK:
179 r9 = 1;
180 break;
181
182 default:
183 status = -1;
184 break;
185 }
186 } else if (index == SAL_SET_VECTORS) {
187 ;
188 } else if (index == SAL_GET_STATE_INFO) {
189 ;
190 } else if (index == SAL_GET_STATE_INFO_SIZE) {
191 ;
192 } else if (index == SAL_CLEAR_STATE_INFO) {
193 ;
194 } else if (index == SAL_MC_RENDEZ) {
195 ;
196 } else if (index == SAL_MC_SET_PARAMS) {
197 ;
198 } else if (index == SAL_CACHE_FLUSH) {
199 ;
200 } else if (index == SAL_CACHE_INIT) {
201 ;
202#ifdef CONFIG_PCI
203 } else if (index == SAL_PCI_CONFIG_READ) {
204 /*
205 * in1 contains the PCI configuration address and in2
206 * the size of the read. The value that is read is
207 * returned via the general register r9.
208 */
209 outl(BUILD_CMD(in1), 0xCF8);
210 if (in2 == 1) /* Reading byte */
211 r9 = inb(0xCFC + ((REG_OFFSET(in1) & 3)));
212 else if (in2 == 2) /* Reading word */
213 r9 = inw(0xCFC + ((REG_OFFSET(in1) & 2)));
214 else /* Reading dword */
215 r9 = inl(0xCFC);
216 status = PCIBIOS_SUCCESSFUL;
217 } else if (index == SAL_PCI_CONFIG_WRITE) {
218 /*
219 * in1 contains the PCI configuration address, in2 the
220 * size of the write, and in3 the actual value to be
221 * written out.
222 */
223 outl(BUILD_CMD(in1), 0xCF8);
224 if (in2 == 1) /* Writing byte */
225 outb(in3, 0xCFC + ((REG_OFFSET(in1) & 3)));
226 else if (in2 == 2) /* Writing word */
227 outw(in3, 0xCFC + ((REG_OFFSET(in1) & 2)));
228 else /* Writing dword */
229 outl(in3, 0xCFC);
230 status = PCIBIOS_SUCCESSFUL;
231#endif /* CONFIG_PCI */
232 } else if (index == SAL_UPDATE_PAL) {
233 ;
234 } else {
235 status = -1;
236 }
237 return ((struct sal_ret_values) {status, r9, r10, r11});
238}
239
240
241/*
242 * This is here to work around a bug in egcs-1.1.1b that causes the
243 * compiler to crash (seems like a bug in the new alias analysis code.
244 */
245void *
246id (long addr)
247{
248 return (void *) addr;
249}
250
251struct ia64_boot_param *
252sys_fw_init (const char *args, int arglen)
253{
254 efi_system_table_t *efi_systab;
255 efi_runtime_services_t *efi_runtime;
256 efi_config_table_t *efi_tables;
257 struct ia64_sal_systab *sal_systab;
258 efi_memory_desc_t *efi_memmap, *md;
259 unsigned long *pal_desc, *sal_desc;
260 struct ia64_sal_desc_entry_point *sal_ed;
261 struct ia64_boot_param *bp;
262 unsigned char checksum = 0;
263 char *cp, *cmd_line;
264 int i = 0;
265# define MAKE_MD(typ, attr, start, end) \
266 do { \
267 md = efi_memmap + i++; \
268 md->type = typ; \
269 md->pad = 0; \
270 md->phys_addr = start; \
271 md->virt_addr = 0; \
272 md->num_pages = (end - start) >> 12; \
273 md->attribute = attr; \
274 } while (0)
275
276 memset(fw_mem, 0, sizeof(fw_mem));
277
278 pal_desc = (unsigned long *) &pal_emulator_static;
279 sal_desc = (unsigned long *) &sal_emulator;
280
281 cp = fw_mem;
282 efi_systab = (void *) cp; cp += sizeof(*efi_systab);
283 efi_runtime = (void *) cp; cp += sizeof(*efi_runtime);
284 efi_tables = (void *) cp; cp += sizeof(*efi_tables);
285 sal_systab = (void *) cp; cp += sizeof(*sal_systab);
286 sal_ed = (void *) cp; cp += sizeof(*sal_ed);
287 efi_memmap = (void *) cp; cp += NUM_MEM_DESCS*sizeof(*efi_memmap);
288 bp = (void *) cp; cp += sizeof(*bp);
289 cmd_line = (void *) cp;
290
291 if (args) {
292 if (arglen >= 1024)
293 arglen = 1023;
294 memcpy(cmd_line, args, arglen);
295 } else {
296 arglen = 0;
297 }
298 cmd_line[arglen] = '\0';
299
300 memset(efi_systab, 0, sizeof(efi_systab));
301 efi_systab->hdr.signature = EFI_SYSTEM_TABLE_SIGNATURE;
302 efi_systab->hdr.revision = EFI_SYSTEM_TABLE_REVISION;
303 efi_systab->hdr.headersize = sizeof(efi_systab->hdr);
304 efi_systab->fw_vendor = __pa("H\0e\0w\0l\0e\0t\0t\0-\0P\0a\0c\0k\0a\0r\0d\0\0");
305 efi_systab->fw_revision = 1;
306 efi_systab->runtime = (void *) __pa(efi_runtime);
307 efi_systab->nr_tables = 1;
308 efi_systab->tables = __pa(efi_tables);
309
310 efi_runtime->hdr.signature = EFI_RUNTIME_SERVICES_SIGNATURE;
311 efi_runtime->hdr.revision = EFI_RUNTIME_SERVICES_REVISION;
312 efi_runtime->hdr.headersize = sizeof(efi_runtime->hdr);
313 efi_runtime->get_time = __pa(&fw_efi_get_time);
314 efi_runtime->set_time = __pa(&efi_unimplemented);
315 efi_runtime->get_wakeup_time = __pa(&efi_unimplemented);
316 efi_runtime->set_wakeup_time = __pa(&efi_unimplemented);
317 efi_runtime->set_virtual_address_map = __pa(&efi_unimplemented);
318 efi_runtime->get_variable = __pa(&efi_unimplemented);
319 efi_runtime->get_next_variable = __pa(&efi_unimplemented);
320 efi_runtime->set_variable = __pa(&efi_unimplemented);
321 efi_runtime->get_next_high_mono_count = __pa(&efi_unimplemented);
322 efi_runtime->reset_system = __pa(&efi_reset_system);
323
324 efi_tables->guid = SAL_SYSTEM_TABLE_GUID;
325 efi_tables->table = __pa(sal_systab);
326
327 /* fill in the SAL system table: */
328 memcpy(sal_systab->signature, "SST_", 4);
329 sal_systab->size = sizeof(*sal_systab);
330 sal_systab->sal_rev_minor = 1;
331 sal_systab->sal_rev_major = 0;
332 sal_systab->entry_count = 1;
333
334#ifdef CONFIG_IA64_GENERIC
335 strcpy(sal_systab->oem_id, "Generic");
336 strcpy(sal_systab->product_id, "IA-64 system");
337#endif
338
339#ifdef CONFIG_IA64_HP_SIM
340 strcpy(sal_systab->oem_id, "Hewlett-Packard");
341 strcpy(sal_systab->product_id, "HP-simulator");
342#endif
343
344#ifdef CONFIG_IA64_SDV
345 strcpy(sal_systab->oem_id, "Intel");
346 strcpy(sal_systab->product_id, "SDV");
347#endif
348
349 /* fill in an entry point: */
350 sal_ed->type = SAL_DESC_ENTRY_POINT;
351 sal_ed->pal_proc = __pa(pal_desc[0]);
352 sal_ed->sal_proc = __pa(sal_desc[0]);
353 sal_ed->gp = __pa(sal_desc[1]);
354
355 for (cp = (char *) sal_systab; cp < (char *) efi_memmap; ++cp)
356 checksum += *cp;
357
358 sal_systab->checksum = -checksum;
359
360#if SIMPLE_MEMMAP
361 /* simulate free memory at physical address zero */
362 MAKE_MD(EFI_BOOT_SERVICES_DATA, EFI_MEMORY_WB, 0*MB, 1*MB);
363 MAKE_MD(EFI_PAL_CODE, EFI_MEMORY_WB, 1*MB, 2*MB);
364 MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, 2*MB, 130*MB);
365 MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, 4096*MB, 4128*MB);
366#else
367 MAKE_MD( 4, 0x9, 0x0000000000000000, 0x0000000000001000);
368 MAKE_MD( 7, 0x9, 0x0000000000001000, 0x000000000008a000);
369 MAKE_MD( 4, 0x9, 0x000000000008a000, 0x00000000000a0000);
370 MAKE_MD( 5, 0x8000000000000009, 0x00000000000c0000, 0x0000000000100000);
371 MAKE_MD( 7, 0x9, 0x0000000000100000, 0x0000000004400000);
372 MAKE_MD( 2, 0x9, 0x0000000004400000, 0x0000000004be5000);
373 MAKE_MD( 7, 0x9, 0x0000000004be5000, 0x000000007f77e000);
374 MAKE_MD( 6, 0x8000000000000009, 0x000000007f77e000, 0x000000007fb94000);
375 MAKE_MD( 6, 0x8000000000000009, 0x000000007fb94000, 0x000000007fb95000);
376 MAKE_MD( 6, 0x8000000000000009, 0x000000007fb95000, 0x000000007fc00000);
377 MAKE_MD(13, 0x8000000000000009, 0x000000007fc00000, 0x000000007fc3a000);
378 MAKE_MD( 7, 0x9, 0x000000007fc3a000, 0x000000007fea0000);
379 MAKE_MD( 5, 0x8000000000000009, 0x000000007fea0000, 0x000000007fea8000);
380 MAKE_MD( 7, 0x9, 0x000000007fea8000, 0x000000007feab000);
381 MAKE_MD( 5, 0x8000000000000009, 0x000000007feab000, 0x000000007ffff000);
382 MAKE_MD( 7, 0x9, 0x00000000ff400000, 0x0000000104000000);
383#endif
384
385 bp->efi_systab = __pa(&fw_mem);
386 bp->efi_memmap = __pa(efi_memmap);
387 bp->efi_memmap_size = NUM_MEM_DESCS*sizeof(efi_memory_desc_t);
388 bp->efi_memdesc_size = sizeof(efi_memory_desc_t);
389 bp->efi_memdesc_version = 1;
390 bp->command_line = __pa(cmd_line);
391 bp->console_info.num_cols = 80;
392 bp->console_info.num_rows = 25;
393 bp->console_info.orig_x = 0;
394 bp->console_info.orig_y = 24;
395 bp->fpswa = 0;
396
397 return bp;
398}
diff --git a/arch/ia64/hp/sim/boot/ssc.h b/arch/ia64/hp/sim/boot/ssc.h
new file mode 100644
index 00000000000..3b94c03e43a
--- /dev/null
+++ b/arch/ia64/hp/sim/boot/ssc.h
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) 1998-2003 Hewlett-Packard Co
3 * David Mosberger-Tang <davidm@hpl.hp.com>
4 * Stephane Eranian <eranian@hpl.hp.com>
5 */
6#ifndef ssc_h
7#define ssc_h
8
9/* Simulator system calls: */
10
11#define SSC_CONSOLE_INIT 20
12#define SSC_GETCHAR 21
13#define SSC_PUTCHAR 31
14#define SSC_OPEN 50
15#define SSC_CLOSE 51
16#define SSC_READ 52
17#define SSC_WRITE 53
18#define SSC_GET_COMPLETION 54
19#define SSC_WAIT_COMPLETION 55
20#define SSC_CONNECT_INTERRUPT 58
21#define SSC_GENERATE_INTERRUPT 59
22#define SSC_SET_PERIODIC_INTERRUPT 60
23#define SSC_GET_RTC 65
24#define SSC_EXIT 66
25#define SSC_LOAD_SYMBOLS 69
26#define SSC_GET_TOD 74
27
28#define SSC_GET_ARGS 75
29
30/*
31 * Simulator system call.
32 */
33extern long ssc (long arg0, long arg1, long arg2, long arg3, int nr);
34
35#endif /* ssc_h */