summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-08-13 03:25:03 -0400
committerTony Luck <tony.luck@intel.com>2019-08-16 14:33:57 -0400
commitfc5bad03709f9c79ea299f554b6f99fc6f4fe31c (patch)
treed02ddaa88a30e5885e8f0ce4a723415a7903a632
parent05933aac7b11911955de307a329dc2a7a14b7bd0 (diff)
ia64: remove the hpsim platform
The hpsim platform supports the HP IA64 simulator which was useful as a bring up platform. But it is fairly non-standard vs real IA64 system in that it for example doesn't support ACPI. It also comes with a whole bunch of simulator specific drivers. Remove it to simplify the IA64 port. Note that through a weird twist only them hpsim boot loader built the vmlinux.gz file, so the makefile targets for that are moved to the main ia64 Makefile now. Acked-by: Tom Vaden <tom.vaden@hpe.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lkml.kernel.org/r/20190813072514.23299-18-hch@lst.de Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r--arch/ia64/Kconfig34
-rw-r--r--arch/ia64/Makefile27
-rw-r--r--arch/ia64/configs/sim_defconfig52
-rw-r--r--arch/ia64/hp/sim/Kconfig23
-rw-r--r--arch/ia64/hp/sim/Makefile17
-rw-r--r--arch/ia64/hp/sim/boot/Makefile37
-rw-r--r--arch/ia64/hp/sim/boot/boot_head.S165
-rw-r--r--arch/ia64/hp/sim/boot/bootloader.c175
-rw-r--r--arch/ia64/hp/sim/boot/bootloader.lds67
-rw-r--r--arch/ia64/hp/sim/boot/fw-emu.c374
-rw-r--r--arch/ia64/hp/sim/boot/ssc.h36
-rw-r--r--arch/ia64/hp/sim/hpsim.S11
-rw-r--r--arch/ia64/hp/sim/hpsim_console.c77
-rw-r--r--arch/ia64/hp/sim/hpsim_irq.c76
-rw-r--r--arch/ia64/hp/sim/hpsim_machvec.c3
-rw-r--r--arch/ia64/hp/sim/hpsim_setup.c41
-rw-r--r--arch/ia64/hp/sim/hpsim_ssc.h37
-rw-r--r--arch/ia64/hp/sim/simeth.c510
-rw-r--r--arch/ia64/hp/sim/simscsi.c373
-rw-r--r--arch/ia64/hp/sim/simserial.c521
-rw-r--r--arch/ia64/include/asm/acpi.h4
-rw-r--r--arch/ia64/include/asm/hpsim.h17
-rw-r--r--arch/ia64/include/asm/iosapic.h12
-rw-r--r--arch/ia64/include/asm/machvec.h11
-rw-r--r--arch/ia64/include/asm/machvec_hpsim.h19
-rw-r--r--arch/ia64/kernel/Makefile3
-rw-r--r--arch/ia64/kernel/irq_ia64.c2
-rw-r--r--arch/ia64/kernel/setup.c13
28 files changed, 26 insertions, 2711 deletions
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index ae3aca14506e..63db7a5378ac 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -10,11 +10,11 @@ config IA64
10 bool 10 bool
11 select ARCH_MIGHT_HAVE_PC_PARPORT 11 select ARCH_MIGHT_HAVE_PC_PARPORT
12 select ARCH_MIGHT_HAVE_PC_SERIO 12 select ARCH_MIGHT_HAVE_PC_SERIO
13 select ACPI if (!IA64_HP_SIM) 13 select ACPI
14 select ARCH_SUPPORTS_ACPI if (!IA64_HP_SIM) 14 select ARCH_SUPPORTS_ACPI
15 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI 15 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
16 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 16 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
17 select FORCE_PCI if (!IA64_HP_SIM) 17 select FORCE_PCI
18 select PCI_DOMAINS if PCI 18 select PCI_DOMAINS if PCI
19 select PCI_SYSCALL if PCI 19 select PCI_SYSCALL if PCI
20 select HAVE_UNSTABLE_SCHED_CLOCK 20 select HAVE_UNSTABLE_SCHED_CLOCK
@@ -140,7 +140,6 @@ config IA64_GENERIC
140 HP-zx1/sx1000 For HP systems 140 HP-zx1/sx1000 For HP systems
141 HP-zx1/sx1000+swiotlb For HP systems with (broken) DMA-constrained devices. 141 HP-zx1/sx1000+swiotlb For HP systems with (broken) DMA-constrained devices.
142 SGI-UV For SGI UV systems 142 SGI-UV For SGI UV systems
143 Ski-simulator For the HP simulator <http://www.hpl.hp.com/research/linux/ski/>
144 143
145 If you don't know what to do, choose "generic". 144 If you don't know what to do, choose "generic".
146 145
@@ -181,11 +180,6 @@ config IA64_SGI_UV
181 to select this option. If in doubt, select ia64 generic support 180 to select this option. If in doubt, select ia64 generic support
182 instead. 181 instead.
183 182
184config IA64_HP_SIM
185 bool "Ski-simulator"
186 select SWIOTLB
187 depends on !PM
188
189endchoice 183endchoice
190 184
191choice 185choice
@@ -239,14 +233,7 @@ config IA64_PAGE_SIZE_64KB
239 233
240endchoice 234endchoice
241 235
242if IA64_HP_SIM
243config HZ
244 default 32
245endif
246
247if !IA64_HP_SIM
248source "kernel/Kconfig.hz" 236source "kernel/Kconfig.hz"
249endif
250 237
251config IA64_BRL_EMU 238config IA64_BRL_EMU
252 bool 239 bool
@@ -265,11 +252,6 @@ config IA64_CYCLONE
265 Say Y here to enable support for IBM EXA Cyclone time source. 252 Say Y here to enable support for IBM EXA Cyclone time source.
266 If you're unsure, answer N. 253 If you're unsure, answer N.
267 254
268config IOSAPIC
269 bool
270 depends on !IA64_HP_SIM
271 default y
272
273config FORCE_MAX_ZONEORDER 255config FORCE_MAX_ZONEORDER
274 int "MAX_ORDER (11 - 17)" if !HUGETLB_PAGE 256 int "MAX_ORDER (11 - 17)" if !HUGETLB_PAGE
275 range 11 17 if !HUGETLB_PAGE 257 range 11 17 if !HUGETLB_PAGE
@@ -373,7 +355,7 @@ config ARCH_DISCONTIGMEM_DEFAULT
373 355
374config NUMA 356config NUMA
375 bool "NUMA support" 357 bool "NUMA support"
376 depends on !IA64_HP_SIM && !FLATMEM 358 depends on !FLATMEM
377 select ACPI_NUMA if ACPI 359 select ACPI_NUMA if ACPI
378 help 360 help
379 Say Y to compile the kernel to support NUMA (Non-Uniform Memory 361 Say Y to compile the kernel to support NUMA (Non-Uniform Memory
@@ -395,7 +377,7 @@ config NODES_SHIFT
395config VIRTUAL_MEM_MAP 377config VIRTUAL_MEM_MAP
396 bool "Virtual mem map" 378 bool "Virtual mem map"
397 depends on !SPARSEMEM 379 depends on !SPARSEMEM
398 default y if !IA64_HP_SIM 380 default y
399 help 381 help
400 Say Y to compile the kernel with support for a virtual mem map. 382 Say Y to compile the kernel with support for a virtual mem map.
401 This code also only takes effect if a memory hole of greater than 383 This code also only takes effect if a memory hole of greater than
@@ -478,7 +460,7 @@ config IA64_HP_AML_NFW
478 460
479config KEXEC 461config KEXEC
480 bool "kexec system call" 462 bool "kexec system call"
481 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU) 463 depends on !SMP || HOTPLUG_CPU
482 select KEXEC_CORE 464 select KEXEC_CORE
483 help 465 help
484 kexec is a system call that implements the ability to shutdown your 466 kexec is a system call that implements the ability to shutdown your
@@ -496,7 +478,7 @@ config KEXEC
496 478
497config CRASH_DUMP 479config CRASH_DUMP
498 bool "kernel crash dumps" 480 bool "kernel crash dumps"
499 depends on IA64_MCA_RECOVERY && !IA64_HP_SIM && (!SMP || HOTPLUG_CPU) 481 depends on IA64_MCA_RECOVERY && (!SMP || HOTPLUG_CPU)
500 help 482 help
501 Generate crash dump after being started by kexec. 483 Generate crash dump after being started by kexec.
502 484
@@ -518,8 +500,6 @@ endif
518 500
519endmenu 501endmenu
520 502
521source "arch/ia64/hp/sim/Kconfig"
522
523config MSPEC 503config MSPEC
524 tristate "Memory special operations driver" 504 tristate "Memory special operations driver"
525 depends on IA64 505 depends on IA64
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 0d730b061f72..8b866fc1f9cb 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -39,6 +39,12 @@ $(error Sorry, you need a newer version of the assember, one that is built from
39 ftp://ftp.hpl.hp.com/pub/linux-ia64/gas-030124.tar.gz) 39 ftp://ftp.hpl.hp.com/pub/linux-ia64/gas-030124.tar.gz)
40endif 40endif
41 41
42quiet_cmd_gzip = GZIP $@
43cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@
44
45quiet_cmd_objcopy = OBJCOPY $@
46cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
47
42KBUILD_CFLAGS += $(cflags-y) 48KBUILD_CFLAGS += $(cflags-y)
43head-y := arch/ia64/kernel/head.o 49head-y := arch/ia64/kernel/head.o
44 50
@@ -52,15 +58,12 @@ core-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/dig/
52core-$(CONFIG_IA64_SGI_UV) += arch/ia64/uv/ 58core-$(CONFIG_IA64_SGI_UV) += arch/ia64/uv/
53 59
54drivers-$(CONFIG_PCI) += arch/ia64/pci/ 60drivers-$(CONFIG_PCI) += arch/ia64/pci/
55drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim/
56drivers-$(CONFIG_IA64_HP_ZX1) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ 61drivers-$(CONFIG_IA64_HP_ZX1) += arch/ia64/hp/common/ arch/ia64/hp/zx1/
57drivers-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ 62drivers-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/hp/common/ arch/ia64/hp/zx1/
58drivers-$(CONFIG_IA64_GENERIC) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ arch/ia64/hp/sim/ arch/ia64/uv/ 63drivers-$(CONFIG_IA64_GENERIC) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ arch/ia64/uv/
59drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/ 64drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/
60 65
61boot := arch/ia64/hp/sim/boot 66PHONY += compressed check
62
63PHONY += boot compressed check
64 67
65all: compressed unwcheck 68all: compressed unwcheck
66 69
@@ -68,22 +71,21 @@ compressed: vmlinux.gz
68 71
69vmlinuz: vmlinux.gz 72vmlinuz: vmlinux.gz
70 73
71vmlinux.gz: vmlinux 74vmlinux.gz: vmlinux.bin FORCE
72 $(Q)$(MAKE) $(build)=$(boot) $@ 75 $(call if_changed,gzip)
76
77vmlinux.bin: vmlinux FORCE
78 $(call if_changed,objcopy)
73 79
74unwcheck: vmlinux 80unwcheck: vmlinux
75 -$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $< 81 -$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $<
76 82
77archclean: 83archclean:
78 $(Q)$(MAKE) $(clean)=$(boot)
79 84
80archheaders: 85archheaders:
81 $(Q)$(MAKE) $(build)=arch/ia64/kernel/syscalls all 86 $(Q)$(MAKE) $(build)=arch/ia64/kernel/syscalls all
82 87
83CLEAN_FILES += vmlinux.gz bootloader 88CLEAN_FILES += vmlinux.gz
84
85boot: lib/lib.a vmlinux
86 $(Q)$(MAKE) $(build)=$(boot) $@
87 89
88install: vmlinux.gz 90install: vmlinux.gz
89 sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" 91 sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
@@ -91,7 +93,6 @@ install: vmlinux.gz
91define archhelp 93define archhelp
92 echo '* compressed - Build compressed kernel image' 94 echo '* compressed - Build compressed kernel image'
93 echo ' install - Install compressed kernel image' 95 echo ' install - Install compressed kernel image'
94 echo ' boot - Build vmlinux and bootloader for Ski simulator'
95 echo '* unwcheck - Check vmlinux for invalid unwind info' 96 echo '* unwcheck - Check vmlinux for invalid unwind info'
96endef 97endef
97 98
diff --git a/arch/ia64/configs/sim_defconfig b/arch/ia64/configs/sim_defconfig
deleted file mode 100644
index f0f69fdbddae..000000000000
--- a/arch/ia64/configs/sim_defconfig
+++ /dev/null
@@ -1,52 +0,0 @@
1CONFIG_SYSVIPC=y
2CONFIG_IKCONFIG=y
3CONFIG_IKCONFIG_PROC=y
4CONFIG_LOG_BUF_SHIFT=16
5CONFIG_MODULES=y
6CONFIG_MODULE_UNLOAD=y
7CONFIG_MODULE_FORCE_UNLOAD=y
8CONFIG_MODVERSIONS=y
9CONFIG_PARTITION_ADVANCED=y
10CONFIG_IA64_HP_SIM=y
11CONFIG_MCKINLEY=y
12CONFIG_IA64_PAGE_SIZE_64KB=y
13CONFIG_SMP=y
14CONFIG_NR_CPUS=64
15CONFIG_PREEMPT=y
16CONFIG_IA64_PALINFO=m
17CONFIG_EFI_VARS=y
18CONFIG_BINFMT_MISC=y
19CONFIG_NET=y
20CONFIG_PACKET=y
21CONFIG_INET=y
22CONFIG_IP_MULTICAST=y
23# CONFIG_IPV6 is not set
24# CONFIG_STANDALONE is not set
25CONFIG_BLK_DEV_LOOP=y
26CONFIG_BLK_DEV_RAM=y
27CONFIG_SCSI=y
28CONFIG_BLK_DEV_SD=y
29CONFIG_SCSI_CONSTANTS=y
30CONFIG_SCSI_LOGGING=y
31CONFIG_SCSI_SPI_ATTRS=y
32# CONFIG_INPUT_KEYBOARD is not set
33# CONFIG_INPUT_MOUSE is not set
34# CONFIG_SERIO_I8042 is not set
35# CONFIG_LEGACY_PTYS is not set
36CONFIG_EFI_RTC=y
37# CONFIG_VGA_CONSOLE is not set
38CONFIG_HP_SIMETH=y
39CONFIG_HP_SIMSERIAL=y
40CONFIG_HP_SIMSERIAL_CONSOLE=y
41CONFIG_HP_SIMSCSI=y
42CONFIG_EXT2_FS=y
43CONFIG_EXT3_FS=y
44# CONFIG_EXT3_FS_XATTR is not set
45CONFIG_PROC_KCORE=y
46CONFIG_HUGETLBFS=y
47CONFIG_NFS_FS=y
48CONFIG_NFSD=y
49CONFIG_NFSD_V3=y
50CONFIG_DEBUG_INFO=y
51CONFIG_DEBUG_KERNEL=y
52CONFIG_DEBUG_MUTEXES=y
diff --git a/arch/ia64/hp/sim/Kconfig b/arch/ia64/hp/sim/Kconfig
deleted file mode 100644
index 56fb4f1d4f7c..000000000000
--- a/arch/ia64/hp/sim/Kconfig
+++ /dev/null
@@ -1,23 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0
2
3menu "HP Simulator drivers"
4 depends on IA64_HP_SIM || IA64_GENERIC
5
6config HP_SIMETH
7 bool "Simulated Ethernet "
8 depends on NET
9
10config HP_SIMSERIAL
11 bool "Simulated serial driver support"
12 depends on TTY
13
14config HP_SIMSERIAL_CONSOLE
15 bool "Console for HP simulator"
16 depends on HP_SIMSERIAL
17
18config HP_SIMSCSI
19 bool "Simulated SCSI disk"
20 depends on SCSI=y
21
22endmenu
23
diff --git a/arch/ia64/hp/sim/Makefile b/arch/ia64/hp/sim/Makefile
deleted file mode 100644
index 0224a13d2c5b..000000000000
--- a/arch/ia64/hp/sim/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0
2#
3# ia64/platform/hp/sim/Makefile
4#
5# Copyright (C) 2002 Hewlett-Packard Co.
6# David Mosberger-Tang <davidm@hpl.hp.com>
7# Copyright (C) 1999 Silicon Graphics, Inc.
8# Copyright (C) Srinivasa Thirumalachar (sprasad@engr.sgi.com)
9#
10
11obj-y := hpsim_irq.o hpsim_setup.o hpsim.o
12obj-$(CONFIG_IA64_GENERIC) += hpsim_machvec.o
13
14obj-$(CONFIG_HP_SIMETH) += simeth.o
15obj-$(CONFIG_HP_SIMSERIAL) += simserial.o
16obj-$(CONFIG_HP_SIMSERIAL_CONSOLE) += hpsim_console.o
17obj-$(CONFIG_HP_SIMSCSI) += simscsi.o
diff --git a/arch/ia64/hp/sim/boot/Makefile b/arch/ia64/hp/sim/boot/Makefile
deleted file mode 100644
index df6e9968c845..000000000000
--- a/arch/ia64/hp/sim/boot/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
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
deleted file mode 100644
index a7d178fb41e8..000000000000
--- a/arch/ia64/hp/sim/boot/boot_head.S
+++ /dev/null
@@ -1,165 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 1998-2003 Hewlett-Packard Co
4 * David Mosberger-Tang <davidm@hpl.hp.com>
5 */
6
7#include <asm/asmmacro.h>
8#include <asm/pal.h>
9
10 .bss
11 .align 16
12stack_mem:
13 .skip 16834
14
15 .text
16
17/* This needs to be defined because lib/string.c:strlcat() calls it in case of error... */
18GLOBAL_ENTRY(printk)
19 break 0
20END(printk)
21
22GLOBAL_ENTRY(_start)
23 .prologue
24 .save rp, r0
25 .body
26 movl gp = __gp
27 movl sp = stack_mem+16384-16
28 bsw.1
29 br.call.sptk.many rp=start_bootloader
300: nop 0 /* dummy nop to make unwinding work */
31END(_start)
32
33/*
34 * Set a break point on this function so that symbols are available to set breakpoints in
35 * the kernel being debugged.
36 */
37GLOBAL_ENTRY(debug_break)
38 br.ret.sptk.many b0
39END(debug_break)
40
41GLOBAL_ENTRY(ssc)
42 .regstk 5,0,0,0
43 mov r15=in4
44 break 0x80001
45 br.ret.sptk.many b0
46END(ssc)
47
48GLOBAL_ENTRY(jmp_to_kernel)
49 .regstk 2,0,0,0
50 mov r28=in0
51 mov b7=in1
52 br.sptk.few b7
53END(jmp_to_kernel)
54
55/*
56 * r28 contains the index of the PAL function
57 * r29--31 the args
58 * Return values in ret0--3 (r8--11)
59 */
60GLOBAL_ENTRY(pal_emulator_static)
61 mov r8=-1
62 mov r9=256
63 ;;
64 cmp.gtu p6,p7=r9,r28 /* r28 <= 255? */
65(p6) br.cond.sptk.few static
66 ;;
67 mov r9=512
68 ;;
69 cmp.gtu p6,p7=r9,r28
70(p6) br.cond.sptk.few stacked
71 ;;
72static: cmp.eq p6,p7=PAL_PTCE_INFO,r28
73(p7) br.cond.sptk.few 1f
74 ;;
75 mov r8=0 /* status = 0 */
76 movl r9=0x100000000 /* tc.base */
77 movl r10=0x0000000200000003 /* count[0], count[1] */
78 movl r11=0x1000000000002000 /* stride[0], stride[1] */
79 br.cond.sptk.few rp
801: cmp.eq p6,p7=PAL_FREQ_RATIOS,r28
81(p7) br.cond.sptk.few 1f
82 mov r8=0 /* status = 0 */
83 movl r9 =0x100000064 /* proc_ratio (1/100) */
84 movl r10=0x100000100 /* bus_ratio<<32 (1/256) */
85 movl r11=0x100000064 /* itc_ratio<<32 (1/100) */
86 ;;
871: cmp.eq p6,p7=PAL_RSE_INFO,r28
88(p7) br.cond.sptk.few 1f
89 mov r8=0 /* status = 0 */
90 mov r9=96 /* num phys stacked */
91 mov r10=0 /* hints */
92 mov r11=0
93 br.cond.sptk.few rp
941: cmp.eq p6,p7=PAL_CACHE_FLUSH,r28 /* PAL_CACHE_FLUSH */
95(p7) br.cond.sptk.few 1f
96 mov r9=ar.lc
97 movl r8=524288 /* flush 512k million cache lines (16MB) */
98 ;;
99 mov ar.lc=r8
100 movl r8=0xe000000000000000
101 ;;
102.loop: fc r8
103 add r8=32,r8
104 br.cloop.sptk.few .loop
105 sync.i
106 ;;
107 srlz.i
108 ;;
109 mov ar.lc=r9
110 mov r8=r0
111 ;;
1121: cmp.eq p6,p7=PAL_PERF_MON_INFO,r28
113(p7) br.cond.sptk.few 1f
114 mov r8=0 /* status = 0 */
115 movl r9 =0x08122f04 /* generic=4 width=47 retired=8 cycles=18 */
116 mov r10=0 /* reserved */
117 mov r11=0 /* reserved */
118 mov r16=0xffff /* implemented PMC */
119 mov r17=0x3ffff /* implemented PMD */
120 add r18=8,r29 /* second index */
121 ;;
122 st8 [r29]=r16,16 /* store implemented PMC */
123 st8 [r18]=r0,16 /* clear remaining bits */
124 ;;
125 st8 [r29]=r0,16 /* clear remaining bits */
126 st8 [r18]=r0,16 /* clear remaining bits */
127 ;;
128 st8 [r29]=r17,16 /* store implemented PMD */
129 st8 [r18]=r0,16 /* clear remaining bits */
130 mov r16=0xf0 /* cycles count capable PMC */
131 ;;
132 st8 [r29]=r0,16 /* clear remaining bits */
133 st8 [r18]=r0,16 /* clear remaining bits */
134 mov r17=0xf0 /* retired bundles capable PMC */
135 ;;
136 st8 [r29]=r16,16 /* store cycles capable */
137 st8 [r18]=r0,16 /* clear remaining bits */
138 ;;
139 st8 [r29]=r0,16 /* clear remaining bits */
140 st8 [r18]=r0,16 /* clear remaining bits */
141 ;;
142 st8 [r29]=r17,16 /* store retired bundle capable */
143 st8 [r18]=r0,16 /* clear remaining bits */
144 ;;
145 st8 [r29]=r0,16 /* clear remaining bits */
146 st8 [r18]=r0,16 /* clear remaining bits */
147 ;;
1481: cmp.eq p6,p7=PAL_VM_SUMMARY,r28
149(p7) br.cond.sptk.few 1f
150 mov r8=0 /* status = 0 */
151 movl r9=0x2044040020F1865 /* num_tc_levels=2, num_unique_tcs=4 */
152 /* max_itr_entry=64, max_dtr_entry=64 */
153 /* hash_tag_id=2, max_pkr=15 */
154 /* key_size=24, phys_add_size=50, vw=1 */
155 movl r10=0x183C /* rid_size=24, impl_va_msb=60 */
156 ;;
1571: cmp.eq p6,p7=PAL_MEM_ATTRIB,r28
158(p7) br.cond.sptk.few 1f
159 mov r8=0 /* status = 0 */
160 mov r9=0x80|0x01 /* NatPage|WB */
161 ;;
1621: br.cond.sptk.few rp
163stacked:
164 br.ret.sptk.few rp
165END(pal_emulator_static)
diff --git a/arch/ia64/hp/sim/boot/bootloader.c b/arch/ia64/hp/sim/boot/bootloader.c
deleted file mode 100644
index 6d804608dc81..000000000000
--- a/arch/ia64/hp/sim/boot/bootloader.c
+++ /dev/null
@@ -1,175 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * arch/ia64/hp/sim/boot/bootloader.c
4 *
5 * Loads an ELF kernel.
6 *
7 * Copyright (C) 1998-2003 Hewlett-Packard Co
8 * David Mosberger-Tang <davidm@hpl.hp.com>
9 * Stephane Eranian <eranian@hpl.hp.com>
10 *
11 * 01/07/99 S.Eranian modified to pass command line arguments to kernel
12 */
13struct task_struct; /* forward declaration for elf.h */
14
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
25#include "ssc.h"
26
27struct disk_req {
28 unsigned long addr;
29 unsigned len;
30};
31
32struct disk_stat {
33 int fd;
34 unsigned count;
35};
36
37extern void jmp_to_kernel (unsigned long bp, unsigned long e_entry);
38extern struct ia64_boot_param *sys_fw_init (const char *args, int arglen);
39extern void debug_break (void);
40
41static void
42cons_write (const char *buf)
43{
44 unsigned long ch;
45
46 while ((ch = *buf++) != '\0') {
47 ssc(ch, 0, 0, 0, SSC_PUTCHAR);
48 if (ch == '\n')
49 ssc('\r', 0, 0, 0, SSC_PUTCHAR);
50 }
51}
52
53#define MAX_ARGS 32
54
55void
56start_bootloader (void)
57{
58 static char mem[4096];
59 static char buffer[1024];
60 unsigned long off;
61 int fd, i;
62 struct disk_req req;
63 struct disk_stat stat;
64 struct elfhdr *elf;
65 struct elf_phdr *elf_phdr; /* program header */
66 unsigned long e_entry, e_phoff, e_phnum;
67 register struct ia64_boot_param *bp;
68 char *kpath, *args;
69 long arglen = 0;
70
71 ssc(0, 0, 0, 0, SSC_CONSOLE_INIT);
72
73 /*
74 * S.Eranian: extract the commandline argument from the simulator
75 *
76 * The expected format is as follows:
77 *
78 * kernelname args...
79 *
80 * Both are optional but you can't have the second one without the first.
81 */
82 arglen = ssc((long) buffer, 0, 0, 0, SSC_GET_ARGS);
83
84 kpath = "vmlinux";
85 args = buffer;
86 if (arglen > 0) {
87 kpath = buffer;
88 while (*args != ' ' && *args != '\0')
89 ++args, --arglen;
90 if (*args == ' ')
91 *args++ = '\0', --arglen;
92 }
93
94 if (arglen <= 0) {
95 args = "";
96 arglen = 1;
97 }
98
99 fd = ssc((long) kpath, 1, 0, 0, SSC_OPEN);
100
101 if (fd < 0) {
102 cons_write(kpath);
103 cons_write(": file not found, reboot now\n");
104 for(;;);
105 }
106 stat.fd = fd;
107 off = 0;
108
109 req.len = sizeof(mem);
110 req.addr = (long) mem;
111 ssc(fd, 1, (long) &req, off, SSC_READ);
112 ssc((long) &stat, 0, 0, 0, SSC_WAIT_COMPLETION);
113
114 elf = (struct elfhdr *) mem;
115 if (elf->e_ident[0] == 0x7f && strncmp(elf->e_ident + 1, "ELF", 3) != 0) {
116 cons_write("not an ELF file\n");
117 return;
118 }
119 if (elf->e_type != ET_EXEC) {
120 cons_write("not an ELF executable\n");
121 return;
122 }
123 if (!elf_check_arch(elf)) {
124 cons_write("kernel not for this processor\n");
125 return;
126 }
127
128 e_entry = elf->e_entry;
129 e_phnum = elf->e_phnum;
130 e_phoff = elf->e_phoff;
131
132 cons_write("loading ");
133 cons_write(kpath);
134 cons_write("...\n");
135
136 for (i = 0; i < e_phnum; ++i) {
137 req.len = sizeof(*elf_phdr);
138 req.addr = (long) mem;
139 ssc(fd, 1, (long) &req, e_phoff, SSC_READ);
140 ssc((long) &stat, 0, 0, 0, SSC_WAIT_COMPLETION);
141 if (stat.count != sizeof(*elf_phdr)) {
142 cons_write("failed to read phdr\n");
143 return;
144 }
145 e_phoff += sizeof(*elf_phdr);
146
147 elf_phdr = (struct elf_phdr *) mem;
148
149 if (elf_phdr->p_type != PT_LOAD)
150 continue;
151
152 req.len = elf_phdr->p_filesz;
153 req.addr = __pa(elf_phdr->p_paddr);
154 ssc(fd, 1, (long) &req, elf_phdr->p_offset, SSC_READ);
155 ssc((long) &stat, 0, 0, 0, SSC_WAIT_COMPLETION);
156 memset((char *)__pa(elf_phdr->p_paddr) + elf_phdr->p_filesz, 0,
157 elf_phdr->p_memsz - elf_phdr->p_filesz);
158 }
159 ssc(fd, 0, 0, 0, SSC_CLOSE);
160
161 cons_write("starting kernel...\n");
162
163 /* fake an I/O base address: */
164 ia64_setreg(_IA64_REG_AR_KR0, 0xffffc000000UL);
165
166 bp = sys_fw_init(args, arglen);
167
168 ssc(0, (long) kpath, 0, 0, SSC_LOAD_SYMBOLS);
169
170 debug_break();
171 jmp_to_kernel((unsigned long) bp, e_entry);
172
173 cons_write("kernel returned!\n");
174 ssc(-1, 0, 0, 0, SSC_EXIT);
175}
diff --git a/arch/ia64/hp/sim/boot/bootloader.lds b/arch/ia64/hp/sim/boot/bootloader.lds
deleted file mode 100644
index f3f284d6514c..000000000000
--- a/arch/ia64/hp/sim/boot/bootloader.lds
+++ /dev/null
@@ -1,67 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2OUTPUT_FORMAT("elf64-ia64-little")
3OUTPUT_ARCH(ia64)
4ENTRY(_start)
5SECTIONS
6{
7 /* Read-only sections, merged into text segment: */
8 . = 0x100000;
9
10 _text = .;
11 .text : { *(__ivt_section) *(.text) }
12 _etext = .;
13
14 /* Global data */
15 _data = .;
16 .rodata : { *(.rodata) *(.rodata.*) }
17 .data : { *(.data) *(.gnu.linkonce.d*) CONSTRUCTORS }
18 __gp = ALIGN (8) + 0x200000;
19 .got : { *(.got.plt) *(.got) }
20 /* We want the small data sections together, so single-instruction offsets
21 can access them all, and initialized data all before uninitialized, so
22 we can shorten the on-disk segment size. */
23 .sdata : { *(.sdata) }
24 _edata = .;
25
26 __bss_start = .;
27 .sbss : { *(.sbss) *(.scommon) }
28 .bss : { *(.bss) *(COMMON) }
29 . = ALIGN(64 / 8);
30 __bss_stop = .;
31 _end = . ;
32
33 /* Stabs debugging sections. */
34 .stab 0 : { *(.stab) }
35 .stabstr 0 : { *(.stabstr) }
36 .stab.excl 0 : { *(.stab.excl) }
37 .stab.exclstr 0 : { *(.stab.exclstr) }
38 .stab.index 0 : { *(.stab.index) }
39 .stab.indexstr 0 : { *(.stab.indexstr) }
40 .comment 0 : { *(.comment) }
41 /* DWARF debug sections.
42 Symbols in the DWARF debugging sections are relative to the beginning
43 of the section so we begin them at 0. */
44 /* DWARF 1 */
45 .debug 0 : { *(.debug) }
46 .line 0 : { *(.line) }
47 /* GNU DWARF 1 extensions */
48 .debug_srcinfo 0 : { *(.debug_srcinfo) }
49 .debug_sfnames 0 : { *(.debug_sfnames) }
50 /* DWARF 1.1 and DWARF 2 */
51 .debug_aranges 0 : { *(.debug_aranges) }
52 .debug_pubnames 0 : { *(.debug_pubnames) }
53 /* DWARF 2 */
54 .debug_info 0 : { *(.debug_info) }
55 .debug_abbrev 0 : { *(.debug_abbrev) }
56 .debug_line 0 : { *(.debug_line) }
57 .debug_frame 0 : { *(.debug_frame) }
58 .debug_str 0 : { *(.debug_str) }
59 .debug_loc 0 : { *(.debug_loc) }
60 .debug_macinfo 0 : { *(.debug_macinfo) }
61 /* SGI/MIPS DWARF 2 extensions */
62 .debug_weaknames 0 : { *(.debug_weaknames) }
63 .debug_funcnames 0 : { *(.debug_funcnames) }
64 .debug_typenames 0 : { *(.debug_typenames) }
65 .debug_varnames 0 : { *(.debug_varnames) }
66 /* These must appear regardless of . */
67}
diff --git a/arch/ia64/hp/sim/boot/fw-emu.c b/arch/ia64/hp/sim/boot/fw-emu.c
deleted file mode 100644
index 517fb2822e04..000000000000
--- a/arch/ia64/hp/sim/boot/fw-emu.c
+++ /dev/null
@@ -1,374 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * PAL & SAL emulation.
4 *
5 * Copyright (C) 1998-2001 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 */
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#include <asm/setup.h>
18
19#include "ssc.h"
20
21#define MB (1024*1024UL)
22
23#define SIMPLE_MEMMAP 1
24
25#if SIMPLE_MEMMAP
26# define NUM_MEM_DESCS 4
27#else
28# define NUM_MEM_DESCS 16
29#endif
30
31static char fw_mem[( sizeof(struct ia64_boot_param)
32 + sizeof(efi_system_table_t)
33 + sizeof(efi_runtime_services_t)
34 + 1*sizeof(efi_config_table_t)
35 + sizeof(struct ia64_sal_systab)
36 + sizeof(struct ia64_sal_desc_entry_point)
37 + NUM_MEM_DESCS*(sizeof(efi_memory_desc_t))
38 + 1024)] __attribute__ ((aligned (8)));
39
40#define SECS_PER_HOUR (60 * 60)
41#define SECS_PER_DAY (SECS_PER_HOUR * 24)
42
43/* Compute the `struct tm' representation of *T,
44 offset OFFSET seconds east of UTC,
45 and store year, yday, mon, mday, wday, hour, min, sec into *TP.
46 Return nonzero if successful. */
47int
48offtime (unsigned long t, efi_time_t *tp)
49{
50 const unsigned short int __mon_yday[2][13] =
51 {
52 /* Normal years. */
53 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
54 /* Leap years. */
55 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
56 };
57 long int days, rem, y;
58 const unsigned short int *ip;
59
60 days = t / SECS_PER_DAY;
61 rem = t % SECS_PER_DAY;
62 while (rem < 0) {
63 rem += SECS_PER_DAY;
64 --days;
65 }
66 while (rem >= SECS_PER_DAY) {
67 rem -= SECS_PER_DAY;
68 ++days;
69 }
70 tp->hour = rem / SECS_PER_HOUR;
71 rem %= SECS_PER_HOUR;
72 tp->minute = rem / 60;
73 tp->second = rem % 60;
74 /* January 1, 1970 was a Thursday. */
75 y = 1970;
76
77# define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
78# define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
79# define __isleap(year) \
80 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
81
82 while (days < 0 || days >= (__isleap (y) ? 366 : 365)) {
83 /* Guess a corrected year, assuming 365 days per year. */
84 long int yg = y + days / 365 - (days % 365 < 0);
85
86 /* Adjust DAYS and Y to match the guessed year. */
87 days -= ((yg - y) * 365 + LEAPS_THRU_END_OF (yg - 1)
88 - LEAPS_THRU_END_OF (y - 1));
89 y = yg;
90 }
91 tp->year = y;
92 ip = __mon_yday[__isleap(y)];
93 for (y = 11; days < (long int) ip[y]; --y)
94 continue;
95 days -= ip[y];
96 tp->month = y + 1;
97 tp->day = days + 1;
98 return 1;
99}
100
101extern void pal_emulator_static (void);
102
103/* Macro to emulate SAL call using legacy IN and OUT calls to CF8, CFC etc.. */
104
105#define BUILD_CMD(addr) ((0x80000000 | (addr)) & ~3)
106
107#define REG_OFFSET(addr) (0x00000000000000FF & (addr))
108#define DEVICE_FUNCTION(addr) (0x000000000000FF00 & (addr))
109#define BUS_NUMBER(addr) (0x0000000000FF0000 & (addr))
110
111static efi_status_t
112fw_efi_get_time (efi_time_t *tm, efi_time_cap_t *tc)
113{
114#if defined(CONFIG_IA64_HP_SIM) || defined(CONFIG_IA64_GENERIC)
115 struct {
116 int tv_sec; /* must be 32bits to work */
117 int tv_usec;
118 } tv32bits;
119
120 ssc((unsigned long) &tv32bits, 0, 0, 0, SSC_GET_TOD);
121
122 memset(tm, 0, sizeof(*tm));
123 offtime(tv32bits.tv_sec, tm);
124
125 if (tc)
126 memset(tc, 0, sizeof(*tc));
127#else
128# error Not implemented yet...
129#endif
130 return EFI_SUCCESS;
131}
132
133static void
134efi_reset_system (int reset_type, efi_status_t status, unsigned long data_size, efi_char16_t *data)
135{
136#if defined(CONFIG_IA64_HP_SIM) || defined(CONFIG_IA64_GENERIC)
137 ssc(status, 0, 0, 0, SSC_EXIT);
138#else
139# error Not implemented yet...
140#endif
141}
142
143static efi_status_t
144efi_unimplemented (void)
145{
146 return EFI_UNSUPPORTED;
147}
148
149static struct sal_ret_values
150sal_emulator (long index, unsigned long in1, unsigned long in2,
151 unsigned long in3, unsigned long in4, unsigned long in5,
152 unsigned long in6, unsigned long in7)
153{
154 long r9 = 0;
155 long r10 = 0;
156 long r11 = 0;
157 long status;
158
159 /*
160 * Don't do a "switch" here since that gives us code that
161 * isn't self-relocatable.
162 */
163 status = 0;
164 if (index == SAL_FREQ_BASE) {
165 if (in1 == SAL_FREQ_BASE_PLATFORM)
166 r9 = 200000000;
167 else if (in1 == SAL_FREQ_BASE_INTERVAL_TIMER) {
168 /*
169 * Is this supposed to be the cr.itc frequency
170 * or something platform specific? The SAL
171 * doc ain't exactly clear on this...
172 */
173 r9 = 700000000;
174 } else if (in1 == SAL_FREQ_BASE_REALTIME_CLOCK)
175 r9 = 1;
176 else
177 status = -1;
178 } else if (index == SAL_SET_VECTORS) {
179 ;
180 } else if (index == SAL_GET_STATE_INFO) {
181 ;
182 } else if (index == SAL_GET_STATE_INFO_SIZE) {
183 ;
184 } else if (index == SAL_CLEAR_STATE_INFO) {
185 ;
186 } else if (index == SAL_MC_RENDEZ) {
187 ;
188 } else if (index == SAL_MC_SET_PARAMS) {
189 ;
190 } else if (index == SAL_CACHE_FLUSH) {
191 ;
192 } else if (index == SAL_CACHE_INIT) {
193 ;
194#ifdef CONFIG_PCI
195 } else if (index == SAL_PCI_CONFIG_READ) {
196 /*
197 * in1 contains the PCI configuration address and in2
198 * the size of the read. The value that is read is
199 * returned via the general register r9.
200 */
201 outl(BUILD_CMD(in1), 0xCF8);
202 if (in2 == 1) /* Reading byte */
203 r9 = inb(0xCFC + ((REG_OFFSET(in1) & 3)));
204 else if (in2 == 2) /* Reading word */
205 r9 = inw(0xCFC + ((REG_OFFSET(in1) & 2)));
206 else /* Reading dword */
207 r9 = inl(0xCFC);
208 status = PCIBIOS_SUCCESSFUL;
209 } else if (index == SAL_PCI_CONFIG_WRITE) {
210 /*
211 * in1 contains the PCI configuration address, in2 the
212 * size of the write, and in3 the actual value to be
213 * written out.
214 */
215 outl(BUILD_CMD(in1), 0xCF8);
216 if (in2 == 1) /* Writing byte */
217 outb(in3, 0xCFC + ((REG_OFFSET(in1) & 3)));
218 else if (in2 == 2) /* Writing word */
219 outw(in3, 0xCFC + ((REG_OFFSET(in1) & 2)));
220 else /* Writing dword */
221 outl(in3, 0xCFC);
222 status = PCIBIOS_SUCCESSFUL;
223#endif /* CONFIG_PCI */
224 } else if (index == SAL_UPDATE_PAL) {
225 ;
226 } else {
227 status = -1;
228 }
229 return ((struct sal_ret_values) {status, r9, r10, r11});
230}
231
232struct ia64_boot_param *
233sys_fw_init (const char *args, int arglen)
234{
235 efi_system_table_t *efi_systab;
236 efi_runtime_services_t *efi_runtime;
237 efi_config_table_t *efi_tables;
238 struct ia64_sal_systab *sal_systab;
239 efi_memory_desc_t *efi_memmap, *md;
240 unsigned long *pal_desc, *sal_desc;
241 struct ia64_sal_desc_entry_point *sal_ed;
242 struct ia64_boot_param *bp;
243 unsigned char checksum = 0;
244 char *cp, *cmd_line;
245 int i = 0;
246# define MAKE_MD(typ, attr, start, end) \
247 do { \
248 md = efi_memmap + i++; \
249 md->type = typ; \
250 md->pad = 0; \
251 md->phys_addr = start; \
252 md->virt_addr = 0; \
253 md->num_pages = (end - start) >> 12; \
254 md->attribute = attr; \
255 } while (0)
256
257 memset(fw_mem, 0, sizeof(fw_mem));
258
259 pal_desc = (unsigned long *) &pal_emulator_static;
260 sal_desc = (unsigned long *) &sal_emulator;
261
262 cp = fw_mem;
263 efi_systab = (void *) cp; cp += sizeof(*efi_systab);
264 efi_runtime = (void *) cp; cp += sizeof(*efi_runtime);
265 efi_tables = (void *) cp; cp += sizeof(*efi_tables);
266 sal_systab = (void *) cp; cp += sizeof(*sal_systab);
267 sal_ed = (void *) cp; cp += sizeof(*sal_ed);
268 efi_memmap = (void *) cp; cp += NUM_MEM_DESCS*sizeof(*efi_memmap);
269 bp = (void *) cp; cp += sizeof(*bp);
270 cmd_line = (void *) cp;
271
272 if (args) {
273 if (arglen >= 1024)
274 arglen = 1023;
275 memcpy(cmd_line, args, arglen);
276 } else {
277 arglen = 0;
278 }
279 cmd_line[arglen] = '\0';
280
281 memset(efi_systab, 0, sizeof(*efi_systab));
282 efi_systab->hdr.signature = EFI_SYSTEM_TABLE_SIGNATURE;
283 efi_systab->hdr.revision = ((1 << 16) | 00);
284 efi_systab->hdr.headersize = sizeof(efi_systab->hdr);
285 efi_systab->fw_vendor = __pa("H\0e\0w\0l\0e\0t\0t\0-\0P\0a\0c\0k\0a\0r\0d\0\0");
286 efi_systab->fw_revision = 1;
287 efi_systab->runtime = (void *) __pa(efi_runtime);
288 efi_systab->nr_tables = 1;
289 efi_systab->tables = __pa(efi_tables);
290
291 efi_runtime->hdr.signature = EFI_RUNTIME_SERVICES_SIGNATURE;
292 efi_runtime->hdr.revision = EFI_RUNTIME_SERVICES_REVISION;
293 efi_runtime->hdr.headersize = sizeof(efi_runtime->hdr);
294 efi_runtime->get_time = (void *)__pa(&fw_efi_get_time);
295 efi_runtime->set_time = (void *)__pa(&efi_unimplemented);
296 efi_runtime->get_wakeup_time = (void *)__pa(&efi_unimplemented);
297 efi_runtime->set_wakeup_time = (void *)__pa(&efi_unimplemented);
298 efi_runtime->set_virtual_address_map = (void *)__pa(&efi_unimplemented);
299 efi_runtime->get_variable = (void *)__pa(&efi_unimplemented);
300 efi_runtime->get_next_variable = (void *)__pa(&efi_unimplemented);
301 efi_runtime->set_variable = (void *)__pa(&efi_unimplemented);
302 efi_runtime->get_next_high_mono_count = (void *)__pa(&efi_unimplemented);
303 efi_runtime->reset_system = (void *)__pa(&efi_reset_system);
304
305 efi_tables->guid = SAL_SYSTEM_TABLE_GUID;
306 efi_tables->table = __pa(sal_systab);
307
308 /* fill in the SAL system table: */
309 memcpy(sal_systab->signature, "SST_", 4);
310 sal_systab->size = sizeof(*sal_systab);
311 sal_systab->sal_rev_minor = 1;
312 sal_systab->sal_rev_major = 0;
313 sal_systab->entry_count = 1;
314
315#ifdef CONFIG_IA64_GENERIC
316 strcpy(sal_systab->oem_id, "Generic");
317 strcpy(sal_systab->product_id, "IA-64 system");
318#endif
319
320#ifdef CONFIG_IA64_HP_SIM
321 strcpy(sal_systab->oem_id, "Hewlett-Packard");
322 strcpy(sal_systab->product_id, "HP-simulator");
323#endif
324
325 /* fill in an entry point: */
326 sal_ed->type = SAL_DESC_ENTRY_POINT;
327 sal_ed->pal_proc = __pa(pal_desc[0]);
328 sal_ed->sal_proc = __pa(sal_desc[0]);
329 sal_ed->gp = __pa(sal_desc[1]);
330
331 for (cp = (char *) sal_systab; cp < (char *) efi_memmap; ++cp)
332 checksum += *cp;
333
334 sal_systab->checksum = -checksum;
335
336#if SIMPLE_MEMMAP
337 /* simulate free memory at physical address zero */
338 MAKE_MD(EFI_BOOT_SERVICES_DATA, EFI_MEMORY_WB, 0*MB, 1*MB);
339 MAKE_MD(EFI_PAL_CODE, EFI_MEMORY_WB, 1*MB, 2*MB);
340 MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, 2*MB, 130*MB);
341 MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, 4096*MB, 4128*MB);
342#else
343 MAKE_MD( 4, 0x9, 0x0000000000000000, 0x0000000000001000);
344 MAKE_MD( 7, 0x9, 0x0000000000001000, 0x000000000008a000);
345 MAKE_MD( 4, 0x9, 0x000000000008a000, 0x00000000000a0000);
346 MAKE_MD( 5, 0x8000000000000009, 0x00000000000c0000, 0x0000000000100000);
347 MAKE_MD( 7, 0x9, 0x0000000000100000, 0x0000000004400000);
348 MAKE_MD( 2, 0x9, 0x0000000004400000, 0x0000000004be5000);
349 MAKE_MD( 7, 0x9, 0x0000000004be5000, 0x000000007f77e000);
350 MAKE_MD( 6, 0x8000000000000009, 0x000000007f77e000, 0x000000007fb94000);
351 MAKE_MD( 6, 0x8000000000000009, 0x000000007fb94000, 0x000000007fb95000);
352 MAKE_MD( 6, 0x8000000000000009, 0x000000007fb95000, 0x000000007fc00000);
353 MAKE_MD(13, 0x8000000000000009, 0x000000007fc00000, 0x000000007fc3a000);
354 MAKE_MD( 7, 0x9, 0x000000007fc3a000, 0x000000007fea0000);
355 MAKE_MD( 5, 0x8000000000000009, 0x000000007fea0000, 0x000000007fea8000);
356 MAKE_MD( 7, 0x9, 0x000000007fea8000, 0x000000007feab000);
357 MAKE_MD( 5, 0x8000000000000009, 0x000000007feab000, 0x000000007ffff000);
358 MAKE_MD( 7, 0x9, 0x00000000ff400000, 0x0000000104000000);
359#endif
360
361 bp->efi_systab = __pa(&fw_mem);
362 bp->efi_memmap = __pa(efi_memmap);
363 bp->efi_memmap_size = NUM_MEM_DESCS*sizeof(efi_memory_desc_t);
364 bp->efi_memdesc_size = sizeof(efi_memory_desc_t);
365 bp->efi_memdesc_version = 1;
366 bp->command_line = __pa(cmd_line);
367 bp->console_info.num_cols = 80;
368 bp->console_info.num_rows = 25;
369 bp->console_info.orig_x = 0;
370 bp->console_info.orig_y = 24;
371 bp->fpswa = 0;
372
373 return bp;
374}
diff --git a/arch/ia64/hp/sim/boot/ssc.h b/arch/ia64/hp/sim/boot/ssc.h
deleted file mode 100644
index 88752c7509e0..000000000000
--- a/arch/ia64/hp/sim/boot/ssc.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 1998-2003 Hewlett-Packard Co
4 * David Mosberger-Tang <davidm@hpl.hp.com>
5 * Stephane Eranian <eranian@hpl.hp.com>
6 */
7#ifndef ssc_h
8#define ssc_h
9
10/* Simulator system calls: */
11
12#define SSC_CONSOLE_INIT 20
13#define SSC_GETCHAR 21
14#define SSC_PUTCHAR 31
15#define SSC_OPEN 50
16#define SSC_CLOSE 51
17#define SSC_READ 52
18#define SSC_WRITE 53
19#define SSC_GET_COMPLETION 54
20#define SSC_WAIT_COMPLETION 55
21#define SSC_CONNECT_INTERRUPT 58
22#define SSC_GENERATE_INTERRUPT 59
23#define SSC_SET_PERIODIC_INTERRUPT 60
24#define SSC_GET_RTC 65
25#define SSC_EXIT 66
26#define SSC_LOAD_SYMBOLS 69
27#define SSC_GET_TOD 74
28
29#define SSC_GET_ARGS 75
30
31/*
32 * Simulator system call.
33 */
34extern long ssc (long arg0, long arg1, long arg2, long arg3, int nr);
35
36#endif /* ssc_h */
diff --git a/arch/ia64/hp/sim/hpsim.S b/arch/ia64/hp/sim/hpsim.S
deleted file mode 100644
index 44b4d53e1689..000000000000
--- a/arch/ia64/hp/sim/hpsim.S
+++ /dev/null
@@ -1,11 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#include <asm/asmmacro.h>
3
4/*
5 * Simulator system call.
6 */
7GLOBAL_ENTRY(ia64_ssc)
8 mov r15=r36
9 break 0x80001
10 br.ret.sptk.many rp
11END(ia64_ssc)
diff --git a/arch/ia64/hp/sim/hpsim_console.c b/arch/ia64/hp/sim/hpsim_console.c
deleted file mode 100644
index bffd9f67a8a1..000000000000
--- a/arch/ia64/hp/sim/hpsim_console.c
+++ /dev/null
@@ -1,77 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Platform dependent support for HP simulator.
4 *
5 * Copyright (C) 1998, 1999, 2002 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 * Copyright (C) 1999 Vijay Chander <vijay@engr.sgi.com>
8 */
9
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/param.h>
13#include <linux/string.h>
14#include <linux/types.h>
15#include <linux/tty.h>
16#include <linux/kdev_t.h>
17#include <linux/console.h>
18
19#include <asm/delay.h>
20#include <asm/irq.h>
21#include <asm/pal.h>
22#include <asm/machvec.h>
23#include <asm/pgtable.h>
24#include <asm/sal.h>
25#include <asm/hpsim.h>
26
27#include "hpsim_ssc.h"
28
29static int simcons_init (struct console *, char *);
30static void simcons_write (struct console *, const char *, unsigned);
31static struct tty_driver *simcons_console_device (struct console *, int *);
32
33static struct console hpsim_cons = {
34 .name = "simcons",
35 .write = simcons_write,
36 .device = simcons_console_device,
37 .setup = simcons_init,
38 .flags = CON_PRINTBUFFER,
39 .index = -1,
40};
41
42static int
43simcons_init (struct console *cons, char *options)
44{
45 return 0;
46}
47
48static void
49simcons_write (struct console *cons, const char *buf, unsigned count)
50{
51 unsigned long ch;
52
53 while (count-- > 0) {
54 ch = *buf++;
55 ia64_ssc(ch, 0, 0, 0, SSC_PUTCHAR);
56 if (ch == '\n')
57 ia64_ssc('\r', 0, 0, 0, SSC_PUTCHAR);
58 }
59}
60
61static struct tty_driver *simcons_console_device (struct console *c, int *index)
62{
63 *index = c->index;
64 return hp_simserial_driver;
65}
66
67int simcons_register(void)
68{
69 if (!ia64_platform_is("hpsim"))
70 return 1;
71
72 if (hpsim_cons.flags & CON_ENABLED)
73 return 1;
74
75 register_console(&hpsim_cons);
76 return 0;
77}
diff --git a/arch/ia64/hp/sim/hpsim_irq.c b/arch/ia64/hp/sim/hpsim_irq.c
deleted file mode 100644
index 2f1cc59650ab..000000000000
--- a/arch/ia64/hp/sim/hpsim_irq.c
+++ /dev/null
@@ -1,76 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Platform dependent support for HP simulator.
4 *
5 * Copyright (C) 1998-2001 Hewlett-Packard Co
6 * Copyright (C) 1998-2001 David Mosberger-Tang <davidm@hpl.hp.com>
7 */
8
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/irq.h>
13
14#include "hpsim_ssc.h"
15
16static unsigned int
17hpsim_irq_startup(struct irq_data *data)
18{
19 return 0;
20}
21
22static void
23hpsim_irq_noop(struct irq_data *data)
24{
25}
26
27static int
28hpsim_set_affinity_noop(struct irq_data *d, const struct cpumask *b, bool f)
29{
30 return 0;
31}
32
33static struct irq_chip irq_type_hp_sim = {
34 .name = "hpsim",
35 .irq_startup = hpsim_irq_startup,
36 .irq_shutdown = hpsim_irq_noop,
37 .irq_enable = hpsim_irq_noop,
38 .irq_disable = hpsim_irq_noop,
39 .irq_ack = hpsim_irq_noop,
40 .irq_set_affinity = hpsim_set_affinity_noop,
41};
42
43static void hpsim_irq_set_chip(int irq)
44{
45 struct irq_chip *chip = irq_get_chip(irq);
46
47 if (chip == &no_irq_chip)
48 irq_set_chip(irq, &irq_type_hp_sim);
49}
50
51static void hpsim_connect_irq(int intr, int irq)
52{
53 ia64_ssc(intr, irq, 0, 0, SSC_CONNECT_INTERRUPT);
54}
55
56int hpsim_get_irq(int intr)
57{
58 int irq = assign_irq_vector(AUTO_ASSIGN);
59
60 if (irq >= 0) {
61 hpsim_irq_set_chip(irq);
62 irq_set_handler(irq, handle_simple_irq);
63 hpsim_connect_irq(intr, irq);
64 }
65
66 return irq;
67}
68
69void __init
70hpsim_irq_init (void)
71{
72 int i;
73
74 for_each_active_irq(i)
75 hpsim_irq_set_chip(i);
76}
diff --git a/arch/ia64/hp/sim/hpsim_machvec.c b/arch/ia64/hp/sim/hpsim_machvec.c
deleted file mode 100644
index c21419359185..000000000000
--- a/arch/ia64/hp/sim/hpsim_machvec.c
+++ /dev/null
@@ -1,3 +0,0 @@
1#define MACHVEC_PLATFORM_NAME hpsim
2#define MACHVEC_PLATFORM_HEADER <asm/machvec_hpsim.h>
3#include <asm/machvec_init.h>
diff --git a/arch/ia64/hp/sim/hpsim_setup.c b/arch/ia64/hp/sim/hpsim_setup.c
deleted file mode 100644
index 41d21d51dc4d..000000000000
--- a/arch/ia64/hp/sim/hpsim_setup.c
+++ /dev/null
@@ -1,41 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Platform dependent support for HP simulator.
4 *
5 * Copyright (C) 1998, 1999, 2002 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 * Copyright (C) 1999 Vijay Chander <vijay@engr.sgi.com>
8 */
9#include <linux/console.h>
10#include <linux/init.h>
11#include <linux/kdev_t.h>
12#include <linux/kernel.h>
13#include <linux/major.h>
14#include <linux/param.h>
15#include <linux/root_dev.h>
16#include <linux/string.h>
17#include <linux/types.h>
18
19#include <asm/delay.h>
20#include <asm/irq.h>
21#include <asm/pal.h>
22#include <asm/machvec.h>
23#include <asm/pgtable.h>
24#include <asm/sal.h>
25#include <asm/hpsim.h>
26
27#include "hpsim_ssc.h"
28
29void
30ia64_ctl_trace (long on)
31{
32 ia64_ssc(on, 0, 0, 0, SSC_CTL_TRACE);
33}
34
35void __init
36hpsim_setup (char **cmdline_p)
37{
38 ROOT_DEV = Root_SDA1; /* default to first SCSI drive */
39
40 simcons_register();
41}
diff --git a/arch/ia64/hp/sim/hpsim_ssc.h b/arch/ia64/hp/sim/hpsim_ssc.h
deleted file mode 100644
index 6fd97a487811..000000000000
--- a/arch/ia64/hp/sim/hpsim_ssc.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Platform dependent support for HP simulator.
4 *
5 * Copyright (C) 1998, 1999 Hewlett-Packard Co
6 * Copyright (C) 1998, 1999 David Mosberger-Tang <davidm@hpl.hp.com>
7 * Copyright (C) 1999 Vijay Chander <vijay@engr.sgi.com>
8 */
9#ifndef _IA64_PLATFORM_HPSIM_SSC_H
10#define _IA64_PLATFORM_HPSIM_SSC_H
11
12/* Simulator system calls: */
13
14#define SSC_CONSOLE_INIT 20
15#define SSC_GETCHAR 21
16#define SSC_PUTCHAR 31
17#define SSC_CONNECT_INTERRUPT 58
18#define SSC_GENERATE_INTERRUPT 59
19#define SSC_SET_PERIODIC_INTERRUPT 60
20#define SSC_GET_RTC 65
21#define SSC_EXIT 66
22#define SSC_LOAD_SYMBOLS 69
23#define SSC_GET_TOD 74
24#define SSC_CTL_TRACE 76
25
26#define SSC_NETDEV_PROBE 100
27#define SSC_NETDEV_SEND 101
28#define SSC_NETDEV_RECV 102
29#define SSC_NETDEV_ATTACH 103
30#define SSC_NETDEV_DETACH 104
31
32/*
33 * Simulator system call.
34 */
35extern long ia64_ssc (long arg0, long arg1, long arg2, long arg3, int nr);
36
37#endif /* _IA64_PLATFORM_HPSIM_SSC_H */
diff --git a/arch/ia64/hp/sim/simeth.c b/arch/ia64/hp/sim/simeth.c
deleted file mode 100644
index f39ef2b4ed72..000000000000
--- a/arch/ia64/hp/sim/simeth.c
+++ /dev/null
@@ -1,510 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Simulated Ethernet Driver
4 *
5 * Copyright (C) 1999-2001, 2003 Hewlett-Packard Co
6 * Stephane Eranian <eranian@hpl.hp.com>
7 */
8#include <linux/kernel.h>
9#include <linux/sched.h>
10#include <linux/types.h>
11#include <linux/in.h>
12#include <linux/string.h>
13#include <linux/init.h>
14#include <linux/errno.h>
15#include <linux/interrupt.h>
16#include <linux/netdevice.h>
17#include <linux/etherdevice.h>
18#include <linux/inetdevice.h>
19#include <linux/if_ether.h>
20#include <linux/if_arp.h>
21#include <linux/skbuff.h>
22#include <linux/notifier.h>
23#include <linux/bitops.h>
24#include <asm/irq.h>
25#include <asm/hpsim.h>
26
27#include "hpsim_ssc.h"
28
29#define SIMETH_RECV_MAX 10
30
31/*
32 * Maximum possible received frame for Ethernet.
33 * We preallocate an sk_buff of that size to avoid costly
34 * memcpy for temporary buffer into sk_buff. We do basically
35 * what's done in other drivers, like eepro with a ring.
36 * The difference is, of course, that we don't have real DMA !!!
37 */
38#define SIMETH_FRAME_SIZE ETH_FRAME_LEN
39
40
41#define NETWORK_INTR 8
42
43struct simeth_local {
44 struct net_device_stats stats;
45 int simfd; /* descriptor in the simulator */
46};
47
48static int simeth_probe1(void);
49static int simeth_open(struct net_device *dev);
50static int simeth_close(struct net_device *dev);
51static int simeth_tx(struct sk_buff *skb, struct net_device *dev);
52static int simeth_rx(struct net_device *dev);
53static struct net_device_stats *simeth_get_stats(struct net_device *dev);
54static irqreturn_t simeth_interrupt(int irq, void *dev_id);
55static void set_multicast_list(struct net_device *dev);
56static int simeth_device_event(struct notifier_block *this,unsigned long event, void *ptr);
57
58static char *simeth_version="0.3";
59
60/*
61 * This variable is used to establish a mapping between the Linux/ia64 kernel
62 * and the host linux kernel.
63 *
64 * As of today, we support only one card, even though most of the code
65 * is ready for many more. The mapping is then:
66 * linux/ia64 -> linux/x86
67 * eth0 -> eth1
68 *
69 * In the future, we some string operations, we could easily support up
70 * to 10 cards (0-9).
71 *
72 * The default mapping can be changed on the kernel command line by
73 * specifying simeth=ethX (or whatever string you want).
74 */
75static char *simeth_device="eth0"; /* default host interface to use */
76
77
78
79static volatile unsigned int card_count; /* how many cards "found" so far */
80static int simeth_debug; /* set to 1 to get debug information */
81
82/*
83 * Used to catch IFF_UP & IFF_DOWN events
84 */
85static struct notifier_block simeth_dev_notifier = {
86 simeth_device_event,
87 NULL
88};
89
90
91/*
92 * Function used when using a kernel command line option.
93 *
94 * Format: simeth=interface_name (like eth0)
95 */
96static int __init
97simeth_setup(char *str)
98{
99 simeth_device = str;
100 return 1;
101}
102
103__setup("simeth=", simeth_setup);
104
105/*
106 * Function used to probe for simeth devices when not installed
107 * as a loadable module
108 */
109
110int __init
111simeth_probe (void)
112{
113 int r;
114
115 printk(KERN_INFO "simeth: v%s\n", simeth_version);
116
117 r = simeth_probe1();
118
119 if (r == 0) register_netdevice_notifier(&simeth_dev_notifier);
120
121 return r;
122}
123
124static inline int
125netdev_probe(char *name, unsigned char *ether)
126{
127 return ia64_ssc(__pa(name), __pa(ether), 0,0, SSC_NETDEV_PROBE);
128}
129
130
131static inline int
132netdev_attach(int fd, int irq, unsigned int ipaddr)
133{
134 /* this puts the host interface in the right mode (start interrupting) */
135 return ia64_ssc(fd, ipaddr, 0,0, SSC_NETDEV_ATTACH);
136}
137
138
139static inline int
140netdev_detach(int fd)
141{
142 /*
143 * inactivate the host interface (don't interrupt anymore) */
144 return ia64_ssc(fd, 0,0,0, SSC_NETDEV_DETACH);
145}
146
147static inline int
148netdev_send(int fd, unsigned char *buf, unsigned int len)
149{
150 return ia64_ssc(fd, __pa(buf), len, 0, SSC_NETDEV_SEND);
151}
152
153static inline int
154netdev_read(int fd, unsigned char *buf, unsigned int len)
155{
156 return ia64_ssc(fd, __pa(buf), len, 0, SSC_NETDEV_RECV);
157}
158
159static const struct net_device_ops simeth_netdev_ops = {
160 .ndo_open = simeth_open,
161 .ndo_stop = simeth_close,
162 .ndo_start_xmit = simeth_tx,
163 .ndo_get_stats = simeth_get_stats,
164 .ndo_set_rx_mode = set_multicast_list, /* not yet used */
165
166};
167
168/*
169 * Function shared with module code, so cannot be in init section
170 *
171 * So far this function "detects" only one card (test_&_set) but could
172 * be extended easily.
173 *
174 * Return:
175 * - -ENODEV is no device found
176 * - -ENOMEM is no more memory
177 * - 0 otherwise
178 */
179static int
180simeth_probe1(void)
181{
182 unsigned char mac_addr[ETH_ALEN];
183 struct simeth_local *local;
184 struct net_device *dev;
185 int fd, err, rc;
186
187 /*
188 * XXX Fix me
189 * let's support just one card for now
190 */
191 if (test_and_set_bit(0, &card_count))
192 return -ENODEV;
193
194 /*
195 * check with the simulator for the device
196 */
197 fd = netdev_probe(simeth_device, mac_addr);
198 if (fd == -1)
199 return -ENODEV;
200
201 dev = alloc_etherdev(sizeof(struct simeth_local));
202 if (!dev)
203 return -ENOMEM;
204
205 memcpy(dev->dev_addr, mac_addr, sizeof(mac_addr));
206
207 local = netdev_priv(dev);
208 local->simfd = fd; /* keep track of underlying file descriptor */
209
210 dev->netdev_ops = &simeth_netdev_ops;
211
212 err = register_netdev(dev);
213 if (err) {
214 free_netdev(dev);
215 return err;
216 }
217
218 /*
219 * attach the interrupt in the simulator, this does enable interrupts
220 * until a netdev_attach() is called
221 */
222 if ((rc = hpsim_get_irq(NETWORK_INTR)) < 0)
223 panic("%s: out of interrupt vectors!\n", __func__);
224 dev->irq = rc;
225
226 printk(KERN_INFO "%s: hosteth=%s simfd=%d, HwAddr=%pm, IRQ %d\n",
227 dev->name, simeth_device, local->simfd, dev->dev_addr, dev->irq);
228
229 return 0;
230}
231
232/*
233 * actually binds the device to an interrupt vector
234 */
235static int
236simeth_open(struct net_device *dev)
237{
238 if (request_irq(dev->irq, simeth_interrupt, 0, "simeth", dev)) {
239 printk(KERN_WARNING "simeth: unable to get IRQ %d.\n", dev->irq);
240 return -EAGAIN;
241 }
242
243 netif_start_queue(dev);
244
245 return 0;
246}
247
248/* copied from lapbether.c */
249static __inline__ int dev_is_ethdev(struct net_device *dev)
250{
251 return ( dev->type == ARPHRD_ETHER && strncmp(dev->name, "dummy", 5));
252}
253
254
255/*
256 * Handler for IFF_UP or IFF_DOWN
257 *
258 * The reason for that is that we don't want to be interrupted when the
259 * interface is down. There is no way to unconnect in the simualtor. Instead
260 * we use this function to shutdown packet processing in the frame filter
261 * in the simulator. Thus no interrupts are generated
262 *
263 *
264 * That's also the place where we pass the IP address of this device to the
265 * simulator so that that we can start filtering packets for it
266 *
267 * There may be a better way of doing this, but I don't know which yet.
268 */
269static int
270simeth_device_event(struct notifier_block *this,unsigned long event, void *ptr)
271{
272 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
273 struct simeth_local *local;
274 struct in_device *in_dev;
275 struct in_ifaddr **ifap = NULL;
276 struct in_ifaddr *ifa = NULL;
277 int r;
278
279
280 if ( ! dev ) {
281 printk(KERN_WARNING "simeth_device_event dev=0\n");
282 return NOTIFY_DONE;
283 }
284
285 if (dev_net(dev) != &init_net)
286 return NOTIFY_DONE;
287
288 if ( event != NETDEV_UP && event != NETDEV_DOWN ) return NOTIFY_DONE;
289
290 /*
291 * Check whether or not it's for an ethernet device
292 *
293 * XXX Fixme: This works only as long as we support one
294 * type of ethernet device.
295 */
296 if ( !dev_is_ethdev(dev) ) return NOTIFY_DONE;
297
298 if ((in_dev=dev->ip_ptr) != NULL) {
299 for (ifap=&in_dev->ifa_list; (ifa=*ifap) != NULL; ifap=&ifa->ifa_next)
300 if (strcmp(dev->name, ifa->ifa_label) == 0) break;
301 }
302 if ( ifa == NULL ) {
303 printk(KERN_ERR "simeth_open: can't find device %s's ifa\n", dev->name);
304 return NOTIFY_DONE;
305 }
306
307 printk(KERN_INFO "simeth_device_event: %s ipaddr=0x%x\n",
308 dev->name, ntohl(ifa->ifa_local));
309
310 /*
311 * XXX Fix me
312 * if the device was up, and we're simply reconfiguring it, not sure
313 * we get DOWN then UP.
314 */
315
316 local = netdev_priv(dev);
317 /* now do it for real */
318 r = event == NETDEV_UP ?
319 netdev_attach(local->simfd, dev->irq, ntohl(ifa->ifa_local)):
320 netdev_detach(local->simfd);
321
322 printk(KERN_INFO "simeth: netdev_attach/detach: event=%s ->%d\n",
323 event == NETDEV_UP ? "attach":"detach", r);
324
325 return NOTIFY_DONE;
326}
327
328static int
329simeth_close(struct net_device *dev)
330{
331 netif_stop_queue(dev);
332
333 free_irq(dev->irq, dev);
334
335 return 0;
336}
337
338/*
339 * Only used for debug
340 */
341static void
342frame_print(unsigned char *from, unsigned char *frame, int len)
343{
344 int i;
345
346 printk("%s: (%d) %02x", from, len, frame[0] & 0xff);
347 for(i=1; i < 6; i++ ) {
348 printk(":%02x", frame[i] &0xff);
349 }
350 printk(" %2x", frame[6] &0xff);
351 for(i=7; i < 12; i++ ) {
352 printk(":%02x", frame[i] &0xff);
353 }
354 printk(" [%02x%02x]\n", frame[12], frame[13]);
355
356 for(i=14; i < len; i++ ) {
357 printk("%02x ", frame[i] &0xff);
358 if ( (i%10)==0) printk("\n");
359 }
360 printk("\n");
361}
362
363
364/*
365 * Function used to transmit of frame, very last one on the path before
366 * going to the simulator.
367 */
368static int
369simeth_tx(struct sk_buff *skb, struct net_device *dev)
370{
371 struct simeth_local *local = netdev_priv(dev);
372
373#if 0
374 /* ensure we have at least ETH_ZLEN bytes (min frame size) */
375 unsigned int length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
376 /* Where do the extra padding bytes comes from inthe skbuff ? */
377#else
378 /* the real driver in the host system is going to take care of that
379 * or maybe it's the NIC itself.
380 */
381 unsigned int length = skb->len;
382#endif
383
384 local->stats.tx_bytes += skb->len;
385 local->stats.tx_packets++;
386
387
388 if (simeth_debug > 5) frame_print("simeth_tx", skb->data, length);
389
390 netdev_send(local->simfd, skb->data, length);
391
392 /*
393 * we are synchronous on write, so we don't simulate a
394 * trasnmit complete interrupt, thus we don't need to arm a tx
395 */
396
397 dev_kfree_skb(skb);
398 return NETDEV_TX_OK;
399}
400
401static inline struct sk_buff *
402make_new_skb(struct net_device *dev)
403{
404 struct sk_buff *nskb;
405
406 /*
407 * The +2 is used to make sure that the IP header is nicely
408 * aligned (on 4byte boundary I assume 14+2=16)
409 */
410 nskb = dev_alloc_skb(SIMETH_FRAME_SIZE + 2);
411 if ( nskb == NULL ) {
412 printk(KERN_NOTICE "%s: memory squeeze. dropping packet.\n", dev->name);
413 return NULL;
414 }
415
416 skb_reserve(nskb, 2); /* Align IP on 16 byte boundaries */
417
418 skb_put(nskb,SIMETH_FRAME_SIZE);
419
420 return nskb;
421}
422
423/*
424 * called from interrupt handler to process a received frame
425 */
426static int
427simeth_rx(struct net_device *dev)
428{
429 struct simeth_local *local;
430 struct sk_buff *skb;
431 int len;
432 int rcv_count = SIMETH_RECV_MAX;
433
434 local = netdev_priv(dev);
435 /*
436 * the loop concept has been borrowed from other drivers
437 * looks to me like it's a throttling thing to avoid pushing to many
438 * packets at one time into the stack. Making sure we can process them
439 * upstream and make forward progress overall
440 */
441 do {
442 if ( (skb=make_new_skb(dev)) == NULL ) {
443 printk(KERN_NOTICE "%s: memory squeeze. dropping packet.\n", dev->name);
444 local->stats.rx_dropped++;
445 return 0;
446 }
447 /*
448 * Read only one frame at a time
449 */
450 len = netdev_read(local->simfd, skb->data, SIMETH_FRAME_SIZE);
451 if ( len == 0 ) {
452 if ( simeth_debug > 0 ) printk(KERN_WARNING "%s: count=%d netdev_read=0\n",
453 dev->name, SIMETH_RECV_MAX-rcv_count);
454 break;
455 }
456#if 0
457 /*
458 * XXX Fix me
459 * Should really do a csum+copy here
460 */
461 skb_copy_to_linear_data(skb, frame, len);
462#endif
463 skb->protocol = eth_type_trans(skb, dev);
464
465 if ( simeth_debug > 6 ) frame_print("simeth_rx", skb->data, len);
466
467 /*
468 * push the packet up & trigger software interrupt
469 */
470 netif_rx(skb);
471
472 local->stats.rx_packets++;
473 local->stats.rx_bytes += len;
474
475 } while ( --rcv_count );
476
477 return len; /* 0 = nothing left to read, otherwise, we can try again */
478}
479
480/*
481 * Interrupt handler (Yes, we can do it too !!!)
482 */
483static irqreturn_t
484simeth_interrupt(int irq, void *dev_id)
485{
486 struct net_device *dev = dev_id;
487
488 /*
489 * very simple loop because we get interrupts only when receiving
490 */
491 while (simeth_rx(dev));
492 return IRQ_HANDLED;
493}
494
495static struct net_device_stats *
496simeth_get_stats(struct net_device *dev)
497{
498 struct simeth_local *local = netdev_priv(dev);
499
500 return &local->stats;
501}
502
503/* fake multicast ability */
504static void
505set_multicast_list(struct net_device *dev)
506{
507 printk(KERN_WARNING "%s: set_multicast_list called\n", dev->name);
508}
509
510__initcall(simeth_probe);
diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c
deleted file mode 100644
index 0a8a74271173..000000000000
--- a/arch/ia64/hp/sim/simscsi.c
+++ /dev/null
@@ -1,373 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Simulated SCSI driver.
4 *
5 * Copyright (C) 1999, 2001-2003 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 * Stephane Eranian <eranian@hpl.hp.com>
8 *
9 * 02/01/15 David Mosberger Updated for v2.5.1
10 * 99/12/18 David Mosberger Added support for READ10/WRITE10 needed by linux v2.3.33
11 */
12#include <linux/blkdev.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <linux/kernel.h>
16#include <linux/timer.h>
17#include <asm/irq.h>
18#include "hpsim_ssc.h"
19
20#include <scsi/scsi.h>
21#include <scsi/scsi_cmnd.h>
22#include <scsi/scsi_device.h>
23#include <scsi/scsi_host.h>
24
25#define DEBUG_SIMSCSI 0
26
27#define SIMSCSI_REQ_QUEUE_LEN 64
28#define DEFAULT_SIMSCSI_ROOT "/var/ski-disks/sd"
29
30/* Simulator system calls: */
31
32#define SSC_OPEN 50
33#define SSC_CLOSE 51
34#define SSC_READ 52
35#define SSC_WRITE 53
36#define SSC_GET_COMPLETION 54
37#define SSC_WAIT_COMPLETION 55
38
39#define SSC_WRITE_ACCESS 2
40#define SSC_READ_ACCESS 1
41
42#if DEBUG_SIMSCSI
43 int simscsi_debug;
44# define DBG simscsi_debug
45#else
46# define DBG 0
47#endif
48
49static struct Scsi_Host *host;
50
51static void simscsi_interrupt (unsigned long val);
52static DECLARE_TASKLET(simscsi_tasklet, simscsi_interrupt, 0);
53
54struct disk_req {
55 unsigned long addr;
56 unsigned len;
57};
58
59struct disk_stat {
60 int fd;
61 unsigned count;
62};
63
64static int desc[16] = {
65 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
66};
67
68static struct queue_entry {
69 struct scsi_cmnd *sc;
70} queue[SIMSCSI_REQ_QUEUE_LEN];
71
72static int rd, wr;
73static atomic_t num_reqs = ATOMIC_INIT(0);
74
75/* base name for default disks */
76static char *simscsi_root = DEFAULT_SIMSCSI_ROOT;
77
78#define MAX_ROOT_LEN 128
79
80/*
81 * used to setup a new base for disk images
82 * to use /foo/bar/disk[a-z] as disk images
83 * you have to specify simscsi=/foo/bar/disk on the command line
84 */
85static int __init
86simscsi_setup (char *s)
87{
88 /* XXX Fix me we may need to strcpy() ? */
89 if (strlen(s) > MAX_ROOT_LEN) {
90 printk(KERN_ERR "simscsi_setup: prefix too long---using default %s\n",
91 simscsi_root);
92 } else
93 simscsi_root = s;
94 return 1;
95}
96
97__setup("simscsi=", simscsi_setup);
98
99static void
100simscsi_interrupt (unsigned long val)
101{
102 struct scsi_cmnd *sc;
103
104 while ((sc = queue[rd].sc) != NULL) {
105 atomic_dec(&num_reqs);
106 queue[rd].sc = NULL;
107 if (DBG)
108 printk("simscsi_interrupt: done with %u\n",
109 sc->request->tag);
110 (*sc->scsi_done)(sc);
111 rd = (rd + 1) % SIMSCSI_REQ_QUEUE_LEN;
112 }
113}
114
115static int
116simscsi_biosparam (struct scsi_device *sdev, struct block_device *n,
117 sector_t capacity, int ip[])
118{
119 ip[0] = 64; /* heads */
120 ip[1] = 32; /* sectors */
121 ip[2] = capacity >> 11; /* cylinders */
122 return 0;
123}
124
125static void
126simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset)
127{
128 int i;
129 struct scatterlist *sl;
130 struct disk_stat stat;
131 struct disk_req req;
132
133 stat.fd = desc[sc->device->id];
134
135 scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) {
136 req.addr = __pa(sg_virt(sl));
137 req.len = sl->length;
138 if (DBG)
139 printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n",
140 mode == SSC_READ ? "read":"write", req.addr, offset,
141 scsi_sg_count(sc) - i, sl->length);
142 ia64_ssc(stat.fd, 1, __pa(&req), offset, mode);
143 ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION);
144
145 /* should not happen in our case */
146 if (stat.count != req.len) {
147 sc->result = DID_ERROR << 16;
148 return;
149 }
150 offset += sl->length;
151 }
152 sc->result = GOOD;
153}
154
155/*
156 * function handling both READ_6/WRITE_6 (non-scatter/gather mode)
157 * commands.
158 * Added 02/26/99 S.Eranian
159 */
160static void
161simscsi_readwrite6 (struct scsi_cmnd *sc, int mode)
162{
163 unsigned long offset;
164
165 offset = (((sc->cmnd[1] & 0x1f) << 16) | (sc->cmnd[2] << 8) | sc->cmnd[3])*512;
166 simscsi_sg_readwrite(sc, mode, offset);
167}
168
169static size_t
170simscsi_get_disk_size (int fd)
171{
172 struct disk_stat stat;
173 size_t bit, sectors = 0;
174 struct disk_req req;
175 char buf[512];
176
177 /*
178 * This is a bit kludgey: the simulator doesn't provide a
179 * direct way of determining the disk size, so we do a binary
180 * search, assuming a maximum disk size of 128GB.
181 */
182 for (bit = (128UL << 30)/512; bit != 0; bit >>= 1) {
183 req.addr = __pa(&buf);
184 req.len = sizeof(buf);
185 ia64_ssc(fd, 1, __pa(&req), ((sectors | bit) - 1)*512, SSC_READ);
186 stat.fd = fd;
187 ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION);
188 if (stat.count == sizeof(buf))
189 sectors |= bit;
190 }
191 return sectors - 1; /* return last valid sector number */
192}
193
194static void
195simscsi_readwrite10 (struct scsi_cmnd *sc, int mode)
196{
197 unsigned long offset;
198
199 offset = (((unsigned long)sc->cmnd[2] << 24)
200 | ((unsigned long)sc->cmnd[3] << 16)
201 | ((unsigned long)sc->cmnd[4] << 8)
202 | ((unsigned long)sc->cmnd[5] << 0))*512UL;
203 simscsi_sg_readwrite(sc, mode, offset);
204}
205
206static int
207simscsi_queuecommand_lck (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
208{
209 unsigned int target_id = sc->device->id;
210 char fname[MAX_ROOT_LEN+16];
211 size_t disk_size;
212 char *buf;
213 char localbuf[36];
214#if DEBUG_SIMSCSI
215 register long sp asm ("sp");
216
217 if (DBG)
218 printk("simscsi_queuecommand: target=%d,cmnd=%u,sc=%u,sp=%lx,done=%p\n",
219 target_id, sc->cmnd[0], sc->request->tag, sp, done);
220#endif
221
222 sc->result = DID_BAD_TARGET << 16;
223 sc->scsi_done = done;
224 if (target_id <= 15 && sc->device->lun == 0) {
225 switch (sc->cmnd[0]) {
226 case INQUIRY:
227 if (scsi_bufflen(sc) < 35) {
228 break;
229 }
230 sprintf (fname, "%s%c", simscsi_root, 'a' + target_id);
231 desc[target_id] = ia64_ssc(__pa(fname), SSC_READ_ACCESS|SSC_WRITE_ACCESS,
232 0, 0, SSC_OPEN);
233 if (desc[target_id] < 0) {
234 /* disk doesn't exist... */
235 break;
236 }
237 buf = localbuf;
238 buf[0] = 0; /* magnetic disk */
239 buf[1] = 0; /* not a removable medium */
240 buf[2] = 2; /* SCSI-2 compliant device */
241 buf[3] = 2; /* SCSI-2 response data format */
242 buf[4] = 31; /* additional length (bytes) */
243 buf[5] = 0; /* reserved */
244 buf[6] = 0; /* reserved */
245 buf[7] = 0; /* various flags */
246 memcpy(buf + 8, "HP SIMULATED DISK 0.00", 28);
247 scsi_sg_copy_from_buffer(sc, buf, 36);
248 sc->result = GOOD;
249 break;
250
251 case TEST_UNIT_READY:
252 sc->result = GOOD;
253 break;
254
255 case READ_6:
256 if (desc[target_id] < 0 )
257 break;
258 simscsi_readwrite6(sc, SSC_READ);
259 break;
260
261 case READ_10:
262 if (desc[target_id] < 0 )
263 break;
264 simscsi_readwrite10(sc, SSC_READ);
265 break;
266
267 case WRITE_6:
268 if (desc[target_id] < 0)
269 break;
270 simscsi_readwrite6(sc, SSC_WRITE);
271 break;
272
273 case WRITE_10:
274 if (desc[target_id] < 0)
275 break;
276 simscsi_readwrite10(sc, SSC_WRITE);
277 break;
278
279 case READ_CAPACITY:
280 if (desc[target_id] < 0 || scsi_bufflen(sc) < 8) {
281 break;
282 }
283 buf = localbuf;
284 disk_size = simscsi_get_disk_size(desc[target_id]);
285
286 buf[0] = (disk_size >> 24) & 0xff;
287 buf[1] = (disk_size >> 16) & 0xff;
288 buf[2] = (disk_size >> 8) & 0xff;
289 buf[3] = (disk_size >> 0) & 0xff;
290 /* set block size of 512 bytes: */
291 buf[4] = 0;
292 buf[5] = 0;
293 buf[6] = 2;
294 buf[7] = 0;
295 scsi_sg_copy_from_buffer(sc, buf, 8);
296 sc->result = GOOD;
297 break;
298
299 case MODE_SENSE:
300 case MODE_SENSE_10:
301 /* sd.c uses this to determine whether disk does write-caching. */
302 scsi_sg_copy_from_buffer(sc, (char *)empty_zero_page,
303 PAGE_SIZE);
304 sc->result = GOOD;
305 break;
306
307 case START_STOP:
308 printk(KERN_ERR "START_STOP\n");
309 break;
310
311 default:
312 panic("simscsi: unknown SCSI command %u\n", sc->cmnd[0]);
313 }
314 }
315 if (sc->result == DID_BAD_TARGET) {
316 sc->result |= DRIVER_SENSE << 24;
317 sc->sense_buffer[0] = 0x70;
318 sc->sense_buffer[2] = 0x00;
319 }
320 if (atomic_read(&num_reqs) >= SIMSCSI_REQ_QUEUE_LEN) {
321 panic("Attempt to queue command while command is pending!!");
322 }
323 atomic_inc(&num_reqs);
324 queue[wr].sc = sc;
325 wr = (wr + 1) % SIMSCSI_REQ_QUEUE_LEN;
326
327 tasklet_schedule(&simscsi_tasklet);
328 return 0;
329}
330
331static DEF_SCSI_QCMD(simscsi_queuecommand)
332
333static int
334simscsi_host_reset (struct scsi_cmnd *sc)
335{
336 printk(KERN_ERR "simscsi_host_reset: not implemented\n");
337 return 0;
338}
339
340static struct scsi_host_template driver_template = {
341 .name = "simulated SCSI host adapter",
342 .proc_name = "simscsi",
343 .queuecommand = simscsi_queuecommand,
344 .eh_host_reset_handler = simscsi_host_reset,
345 .bios_param = simscsi_biosparam,
346 .can_queue = SIMSCSI_REQ_QUEUE_LEN,
347 .this_id = -1,
348 .sg_tablesize = SG_ALL,
349 .max_sectors = 1024,
350 .cmd_per_lun = SIMSCSI_REQ_QUEUE_LEN,
351 .dma_boundary = PAGE_SIZE - 1,
352};
353
354static int __init
355simscsi_init(void)
356{
357 int error;
358
359 host = scsi_host_alloc(&driver_template, 0);
360 if (!host)
361 return -ENOMEM;
362
363 error = scsi_add_host(host, NULL);
364 if (error)
365 goto free_host;
366 scsi_scan_host(host);
367 return 0;
368
369 free_host:
370 scsi_host_put(host);
371 return error;
372}
373device_initcall(simscsi_init);
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
deleted file mode 100644
index 1a338e541334..000000000000
--- a/arch/ia64/hp/sim/simserial.c
+++ /dev/null
@@ -1,521 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Simulated Serial Driver (fake serial)
4 *
5 * This driver is mostly used for bringup purposes and will go away.
6 * It has a strong dependency on the system console. All outputs
7 * are rerouted to the same facility as the one used by printk which, in our
8 * case means sys_sim.c console (goes via the simulator).
9 *
10 * Copyright (C) 1999-2000, 2002-2003 Hewlett-Packard Co
11 * Stephane Eranian <eranian@hpl.hp.com>
12 * David Mosberger-Tang <davidm@hpl.hp.com>
13 */
14
15#include <linux/init.h>
16#include <linux/errno.h>
17#include <linux/sched.h>
18#include <linux/sched/debug.h>
19#include <linux/tty.h>
20#include <linux/tty_flip.h>
21#include <linux/major.h>
22#include <linux/fcntl.h>
23#include <linux/mm.h>
24#include <linux/seq_file.h>
25#include <linux/slab.h>
26#include <linux/capability.h>
27#include <linux/circ_buf.h>
28#include <linux/console.h>
29#include <linux/irq.h>
30#include <linux/module.h>
31#include <linux/serial.h>
32#include <linux/sysrq.h>
33#include <linux/uaccess.h>
34
35#include <asm/hpsim.h>
36
37#include "hpsim_ssc.h"
38
39#undef SIMSERIAL_DEBUG /* define this to get some debug information */
40
41#define KEYBOARD_INTR 3 /* must match with simulator! */
42
43#define NR_PORTS 1 /* only one port for now */
44
45struct serial_state {
46 struct tty_port port;
47 struct circ_buf xmit;
48 int irq;
49 int x_char;
50};
51
52static struct serial_state rs_table[NR_PORTS];
53
54struct tty_driver *hp_simserial_driver;
55
56static struct console *console;
57
58static void receive_chars(struct tty_port *port)
59{
60 unsigned char ch;
61 static unsigned char seen_esc = 0;
62
63 while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) {
64 if (ch == 27 && seen_esc == 0) {
65 seen_esc = 1;
66 continue;
67 } else if (seen_esc == 1 && ch == 'O') {
68 seen_esc = 2;
69 continue;
70 } else if (seen_esc == 2) {
71 if (ch == 'P') /* F1 */
72 show_state();
73#ifdef CONFIG_MAGIC_SYSRQ
74 if (ch == 'S') { /* F4 */
75 do {
76 ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR);
77 } while (!ch);
78 handle_sysrq(ch);
79 }
80#endif
81 seen_esc = 0;
82 continue;
83 }
84 seen_esc = 0;
85
86 if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0)
87 break;
88 }
89 tty_flip_buffer_push(port);
90}
91
92/*
93 * This is the serial driver's interrupt routine for a single port
94 */
95static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
96{
97 struct serial_state *info = dev_id;
98
99 receive_chars(&info->port);
100
101 return IRQ_HANDLED;
102}
103
104/*
105 * -------------------------------------------------------------------
106 * Here ends the serial interrupt routines.
107 * -------------------------------------------------------------------
108 */
109
110static int rs_put_char(struct tty_struct *tty, unsigned char ch)
111{
112 struct serial_state *info = tty->driver_data;
113 unsigned long flags;
114
115 if (!info->xmit.buf)
116 return 0;
117
118 local_irq_save(flags);
119 if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) == 0) {
120 local_irq_restore(flags);
121 return 0;
122 }
123 info->xmit.buf[info->xmit.head] = ch;
124 info->xmit.head = (info->xmit.head + 1) & (SERIAL_XMIT_SIZE-1);
125 local_irq_restore(flags);
126 return 1;
127}
128
129static void transmit_chars(struct tty_struct *tty, struct serial_state *info,
130 int *intr_done)
131{
132 int count;
133 unsigned long flags;
134
135 local_irq_save(flags);
136
137 if (info->x_char) {
138 char c = info->x_char;
139
140 console->write(console, &c, 1);
141
142 info->x_char = 0;
143
144 goto out;
145 }
146
147 if (info->xmit.head == info->xmit.tail || tty->stopped) {
148#ifdef SIMSERIAL_DEBUG
149 printk("transmit_chars: head=%d, tail=%d, stopped=%d\n",
150 info->xmit.head, info->xmit.tail, tty->stopped);
151#endif
152 goto out;
153 }
154 /*
155 * We removed the loop and try to do it in to chunks. We need
156 * 2 operations maximum because it's a ring buffer.
157 *
158 * First from current to tail if possible.
159 * Then from the beginning of the buffer until necessary
160 */
161
162 count = min(CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE),
163 SERIAL_XMIT_SIZE - info->xmit.tail);
164 console->write(console, info->xmit.buf+info->xmit.tail, count);
165
166 info->xmit.tail = (info->xmit.tail+count) & (SERIAL_XMIT_SIZE-1);
167
168 /*
169 * We have more at the beginning of the buffer
170 */
171 count = CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
172 if (count) {
173 console->write(console, info->xmit.buf, count);
174 info->xmit.tail += count;
175 }
176out:
177 local_irq_restore(flags);
178}
179
180static void rs_flush_chars(struct tty_struct *tty)
181{
182 struct serial_state *info = tty->driver_data;
183
184 if (info->xmit.head == info->xmit.tail || tty->stopped ||
185 !info->xmit.buf)
186 return;
187
188 transmit_chars(tty, info, NULL);
189}
190
191static int rs_write(struct tty_struct * tty,
192 const unsigned char *buf, int count)
193{
194 struct serial_state *info = tty->driver_data;
195 int c, ret = 0;
196 unsigned long flags;
197
198 if (!info->xmit.buf)
199 return 0;
200
201 local_irq_save(flags);
202 while (1) {
203 c = CIRC_SPACE_TO_END(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
204 if (count < c)
205 c = count;
206 if (c <= 0) {
207 break;
208 }
209 memcpy(info->xmit.buf + info->xmit.head, buf, c);
210 info->xmit.head = ((info->xmit.head + c) &
211 (SERIAL_XMIT_SIZE-1));
212 buf += c;
213 count -= c;
214 ret += c;
215 }
216 local_irq_restore(flags);
217 /*
218 * Hey, we transmit directly from here in our case
219 */
220 if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) &&
221 !tty->stopped)
222 transmit_chars(tty, info, NULL);
223
224 return ret;
225}
226
227static int rs_write_room(struct tty_struct *tty)
228{
229 struct serial_state *info = tty->driver_data;
230
231 return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
232}
233
234static int rs_chars_in_buffer(struct tty_struct *tty)
235{
236 struct serial_state *info = tty->driver_data;
237
238 return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
239}
240
241static void rs_flush_buffer(struct tty_struct *tty)
242{
243 struct serial_state *info = tty->driver_data;
244 unsigned long flags;
245
246 local_irq_save(flags);
247 info->xmit.head = info->xmit.tail = 0;
248 local_irq_restore(flags);
249
250 tty_wakeup(tty);
251}
252
253/*
254 * This function is used to send a high-priority XON/XOFF character to
255 * the device
256 */
257static void rs_send_xchar(struct tty_struct *tty, char ch)
258{
259 struct serial_state *info = tty->driver_data;
260
261 info->x_char = ch;
262 if (ch) {
263 /*
264 * I guess we could call console->write() directly but
265 * let's do that for now.
266 */
267 transmit_chars(tty, info, NULL);
268 }
269}
270
271/*
272 * ------------------------------------------------------------
273 * rs_throttle()
274 *
275 * This routine is called by the upper-layer tty layer to signal that
276 * incoming characters should be throttled.
277 * ------------------------------------------------------------
278 */
279static void rs_throttle(struct tty_struct * tty)
280{
281 if (I_IXOFF(tty))
282 rs_send_xchar(tty, STOP_CHAR(tty));
283
284 printk(KERN_INFO "simrs_throttle called\n");
285}
286
287static void rs_unthrottle(struct tty_struct * tty)
288{
289 struct serial_state *info = tty->driver_data;
290
291 if (I_IXOFF(tty)) {
292 if (info->x_char)
293 info->x_char = 0;
294 else
295 rs_send_xchar(tty, START_CHAR(tty));
296 }
297 printk(KERN_INFO "simrs_unthrottle called\n");
298}
299
300static int rs_setserial(struct tty_struct *tty, struct serial_struct *ss)
301{
302 return 0;
303}
304
305static int rs_getserial(struct tty_struct *tty, struct serial_struct *ss)
306{
307 return 0;
308}
309
310static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
311{
312 if ((cmd != TIOCSERCONFIG) && (cmd != TIOCMIWAIT)) {
313 if (tty_io_error(tty))
314 return -EIO;
315 }
316
317 switch (cmd) {
318 case TIOCMIWAIT:
319 return 0;
320 case TIOCSERCONFIG:
321 case TIOCSERGETLSR: /* Get line status register */
322 return -EINVAL;
323 }
324 return -ENOIOCTLCMD;
325}
326
327/*
328 * This routine will shutdown a serial port; interrupts are disabled, and
329 * DTR is dropped if the hangup on close termio flag is on.
330 */
331static void shutdown(struct tty_port *port)
332{
333 struct serial_state *info = container_of(port, struct serial_state,
334 port);
335 unsigned long flags;
336
337 local_irq_save(flags);
338 if (info->irq)
339 free_irq(info->irq, info);
340
341 if (info->xmit.buf) {
342 free_page((unsigned long) info->xmit.buf);
343 info->xmit.buf = NULL;
344 }
345 local_irq_restore(flags);
346}
347
348static void rs_close(struct tty_struct *tty, struct file * filp)
349{
350 struct serial_state *info = tty->driver_data;
351
352 tty_port_close(&info->port, tty, filp);
353}
354
355static void rs_hangup(struct tty_struct *tty)
356{
357 struct serial_state *info = tty->driver_data;
358
359 rs_flush_buffer(tty);
360 tty_port_hangup(&info->port);
361}
362
363static int activate(struct tty_port *port, struct tty_struct *tty)
364{
365 struct serial_state *state = container_of(port, struct serial_state,
366 port);
367 unsigned long flags, page;
368 int retval = 0;
369
370 page = get_zeroed_page(GFP_KERNEL);
371 if (!page)
372 return -ENOMEM;
373
374 local_irq_save(flags);
375
376 if (state->xmit.buf)
377 free_page(page);
378 else
379 state->xmit.buf = (unsigned char *) page;
380
381 if (state->irq) {
382 retval = request_irq(state->irq, rs_interrupt_single, 0,
383 "simserial", state);
384 if (retval)
385 goto errout;
386 }
387
388 state->xmit.head = state->xmit.tail = 0;
389errout:
390 local_irq_restore(flags);
391 return retval;
392}
393
394
395/*
396 * This routine is called whenever a serial port is opened. It
397 * enables interrupts for a serial port, linking in its async structure into
398 * the IRQ chain. It also performs the serial-specific
399 * initialization for the tty structure.
400 */
401static int rs_open(struct tty_struct *tty, struct file * filp)
402{
403 struct serial_state *info = rs_table + tty->index;
404 struct tty_port *port = &info->port;
405
406 tty->driver_data = info;
407 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
408
409 /*
410 * figure out which console to use (should be one already)
411 */
412 console = console_drivers;
413 while (console) {
414 if ((console->flags & CON_ENABLED) && console->write) break;
415 console = console->next;
416 }
417
418 return tty_port_open(port, tty, filp);
419}
420
421/*
422 * /proc fs routines....
423 */
424
425static int rs_proc_show(struct seq_file *m, void *v)
426{
427 int i;
428
429 seq_printf(m, "simserinfo:1.0\n");
430 for (i = 0; i < NR_PORTS; i++)
431 seq_printf(m, "%d: uart:16550 port:3F8 irq:%d\n",
432 i, rs_table[i].irq);
433 return 0;
434}
435
436static const struct tty_operations hp_ops = {
437 .open = rs_open,
438 .close = rs_close,
439 .write = rs_write,
440 .put_char = rs_put_char,
441 .flush_chars = rs_flush_chars,
442 .write_room = rs_write_room,
443 .chars_in_buffer = rs_chars_in_buffer,
444 .flush_buffer = rs_flush_buffer,
445 .ioctl = rs_ioctl,
446 .throttle = rs_throttle,
447 .unthrottle = rs_unthrottle,
448 .send_xchar = rs_send_xchar,
449 .set_serial = rs_setserial,
450 .get_serial = rs_getserial,
451 .hangup = rs_hangup,
452 .proc_show = rs_proc_show,
453};
454
455static const struct tty_port_operations hp_port_ops = {
456 .activate = activate,
457 .shutdown = shutdown,
458};
459
460static int __init simrs_init(void)
461{
462 struct serial_state *state;
463 int retval;
464
465 if (!ia64_platform_is("hpsim"))
466 return -ENODEV;
467
468 hp_simserial_driver = alloc_tty_driver(NR_PORTS);
469 if (!hp_simserial_driver)
470 return -ENOMEM;
471
472 printk(KERN_INFO "SimSerial driver with no serial options enabled\n");
473
474 /* Initialize the tty_driver structure */
475
476 hp_simserial_driver->driver_name = "simserial";
477 hp_simserial_driver->name = "ttyS";
478 hp_simserial_driver->major = TTY_MAJOR;
479 hp_simserial_driver->minor_start = 64;
480 hp_simserial_driver->type = TTY_DRIVER_TYPE_SERIAL;
481 hp_simserial_driver->subtype = SERIAL_TYPE_NORMAL;
482 hp_simserial_driver->init_termios = tty_std_termios;
483 hp_simserial_driver->init_termios.c_cflag =
484 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
485 hp_simserial_driver->flags = TTY_DRIVER_REAL_RAW;
486 tty_set_operations(hp_simserial_driver, &hp_ops);
487
488 state = rs_table;
489 tty_port_init(&state->port);
490 state->port.ops = &hp_port_ops;
491 state->port.close_delay = 0; /* XXX really 0? */
492
493 retval = hpsim_get_irq(KEYBOARD_INTR);
494 if (retval < 0) {
495 printk(KERN_ERR "%s: out of interrupt vectors!\n",
496 __func__);
497 goto err_free_tty;
498 }
499
500 state->irq = retval;
501
502 /* the port is imaginary */
503 printk(KERN_INFO "ttyS0 at 0x03f8 (irq = %d) is a 16550\n", state->irq);
504
505 tty_port_link_device(&state->port, hp_simserial_driver, 0);
506 retval = tty_register_driver(hp_simserial_driver);
507 if (retval) {
508 printk(KERN_ERR "Couldn't register simserial driver\n");
509 goto err_free_tty;
510 }
511
512 return 0;
513err_free_tty:
514 put_tty_driver(hp_simserial_driver);
515 tty_port_destroy(&state->port);
516 return retval;
517}
518
519#ifndef MODULE
520__initcall(simrs_init);
521#endif
diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index 80c5ef8f475e..0afb3bc4b4a1 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -37,9 +37,7 @@ const char *acpi_get_sysname (void);
37#else 37#else
38static inline const char *acpi_get_sysname (void) 38static inline const char *acpi_get_sysname (void)
39{ 39{
40# if defined (CONFIG_IA64_HP_SIM) 40# if defined (CONFIG_IA64_HP_ZX1)
41 return "hpsim";
42# elif defined (CONFIG_IA64_HP_ZX1)
43 return "hpzx1"; 41 return "hpzx1";
44# elif defined (CONFIG_IA64_HP_ZX1_SWIOTLB) 42# elif defined (CONFIG_IA64_HP_ZX1_SWIOTLB)
45 return "hpzx1_swiotlb"; 43 return "hpzx1_swiotlb";
diff --git a/arch/ia64/include/asm/hpsim.h b/arch/ia64/include/asm/hpsim.h
deleted file mode 100644
index 00fbd5cc8ab8..000000000000
--- a/arch/ia64/include/asm/hpsim.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASMIA64_HPSIM_H
3#define _ASMIA64_HPSIM_H
4
5#ifndef CONFIG_HP_SIMSERIAL_CONSOLE
6static inline int simcons_register(void) { return 1; }
7#else
8int simcons_register(void);
9#endif
10
11struct tty_driver;
12extern struct tty_driver *hp_simserial_driver;
13
14extern int hpsim_get_irq(int intr);
15void ia64_ctl_trace(long on);
16
17#endif
diff --git a/arch/ia64/include/asm/iosapic.h b/arch/ia64/include/asm/iosapic.h
index f48556cb8afc..a91aeb413e17 100644
--- a/arch/ia64/include/asm/iosapic.h
+++ b/arch/ia64/include/asm/iosapic.h
@@ -52,8 +52,6 @@
52 52
53#ifndef __ASSEMBLY__ 53#ifndef __ASSEMBLY__
54 54
55#ifdef CONFIG_IOSAPIC
56
57#define NR_IOSAPICS 256 55#define NR_IOSAPICS 256
58 56
59#define iosapic_pcat_compat_init ia64_native_iosapic_pcat_compat_init 57#define iosapic_pcat_compat_init ia64_native_iosapic_pcat_compat_init
@@ -103,16 +101,6 @@ extern int __init iosapic_register_platform_intr (u32 int_type,
103#ifdef CONFIG_NUMA 101#ifdef CONFIG_NUMA
104extern void map_iosapic_to_node (unsigned int, int); 102extern void map_iosapic_to_node (unsigned int, int);
105#endif 103#endif
106#else
107#define iosapic_system_init(pcat_compat) do { } while (0)
108#define iosapic_init(address,gsi_base) (-EINVAL)
109#define iosapic_remove(gsi_base) (-ENODEV)
110#define iosapic_register_intr(gsi,polarity,trigger) (gsi)
111#define iosapic_unregister_intr(irq) do { } while (0)
112#define iosapic_override_isa_irq(isa_irq,gsi,polarity,trigger) do { } while (0)
113#define iosapic_register_platform_intr(type,gsi,pmi,eid,id, \
114 polarity,trigger) (gsi)
115#endif
116 104
117# endif /* !__ASSEMBLY__ */ 105# endif /* !__ASSEMBLY__ */
118#endif /* __ASM_IA64_IOSAPIC_H */ 106#endif /* __ASM_IA64_IOSAPIC_H */
diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index f426a9829595..5a9a8af79308 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -16,7 +16,6 @@
16struct device; 16struct device;
17 17
18typedef void ia64_mv_setup_t (char **); 18typedef void ia64_mv_setup_t (char **);
19typedef void ia64_mv_irq_init_t (void);
20typedef void ia64_mv_dma_init (void); 19typedef void ia64_mv_dma_init (void);
21typedef const struct dma_map_ops *ia64_mv_dma_get_ops(struct device *); 20typedef const struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);
22 21
@@ -27,9 +26,7 @@ machvec_noop (void)
27 26
28extern void machvec_setup (char **); 27extern void machvec_setup (char **);
29 28
30# if defined (CONFIG_IA64_HP_SIM) 29# if defined (CONFIG_IA64_DIG)
31# include <asm/machvec_hpsim.h>
32# elif defined (CONFIG_IA64_DIG)
33# include <asm/machvec_dig.h> 30# include <asm/machvec_dig.h>
34# elif defined(CONFIG_IA64_DIG_VTD) 31# elif defined(CONFIG_IA64_DIG_VTD)
35# include <asm/machvec_dig_vtd.h> 32# include <asm/machvec_dig_vtd.h>
@@ -46,7 +43,6 @@ extern void machvec_setup (char **);
46# else 43# else
47# define ia64_platform_name ia64_mv.name 44# define ia64_platform_name ia64_mv.name
48# define platform_setup ia64_mv.setup 45# define platform_setup ia64_mv.setup
49# define platform_irq_init ia64_mv.irq_init
50# define platform_dma_init ia64_mv.dma_init 46# define platform_dma_init ia64_mv.dma_init
51# define platform_dma_get_ops ia64_mv.dma_get_ops 47# define platform_dma_get_ops ia64_mv.dma_get_ops
52# endif 48# endif
@@ -59,7 +55,6 @@ extern void machvec_setup (char **);
59struct ia64_machine_vector { 55struct ia64_machine_vector {
60 const char *name; 56 const char *name;
61 ia64_mv_setup_t *setup; 57 ia64_mv_setup_t *setup;
62 ia64_mv_irq_init_t *irq_init;
63 ia64_mv_dma_init *dma_init; 58 ia64_mv_dma_init *dma_init;
64 ia64_mv_dma_get_ops *dma_get_ops; 59 ia64_mv_dma_get_ops *dma_get_ops;
65} __attribute__((__aligned__(16))); /* align attrib? see above comment */ 60} __attribute__((__aligned__(16))); /* align attrib? see above comment */
@@ -68,7 +63,6 @@ struct ia64_machine_vector {
68{ \ 63{ \
69 #name, \ 64 #name, \
70 platform_setup, \ 65 platform_setup, \
71 platform_irq_init, \
72 platform_dma_init, \ 66 platform_dma_init, \
73 platform_dma_get_ops, \ 67 platform_dma_get_ops, \
74} 68}
@@ -91,9 +85,6 @@ extern const struct dma_map_ops *dma_get_ops(struct device *);
91#ifndef platform_setup 85#ifndef platform_setup
92# define platform_setup machvec_setup 86# define platform_setup machvec_setup
93#endif 87#endif
94#ifndef platform_irq_init
95# define platform_irq_init machvec_noop
96#endif
97#ifndef platform_dma_init 88#ifndef platform_dma_init
98# define platform_dma_init swiotlb_dma_init 89# define platform_dma_init swiotlb_dma_init
99#endif 90#endif
diff --git a/arch/ia64/include/asm/machvec_hpsim.h b/arch/ia64/include/asm/machvec_hpsim.h
deleted file mode 100644
index 056f8405822e..000000000000
--- a/arch/ia64/include/asm/machvec_hpsim.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_IA64_MACHVEC_HPSIM_h
3#define _ASM_IA64_MACHVEC_HPSIM_h
4
5extern ia64_mv_setup_t hpsim_setup;
6extern ia64_mv_irq_init_t hpsim_irq_init;
7
8/*
9 * This stuff has dual use!
10 *
11 * For a generic kernel, the macros are used to initialize the
12 * platform's machvec structure. When compiling a non-generic kernel,
13 * the macros are used directly.
14 */
15#define ia64_platform_name "hpsim"
16#define platform_setup hpsim_setup
17#define platform_irq_init hpsim_irq_init
18
19#endif /* _ASM_IA64_MACHVEC_HPSIM_h */
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index 4ba05140b249..3ada440ff893 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -12,13 +12,12 @@ extra-y := head.o vmlinux.lds
12obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ 12obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \
13 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \ 13 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \
14 salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \ 14 salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \
15 unwind.o mca.o mca_asm.o topology.o dma-mapping.o 15 unwind.o mca.o mca_asm.o topology.o dma-mapping.o iosapic.o
16 16
17obj-$(CONFIG_ACPI) += acpi.o acpi-ext.o 17obj-$(CONFIG_ACPI) += acpi.o acpi-ext.o
18obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o 18obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o
19 19
20obj-$(CONFIG_IA64_PALINFO) += palinfo.o 20obj-$(CONFIG_IA64_PALINFO) += palinfo.o
21obj-$(CONFIG_IOSAPIC) += iosapic.o
22obj-$(CONFIG_MODULES) += module.o 21obj-$(CONFIG_MODULES) += module.o
23obj-$(CONFIG_SMP) += smp.o smpboot.o 22obj-$(CONFIG_SMP) += smp.o smpboot.o
24obj-$(CONFIG_NUMA) += numa.o 23obj-$(CONFIG_NUMA) += numa.o
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 1c81ec752b04..e3874734b149 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -53,7 +53,6 @@
53#define IRQ_USED (1) 53#define IRQ_USED (1)
54#define IRQ_RSVD (2) 54#define IRQ_RSVD (2)
55 55
56/* These can be overridden in platform_irq_init */
57int ia64_first_device_vector = IA64_DEF_FIRST_DEVICE_VECTOR; 56int ia64_first_device_vector = IA64_DEF_FIRST_DEVICE_VECTOR;
58int ia64_last_device_vector = IA64_DEF_LAST_DEVICE_VECTOR; 57int ia64_last_device_vector = IA64_DEF_LAST_DEVICE_VECTOR;
59 58
@@ -648,7 +647,6 @@ init_IRQ (void)
648#ifdef CONFIG_PERFMON 647#ifdef CONFIG_PERFMON
649 pfm_init_percpu(); 648 pfm_init_percpu();
650#endif 649#endif
651 platform_irq_init();
652} 650}
653 651
654void 652void
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 4dc74500eac5..42ef03ce2fd4 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -63,7 +63,6 @@
63#include <asm/smp.h> 63#include <asm/smp.h>
64#include <asm/tlbflush.h> 64#include <asm/tlbflush.h>
65#include <asm/unistd.h> 65#include <asm/unistd.h>
66#include <asm/hpsim.h>
67 66
68#if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE) 67#if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE)
69# error "struct cpuinfo_ia64 too big!" 68# error "struct cpuinfo_ia64 too big!"
@@ -461,16 +460,11 @@ io_port_init (void)
461static inline int __init 460static inline int __init
462early_console_setup (char *cmdline) 461early_console_setup (char *cmdline)
463{ 462{
464 int earlycons = 0;
465
466#ifdef CONFIG_EFI_PCDP 463#ifdef CONFIG_EFI_PCDP
467 if (!efi_setup_pcdp_console(cmdline)) 464 if (!efi_setup_pcdp_console(cmdline))
468 earlycons++; 465 return 0;
469#endif 466#endif
470 if (!simcons_register()) 467 return -1;
471 earlycons++;
472
473 return (earlycons) ? 0 : -1;
474} 468}
475 469
476static inline void 470static inline void
@@ -608,9 +602,6 @@ setup_arch (char **cmdline_p)
608 ia64_mca_init(); 602 ia64_mca_init();
609 603
610 platform_setup(cmdline_p); 604 platform_setup(cmdline_p);
611#ifndef CONFIG_IA64_HP_SIM
612 check_sal_cache_flush();
613#endif
614 paging_init(); 605 paging_init();
615 606
616 clear_sched_clock_stable(); 607 clear_sched_clock_stable();