Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christoph Hellwig and committed by
Tony Luck
fc5bad03 05933aac

+26 -2711
+7 -27
arch/ia64/Kconfig
··· 10 10 bool 11 11 select ARCH_MIGHT_HAVE_PC_PARPORT 12 12 select ARCH_MIGHT_HAVE_PC_SERIO 13 - select ACPI if (!IA64_HP_SIM) 14 - select ARCH_SUPPORTS_ACPI if (!IA64_HP_SIM) 13 + select ACPI 14 + select ARCH_SUPPORTS_ACPI 15 15 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI 16 16 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 17 - select FORCE_PCI if (!IA64_HP_SIM) 17 + select FORCE_PCI 18 18 select PCI_DOMAINS if PCI 19 19 select PCI_SYSCALL if PCI 20 20 select HAVE_UNSTABLE_SCHED_CLOCK ··· 140 140 HP-zx1/sx1000 For HP systems 141 141 HP-zx1/sx1000+swiotlb For HP systems with (broken) DMA-constrained devices. 142 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 144 If you don't know what to do, choose "generic". 146 145 ··· 179 180 types of ia64 systems. If you have an SGI UV system, it's safe 180 181 to select this option. If in doubt, select ia64 generic support 181 182 instead. 182 - 183 - config IA64_HP_SIM 184 - bool "Ski-simulator" 185 - select SWIOTLB 186 - depends on !PM 187 183 188 184 endchoice 189 185 ··· 233 239 234 240 endchoice 235 241 236 - if IA64_HP_SIM 237 - config HZ 238 - default 32 239 - endif 240 - 241 - if !IA64_HP_SIM 242 242 source "kernel/Kconfig.hz" 243 - endif 244 243 245 244 config IA64_BRL_EMU 246 245 bool ··· 251 264 help 252 265 Say Y here to enable support for IBM EXA Cyclone time source. 253 266 If you're unsure, answer N. 254 - 255 - config IOSAPIC 256 - bool 257 - depends on !IA64_HP_SIM 258 - default y 259 267 260 268 config FORCE_MAX_ZONEORDER 261 269 int "MAX_ORDER (11 - 17)" if !HUGETLB_PAGE ··· 355 373 356 374 config NUMA 357 375 bool "NUMA support" 358 - depends on !IA64_HP_SIM && !FLATMEM 376 + depends on !FLATMEM 359 377 select ACPI_NUMA if ACPI 360 378 help 361 379 Say Y to compile the kernel to support NUMA (Non-Uniform Memory ··· 377 395 config VIRTUAL_MEM_MAP 378 396 bool "Virtual mem map" 379 397 depends on !SPARSEMEM 380 - default y if !IA64_HP_SIM 398 + default y 381 399 help 382 400 Say Y to compile the kernel with support for a virtual mem map. 383 401 This code also only takes effect if a memory hole of greater than ··· 460 478 461 479 config KEXEC 462 480 bool "kexec system call" 463 - depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU) 481 + depends on !SMP || HOTPLUG_CPU 464 482 select KEXEC_CORE 465 483 help 466 484 kexec is a system call that implements the ability to shutdown your ··· 478 496 479 497 config CRASH_DUMP 480 498 bool "kernel crash dumps" 481 - depends on IA64_MCA_RECOVERY && !IA64_HP_SIM && (!SMP || HOTPLUG_CPU) 499 + depends on IA64_MCA_RECOVERY && (!SMP || HOTPLUG_CPU) 482 500 help 483 501 Generate crash dump after being started by kexec. 484 502 ··· 499 517 endif 500 518 501 519 endmenu 502 - 503 - source "arch/ia64/hp/sim/Kconfig" 504 520 505 521 config MSPEC 506 522 tristate "Memory special operations driver"
+14 -13
arch/ia64/Makefile
··· 39 39 ftp://ftp.hpl.hp.com/pub/linux-ia64/gas-030124.tar.gz) 40 40 endif 41 41 42 + quiet_cmd_gzip = GZIP $@ 43 + cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@ 44 + 45 + quiet_cmd_objcopy = OBJCOPY $@ 46 + cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ 47 + 42 48 KBUILD_CFLAGS += $(cflags-y) 43 49 head-y := arch/ia64/kernel/head.o 44 50 ··· 58 52 core-$(CONFIG_IA64_SGI_UV) += arch/ia64/uv/ 59 53 60 54 drivers-$(CONFIG_PCI) += arch/ia64/pci/ 61 - drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim/ 62 55 drivers-$(CONFIG_IA64_HP_ZX1) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ 63 56 drivers-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ 64 - drivers-$(CONFIG_IA64_GENERIC) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ arch/ia64/hp/sim/ arch/ia64/uv/ 57 + drivers-$(CONFIG_IA64_GENERIC) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ arch/ia64/uv/ 65 58 drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/ 66 59 67 - boot := arch/ia64/hp/sim/boot 68 - 69 - PHONY += boot compressed check 60 + PHONY += compressed check 70 61 71 62 all: compressed unwcheck 72 63 ··· 71 68 72 69 vmlinuz: vmlinux.gz 73 70 74 - vmlinux.gz: vmlinux 75 - $(Q)$(MAKE) $(build)=$(boot) $@ 71 + vmlinux.gz: vmlinux.bin FORCE 72 + $(call if_changed,gzip) 73 + 74 + vmlinux.bin: vmlinux FORCE 75 + $(call if_changed,objcopy) 76 76 77 77 unwcheck: vmlinux 78 78 -$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $< 79 79 80 80 archclean: 81 - $(Q)$(MAKE) $(clean)=$(boot) 82 81 83 82 archheaders: 84 83 $(Q)$(MAKE) $(build)=arch/ia64/kernel/syscalls all 85 84 86 - CLEAN_FILES += vmlinux.gz bootloader 87 - 88 - boot: lib/lib.a vmlinux 89 - $(Q)$(MAKE) $(build)=$(boot) $@ 85 + CLEAN_FILES += vmlinux.gz 90 86 91 87 install: vmlinux.gz 92 88 sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" ··· 93 91 define archhelp 94 92 echo '* compressed - Build compressed kernel image' 95 93 echo ' install - Install compressed kernel image' 96 - echo ' boot - Build vmlinux and bootloader for Ski simulator' 97 94 echo '* unwcheck - Check vmlinux for invalid unwind info' 98 95 endef 99 96
-52
arch/ia64/configs/sim_defconfig
··· 1 - CONFIG_SYSVIPC=y 2 - CONFIG_IKCONFIG=y 3 - CONFIG_IKCONFIG_PROC=y 4 - CONFIG_LOG_BUF_SHIFT=16 5 - CONFIG_MODULES=y 6 - CONFIG_MODULE_UNLOAD=y 7 - CONFIG_MODULE_FORCE_UNLOAD=y 8 - CONFIG_MODVERSIONS=y 9 - CONFIG_PARTITION_ADVANCED=y 10 - CONFIG_IA64_HP_SIM=y 11 - CONFIG_MCKINLEY=y 12 - CONFIG_IA64_PAGE_SIZE_64KB=y 13 - CONFIG_SMP=y 14 - CONFIG_NR_CPUS=64 15 - CONFIG_PREEMPT=y 16 - CONFIG_IA64_PALINFO=m 17 - CONFIG_EFI_VARS=y 18 - CONFIG_BINFMT_MISC=y 19 - CONFIG_NET=y 20 - CONFIG_PACKET=y 21 - CONFIG_INET=y 22 - CONFIG_IP_MULTICAST=y 23 - # CONFIG_IPV6 is not set 24 - # CONFIG_STANDALONE is not set 25 - CONFIG_BLK_DEV_LOOP=y 26 - CONFIG_BLK_DEV_RAM=y 27 - CONFIG_SCSI=y 28 - CONFIG_BLK_DEV_SD=y 29 - CONFIG_SCSI_CONSTANTS=y 30 - CONFIG_SCSI_LOGGING=y 31 - CONFIG_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 36 - CONFIG_EFI_RTC=y 37 - # CONFIG_VGA_CONSOLE is not set 38 - CONFIG_HP_SIMETH=y 39 - CONFIG_HP_SIMSERIAL=y 40 - CONFIG_HP_SIMSERIAL_CONSOLE=y 41 - CONFIG_HP_SIMSCSI=y 42 - CONFIG_EXT2_FS=y 43 - CONFIG_EXT3_FS=y 44 - # CONFIG_EXT3_FS_XATTR is not set 45 - CONFIG_PROC_KCORE=y 46 - CONFIG_HUGETLBFS=y 47 - CONFIG_NFS_FS=y 48 - CONFIG_NFSD=y 49 - CONFIG_NFSD_V3=y 50 - CONFIG_DEBUG_INFO=y 51 - CONFIG_DEBUG_KERNEL=y 52 - CONFIG_DEBUG_MUTEXES=y
-23
arch/ia64/hp/sim/Kconfig
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - menu "HP Simulator drivers" 4 - depends on IA64_HP_SIM || IA64_GENERIC 5 - 6 - config HP_SIMETH 7 - bool "Simulated Ethernet " 8 - depends on NET 9 - 10 - config HP_SIMSERIAL 11 - bool "Simulated serial driver support" 12 - depends on TTY 13 - 14 - config HP_SIMSERIAL_CONSOLE 15 - bool "Console for HP simulator" 16 - depends on HP_SIMSERIAL 17 - 18 - config HP_SIMSCSI 19 - bool "Simulated SCSI disk" 20 - depends on SCSI=y 21 - 22 - endmenu 23 -
-17
arch/ia64/hp/sim/Makefile
··· 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 - 11 - obj-y := hpsim_irq.o hpsim_setup.o hpsim.o 12 - obj-$(CONFIG_IA64_GENERIC) += hpsim_machvec.o 13 - 14 - obj-$(CONFIG_HP_SIMETH) += simeth.o 15 - obj-$(CONFIG_HP_SIMSERIAL) += simserial.o 16 - obj-$(CONFIG_HP_SIMSERIAL_CONSOLE) += hpsim_console.o 17 - obj-$(CONFIG_HP_SIMSCSI) += simscsi.o
-37
arch/ia64/hp/sim/boot/Makefile
··· 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 - 11 - targets-$(CONFIG_IA64_HP_SIM) += bootloader 12 - targets := vmlinux.bin vmlinux.gz $(targets-y) 13 - 14 - quiet_cmd_cptotop = LN $@ 15 - cmd_cptotop = ln -f $< $@ 16 - 17 - vmlinux.gz: $(obj)/vmlinux.gz $(addprefix $(obj)/,$(targets-y)) 18 - $(call cmd,cptotop) 19 - @echo ' Kernel: $@ is ready' 20 - 21 - boot: bootloader 22 - 23 - bootloader: $(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 - 33 - LDFLAGS_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)
-165
arch/ia64/hp/sim/boot/boot_head.S
··· 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 12 - stack_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... */ 18 - GLOBAL_ENTRY(printk) 19 - break 0 20 - END(printk) 21 - 22 - GLOBAL_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 30 - 0: nop 0 /* dummy nop to make unwinding work */ 31 - END(_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 - */ 37 - GLOBAL_ENTRY(debug_break) 38 - br.ret.sptk.many b0 39 - END(debug_break) 40 - 41 - GLOBAL_ENTRY(ssc) 42 - .regstk 5,0,0,0 43 - mov r15=in4 44 - break 0x80001 45 - br.ret.sptk.many b0 46 - END(ssc) 47 - 48 - GLOBAL_ENTRY(jmp_to_kernel) 49 - .regstk 2,0,0,0 50 - mov r28=in0 51 - mov b7=in1 52 - br.sptk.few b7 53 - END(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 - */ 60 - GLOBAL_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 - ;; 72 - static: 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 80 - 1: 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 - ;; 87 - 1: 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 94 - 1: 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 - ;; 112 - 1: 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 - ;; 148 - 1: 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 - ;; 157 - 1: 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 - ;; 162 - 1: br.cond.sptk.few rp 163 - stacked: 164 - br.ret.sptk.few rp 165 - END(pal_emulator_static)
-175
arch/ia64/hp/sim/boot/bootloader.c
··· 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 - */ 13 - struct 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 - 27 - struct disk_req { 28 - unsigned long addr; 29 - unsigned len; 30 - }; 31 - 32 - struct disk_stat { 33 - int fd; 34 - unsigned count; 35 - }; 36 - 37 - extern void jmp_to_kernel (unsigned long bp, unsigned long e_entry); 38 - extern struct ia64_boot_param *sys_fw_init (const char *args, int arglen); 39 - extern void debug_break (void); 40 - 41 - static void 42 - cons_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 - 55 - void 56 - start_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 - }
-67
arch/ia64/hp/sim/boot/bootloader.lds
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - OUTPUT_FORMAT("elf64-ia64-little") 3 - OUTPUT_ARCH(ia64) 4 - ENTRY(_start) 5 - SECTIONS 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 - }
-374
arch/ia64/hp/sim/boot/fw-emu.c
··· 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 - 31 - static 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. */ 47 - int 48 - offtime (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 - 101 - extern 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 - 111 - static efi_status_t 112 - fw_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 - 133 - static void 134 - efi_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 - 143 - static efi_status_t 144 - efi_unimplemented (void) 145 - { 146 - return EFI_UNSUPPORTED; 147 - } 148 - 149 - static struct sal_ret_values 150 - sal_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 - 232 - struct ia64_boot_param * 233 - sys_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 - }
-36
arch/ia64/hp/sim/boot/ssc.h
··· 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 - */ 34 - extern long ssc (long arg0, long arg1, long arg2, long arg3, int nr); 35 - 36 - #endif /* ssc_h */
-11
arch/ia64/hp/sim/hpsim.S
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #include <asm/asmmacro.h> 3 - 4 - /* 5 - * Simulator system call. 6 - */ 7 - GLOBAL_ENTRY(ia64_ssc) 8 - mov r15=r36 9 - break 0x80001 10 - br.ret.sptk.many rp 11 - END(ia64_ssc)
-77
arch/ia64/hp/sim/hpsim_console.c
··· 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 - 29 - static int simcons_init (struct console *, char *); 30 - static void simcons_write (struct console *, const char *, unsigned); 31 - static struct tty_driver *simcons_console_device (struct console *, int *); 32 - 33 - static 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 - 42 - static int 43 - simcons_init (struct console *cons, char *options) 44 - { 45 - return 0; 46 - } 47 - 48 - static void 49 - simcons_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 - 61 - static struct tty_driver *simcons_console_device (struct console *c, int *index) 62 - { 63 - *index = c->index; 64 - return hp_simserial_driver; 65 - } 66 - 67 - int 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 - }
-76
arch/ia64/hp/sim/hpsim_irq.c
··· 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 - 16 - static unsigned int 17 - hpsim_irq_startup(struct irq_data *data) 18 - { 19 - return 0; 20 - } 21 - 22 - static void 23 - hpsim_irq_noop(struct irq_data *data) 24 - { 25 - } 26 - 27 - static int 28 - hpsim_set_affinity_noop(struct irq_data *d, const struct cpumask *b, bool f) 29 - { 30 - return 0; 31 - } 32 - 33 - static 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 - 43 - static 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 - 51 - static void hpsim_connect_irq(int intr, int irq) 52 - { 53 - ia64_ssc(intr, irq, 0, 0, SSC_CONNECT_INTERRUPT); 54 - } 55 - 56 - int 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 - 69 - void __init 70 - hpsim_irq_init (void) 71 - { 72 - int i; 73 - 74 - for_each_active_irq(i) 75 - hpsim_irq_set_chip(i); 76 - }
-3
arch/ia64/hp/sim/hpsim_machvec.c
··· 1 - #define MACHVEC_PLATFORM_NAME hpsim 2 - #define MACHVEC_PLATFORM_HEADER <asm/machvec_hpsim.h> 3 - #include <asm/machvec_init.h>
-41
arch/ia64/hp/sim/hpsim_setup.c
··· 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 - 29 - void 30 - ia64_ctl_trace (long on) 31 - { 32 - ia64_ssc(on, 0, 0, 0, SSC_CTL_TRACE); 33 - } 34 - 35 - void __init 36 - hpsim_setup (char **cmdline_p) 37 - { 38 - ROOT_DEV = Root_SDA1; /* default to first SCSI drive */ 39 - 40 - simcons_register(); 41 - }
-37
arch/ia64/hp/sim/hpsim_ssc.h
··· 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 - */ 35 - extern long ia64_ssc (long arg0, long arg1, long arg2, long arg3, int nr); 36 - 37 - #endif /* _IA64_PLATFORM_HPSIM_SSC_H */
-510
arch/ia64/hp/sim/simeth.c
··· 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 - 43 - struct simeth_local { 44 - struct net_device_stats stats; 45 - int simfd; /* descriptor in the simulator */ 46 - }; 47 - 48 - static int simeth_probe1(void); 49 - static int simeth_open(struct net_device *dev); 50 - static int simeth_close(struct net_device *dev); 51 - static int simeth_tx(struct sk_buff *skb, struct net_device *dev); 52 - static int simeth_rx(struct net_device *dev); 53 - static struct net_device_stats *simeth_get_stats(struct net_device *dev); 54 - static irqreturn_t simeth_interrupt(int irq, void *dev_id); 55 - static void set_multicast_list(struct net_device *dev); 56 - static int simeth_device_event(struct notifier_block *this,unsigned long event, void *ptr); 57 - 58 - static 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 - */ 75 - static char *simeth_device="eth0"; /* default host interface to use */ 76 - 77 - 78 - 79 - static volatile unsigned int card_count; /* how many cards "found" so far */ 80 - static int simeth_debug; /* set to 1 to get debug information */ 81 - 82 - /* 83 - * Used to catch IFF_UP & IFF_DOWN events 84 - */ 85 - static 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 - */ 96 - static int __init 97 - simeth_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 - 110 - int __init 111 - simeth_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 - 124 - static inline int 125 - netdev_probe(char *name, unsigned char *ether) 126 - { 127 - return ia64_ssc(__pa(name), __pa(ether), 0,0, SSC_NETDEV_PROBE); 128 - } 129 - 130 - 131 - static inline int 132 - netdev_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 - 139 - static inline int 140 - netdev_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 - 147 - static inline int 148 - netdev_send(int fd, unsigned char *buf, unsigned int len) 149 - { 150 - return ia64_ssc(fd, __pa(buf), len, 0, SSC_NETDEV_SEND); 151 - } 152 - 153 - static inline int 154 - netdev_read(int fd, unsigned char *buf, unsigned int len) 155 - { 156 - return ia64_ssc(fd, __pa(buf), len, 0, SSC_NETDEV_RECV); 157 - } 158 - 159 - static 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 - */ 179 - static int 180 - simeth_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 - */ 235 - static int 236 - simeth_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 */ 249 - static __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 - */ 269 - static int 270 - simeth_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 - 328 - static int 329 - simeth_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 - */ 341 - static void 342 - frame_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 - */ 368 - static int 369 - simeth_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 - 401 - static inline struct sk_buff * 402 - make_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 - */ 426 - static int 427 - simeth_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 - */ 483 - static irqreturn_t 484 - simeth_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 - 495 - static struct net_device_stats * 496 - simeth_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 */ 504 - static void 505 - set_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);
-373
arch/ia64/hp/sim/simscsi.c
··· 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 - 49 - static struct Scsi_Host *host; 50 - 51 - static void simscsi_interrupt (unsigned long val); 52 - static DECLARE_TASKLET(simscsi_tasklet, simscsi_interrupt, 0); 53 - 54 - struct disk_req { 55 - unsigned long addr; 56 - unsigned len; 57 - }; 58 - 59 - struct disk_stat { 60 - int fd; 61 - unsigned count; 62 - }; 63 - 64 - static int desc[16] = { 65 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 66 - }; 67 - 68 - static struct queue_entry { 69 - struct scsi_cmnd *sc; 70 - } queue[SIMSCSI_REQ_QUEUE_LEN]; 71 - 72 - static int rd, wr; 73 - static atomic_t num_reqs = ATOMIC_INIT(0); 74 - 75 - /* base name for default disks */ 76 - static 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 - */ 85 - static int __init 86 - simscsi_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 - 99 - static void 100 - simscsi_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 - 115 - static int 116 - simscsi_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 - 125 - static void 126 - simscsi_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 - */ 160 - static void 161 - simscsi_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 - 169 - static size_t 170 - simscsi_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 - 194 - static void 195 - simscsi_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 - 206 - static int 207 - simscsi_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 - 331 - static DEF_SCSI_QCMD(simscsi_queuecommand) 332 - 333 - static int 334 - simscsi_host_reset (struct scsi_cmnd *sc) 335 - { 336 - printk(KERN_ERR "simscsi_host_reset: not implemented\n"); 337 - return 0; 338 - } 339 - 340 - static 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 - 354 - static int __init 355 - simscsi_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 - } 373 - device_initcall(simscsi_init);
-521
arch/ia64/hp/sim/simserial.c
··· 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 - 45 - struct serial_state { 46 - struct tty_port port; 47 - struct circ_buf xmit; 48 - int irq; 49 - int x_char; 50 - }; 51 - 52 - static struct serial_state rs_table[NR_PORTS]; 53 - 54 - struct tty_driver *hp_simserial_driver; 55 - 56 - static struct console *console; 57 - 58 - static 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 - */ 95 - static 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 - 110 - static 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 - 129 - static 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 - } 176 - out: 177 - local_irq_restore(flags); 178 - } 179 - 180 - static 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 - 191 - static 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 - 227 - static 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 - 234 - static 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 - 241 - static 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 - */ 257 - static 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 - */ 279 - static 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 - 287 - static 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 - 300 - static int rs_setserial(struct tty_struct *tty, struct serial_struct *ss) 301 - { 302 - return 0; 303 - } 304 - 305 - static int rs_getserial(struct tty_struct *tty, struct serial_struct *ss) 306 - { 307 - return 0; 308 - } 309 - 310 - static 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 - */ 331 - static 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 - 348 - static 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 - 355 - static 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 - 363 - static 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; 389 - errout: 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 - */ 401 - static 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 - 425 - static 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 - 436 - static 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 - 455 - static const struct tty_port_operations hp_port_ops = { 456 - .activate = activate, 457 - .shutdown = shutdown, 458 - }; 459 - 460 - static 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; 513 - err_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
+1 -3
arch/ia64/include/asm/acpi.h
··· 37 37 #else 38 38 static inline const char *acpi_get_sysname (void) 39 39 { 40 - # if defined (CONFIG_IA64_HP_SIM) 41 - return "hpsim"; 42 - # elif defined (CONFIG_IA64_HP_ZX1) 40 + # if defined (CONFIG_IA64_HP_ZX1) 43 41 return "hpzx1"; 44 42 # elif defined (CONFIG_IA64_HP_ZX1_SWIOTLB) 45 43 return "hpzx1_swiotlb";
-17
arch/ia64/include/asm/hpsim.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ASMIA64_HPSIM_H 3 - #define _ASMIA64_HPSIM_H 4 - 5 - #ifndef CONFIG_HP_SIMSERIAL_CONSOLE 6 - static inline int simcons_register(void) { return 1; } 7 - #else 8 - int simcons_register(void); 9 - #endif 10 - 11 - struct tty_driver; 12 - extern struct tty_driver *hp_simserial_driver; 13 - 14 - extern int hpsim_get_irq(int intr); 15 - void ia64_ctl_trace(long on); 16 - 17 - #endif
-12
arch/ia64/include/asm/iosapic.h
··· 52 52 53 53 #ifndef __ASSEMBLY__ 54 54 55 - #ifdef CONFIG_IOSAPIC 56 - 57 55 #define NR_IOSAPICS 256 58 56 59 57 #define iosapic_pcat_compat_init ia64_native_iosapic_pcat_compat_init ··· 100 102 101 103 #ifdef CONFIG_NUMA 102 104 extern void map_iosapic_to_node (unsigned int, int); 103 - #endif 104 - #else 105 - #define iosapic_system_init(pcat_compat) do { } while (0) 106 - #define iosapic_init(address,gsi_base) (-EINVAL) 107 - #define iosapic_remove(gsi_base) (-ENODEV) 108 - #define iosapic_register_intr(gsi,polarity,trigger) (gsi) 109 - #define iosapic_unregister_intr(irq) do { } while (0) 110 - #define iosapic_override_isa_irq(isa_irq,gsi,polarity,trigger) do { } while (0) 111 - #define iosapic_register_platform_intr(type,gsi,pmi,eid,id, \ 112 - polarity,trigger) (gsi) 113 105 #endif 114 106 115 107 # endif /* !__ASSEMBLY__ */
+1 -10
arch/ia64/include/asm/machvec.h
··· 16 16 struct device; 17 17 18 18 typedef void ia64_mv_setup_t (char **); 19 - typedef void ia64_mv_irq_init_t (void); 20 19 typedef void ia64_mv_dma_init (void); 21 20 typedef const struct dma_map_ops *ia64_mv_dma_get_ops(struct device *); 22 21 ··· 26 27 27 28 extern void machvec_setup (char **); 28 29 29 - # if defined (CONFIG_IA64_HP_SIM) 30 - # include <asm/machvec_hpsim.h> 31 - # elif defined (CONFIG_IA64_DIG) 30 + # if defined (CONFIG_IA64_DIG) 32 31 # include <asm/machvec_dig.h> 33 32 # elif defined(CONFIG_IA64_DIG_VTD) 34 33 # include <asm/machvec_dig_vtd.h> ··· 43 46 # else 44 47 # define ia64_platform_name ia64_mv.name 45 48 # define platform_setup ia64_mv.setup 46 - # define platform_irq_init ia64_mv.irq_init 47 49 # define platform_dma_init ia64_mv.dma_init 48 50 # define platform_dma_get_ops ia64_mv.dma_get_ops 49 51 # endif ··· 55 59 struct ia64_machine_vector { 56 60 const char *name; 57 61 ia64_mv_setup_t *setup; 58 - ia64_mv_irq_init_t *irq_init; 59 62 ia64_mv_dma_init *dma_init; 60 63 ia64_mv_dma_get_ops *dma_get_ops; 61 64 } __attribute__((__aligned__(16))); /* align attrib? see above comment */ ··· 63 68 { \ 64 69 #name, \ 65 70 platform_setup, \ 66 - platform_irq_init, \ 67 71 platform_dma_init, \ 68 72 platform_dma_get_ops, \ 69 73 } ··· 84 90 */ 85 91 #ifndef platform_setup 86 92 # define platform_setup machvec_setup 87 - #endif 88 - #ifndef platform_irq_init 89 - # define platform_irq_init machvec_noop 90 93 #endif 91 94 #ifndef platform_dma_init 92 95 # define platform_dma_init swiotlb_dma_init
-19
arch/ia64/include/asm/machvec_hpsim.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ASM_IA64_MACHVEC_HPSIM_h 3 - #define _ASM_IA64_MACHVEC_HPSIM_h 4 - 5 - extern ia64_mv_setup_t hpsim_setup; 6 - extern 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 */
+1 -2
arch/ia64/kernel/Makefile
··· 12 12 obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ 13 13 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \ 14 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 17 17 obj-$(CONFIG_ACPI) += acpi.o acpi-ext.o 18 18 obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o 19 19 20 20 obj-$(CONFIG_IA64_PALINFO) += palinfo.o 21 - obj-$(CONFIG_IOSAPIC) += iosapic.o 22 21 obj-$(CONFIG_MODULES) += module.o 23 22 obj-$(CONFIG_SMP) += smp.o smpboot.o 24 23 obj-$(CONFIG_NUMA) += numa.o
-2
arch/ia64/kernel/irq_ia64.c
··· 53 53 #define IRQ_USED (1) 54 54 #define IRQ_RSVD (2) 55 55 56 - /* These can be overridden in platform_irq_init */ 57 56 int ia64_first_device_vector = IA64_DEF_FIRST_DEVICE_VECTOR; 58 57 int ia64_last_device_vector = IA64_DEF_LAST_DEVICE_VECTOR; 59 58 ··· 647 648 #ifdef CONFIG_PERFMON 648 649 pfm_init_percpu(); 649 650 #endif 650 - platform_irq_init(); 651 651 } 652 652 653 653 void
+2 -11
arch/ia64/kernel/setup.c
··· 63 63 #include <asm/smp.h> 64 64 #include <asm/tlbflush.h> 65 65 #include <asm/unistd.h> 66 - #include <asm/hpsim.h> 67 66 68 67 #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE) 69 68 # error "struct cpuinfo_ia64 too big!" ··· 460 461 static inline int __init 461 462 early_console_setup (char *cmdline) 462 463 { 463 - int earlycons = 0; 464 - 465 464 #ifdef CONFIG_EFI_PCDP 466 465 if (!efi_setup_pcdp_console(cmdline)) 467 - earlycons++; 466 + return 0; 468 467 #endif 469 - if (!simcons_register()) 470 - earlycons++; 471 - 472 - return (earlycons) ? 0 : -1; 468 + return -1; 473 469 } 474 470 475 471 static inline void ··· 602 608 ia64_mca_init(); 603 609 604 610 platform_setup(cmdline_p); 605 - #ifndef CONFIG_IA64_HP_SIM 606 - check_sal_cache_flush(); 607 - #endif 608 611 paging_init(); 609 612 610 613 clear_sched_clock_stable();