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

Merge tag 'for-4.2' of git://git.sourceforge.jp/gitroot/uclinux-h8/linux

Pull Renesas H8/300 architecture re-introduction from Yoshinori Sato.

We dropped arch/h8300 two years ago as stale and old, this is a new and
more modern rewritten arch support for the same architecture.

* tag 'for-4.2' of git://git.sourceforge.jp/gitroot/uclinux-h8/linux: (27 commits)
h8300: fix typo.
h8300: Always build dtb
h8300: Remove ARCH_WANT_IPC_PARSE_VERSION
sh-sci: Get register size from platform device
clk: h8300: fix error handling in h8s2678_pll_clk_setup()
h8300: Symbol name fix
h8300: devicetree source
h8300: configs
h8300: IRQ chip driver
h8300: clocksource
h8300: clock driver
h8300: Build scripts
h8300: library functions
h8300: Memory management
h8300: miscellaneous functions
h8300: process helpers
h8300: compressed image support
h8300: Low level entry
h8300: kernel startup
h8300: Interrupt and exceptions
...

+7597 -28
-5
CREDITS
··· 3219 3219 E: dipankar@in.ibm.com 3220 3220 D: RCU 3221 3221 3222 - N: Yoshinori Sato 3223 - E: ysato@users.sourceforge.jp 3224 - D: uClinux for Renesas H8/300 (H8300) 3225 - D: http://uclinux-h8.sourceforge.jp/ 3226 - 3227 3222 N: Hannu Savolainen 3228 3223 E: hannu@opensound.com 3229 3224 D: Maintainer of the sound drivers until 2.1.x days.
+24
Documentation/devicetree/bindings/clock/renesas,h8300-div-clock.txt
··· 1 + * Renesas H8/300 divider clock 2 + 3 + Required Properties: 4 + 5 + - compatible: Must be "renesas,sh73a0-h8300-div-clock" 6 + 7 + - clocks: Reference to the parent clocks ("extal1" and "extal2") 8 + 9 + - #clock-cells: Must be 1 10 + 11 + - reg: Base address and length of the divide rate selector 12 + 13 + - renesas,width: bit width of selector 14 + 15 + Example 16 + ------- 17 + 18 + cclk: cclk { 19 + compatible = "renesas,h8300-div-clock"; 20 + clocks = <&xclk>; 21 + #clock-cells = <0>; 22 + reg = <0xfee01b 2>; 23 + renesas,width = <2>; 24 + };
+23
Documentation/devicetree/bindings/clock/renesas,h8s2678-pll-clock.txt
··· 1 + Renesas H8S2678 PLL clock 2 + 3 + This device is Clock multiplyer 4 + 5 + Required Properties: 6 + 7 + - compatible: Must be "renesas,h8s2678-pll-clock" 8 + 9 + - clocks: Reference to the parent clocks 10 + 11 + - #clock-cells: Must be 0 12 + 13 + - reg: Two rate selector (Multiply / Divide) register address 14 + 15 + Example 16 + ------- 17 + 18 + pllclk: pllclk { 19 + compatible = "renesas,h8s2678-pll-clock"; 20 + clocks = <&xclk>; 21 + #clock-cells = <0>; 22 + reg = <0xfee03b 2>, <0xfee045 2>; 23 + };
+13
Documentation/devicetree/bindings/h8300/cpu.txt
··· 1 + * H8/300 CPU bindings 2 + 3 + Required properties: 4 + 5 + - compatible: Compatible property value should be "renesas,h8300". 6 + - clock-frequency: Contains the clock frequency for CPU, in Hz. 7 + 8 + Example: 9 + 10 + cpu@0 { 11 + compatible = "renesas,h8300"; 12 + clock-frequency = <20000000>; 13 + };
+22
Documentation/devicetree/bindings/interrupt-controller/renesas,h8300h-intc.txt
··· 1 + * H8/300H Interrupt controller 2 + 3 + Required properties: 4 + 5 + - compatible: has to be "renesas,h8300h-intc", "renesas,h8300-intc" as fallback. 6 + - #interrupt-cells: has to be <2>: an interrupt index and flags, as defined in 7 + interrupts.txt in this directory 8 + - regs: Base address of interrupt controller registers. 9 + 10 + Optional properties: 11 + 12 + - any properties, listed in interrupts.txt, and any standard resource allocation 13 + properties 14 + 15 + Example: 16 + 17 + h8intc: interrupt-controller@fee012 { 18 + compatible = "renesas,h8300h-intc", "renesas,h8300-intc"; 19 + #interrupt-cells = <2>; 20 + interrupt-controller; 21 + reg = <0xfee012 7>; 22 + };
+22
Documentation/devicetree/bindings/interrupt-controller/renesas,h8s-intc.txt
··· 1 + * H8S Interrupt controller 2 + 3 + Required properties: 4 + 5 + - compatible: has to be "renesas,h8s-intc", "renesas,h8300-intc" as fallback. 6 + - #interrupt-cells: has to be <2>: an interrupt index and flags, as defined in 7 + interrupts.txt in this directory 8 + - regs: Base address of interrupt controller registers. 9 + 10 + Optional properties: 11 + 12 + - any properties, listed in interrupts.txt, and any standard resource allocation 13 + properties 14 + 15 + Example: 16 + 17 + h8intc: interrupt-controller@fffe00 { 18 + compatible = "renesas,h8s-intc", "renesas,h8300-intc"; 19 + #interrupt-cells = <2>; 20 + interrupt-controller; 21 + reg = <0xfffe00 24>; 22 + };
+12
Documentation/devicetree/bindings/memory-controllers/renesas,h8300-bsc.txt
··· 1 + * H8/300 bus controller 2 + 3 + Required properties: 4 + - compatible: Must be "renesas,h8300-bsc". 5 + - reg: Base address and length of BSC registers. 6 + 7 + Example. 8 + bsc: memory-controller@fee01e { 9 + compatible = "renesas,h8300h-bsc", "renesas,h8300-bsc"; 10 + reg = <0xfee01e 8>; 11 + }; 12 +
+1
Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
··· 29 29 - "renesas,scifa" for generic SCIFA compatible UART. 30 30 - "renesas,scifb" for generic SCIFB compatible UART. 31 31 - "renesas,hscif" for generic HSCIF compatible UART. 32 + - "renesas,sci" for generic SCI compatible UART. 32 33 33 34 When compatible with the generic version, nodes must list the 34 35 SoC-specific version corresponding to the platform first followed by the
+25
Documentation/devicetree/bindings/timer/renesas,16bit-timer.txt
··· 1 + * Renesas H8/300 16bit timer 2 + 3 + The 16bit timer is a 16bit timer/counter with configurable clock inputs and 4 + programmable compare match. 5 + 6 + Required Properties: 7 + 8 + - compatible: must contain "renesas,16bit-timer" 9 + - reg: base address and length of the registers block for the timer module. 10 + - interrupts: interrupt-specifier for the timer, IMIA 11 + - clocks: a list of phandle, one for each entry in clock-names. 12 + - clock-names: must contain "peripheral_clk" for the functional clock. 13 + - renesas,channel: timer channel number. 14 + 15 + Example: 16 + 17 + timer16: timer@ffff68 { 18 + compatible = "reneas,16bit-timer"; 19 + reg = <0xffff68 8>, <0xffff60 8>; 20 + interrupts = <24>; 21 + renesas,channel = <0>; 22 + clocks = <&pclk>; 23 + clock-names = "peripheral_clk"; 24 + }; 25 +
+25
Documentation/devicetree/bindings/timer/renesas,8bit-timer.txt
··· 1 + * Renesas H8/300 8bit timer 2 + 3 + The 8bit timer is a 8bit timer/counter with configurable clock inputs and 4 + programmable compare match. 5 + 6 + This implement only supported cascade mode. 7 + 8 + Required Properties: 9 + 10 + - compatible: must contain "renesas,8bit-timer" 11 + - reg: base address and length of the registers block for the timer module. 12 + - interrupts: interrupt-specifier for the timer, CMIA and TOVI 13 + - clocks: a list of phandle, one for each entry in clock-names. 14 + - clock-names: must contain "fck" for the functional clock. 15 + 16 + Example: 17 + 18 + timer8_0: timer@ffff80 { 19 + compatible = "renesas,8bit-timer"; 20 + reg = <0xffff80 10>; 21 + interrupts = <36>; 22 + clocks = <&fclk>; 23 + clock-names = "fck"; 24 + }; 25 +
+21
Documentation/devicetree/bindings/timer/renesas,tpu.txt
··· 1 + * Renesas H8/300 Timer Pluse Unit 2 + 3 + The TPU is a 16bit timer/counter with configurable clock inputs and 4 + programmable compare match. 5 + This implementation support only cascade mode. 6 + 7 + Required Properties: 8 + 9 + - compatible: must contain "renesas,tpu" 10 + - reg: base address and length of the registers block in 2 channel. 11 + - clocks: a list of phandle, one for each entry in clock-names. 12 + - clock-names: must contain "peripheral_clk" for the functional clock. 13 + 14 + 15 + Example: 16 + tpu: tpu@ffffe0 { 17 + compatible = "renesas,tpu"; 18 + reg = <0xffffe0 16>, <0xfffff0 12>; 19 + clocks = <&pclk>; 20 + clock-names = "peripheral_clk"; 21 + };
+11
MAINTAINERS
··· 4549 4549 S: Maintained 4550 4550 F: drivers/media/usb/stk1160/ 4551 4551 4552 + H8/300 ARCHITECTURE 4553 + M: Yoshinori Sato <ysato@users.sourceforge.jp> 4554 + L: uclinux-h8-devel@lists.sourceforge.jp 4555 + W: http://uclinux-h8.sourceforge.jp 4556 + T: git git://git.sourceforge.jp/gitroot/uclinux-h8/linux.git 4557 + S: Maintained 4558 + F: arch/h8300/ 4559 + F: drivers/clocksource/h8300_*.c 4560 + F: drivers/clk/h8300/ 4561 + F: drivers/irqchip/irq-renesas-h8*.c 4562 + 4552 4563 HARD DRIVE ACTIVE PROTECTION SYSTEM (HDAPS) DRIVER 4553 4564 M: Frank Seidel <frank@f-seidel.de> 4554 4565 L: platform-driver-x86@vger.kernel.org
+76
arch/h8300/Kconfig
··· 1 + config H8300 2 + def_bool y 3 + select GENERIC_ATOMIC64 4 + select HAVE_UID16 5 + select VIRT_TO_BUS 6 + select GENERIC_IRQ_SHOW 7 + select FRAME_POINTER 8 + select GENERIC_CPU_DEVICES 9 + select MODULES_USE_ELF_RELA 10 + select GENERIC_CLOCKEVENTS 11 + select CLKDEV_LOOKUP 12 + select COMMON_CLK 13 + select ARCH_WANT_FRAME_POINTERS 14 + select OF 15 + select OF_IRQ 16 + select OF_EARLY_FLATTREE 17 + select HAVE_MEMBLOCK 18 + select HAVE_DMA_ATTRS 19 + 20 + config RWSEM_GENERIC_SPINLOCK 21 + def_bool y 22 + 23 + config GENERIC_HWEIGHT 24 + def_bool y 25 + 26 + config NO_IOPORT_MAP 27 + def_bool y 28 + 29 + config GENERIC_CSUM 30 + def_bool y 31 + 32 + config HZ 33 + int 34 + default 100 35 + 36 + config NR_CPUS 37 + int 38 + default 1 39 + 40 + source "init/Kconfig" 41 + 42 + source "kernel/Kconfig.freezer" 43 + 44 + source "arch/h8300/Kconfig.cpu" 45 + 46 + menu "Kernel Features" 47 + 48 + source "kernel/Kconfig.preempt" 49 + 50 + source "mm/Kconfig" 51 + 52 + endmenu 53 + 54 + menu "Executable file formats" 55 + 56 + source "fs/Kconfig.binfmt" 57 + 58 + endmenu 59 + 60 + source "net/Kconfig" 61 + 62 + source "drivers/Kconfig" 63 + 64 + source "fs/Kconfig" 65 + 66 + menu "Kernel hacking" 67 + 68 + source "lib/Kconfig.debug" 69 + 70 + endmenu 71 + 72 + source "security/Kconfig" 73 + 74 + source "crypto/Kconfig" 75 + 76 + source "lib/Kconfig"
+99
arch/h8300/Kconfig.cpu
··· 1 + config CPU_H8300H 2 + bool 3 + 4 + config CPU_H8S 5 + bool 6 + 7 + config H83069 8 + bool 9 + select CPU_H8300H 10 + select H8300_TMR16 11 + select RENESAS_H8300H_INTC 12 + 13 + config H8S2678 14 + bool 15 + select CPU_H8S 16 + select H8300_TPU 17 + select RENESAS_H8S_INTC 18 + 19 + config RAMKERNEL 20 + bool 21 + 22 + config ROMKERNEL 23 + bool 24 + 25 + menu "Processor type and features" 26 + 27 + choice 28 + prompt "H8/300 platform" 29 + 30 + config H8300_AE3068 31 + bool "AE-3068/69" 32 + select H83069 33 + select RAMKERNEL 34 + help 35 + AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support 36 + More Information. (Japanese Only) 37 + <http://akizukidenshi.com/catalog/default.aspx> 38 + AE-3068/69 Evaluation Board Support 39 + More Information. 40 + <http://www.microtronique.com/ae3069lan.htm> 41 + 42 + config H8300_H8MAX 43 + bool "H8MAX" 44 + select H83069 45 + select RAMKERNEL 46 + select HAVE_IDE 47 + help 48 + H8MAX Evaluation Board Support 49 + More Information. (Japanese Only) 50 + <http://strawberry-linux.com/h8/index.html> 51 + 52 + config H8300_KANEBEBE 53 + bool "KaneBebe" 54 + select H83069 55 + select RAMKERNEL 56 + help 57 + KaneBebe Evalition Board Support 58 + More Information. (Japanese Only) 59 + <http://www.nissin-tech.com/2009/10/uclinuxkane-bebe-h83069f.html> 60 + 61 + config H8300H_SIM 62 + bool "H8/300H GDB Simulator" 63 + select H83069 64 + select ROMKERNEL 65 + help 66 + GDB Simulator Support 67 + More Information. 68 + <http://sourceware.org/sid/> 69 + 70 + config H8S_EDOSK2674 71 + bool "EDOSK-2674" 72 + select H8S2678 73 + select RAMKERNEL 74 + help 75 + Renesas EDOSK-2674 Evaluation Board Support 76 + More Information. 77 + <http://www.azpower.com/H8-uClinux/index.html> 78 + <http://www.renesas.eu/products/tools/introductory_evaluation_tools/evaluation_development_os_kits/edosk2674r/edosk2674r_software_tools_root.jsp> 79 + 80 + config H8S_SIM 81 + bool "H8S GDB Simulator" 82 + select H8S2678 83 + select ROMKERNEL 84 + help 85 + GDB Simulator Support 86 + More Information. 87 + <http://sourceware.org/sid/> 88 + 89 + endchoice 90 + 91 + config H8300_BUILTIN_DTB 92 + string "Builtin DTB" 93 + default "" 94 + 95 + config OFFSET 96 + hex "Load offset" 97 + default 0 98 + 99 + endmenu
+55
arch/h8300/Makefile
··· 1 + # 2 + # arch/h8300/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 + # (C) Copyright 2002-2015 Yoshinori Sato <ysato@users.sourceforge.jp> 9 + # 10 + 11 + cflags-$(CONFIG_CPU_H8300H) := -mh 12 + aflags-$(CONFIG_CPU_H8300H) := -mh -Wa,--mach=h8300h 13 + ldflags-$(CONFIG_CPU_H8300H) := -mh8300helf_linux 14 + cflags-$(CONFIG_CPU_H8S) := -ms 15 + aflags-$(CONFIG_CPU_H8S) := -ms -Wa,--mach=h8300s 16 + ldflags-$(CONFIG_CPU_H8S) := -mh8300self_linux 17 + 18 + KBUILD_CFLAGS += $(cflags-y) 19 + KBUILD_CFLAGS += -mint32 -fno-builtin 20 + KBUILD_CFLAGS += -D__linux__ 21 + KBUILD_CFLAGS += -DUTS_SYSNAME=\"uClinux\" 22 + KBUILD_AFLAGS += $(aflags-y) 23 + LDFLAGS += $(ldflags-y) 24 + 25 + CROSS_COMPILE := h8300-unknown-linux- 26 + 27 + core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ 28 + ifneq '$(CONFIG_H8300_BUILTIN_DTB)' '""' 29 + core-y += arch/h8300/boot/dts/ 30 + endif 31 + 32 + libs-y += arch/$(ARCH)/lib/ 33 + 34 + boot := arch/h8300/boot 35 + 36 + %.dtb %.dtb.S %.dtb.o: | scripts 37 + $(Q)$(MAKE) $(build)=arch/h8300/boot/dts arch/h8300/boot/dts/$@ 38 + 39 + PHONY += dtbs 40 + dtbs: scripts 41 + $(Q)$(MAKE) $(build)=arch/h8300/boot/dts 42 + 43 + archmrproper: 44 + 45 + archclean: 46 + $(Q)$(MAKE) $(clean)=$(boot) 47 + 48 + vmlinux.srec vmlinux.bin zImage uImage.bin: vmlinux 49 + $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 50 + 51 + define archhelp 52 + @echo 'vmlinux.bin - Create raw binary' 53 + @echo 'vmlinux.srec - Create srec binary' 54 + @echo 'zImage - Compressed kernel image' 55 + endef
+26
arch/h8300/boot/Makefile
··· 1 + # arch/h8300/boot/Makefile 2 + 3 + targets := vmlinux.srec vmlinux.bin zImage 4 + subdir- := compressed 5 + 6 + OBJCOPYFLAGS_vmlinux.srec := -Osrec 7 + OBJCOPYFLAGS_vmlinux.bin := -Obinary 8 + OBJCOPYFLAGS_zImage := -O binary -R .note -R .comment -R .stab -R .stabstr -S 9 + 10 + UIMAGE_LOADADDR = $(CONFIG_RAMBASE) 11 + UIMAGE_ENTRYADDR = $(shell /bin/bash -c 'printf "0x%08x" \ 12 + $$[$(CONFIG_RAMBASE) + $(CONFIG_OFFSET)]') 13 + 14 + $(obj)/vmlinux.srec $(obj)/vmlinux.bin: vmlinux FORCE 15 + $(call if_changed,objcopy) 16 + 17 + $(obj)/zImage: $(obj)/compressed/vmlinux FORCE 18 + $(call if_changed,objcopy) 19 + 20 + $(obj)/compressed/vmlinux: FORCE 21 + $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 22 + 23 + $(obj)/uImage.bin: $(obj)/vmlinux.bin 24 + $(call if_changed,uimage,none) 25 + 26 + CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec arch/$(ARCH)/uImage.bin
+37
arch/h8300/boot/compressed/Makefile
··· 1 + # 2 + # linux/arch/sh/boot/compressed/Makefile 3 + # 4 + # create a compressed vmlinux image from the original vmlinux 5 + # 6 + 7 + targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o 8 + 9 + OBJECTS = $(obj)/head.o $(obj)/misc.o 10 + 11 + # 12 + # IMAGE_OFFSET is the load offset of the compression loader 13 + # Assign dummy values if these 2 variables are not defined, 14 + # in order to suppress error message. 15 + # 16 + CONFIG_MEMORY_START ?= 0x00400000 17 + CONFIG_BOOT_LINK_OFFSET ?= 0x00140000 18 + IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)))) 19 + 20 + LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) 21 + LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup $(obj)/vmlinux.lds 22 + 23 + $(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE 24 + $(call if_changed,ld) 25 + @: 26 + 27 + $(obj)/vmlinux.bin: vmlinux FORCE 28 + $(call if_changed,objcopy) 29 + 30 + $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE 31 + $(call if_changed,gzip) 32 + 33 + LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T 34 + OBJCOPYFLAGS := -O binary 35 + 36 + $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE 37 + $(call if_changed,ld)
+48
arch/h8300/boot/compressed/head.S
··· 1 + /* 2 + * linux/arch/h8300/boot/compressed/head.S 3 + * 4 + * Copyright (C) 2006 Yoshinori Sato 5 + */ 6 + 7 + #include <linux/linkage.h> 8 + 9 + .section .text..startup,"ax" 10 + .global startup 11 + startup: 12 + mov.l er0, er4 13 + mov.l er0, sp 14 + mov.l #__sbss, er0 15 + mov.l #__ebss, er1 16 + sub.l er0, er1 17 + shlr er1 18 + shlr er1 19 + sub.l er2, er2 20 + 1: 21 + mov.l er2, @er0 22 + adds #4, er0 23 + dec.l #1, er1 24 + bne 1b 25 + jsr @decompress_kernel 26 + mov.l er4, er0 27 + jmp @0x400000 28 + 29 + .align 9 30 + fake_headers_as_bzImage: 31 + .word 0 32 + .ascii "HdrS" ; header signature 33 + .word 0x0202 ; header version number (>= 0x0105) 34 + ; or else old loadlin-1.5 will fail) 35 + .word 0 ; default_switch 36 + .word 0 ; SETUPSEG 37 + .word 0x1000 38 + .word 0 ; pointing to kernel version string 39 + .byte 0 ; = 0, old one (LILO, Loadlin, 40 + ; 0xTV: T=0 for LILO 41 + ; V = version 42 + .byte 1 ; Load flags bzImage=1 43 + .word 0x8000 ; size to move, when setup is not 44 + .long 0x100000 ; 0x100000 = default for big kernel 45 + .long 0 ; address of loaded ramdisk image 46 + .long 0 ; its size in bytes 47 + 48 + .end
+74
arch/h8300/boot/compressed/misc.c
··· 1 + /* 2 + * arch/h8300/boot/compressed/misc.c 3 + * 4 + * This is a collection of several routines from gzip-1.0.3 5 + * adapted for Linux. 6 + * 7 + * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 8 + * 9 + * Adapted for h8300 by Yoshinori Sato 2006 10 + */ 11 + 12 + #include <asm/uaccess.h> 13 + 14 + /* 15 + * gzip declarations 16 + */ 17 + 18 + #define OF(args) args 19 + #define STATIC static 20 + 21 + #undef memset 22 + #undef memcpy 23 + #define memzero(s, n) memset((s), (0), (n)) 24 + 25 + extern int _end; 26 + static unsigned long free_mem_ptr; 27 + static unsigned long free_mem_end_ptr; 28 + 29 + extern char input_data[]; 30 + extern int input_len; 31 + static unsigned char *output; 32 + 33 + #define HEAP_SIZE 0x10000 34 + 35 + #include "../../../../lib/decompress_inflate.c" 36 + 37 + void *memset(void *s, int c, size_t n) 38 + { 39 + int i; 40 + char *ss = (char *)s; 41 + 42 + for (i = 0; i < n; i++) 43 + ss[i] = c; 44 + return s; 45 + } 46 + 47 + void *memcpy(void *dest, const void *src, size_t n) 48 + { 49 + int i; 50 + char *d = (char *)dest, *s = (char *)src; 51 + 52 + for (i = 0; i < n; i++) 53 + d[i] = s[i]; 54 + return dest; 55 + } 56 + 57 + static void error(char *x) 58 + { 59 + 60 + while (1) 61 + ; /* Halt */ 62 + } 63 + 64 + #define STACK_SIZE (4096) 65 + long user_stack[STACK_SIZE]; 66 + long *stack_start = &user_stack[STACK_SIZE]; 67 + 68 + void decompress_kernel(void) 69 + { 70 + free_mem_ptr = (unsigned long)&_end; 71 + free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; 72 + 73 + decompress(input_data, input_len, NULL, NULL, output, NULL, error); 74 + }
+32
arch/h8300/boot/compressed/vmlinux.lds
··· 1 + SECTIONS 2 + { 3 + .text : 4 + { 5 + __stext = . ; 6 + __text = .; 7 + *(.text..startup) 8 + *(.text) 9 + __etext = . ; 10 + } 11 + 12 + .rodata : 13 + { 14 + *(.rodata) 15 + } 16 + .data : 17 + 18 + { 19 + __sdata = . ; 20 + ___data_start = . ; 21 + *(.data.*) 22 + } 23 + .bss : 24 + { 25 + . = ALIGN(0x4) ; 26 + __sbss = . ; 27 + *(.bss*) 28 + . = ALIGN(0x4) ; 29 + __ebss = . ; 30 + __end = . ; 31 + } 32 + }
+9
arch/h8300/boot/compressed/vmlinux.scr
··· 1 + SECTIONS 2 + { 3 + .data : { 4 + input_len = .; 5 + LONG(input_data_end - input_data) input_data = .; 6 + *(.data) 7 + input_data_end = .; 8 + } 9 + }
+12
arch/h8300/boot/dts/Makefile
··· 1 + ifneq '$(CONFIG_H8300_BUILTIN_DTB)' '""' 2 + BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_H8300_BUILTIN_DTB)).dtb.o 3 + endif 4 + 5 + obj-y += $(BUILTIN_DTB) 6 + 7 + dtb-$(CONFIG_H8300H_SIM) := h8300h_sim.dtb 8 + dtb-$(CONFIG_H8S_SIM) := h8s_sim.dtb 9 + dtb-$(CONFIG_H8S_EDOSK2674) := edosk2674.dtb 10 + 11 + always := $(dtb-y) 12 + clean-files := *.dtb.S *.dtb
+107
arch/h8300/boot/dts/edosk2674.dts
··· 1 + /dts-v1/; 2 + / { 3 + compatible = "renesas,edosk2674"; 4 + #address-cells = <1>; 5 + #size-cells = <1>; 6 + interrupt-parent = <&h8intc>; 7 + 8 + chosen { 9 + bootargs = "console=ttySC2,38400"; 10 + stdout-path = <&sci2>; 11 + }; 12 + aliases { 13 + serial0 = &sci0; 14 + serial1 = &sci1; 15 + serial2 = &sci2; 16 + }; 17 + 18 + xclk: oscillator { 19 + #clock-cells = <0>; 20 + compatible = "fixed-clock"; 21 + clock-frequency = <33333333>; 22 + clock-output-names = "xtal"; 23 + }; 24 + pllclk: pllclk { 25 + compatible = "renesas,h8s2678-pll-clock"; 26 + clocks = <&xclk>; 27 + #clock-cells = <0>; 28 + reg = <0xfee03b 2>, <0xfee045 2>; 29 + }; 30 + core_clk: core_clk { 31 + compatible = "renesas,h8300-div-clock"; 32 + clocks = <&pllclk>; 33 + #clock-cells = <0>; 34 + reg = <0xfee03b 2>; 35 + renesas,width = <3>; 36 + }; 37 + fclk: fclk { 38 + compatible = "fixed-factor-clock"; 39 + clocks = <&core_clk>; 40 + #clock-cells = <0>; 41 + clock-div = <1>; 42 + clock-mult = <1>; 43 + }; 44 + 45 + memory@400000 { 46 + device_type = "memory"; 47 + reg = <0x400000 0x800000>; 48 + }; 49 + 50 + cpus { 51 + #address-cells = <1>; 52 + #size-cells = <0>; 53 + cpu@0 { 54 + compatible = "renesas,h8300"; 55 + clock-frequency = <33333333>; 56 + }; 57 + }; 58 + 59 + h8intc: interrupt-controller@fffe00 { 60 + compatible = "renesas,h8s-intc", "renesas,h8300-intc"; 61 + #interrupt-cells = <2>; 62 + interrupt-controller; 63 + reg = <0xfffe00 24>; 64 + }; 65 + 66 + bsc: memory-controller@fffec0 { 67 + compatible = "renesas,h8s-bsc", "renesas,h8300-bsc"; 68 + reg = <0xfffec0 24>; 69 + }; 70 + 71 + tpu: timer@ffffe0 { 72 + compatible = "renesas,tpu"; 73 + reg = <0xffffe0 16>, <0xfffff0 12>; 74 + clocks = <&fclk>; 75 + clock-names = "fck"; 76 + }; 77 + 78 + timer8: timer@ffffb0 { 79 + compatible = "renesas,8bit-timer"; 80 + reg = <0xffffb0 10>; 81 + interrupts = <72 0>; 82 + clocks = <&fclk>; 83 + clock-names = "fck"; 84 + }; 85 + 86 + sci0: serial@ffff78 { 87 + compatible = "renesas,sci"; 88 + reg = <0xffff78 8>; 89 + interrupts = <88 0>, <89 0>, <90 0>, <91 0>; 90 + clocks = <&fclk>; 91 + clock-names = "sci_ick"; 92 + }; 93 + sci1: serial@ffff80 { 94 + compatible = "renesas,sci"; 95 + reg = <0xffff80 8>; 96 + interrupts = <92 0>, <93 0>, <94 0>, <95 0>; 97 + clocks = <&fclk>; 98 + clock-names = "sci_ick"; 99 + }; 100 + sci2: serial@ffff88 { 101 + compatible = "renesas,sci"; 102 + reg = <0xffff88 8>; 103 + interrupts = <96 0>, <97 0>, <98 0>, <99 0>; 104 + clocks = <&fclk>; 105 + clock-names = "sci_ick"; 106 + }; 107 + };
+96
arch/h8300/boot/dts/h8300h_sim.dts
··· 1 + /dts-v1/; 2 + / { 3 + compatible = "gnu,gdbsim"; 4 + #address-cells = <1>; 5 + #size-cells = <1>; 6 + interrupt-parent = <&h8intc>; 7 + 8 + chosen { 9 + bootargs = "earlyprintk=h8300-sim"; 10 + stdout-path = <&sci0>; 11 + }; 12 + aliases { 13 + serial0 = &sci0; 14 + serial1 = &sci1; 15 + }; 16 + 17 + xclk: oscillator { 18 + #clock-cells = <0>; 19 + compatible = "fixed-clock"; 20 + clock-frequency = <20000000>; 21 + clock-output-names = "xtal"; 22 + }; 23 + core_clk: core_clk { 24 + compatible = "renesas,h8300-div-clock"; 25 + clocks = <&xclk>; 26 + #clock-cells = <0>; 27 + reg = <0xfee01b 2>; 28 + renesas,width = <2>; 29 + }; 30 + fclk: fclk { 31 + compatible = "fixed-factor-clock"; 32 + clocks = <&core_clk>; 33 + #clock-cells = <0>; 34 + clock-div = <1>; 35 + clock-mult = <1>; 36 + }; 37 + 38 + memory@400000 { 39 + device_type = "memory"; 40 + reg = <0x400000 0x400000>; 41 + }; 42 + 43 + cpus { 44 + #address-cells = <1>; 45 + #size-cells = <0>; 46 + cpu@0 { 47 + compatible = "renesas,h8300"; 48 + clock-frequency = <20000000>; 49 + }; 50 + }; 51 + 52 + h8intc: interrupt-controller@fee012 { 53 + compatible = "renesas,h8300h-intc", "renesas,h8300-intc"; 54 + #interrupt-cells = <2>; 55 + interrupt-controller; 56 + reg = <0xfee012 7>; 57 + }; 58 + 59 + bsc: memory-controller@fee01e { 60 + compatible = "renesas,h8300h-bsc", "renesas,h8300-bsc"; 61 + reg = <0xfee01e 8>; 62 + }; 63 + 64 + timer8: timer@ffff80 { 65 + compatible = "renesas,8bit-timer"; 66 + reg = <0xffff80 10>; 67 + interrupts = <36 0>; 68 + clocks = <&fclk>; 69 + clock-names = "fck"; 70 + }; 71 + 72 + timer16: timer@ffff68 { 73 + compatible = "renesas,16bit-timer"; 74 + reg = <0xffff68 8>, <0xffff60 8>; 75 + interrupts = <24 0>; 76 + renesas,channel = <0>; 77 + clocks = <&fclk>; 78 + clock-names = "fck"; 79 + }; 80 + 81 + sci0: serial@ffffb0 { 82 + compatible = "renesas,sci"; 83 + reg = <0xffffb0 8>; 84 + interrupts = <52 0>, <53 0>, <54 0>, <55 0>; 85 + clocks = <&fclk>; 86 + clock-names = "sci_ick"; 87 + }; 88 + 89 + sci1: serial@ffffb8 { 90 + compatible = "renesas,sci"; 91 + reg = <0xffffb8 8>; 92 + interrupts = <56 0>, <57 0>, <58 0>, <59 0>; 93 + clocks = <&fclk>; 94 + clock-names = "sci_ick"; 95 + }; 96 + };
+99
arch/h8300/boot/dts/h8s_sim.dts
··· 1 + /dts-v1/; 2 + / { 3 + compatible = "gnu,gdbsim"; 4 + #address-cells = <1>; 5 + #size-cells = <1>; 6 + interrupt-parent = <&h8intc>; 7 + 8 + chosen { 9 + bootargs = "earlyprintk=h8300-sim"; 10 + stdout-path = <&sci0>; 11 + }; 12 + aliases { 13 + serial0 = &sci0; 14 + serial1 = &sci1; 15 + }; 16 + 17 + xclk: oscillator { 18 + #clock-cells = <0>; 19 + compatible = "fixed-clock"; 20 + clock-frequency = <33333333>; 21 + clock-output-names = "xtal"; 22 + }; 23 + pllclk: pllclk { 24 + compatible = "renesas,h8s2678-pll-clock"; 25 + clocks = <&xclk>; 26 + #clock-cells = <0>; 27 + reg = <0xfee03b 2>, <0xfee045 2>; 28 + }; 29 + core_clk: core_clk { 30 + compatible = "renesas,h8300-div-clock"; 31 + clocks = <&pllclk>; 32 + #clock-cells = <0>; 33 + reg = <0xfee03b 2>; 34 + renesas,width = <3>; 35 + }; 36 + fclk: fclk { 37 + compatible = "fixed-factor-clock"; 38 + clocks = <&core_clk>; 39 + #clock-cells = <0>; 40 + clock-div = <1>; 41 + clock-mult = <1>; 42 + }; 43 + 44 + memory@400000 { 45 + device_type = "memory"; 46 + reg = <0x400000 0x800000>; 47 + }; 48 + 49 + cpus { 50 + #address-cells = <1>; 51 + #size-cells = <0>; 52 + cpu@0 { 53 + compatible = "renesas,h8300"; 54 + clock-frequency = <33333333>; 55 + }; 56 + }; 57 + 58 + h8intc: interrupt-controller@fffe00 { 59 + compatible = "renesas,h8s-intc", "renesas,h8300-intc"; 60 + #interrupt-cells = <2>; 61 + interrupt-controller; 62 + reg = <0xfffe00 24>; 63 + }; 64 + 65 + bsc: memory-controller@fffec0 { 66 + compatible = "renesas,h8s-bsc", "renesas,h8300-bsc"; 67 + reg = <0xfffec0 24>; 68 + }; 69 + 70 + tpu: timer@ffffe0 { 71 + compatible = "renesas,tpu"; 72 + reg = <0xffffe0 16>, <0xfffff0 12>; 73 + clocks = <&fclk>; 74 + clock-names = "fck"; 75 + }; 76 + 77 + timer8: timer@ffffb0 { 78 + compatible = "renesas,8bit-timer"; 79 + reg = <0xffffb0 10>; 80 + interrupts = <72 0>; 81 + clocks = <&fclk>; 82 + clock-names = "fck"; 83 + }; 84 + 85 + sci0: serial@ffff78 { 86 + compatible = "renesas,sci"; 87 + reg = <0xffff78 8>; 88 + interrupts = <88 0>, <89 0>, <90 0>, <91 0>; 89 + clocks = <&fclk>; 90 + clock-names = "sci_ick"; 91 + }; 92 + sci1: serial@ffff80 { 93 + compatible = "renesas,sci"; 94 + reg = <0xffff80 8>; 95 + interrupts = <92 0>, <93 0>, <94 0>, <95 0>; 96 + clocks = <&fclk>; 97 + clock-names = "sci_ick"; 98 + }; 99 + };
+49
arch/h8300/configs/edosk2674_defconfig
··· 1 + # CONFIG_LOCALVERSION_AUTO is not set 2 + # CONFIG_USELIB is not set 3 + CONFIG_CC_OPTIMIZE_FOR_SIZE=y 4 + # CONFIG_UID16 is not set 5 + # CONFIG_SYSFS_SYSCALL is not set 6 + # CONFIG_KALLSYMS is not set 7 + # CONFIG_BASE_FULL is not set 8 + # CONFIG_FUTEX is not set 9 + # CONFIG_EPOLL is not set 10 + # CONFIG_SIGNALFD is not set 11 + # CONFIG_TIMERFD is not set 12 + # CONFIG_EVENTFD is not set 13 + # CONFIG_AIO is not set 14 + # CONFIG_ADVISE_SYSCALLS is not set 15 + CONFIG_EMBEDDED=y 16 + # CONFIG_VM_EVENT_COUNTERS is not set 17 + # CONFIG_COMPAT_BRK is not set 18 + CONFIG_SLOB=y 19 + # CONFIG_BLOCK is not set 20 + CONFIG_H8S_SIM=y 21 + CONFIG_H8300_BUILTIN_DTB="h8s_sim" 22 + # CONFIG_BINFMT_SCRIPT is not set 23 + CONFIG_BINFMT_FLAT=y 24 + # CONFIG_COREDUMP is not set 25 + # CONFIG_UEVENT_HELPER is not set 26 + # CONFIG_STANDALONE is not set 27 + # CONFIG_PREVENT_FIRMWARE_BUILD is not set 28 + # CONFIG_FW_LOADER is not set 29 + # CONFIG_ALLOW_DEV_COREDUMP is not set 30 + # CONFIG_INPUT is not set 31 + # CONFIG_SERIO is not set 32 + # CONFIG_VT is not set 33 + # CONFIG_UNIX98_PTYS is not set 34 + # CONFIG_LEGACY_PTYS is not set 35 + # CONFIG_DEVKMEM is not set 36 + CONFIG_SERIAL_SH_SCI=y 37 + CONFIG_SERIAL_SH_SCI_CONSOLE=y 38 + # CONFIG_HW_RANDOM is not set 39 + # CONFIG_HWMON is not set 40 + # CONFIG_USB_SUPPORT is not set 41 + # CONFIG_FILE_LOCKING is not set 42 + # CONFIG_DNOTIFY is not set 43 + # CONFIG_INOTIFY_USER is not set 44 + # CONFIG_PROC_FS is not set 45 + # CONFIG_SYSFS is not set 46 + # CONFIG_MISC_FILESYSTEMS is not set 47 + CONFIG_DEBUG_INFO=y 48 + # CONFIG_ENABLE_WARN_DEPRECATED is not set 49 + # CONFIG_ENABLE_MUST_CHECK is not set
+49
arch/h8300/configs/h8300h-sim_defconfig
··· 1 + # CONFIG_LOCALVERSION_AUTO is not set 2 + # CONFIG_USELIB is not set 3 + CONFIG_CC_OPTIMIZE_FOR_SIZE=y 4 + # CONFIG_UID16 is not set 5 + # CONFIG_SYSFS_SYSCALL is not set 6 + # CONFIG_KALLSYMS is not set 7 + # CONFIG_BASE_FULL is not set 8 + # CONFIG_FUTEX is not set 9 + # CONFIG_EPOLL is not set 10 + # CONFIG_SIGNALFD is not set 11 + # CONFIG_TIMERFD is not set 12 + # CONFIG_EVENTFD is not set 13 + # CONFIG_AIO is not set 14 + # CONFIG_ADVISE_SYSCALLS is not set 15 + CONFIG_EMBEDDED=y 16 + # CONFIG_VM_EVENT_COUNTERS is not set 17 + # CONFIG_COMPAT_BRK is not set 18 + CONFIG_SLOB=y 19 + # CONFIG_BLOCK is not set 20 + CONFIG_H8300H_SIM=y 21 + CONFIG_H8300_BUILTIN_DTB="h8300h_sim" 22 + # CONFIG_BINFMT_SCRIPT is not set 23 + CONFIG_BINFMT_FLAT=y 24 + # CONFIG_COREDUMP is not set 25 + # CONFIG_UEVENT_HELPER is not set 26 + # CONFIG_STANDALONE is not set 27 + # CONFIG_PREVENT_FIRMWARE_BUILD is not set 28 + # CONFIG_FW_LOADER is not set 29 + # CONFIG_ALLOW_DEV_COREDUMP is not set 30 + # CONFIG_INPUT is not set 31 + # CONFIG_SERIO is not set 32 + # CONFIG_VT is not set 33 + # CONFIG_UNIX98_PTYS is not set 34 + # CONFIG_LEGACY_PTYS is not set 35 + # CONFIG_DEVKMEM is not set 36 + CONFIG_SERIAL_SH_SCI=y 37 + CONFIG_SERIAL_SH_SCI_CONSOLE=y 38 + # CONFIG_HW_RANDOM is not set 39 + # CONFIG_HWMON is not set 40 + # CONFIG_USB_SUPPORT is not set 41 + # CONFIG_FILE_LOCKING is not set 42 + # CONFIG_DNOTIFY is not set 43 + # CONFIG_INOTIFY_USER is not set 44 + # CONFIG_PROC_FS is not set 45 + # CONFIG_SYSFS is not set 46 + # CONFIG_MISC_FILESYSTEMS is not set 47 + CONFIG_DEBUG_INFO=y 48 + # CONFIG_ENABLE_WARN_DEPRECATED is not set 49 + # CONFIG_ENABLE_MUST_CHECK is not set
+49
arch/h8300/configs/h8s-sim_defconfig
··· 1 + # CONFIG_LOCALVERSION_AUTO is not set 2 + # CONFIG_USELIB is not set 3 + CONFIG_CC_OPTIMIZE_FOR_SIZE=y 4 + # CONFIG_UID16 is not set 5 + # CONFIG_SYSFS_SYSCALL is not set 6 + # CONFIG_KALLSYMS is not set 7 + # CONFIG_BASE_FULL is not set 8 + # CONFIG_FUTEX is not set 9 + # CONFIG_EPOLL is not set 10 + # CONFIG_SIGNALFD is not set 11 + # CONFIG_TIMERFD is not set 12 + # CONFIG_EVENTFD is not set 13 + # CONFIG_AIO is not set 14 + # CONFIG_ADVISE_SYSCALLS is not set 15 + CONFIG_EMBEDDED=y 16 + # CONFIG_VM_EVENT_COUNTERS is not set 17 + # CONFIG_COMPAT_BRK is not set 18 + CONFIG_SLOB=y 19 + # CONFIG_BLOCK is not set 20 + CONFIG_H8S_SIM=y 21 + CONFIG_H8300_BUILTIN_DTB="h8s_sim" 22 + # CONFIG_BINFMT_SCRIPT is not set 23 + CONFIG_BINFMT_FLAT=y 24 + # CONFIG_COREDUMP is not set 25 + # CONFIG_UEVENT_HELPER is not set 26 + # CONFIG_STANDALONE is not set 27 + # CONFIG_PREVENT_FIRMWARE_BUILD is not set 28 + # CONFIG_FW_LOADER is not set 29 + # CONFIG_ALLOW_DEV_COREDUMP is not set 30 + # CONFIG_INPUT is not set 31 + # CONFIG_SERIO is not set 32 + # CONFIG_VT is not set 33 + # CONFIG_UNIX98_PTYS is not set 34 + # CONFIG_LEGACY_PTYS is not set 35 + # CONFIG_DEVKMEM is not set 36 + CONFIG_SERIAL_SH_SCI=y 37 + CONFIG_SERIAL_SH_SCI_CONSOLE=y 38 + # CONFIG_HW_RANDOM is not set 39 + # CONFIG_HWMON is not set 40 + # CONFIG_USB_SUPPORT is not set 41 + # CONFIG_FILE_LOCKING is not set 42 + # CONFIG_DNOTIFY is not set 43 + # CONFIG_INOTIFY_USER is not set 44 + # CONFIG_PROC_FS is not set 45 + # CONFIG_SYSFS is not set 46 + # CONFIG_MISC_FILESYSTEMS is not set 47 + CONFIG_DEBUG_INFO=y 48 + # CONFIG_ENABLE_WARN_DEPRECATED is not set 49 + # CONFIG_ENABLE_MUST_CHECK is not set
+75
arch/h8300/include/asm/Kbuild
··· 1 + generic-y += asm-offsets.h 2 + generic-y += auxvec.h 3 + generic-y += barrier.h 4 + generic-y += bugs.h 5 + generic-y += cacheflush.h 6 + generic-y += checksum.h 7 + generic-y += clkdev.h 8 + generic-y += cputime.h 9 + generic-y += current.h 10 + generic-y += delay.h 11 + generic-y += device.h 12 + generic-y += div64.h 13 + generic-y += dma.h 14 + generic-y += emergency-restart.h 15 + generic-y += errno.h 16 + generic-y += exec.h 17 + generic-y += fb.h 18 + generic-y += fcntl.h 19 + generic-y += ftrace.h 20 + generic-y += futex.h 21 + generic-y += hardirq.h 22 + generic-y += hash.h 23 + generic-y += hw_irq.h 24 + generic-y += ioctl.h 25 + generic-y += ioctls.h 26 + generic-y += ipcbuf.h 27 + generic-y += irq_regs.h 28 + generic-y += irq_work.h 29 + generic-y += kdebug.h 30 + generic-y += kmap_types.h 31 + generic-y += kvm_para.h 32 + generic-y += linkage.h 33 + generic-y += local.h 34 + generic-y += local64.h 35 + generic-y += mcs_spinlock.h 36 + generic-y += mman.h 37 + generic-y += mmu.h 38 + generic-y += mmu_context.h 39 + generic-y += module.h 40 + generic-y += msgbuf.h 41 + generic-y += param.h 42 + generic-y += parport.h 43 + generic-y += percpu.h 44 + generic-y += pgalloc.h 45 + generic-y += poll.h 46 + generic-y += posix_types.h 47 + generic-y += preempt.h 48 + generic-y += resource.h 49 + generic-y += scatterlist.h 50 + generic-y += sections.h 51 + generic-y += sembuf.h 52 + generic-y += serial.h 53 + generic-y += setup.h 54 + generic-y += shmbuf.h 55 + generic-y += shmparam.h 56 + generic-y += siginfo.h 57 + generic-y += sizes.h 58 + generic-y += socket.h 59 + generic-y += sockios.h 60 + generic-y += spinlock.h 61 + generic-y += stat.h 62 + generic-y += statfs.h 63 + generic-y += swab.h 64 + generic-y += termbits.h 65 + generic-y += termios.h 66 + generic-y += timex.h 67 + generic-y += tlbflush.h 68 + generic-y += trace_clock.h 69 + generic-y += topology.h 70 + generic-y += types.h 71 + generic-y += uaccess.h 72 + generic-y += ucontext.h 73 + generic-y += unaligned.h 74 + generic-y += vga.h 75 + generic-y += xor.h
+159
arch/h8300/include/asm/atomic.h
··· 1 + #ifndef __ARCH_H8300_ATOMIC__ 2 + #define __ARCH_H8300_ATOMIC__ 3 + 4 + #include <linux/types.h> 5 + #include <asm/cmpxchg.h> 6 + 7 + /* 8 + * Atomic operations that C can't guarantee us. Useful for 9 + * resource counting etc.. 10 + */ 11 + 12 + #define ATOMIC_INIT(i) { (i) } 13 + 14 + #define atomic_read(v) ACCESS_ONCE((v)->counter) 15 + #define atomic_set(v, i) (((v)->counter) = i) 16 + 17 + #include <linux/kernel.h> 18 + 19 + static inline int atomic_add_return(int i, atomic_t *v) 20 + { 21 + h8300flags flags; 22 + int ret; 23 + 24 + flags = arch_local_irq_save(); 25 + ret = v->counter += i; 26 + arch_local_irq_restore(flags); 27 + return ret; 28 + } 29 + 30 + #define atomic_add(i, v) atomic_add_return(i, v) 31 + #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0) 32 + 33 + static inline int atomic_sub_return(int i, atomic_t *v) 34 + { 35 + h8300flags flags; 36 + int ret; 37 + 38 + flags = arch_local_irq_save(); 39 + ret = v->counter -= i; 40 + arch_local_irq_restore(flags); 41 + return ret; 42 + } 43 + 44 + #define atomic_sub(i, v) atomic_sub_return(i, v) 45 + #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0) 46 + 47 + static inline int atomic_inc_return(atomic_t *v) 48 + { 49 + h8300flags flags; 50 + int ret; 51 + 52 + flags = arch_local_irq_save(); 53 + v->counter++; 54 + ret = v->counter; 55 + arch_local_irq_restore(flags); 56 + return ret; 57 + } 58 + 59 + #define atomic_inc(v) atomic_inc_return(v) 60 + 61 + /* 62 + * atomic_inc_and_test - increment and test 63 + * @v: pointer of type atomic_t 64 + * 65 + * Atomically increments @v by 1 66 + * and returns true if the result is zero, or false for all 67 + * other cases. 68 + */ 69 + #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) 70 + 71 + static inline int atomic_dec_return(atomic_t *v) 72 + { 73 + h8300flags flags; 74 + int ret; 75 + 76 + flags = arch_local_irq_save(); 77 + --v->counter; 78 + ret = v->counter; 79 + arch_local_irq_restore(flags); 80 + return ret; 81 + } 82 + 83 + #define atomic_dec(v) atomic_dec_return(v) 84 + 85 + static inline int atomic_dec_and_test(atomic_t *v) 86 + { 87 + h8300flags flags; 88 + int ret; 89 + 90 + flags = arch_local_irq_save(); 91 + --v->counter; 92 + ret = v->counter; 93 + arch_local_irq_restore(flags); 94 + return ret == 0; 95 + } 96 + 97 + static inline int atomic_cmpxchg(atomic_t *v, int old, int new) 98 + { 99 + int ret; 100 + h8300flags flags; 101 + 102 + flags = arch_local_irq_save(); 103 + ret = v->counter; 104 + if (likely(ret == old)) 105 + v->counter = new; 106 + arch_local_irq_restore(flags); 107 + return ret; 108 + } 109 + 110 + static inline int __atomic_add_unless(atomic_t *v, int a, int u) 111 + { 112 + int ret; 113 + h8300flags flags; 114 + 115 + flags = arch_local_irq_save(); 116 + ret = v->counter; 117 + if (ret != u) 118 + v->counter += a; 119 + arch_local_irq_restore(flags); 120 + return ret; 121 + } 122 + 123 + static inline void atomic_clear_mask(unsigned long mask, unsigned long *v) 124 + { 125 + unsigned char ccr; 126 + unsigned long tmp; 127 + 128 + __asm__ __volatile__("stc ccr,%w3\n\t" 129 + "orc #0x80,ccr\n\t" 130 + "mov.l %0,%1\n\t" 131 + "and.l %2,%1\n\t" 132 + "mov.l %1,%0\n\t" 133 + "ldc %w3,ccr" 134 + : "=m"(*v), "=r"(tmp) 135 + : "g"(~(mask)), "r"(ccr)); 136 + } 137 + 138 + static inline void atomic_set_mask(unsigned long mask, unsigned long *v) 139 + { 140 + unsigned char ccr; 141 + unsigned long tmp; 142 + 143 + __asm__ __volatile__("stc ccr,%w3\n\t" 144 + "orc #0x80,ccr\n\t" 145 + "mov.l %0,%1\n\t" 146 + "or.l %2,%1\n\t" 147 + "mov.l %1,%0\n\t" 148 + "ldc %w3,ccr" 149 + : "=m"(*v), "=r"(tmp) 150 + : "g"(~(mask)), "r"(ccr)); 151 + } 152 + 153 + /* Atomic operations are already serializing */ 154 + #define smp_mb__before_atomic_dec() barrier() 155 + #define smp_mb__after_atomic_dec() barrier() 156 + #define smp_mb__before_atomic_inc() barrier() 157 + #define smp_mb__after_atomic_inc() barrier() 158 + 159 + #endif /* __ARCH_H8300_ATOMIC __ */
+185
arch/h8300/include/asm/bitops.h
··· 1 + #ifndef _H8300_BITOPS_H 2 + #define _H8300_BITOPS_H 3 + 4 + /* 5 + * Copyright 1992, Linus Torvalds. 6 + * Copyright 2002, Yoshinori Sato 7 + */ 8 + 9 + #include <linux/compiler.h> 10 + 11 + #ifdef __KERNEL__ 12 + 13 + #ifndef _LINUX_BITOPS_H 14 + #error only <linux/bitops.h> can be included directly 15 + #endif 16 + 17 + /* 18 + * Function prototypes to keep gcc -Wall happy 19 + */ 20 + 21 + /* 22 + * ffz = Find First Zero in word. Undefined if no zero exists, 23 + * so code should check against ~0UL first.. 24 + */ 25 + static inline unsigned long ffz(unsigned long word) 26 + { 27 + unsigned long result; 28 + 29 + result = -1; 30 + __asm__("1:\n\t" 31 + "shlr.l %2\n\t" 32 + "adds #1,%0\n\t" 33 + "bcs 1b" 34 + : "=r"(result) 35 + : "0"(result), "r"(word)); 36 + return result; 37 + } 38 + 39 + #define H8300_GEN_BITOP(FNAME, OP) \ 40 + static inline void FNAME(int nr, volatile unsigned long *addr) \ 41 + { \ 42 + unsigned char *b_addr; \ 43 + unsigned char bit = nr & 7; \ 44 + \ 45 + b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3); \ 46 + if (__builtin_constant_p(nr)) { \ 47 + __asm__(OP " %1,%0" : "+WU"(*b_addr) : "i"(nr & 7)); \ 48 + } else { \ 49 + __asm__(OP " %s1,%0" : "+WU"(*b_addr) : "r"(bit)); \ 50 + } \ 51 + } 52 + 53 + /* 54 + * clear_bit() doesn't provide any barrier for the compiler. 55 + */ 56 + #define smp_mb__before_clear_bit() barrier() 57 + #define smp_mb__after_clear_bit() barrier() 58 + 59 + H8300_GEN_BITOP(set_bit, "bset") 60 + H8300_GEN_BITOP(clear_bit, "bclr") 61 + H8300_GEN_BITOP(change_bit, "bnot") 62 + #define __set_bit(nr, addr) set_bit((nr), (addr)) 63 + #define __clear_bit(nr, addr) clear_bit((nr), (addr)) 64 + #define __change_bit(nr, addr) change_bit((nr), (addr)) 65 + 66 + #undef H8300_GEN_BITOP 67 + 68 + static inline int test_bit(int nr, const unsigned long *addr) 69 + { 70 + int ret = 0; 71 + unsigned char *b_addr; 72 + unsigned char bit = nr & 7; 73 + 74 + b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3); 75 + if (__builtin_constant_p(nr)) { 76 + __asm__("bld %Z2,%1\n\t" 77 + "rotxl %0\n\t" 78 + : "=r"(ret) 79 + : "WU"(*b_addr), "i"(nr & 7), "0"(ret) : "cc"); 80 + } else { 81 + __asm__("btst %w2,%1\n\t" 82 + "beq 1f\n\t" 83 + "inc.l #1,%0\n" 84 + "1:" 85 + : "=r"(ret) 86 + : "WU"(*b_addr), "r"(bit), "0"(ret) : "cc"); 87 + } 88 + return ret; 89 + } 90 + 91 + #define __test_bit(nr, addr) test_bit(nr, addr) 92 + 93 + #define H8300_GEN_TEST_BITOP(FNNAME, OP) \ 94 + static inline int FNNAME(int nr, void *addr) \ 95 + { \ 96 + int retval = 0; \ 97 + char ccrsave; \ 98 + unsigned char *b_addr; \ 99 + unsigned char bit = nr & 7; \ 100 + \ 101 + b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3); \ 102 + if (__builtin_constant_p(nr)) { \ 103 + __asm__("stc ccr,%s2\n\t" \ 104 + "orc #0x80,ccr\n\t" \ 105 + "bld %4,%1\n\t" \ 106 + OP " %4,%1\n\t" \ 107 + "rotxl.l %0\n\t" \ 108 + "ldc %s2,ccr" \ 109 + : "=r"(retval), "+WU" (*b_addr), "=&r"(ccrsave) \ 110 + : "0"(retval), "i"(nr & 7) : "cc"); \ 111 + } else { \ 112 + __asm__("stc ccr,%t3\n\t" \ 113 + "orc #0x80,ccr\n\t" \ 114 + "btst %s3,%1\n\t" \ 115 + OP " %s3,%1\n\t" \ 116 + "beq 1f\n\t" \ 117 + "inc.l #1,%0\n\t" \ 118 + "1:\n" \ 119 + "ldc %t3,ccr" \ 120 + : "=r"(retval), "+WU" (*b_addr) \ 121 + : "0" (retval), "r"(bit) : "cc"); \ 122 + } \ 123 + return retval; \ 124 + } \ 125 + \ 126 + static inline int __ ## FNNAME(int nr, void *addr) \ 127 + { \ 128 + int retval = 0; \ 129 + unsigned char *b_addr; \ 130 + unsigned char bit = nr & 7; \ 131 + \ 132 + b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3); \ 133 + if (__builtin_constant_p(nr)) { \ 134 + __asm__("bld %3,%1\n\t" \ 135 + OP " %3,%1\n\t" \ 136 + "rotxl.l %0\n\t" \ 137 + : "=r"(retval), "+WU"(*b_addr) \ 138 + : "0" (retval), "i"(nr & 7)); \ 139 + } else { \ 140 + __asm__("btst %s3,%1\n\t" \ 141 + OP " %s3,%1\n\t" \ 142 + "beq 1f\n\t" \ 143 + "inc.l #1,%0\n\t" \ 144 + "1:" \ 145 + : "=r"(retval), "+WU"(*b_addr) \ 146 + : "0" (retval), "r"(bit)); \ 147 + } \ 148 + return retval; \ 149 + } 150 + 151 + H8300_GEN_TEST_BITOP(test_and_set_bit, "bset") 152 + H8300_GEN_TEST_BITOP(test_and_clear_bit, "bclr") 153 + H8300_GEN_TEST_BITOP(test_and_change_bit, "bnot") 154 + #undef H8300_GEN_TEST_BITOP 155 + 156 + #include <asm-generic/bitops/ffs.h> 157 + 158 + static inline unsigned long __ffs(unsigned long word) 159 + { 160 + unsigned long result; 161 + 162 + result = -1; 163 + __asm__("1:\n\t" 164 + "shlr.l %2\n\t" 165 + "adds #1,%0\n\t" 166 + "bcc 1b" 167 + : "=r" (result) 168 + : "0"(result), "r"(word)); 169 + return result; 170 + } 171 + 172 + #include <asm-generic/bitops/find.h> 173 + #include <asm-generic/bitops/sched.h> 174 + #include <asm-generic/bitops/hweight.h> 175 + #include <asm-generic/bitops/lock.h> 176 + #include <asm-generic/bitops/le.h> 177 + #include <asm-generic/bitops/ext2-atomic.h> 178 + 179 + #endif /* __KERNEL__ */ 180 + 181 + #include <asm-generic/bitops/fls.h> 182 + #include <asm-generic/bitops/__fls.h> 183 + #include <asm-generic/bitops/fls64.h> 184 + 185 + #endif /* _H8300_BITOPS_H */
+14
arch/h8300/include/asm/bitsperlong.h
··· 1 + #ifndef __ASM_H8300_BITS_PER_LONG 2 + #define __ASM_H8300_BITS_PER_LONG 3 + 4 + #include <asm-generic/bitsperlong.h> 5 + 6 + #if !defined(__ASSEMBLY__) 7 + /* h8300-unknown-linux required long */ 8 + #define __kernel_size_t __kernel_size_t 9 + typedef unsigned long __kernel_size_t; 10 + typedef long __kernel_ssize_t; 11 + typedef long __kernel_ptrdiff_t; 12 + #endif 13 + 14 + #endif /* __ASM_H8300_BITS_PER_LONG */
+12
arch/h8300/include/asm/bug.h
··· 1 + #ifndef _H8300_BUG_H 2 + #define _H8300_BUG_H 3 + 4 + /* always true */ 5 + #define is_valid_bugaddr(addr) (1) 6 + 7 + #include <asm-generic/bug.h> 8 + 9 + struct pt_regs; 10 + extern void die(const char *str, struct pt_regs *fp, unsigned long err); 11 + 12 + #endif
+7
arch/h8300/include/asm/byteorder.h
··· 1 + #ifndef __H8300_BYTEORDER_H__ 2 + #define __H8300_BYTEORDER_H__ 3 + 4 + #define __BIG_ENDIAN __ORDER_BIG_ENDIAN__ 5 + #include <linux/byteorder/big_endian.h> 6 + 7 + #endif
+11
arch/h8300/include/asm/cache.h
··· 1 + #ifndef __ARCH_H8300_CACHE_H 2 + #define __ARCH_H8300_CACHE_H 3 + 4 + /* bytes per L1 cache line */ 5 + #define L1_CACHE_SHIFT 2 6 + #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 7 + 8 + #define __cacheline_aligned 9 + #define ____cacheline_aligned 10 + 11 + #endif
+65
arch/h8300/include/asm/cmpxchg.h
··· 1 + #ifndef __ARCH_H8300_CMPXCHG__ 2 + #define __ARCH_H8300_CMPXCHG__ 3 + 4 + #include <linux/irqflags.h> 5 + 6 + #define xchg(ptr, x) \ 7 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), \ 8 + sizeof(*(ptr)))) 9 + 10 + struct __xchg_dummy { unsigned long a[100]; }; 11 + #define __xg(x) ((volatile struct __xchg_dummy *)(x)) 12 + 13 + static inline unsigned long __xchg(unsigned long x, 14 + volatile void *ptr, int size) 15 + { 16 + unsigned long tmp, flags; 17 + 18 + local_irq_save(flags); 19 + 20 + switch (size) { 21 + case 1: 22 + __asm__ __volatile__ 23 + ("mov.b %2,%0\n\t" 24 + "mov.b %1,%2" 25 + : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr))); 26 + break; 27 + case 2: 28 + __asm__ __volatile__ 29 + ("mov.w %2,%0\n\t" 30 + "mov.w %1,%2" 31 + : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr))); 32 + break; 33 + case 4: 34 + __asm__ __volatile__ 35 + ("mov.l %2,%0\n\t" 36 + "mov.l %1,%2" 37 + : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr))); 38 + break; 39 + default: 40 + tmp = 0; 41 + } 42 + local_irq_restore(flags); 43 + return tmp; 44 + } 45 + 46 + #include <asm-generic/cmpxchg-local.h> 47 + 48 + /* 49 + * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make 50 + * them available. 51 + */ 52 + #define cmpxchg_local(ptr, o, n) \ 53 + ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \ 54 + (unsigned long)(o), \ 55 + (unsigned long)(n), \ 56 + sizeof(*(ptr)))) 57 + #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) 58 + 59 + #ifndef CONFIG_SMP 60 + #include <asm-generic/cmpxchg.h> 61 + #endif 62 + 63 + #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 64 + 65 + #endif /* __ARCH_H8300_CMPXCHG__ */
+57
arch/h8300/include/asm/dma-mapping.h
··· 1 + #ifndef _H8300_DMA_MAPPING_H 2 + #define _H8300_DMA_MAPPING_H 3 + 4 + #include <asm-generic/dma-coherent.h> 5 + 6 + extern struct dma_map_ops h8300_dma_map_ops; 7 + 8 + static inline struct dma_map_ops *get_dma_ops(struct device *dev) 9 + { 10 + return &h8300_dma_map_ops; 11 + } 12 + 13 + #include <asm-generic/dma-mapping-common.h> 14 + 15 + static inline int dma_supported(struct device *dev, u64 mask) 16 + { 17 + return 0; 18 + } 19 + 20 + static inline int dma_set_mask(struct device *dev, u64 mask) 21 + { 22 + return 0; 23 + } 24 + 25 + #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 26 + #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 27 + 28 + #define dma_alloc_coherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL) 29 + 30 + static inline void *dma_alloc_attrs(struct device *dev, size_t size, 31 + dma_addr_t *dma_handle, gfp_t flag, 32 + struct dma_attrs *attrs) 33 + { 34 + struct dma_map_ops *ops = get_dma_ops(dev); 35 + void *memory; 36 + 37 + memory = ops->alloc(dev, size, dma_handle, flag, attrs); 38 + return memory; 39 + } 40 + 41 + #define dma_free_coherent(d, s, c, h) dma_free_attrs(d, s, c, h, NULL) 42 + 43 + static inline void dma_free_attrs(struct device *dev, size_t size, 44 + void *cpu_addr, dma_addr_t dma_handle, 45 + struct dma_attrs *attrs) 46 + { 47 + struct dma_map_ops *ops = get_dma_ops(dev); 48 + 49 + ops->free(dev, size, cpu_addr, dma_handle, attrs); 50 + } 51 + 52 + static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 53 + { 54 + return 0; 55 + } 56 + 57 + #endif
+101
arch/h8300/include/asm/elf.h
··· 1 + #ifndef __ASM_H8300_ELF_H 2 + #define __ASM_H8300_ELF_H 3 + 4 + /* 5 + * ELF register definitions.. 6 + */ 7 + 8 + #include <asm/ptrace.h> 9 + #include <asm/user.h> 10 + 11 + typedef unsigned long elf_greg_t; 12 + 13 + #define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t)) 14 + typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 15 + typedef unsigned long elf_fpregset_t; 16 + 17 + /* 18 + * This is used to ensure we don't load something for the wrong architecture. 19 + */ 20 + #define elf_check_arch(x) ((x)->e_machine == EM_H8_300) 21 + 22 + /* 23 + * These are used to set parameters in the core dumps. 24 + */ 25 + #define ELF_CLASS ELFCLASS32 26 + #define ELF_DATA ELFDATA2MSB 27 + #define ELF_ARCH EM_H8_300 28 + #if defined(CONFIG_CPU_H8300H) 29 + #define ELF_CORE_EFLAGS 0x810000 30 + #endif 31 + #if defined(CONFIG_CPU_H8S) 32 + #define ELF_CORE_EFLAGS 0x820000 33 + #endif 34 + 35 + #define ELF_PLAT_INIT(_r) do { (_r)->er1 = 0; } while (0) 36 + 37 + #define ELF_EXEC_PAGESIZE 4096 38 + 39 + /* This is the location that an ET_DYN program is loaded if exec'ed. Typical 40 + use of this is to invoke "./ld.so someprog" to test out a new version of 41 + the loader. We need to make sure that it is out of the way of the program 42 + that it will "exec", and that there is sufficient room for the brk. */ 43 + 44 + #define ELF_ET_DYN_BASE 0xD0000000UL 45 + 46 + /* This yields a mask that user programs can use to figure out what 47 + instruction set this cpu supports. */ 48 + 49 + #define ELF_HWCAP (0) 50 + 51 + /* This yields a string that ld.so will use to load implementation 52 + specific libraries for optimization. This is more specific in 53 + intent than poking at uname or /proc/cpuinfo. */ 54 + 55 + #define ELF_PLATFORM (NULL) 56 + 57 + #define R_H8_NONE 0 58 + #define R_H8_DIR32 1 59 + #define R_H8_DIR32_28 2 60 + #define R_H8_DIR32_24 3 61 + #define R_H8_DIR32_16 4 62 + #define R_H8_DIR32U 6 63 + #define R_H8_DIR32U_28 7 64 + #define R_H8_DIR32U_24 8 65 + #define R_H8_DIR32U_20 9 66 + #define R_H8_DIR32U_16 10 67 + #define R_H8_DIR24 11 68 + #define R_H8_DIR24_20 12 69 + #define R_H8_DIR24_16 13 70 + #define R_H8_DIR24U 14 71 + #define R_H8_DIR24U_20 15 72 + #define R_H8_DIR24U_16 16 73 + #define R_H8_DIR16 17 74 + #define R_H8_DIR16U 18 75 + #define R_H8_DIR16S_32 19 76 + #define R_H8_DIR16S_28 20 77 + #define R_H8_DIR16S_24 21 78 + #define R_H8_DIR16S_20 22 79 + #define R_H8_DIR16S 23 80 + #define R_H8_DIR8 24 81 + #define R_H8_DIR8U 25 82 + #define R_H8_DIR8Z_32 26 83 + #define R_H8_DIR8Z_28 27 84 + #define R_H8_DIR8Z_24 28 85 + #define R_H8_DIR8Z_20 29 86 + #define R_H8_DIR8Z_16 30 87 + #define R_H8_PCREL16 31 88 + #define R_H8_PCREL8 32 89 + #define R_H8_BPOS 33 90 + #define R_H8_PCREL32 34 91 + #define R_H8_GOT32O 35 92 + #define R_H8_GOT16O 36 93 + #define R_H8_DIR16A8 59 94 + #define R_H8_DIR16R8 60 95 + #define R_H8_DIR24A8 61 96 + #define R_H8_DIR24R8 62 97 + #define R_H8_DIR32A16 63 98 + #define R_H8_ABS32 65 99 + #define R_H8_ABS32A16 127 100 + 101 + #endif
+28
arch/h8300/include/asm/flat.h
··· 1 + /* 2 + * arch/h8300/asm/include/flat.h -- uClinux flat-format executables 3 + */ 4 + 5 + #ifndef __H8300_FLAT_H__ 6 + #define __H8300_FLAT_H__ 7 + 8 + #define flat_argvp_envp_on_stack() 1 9 + #define flat_old_ram_flag(flags) 1 10 + #define flat_reloc_valid(reloc, size) ((reloc) <= (size)) 11 + #define flat_set_persistent(relval, p) 0 12 + 13 + /* 14 + * on the H8 a couple of the relocations have an instruction in the 15 + * top byte. As there can only be 24bits of address space, we just 16 + * always preserve that 8bits at the top, when it isn't an instruction 17 + * is is 0 (davidm@snapgear.com) 18 + */ 19 + 20 + #define flat_get_relocate_addr(rel) (rel & ~0x00000001) 21 + #define flat_get_addr_from_rp(rp, relval, flags, persistent) \ 22 + ({(void)persistent; \ 23 + get_unaligned(rp) & (((flags) & FLAT_FLAG_GOTPIC) ? \ 24 + 0xffffffff : 0x00ffffff); }) 25 + #define flat_put_addr_at_rp(rp, addr, rel) \ 26 + put_unaligned(((*(char *)(rp)) << 24) | ((addr) & 0x00ffffff), (rp)) 27 + 28 + #endif /* __H8300_FLAT_H__ */
+57
arch/h8300/include/asm/io.h
··· 1 + #ifndef _H8300_IO_H 2 + #define _H8300_IO_H 3 + 4 + #ifdef __KERNEL__ 5 + 6 + #include <asm-generic/io.h> 7 + 8 + /* H8/300 internal I/O functions */ 9 + static inline unsigned char ctrl_inb(unsigned long addr) 10 + { 11 + return *(volatile unsigned char *)addr; 12 + } 13 + 14 + static inline unsigned short ctrl_inw(unsigned long addr) 15 + { 16 + return *(volatile unsigned short *)addr; 17 + } 18 + 19 + static inline unsigned long ctrl_inl(unsigned long addr) 20 + { 21 + return *(volatile unsigned long *)addr; 22 + } 23 + 24 + static inline void ctrl_outb(unsigned char b, unsigned long addr) 25 + { 26 + *(volatile unsigned char *)addr = b; 27 + } 28 + 29 + static inline void ctrl_outw(unsigned short b, unsigned long addr) 30 + { 31 + *(volatile unsigned short *)addr = b; 32 + } 33 + 34 + static inline void ctrl_outl(unsigned long b, unsigned long addr) 35 + { 36 + *(volatile unsigned long *)addr = b; 37 + } 38 + 39 + static inline void ctrl_bclr(int b, unsigned long addr) 40 + { 41 + if (__builtin_constant_p(b)) 42 + __asm__("bclr %1,%0" : : "WU"(addr), "i"(b)); 43 + else 44 + __asm__("bclr %w1,%0" : : "WU"(addr), "r"(b)); 45 + } 46 + 47 + static inline void ctrl_bset(int b, unsigned long addr) 48 + { 49 + if (__builtin_constant_p(b)) 50 + __asm__("bset %1,%0" : : "WU"(addr), "i"(b)); 51 + else 52 + __asm__("bset %w1,%0" : : "WU"(addr), "r"(b)); 53 + } 54 + 55 + #endif /* __KERNEL__ */ 56 + 57 + #endif /* _H8300_IO_H */
+26
arch/h8300/include/asm/irq.h
··· 1 + #ifndef _H8300_IRQ_H_ 2 + #define _H8300_IRQ_H_ 3 + 4 + #include <linux/irqchip.h> 5 + 6 + #if defined(CONFIG_CPU_H8300H) 7 + #define NR_IRQS 64 8 + #define IRQ_CHIP h8300h_irq_chip 9 + #define EXT_IRQ0 12 10 + #define EXT_IRQS 6 11 + #elif defined(CONFIG_CPU_H8S) 12 + #define NR_IRQS 128 13 + #define IRQ_CHIP h8s_irq_chip 14 + #define EXT_IRQ0 16 15 + #define EXT_IRQS 16 16 + #endif 17 + 18 + static inline int irq_canonicalize(int irq) 19 + { 20 + return irq; 21 + } 22 + 23 + void h8300_init_ipr(void); 24 + extern struct irq_chip h8300h_irq_chip; 25 + extern struct irq_chip h8s_irq_chip; 26 + #endif /* _H8300_IRQ_H_ */
+96
arch/h8300/include/asm/irqflags.h
··· 1 + #ifndef _H8300_IRQFLAGS_H 2 + #define _H8300_IRQFLAGS_H 3 + 4 + #ifdef CONFIG_CPU_H8300H 5 + typedef unsigned char h8300flags; 6 + 7 + static inline h8300flags arch_local_save_flags(void) 8 + { 9 + h8300flags flags; 10 + 11 + __asm__ volatile ("stc ccr,%w0" : "=r" (flags)); 12 + return flags; 13 + } 14 + 15 + static inline void arch_local_irq_disable(void) 16 + { 17 + __asm__ volatile ("orc #0xc0,ccr"); 18 + } 19 + 20 + static inline void arch_local_irq_enable(void) 21 + { 22 + __asm__ volatile ("andc #0x3f,ccr"); 23 + } 24 + 25 + static inline h8300flags arch_local_irq_save(void) 26 + { 27 + h8300flags flags; 28 + 29 + __asm__ volatile ("stc ccr,%w0\n\t" 30 + "orc #0xc0,ccr" : "=r" (flags)); 31 + return flags; 32 + } 33 + 34 + static inline void arch_local_irq_restore(h8300flags flags) 35 + { 36 + __asm__ volatile ("ldc %w0,ccr" : : "r" (flags) : "cc"); 37 + } 38 + 39 + static inline int arch_irqs_disabled_flags(unsigned long flags) 40 + { 41 + return (flags & 0xc0) == 0xc0; 42 + } 43 + #endif 44 + #ifdef CONFIG_CPU_H8S 45 + typedef unsigned short h8300flags; 46 + 47 + static inline h8300flags arch_local_save_flags(void) 48 + { 49 + h8300flags flags; 50 + 51 + __asm__ volatile ("stc ccr,%w0\n\tstc exr,%x0" : "=r" (flags)); 52 + return flags; 53 + } 54 + 55 + static inline void arch_local_irq_disable(void) 56 + { 57 + __asm__ volatile ("orc #0x80,ccr\n\t"); 58 + } 59 + 60 + static inline void arch_local_irq_enable(void) 61 + { 62 + __asm__ volatile ("andc #0x7f,ccr\n\t" 63 + "andc #0xf0,exr\n\t"); 64 + } 65 + 66 + static inline h8300flags arch_local_irq_save(void) 67 + { 68 + h8300flags flags; 69 + 70 + __asm__ volatile ("stc ccr,%w0\n\t" 71 + "stc exr,%x0\n\t" 72 + "orc #0x80,ccr\n\t" 73 + : "=r" (flags)); 74 + return flags; 75 + } 76 + 77 + static inline void arch_local_irq_restore(h8300flags flags) 78 + { 79 + __asm__ volatile ("ldc %w0,ccr\n\t" 80 + "ldc %x0,exr" 81 + : : "r" (flags) : "cc"); 82 + } 83 + 84 + static inline int arch_irqs_disabled_flags(h8300flags flags) 85 + { 86 + return (flags & 0x0080) == 0x0080; 87 + } 88 + 89 + #endif 90 + 91 + static inline int arch_irqs_disabled(void) 92 + { 93 + return arch_irqs_disabled_flags(arch_local_save_flags()); 94 + } 95 + 96 + #endif /* _H8300_IRQFLAGS_H */
+9
arch/h8300/include/asm/mc146818rtc.h
··· 1 + /* 2 + * Machine dependent access functions for RTC registers. 3 + */ 4 + #ifndef _H8300_MC146818RTC_H 5 + #define _H8300_MC146818RTC_H 6 + 7 + /* empty include file to satisfy the include in genrtc.c/ide-geometry.c */ 8 + 9 + #endif /* _H8300_MC146818RTC_H */
+9
arch/h8300/include/asm/mutex.h
··· 1 + /* 2 + * Pull in the generic implementation for the mutex fastpath. 3 + * 4 + * TODO: implement optimized primitives instead, or leave the generic 5 + * implementation in place, or pick the atomic_xchg() based generic 6 + * implementation. (see asm-generic/mutex-xchg.h for details) 7 + */ 8 + 9 + #include <asm-generic/mutex-dec.h>
+18
arch/h8300/include/asm/page.h
··· 1 + #ifndef _H8300_PAGE_H 2 + #define _H8300_PAGE_H 3 + 4 + #include <asm-generic/page.h> 5 + #include <linux/types.h> 6 + 7 + #define MAP_NR(addr) (((uintptr_t)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) 8 + #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ 9 + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 10 + 11 + #ifndef __ASSEMBLY__ 12 + extern unsigned long rom_length; 13 + extern unsigned long memory_start; 14 + extern unsigned long memory_end; 15 + extern unsigned long _ramend; 16 + #endif 17 + 18 + #endif
+2
arch/h8300/include/asm/page_offset.h
··· 1 + 2 + #define PAGE_OFFSET_RAW 0x00000000
+19
arch/h8300/include/asm/pci.h
··· 1 + #ifndef _ASM_H8300_PCI_H 2 + #define _ASM_H8300_PCI_H 3 + 4 + /* 5 + * asm-h8300/pci.h - H8/300 specific PCI declarations. 6 + * 7 + * Yoshinori Sato <ysato@users.sourceforge.jp> 8 + */ 9 + 10 + #define pcibios_assign_all_busses() 0 11 + 12 + static inline void pcibios_penalize_isa_irq(int irq, int active) 13 + { 14 + /* We don't do dynamic PCI IRQ allocation */ 15 + } 16 + 17 + #define PCI_DMA_BUS_IS_PHYS (1) 18 + 19 + #endif /* _ASM_H8300_PCI_H */
+49
arch/h8300/include/asm/pgtable.h
··· 1 + #ifndef _H8300_PGTABLE_H 2 + #define _H8300_PGTABLE_H 3 + #include <asm-generic/pgtable-nopud.h> 4 + #include <asm-generic/pgtable.h> 5 + #define pgtable_cache_init() do { } while (0) 6 + extern void paging_init(void); 7 + #define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */ 8 + #define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */ 9 + #define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */ 10 + #define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */ 11 + #define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */ 12 + #define __swp_type(x) (0) 13 + #define __swp_offset(x) (0) 14 + #define __swp_entry(typ, off) ((swp_entry_t) { ((typ) | ((off) << 7)) }) 15 + #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 16 + #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 17 + #define kern_addr_valid(addr) (1) 18 + #define pgprot_writecombine(prot) (prot) 19 + #define pgprot_noncached pgprot_writecombine 20 + 21 + static inline int pte_file(pte_t pte) { return 0; } 22 + #define swapper_pg_dir ((pgd_t *) 0) 23 + /* 24 + * ZERO_PAGE is a global shared page that is always zero: used 25 + * for zero-mapped memory areas etc.. 26 + */ 27 + #define ZERO_PAGE(vaddr) (virt_to_page(0)) 28 + 29 + /* 30 + * These would be in other places but having them here reduces the diffs. 31 + */ 32 + extern unsigned int kobjsize(const void *objp); 33 + extern int is_in_rom(unsigned long); 34 + 35 + /* 36 + * No page table caches to initialise 37 + */ 38 + #define pgtable_cache_init() do { } while (0) 39 + 40 + /* 41 + * All 32bit addresses are effectively valid for vmalloc... 42 + * Sort of meaningless for non-VM targets. 43 + */ 44 + #define VMALLOC_START 0 45 + #define VMALLOC_END 0xffffffff 46 + 47 + #define arch_enter_lazy_cpu_mode() do {} while (0) 48 + 49 + #endif /* _H8300_PGTABLE_H */
+144
arch/h8300/include/asm/processor.h
··· 1 + /* 2 + * include/asm-h8300/processor.h 3 + * 4 + * Copyright (C) 2002 Yoshinori Sato 5 + * 6 + * Based on: linux/asm-m68nommu/processor.h 7 + * 8 + * Copyright (C) 1995 Hamish Macdonald 9 + */ 10 + 11 + #ifndef __ASM_H8300_PROCESSOR_H 12 + #define __ASM_H8300_PROCESSOR_H 13 + 14 + /* 15 + * Default implementation of macro that returns current 16 + * instruction pointer ("program counter"). 17 + */ 18 + #define current_text_addr() ({ __label__ _l; _l: &&_l; }) 19 + 20 + #include <linux/compiler.h> 21 + #include <asm/segment.h> 22 + #include <asm/ptrace.h> 23 + #include <asm/current.h> 24 + 25 + static inline unsigned long rdusp(void) 26 + { 27 + extern unsigned int _sw_usp; 28 + 29 + return _sw_usp; 30 + } 31 + 32 + static inline void wrusp(unsigned long usp) 33 + { 34 + extern unsigned int _sw_usp; 35 + 36 + _sw_usp = usp; 37 + } 38 + 39 + /* 40 + * User space process size: 3.75GB. This is hardcoded into a few places, 41 + * so don't change it unless you know what you are doing. 42 + */ 43 + #define TASK_SIZE (0xFFFFFFFFUL) 44 + 45 + #ifdef __KERNEL__ 46 + #define STACK_TOP TASK_SIZE 47 + #define STACK_TOP_MAX STACK_TOP 48 + #endif 49 + 50 + /* 51 + * This decides where the kernel will search for a free chunk of vm 52 + * space during mmap's. We won't be using it 53 + */ 54 + #define TASK_UNMAPPED_BASE 0 55 + 56 + struct thread_struct { 57 + unsigned long ksp; /* kernel stack pointer */ 58 + unsigned long usp; /* user stack pointer */ 59 + unsigned long ccr; /* saved status register */ 60 + unsigned long esp0; /* points to SR of stack frame */ 61 + struct { 62 + unsigned short *addr; 63 + unsigned short inst; 64 + } breakinfo; 65 + }; 66 + 67 + #define INIT_THREAD { \ 68 + .ksp = sizeof(init_stack) + (unsigned long)init_stack, \ 69 + .usp = 0, \ 70 + .ccr = PS_S, \ 71 + .esp0 = 0, \ 72 + .breakinfo = { \ 73 + .addr = (unsigned short *)-1, \ 74 + .inst = 0 \ 75 + } \ 76 + } 77 + 78 + /* 79 + * Do necessary setup to start up a newly executed thread. 80 + * 81 + * pass the data segment into user programs if it exists, 82 + * it can't hurt anything as far as I can tell 83 + */ 84 + #if defined(CONFIG_CPU_H8300H) 85 + #define start_thread(_regs, _pc, _usp) \ 86 + do { \ 87 + (_regs)->pc = (_pc); \ 88 + (_regs)->ccr = 0x00; /* clear all flags */ \ 89 + (_regs)->er5 = current->mm->start_data; /* GOT base */ \ 90 + (_regs)->sp = ((unsigned long)(_usp)) - sizeof(unsigned long) * 3; \ 91 + } while (0) 92 + #endif 93 + #if defined(CONFIG_CPU_H8S) 94 + #define start_thread(_regs, _pc, _usp) \ 95 + do { \ 96 + (_regs)->pc = (_pc); \ 97 + (_regs)->ccr = 0x00; /* clear kernel flag */ \ 98 + (_regs)->exr = 0x78; /* enable all interrupts */ \ 99 + (_regs)->er5 = current->mm->start_data; /* GOT base */ \ 100 + /* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \ 101 + (_regs)->sp = ((unsigned long)(_usp)) - 14; \ 102 + } while (0) 103 + #endif 104 + 105 + /* Forward declaration, a strange C thing */ 106 + struct task_struct; 107 + 108 + /* Free all resources held by a thread. */ 109 + static inline void release_thread(struct task_struct *dead_task) 110 + { 111 + } 112 + 113 + /* 114 + * Free current thread data structures etc.. 115 + */ 116 + static inline void exit_thread(void) 117 + { 118 + } 119 + 120 + /* 121 + * Return saved PC of a blocked thread. 122 + */ 123 + unsigned long thread_saved_pc(struct task_struct *tsk); 124 + unsigned long get_wchan(struct task_struct *p); 125 + 126 + #define KSTK_EIP(tsk) \ 127 + ({ \ 128 + unsigned long eip = 0; \ 129 + if ((tsk)->thread.esp0 > PAGE_SIZE && \ 130 + MAP_NR((tsk)->thread.esp0) < max_mapnr) \ 131 + eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \ 132 + eip; }) 133 + 134 + #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp) 135 + 136 + #define cpu_relax() barrier() 137 + #define cpu_relax_lowlatency() cpu_relax() 138 + 139 + #define HARD_RESET_NOW() ({ \ 140 + local_irq_disable(); \ 141 + asm("jmp @@0"); \ 142 + }) 143 + 144 + #endif
+36
arch/h8300/include/asm/ptrace.h
··· 1 + #ifndef _H8300_PTRACE_H 2 + #define _H8300_PTRACE_H 3 + 4 + #include <uapi/asm/ptrace.h> 5 + 6 + #ifndef __ASSEMBLY__ 7 + #ifndef PS_S 8 + #define PS_S (0x10) 9 + #endif 10 + 11 + #if defined(CONFIG_CPU_H8300H) 12 + #define H8300_REGS_NO 11 13 + #endif 14 + #if defined(CONFIG_CPU_H8S) 15 + #define H8300_REGS_NO 12 16 + #endif 17 + 18 + #define arch_has_single_step() (1) 19 + 20 + #define user_mode(regs) (!((regs)->ccr & PS_S)) 21 + #define instruction_pointer(regs) ((regs)->pc) 22 + #define profile_pc(regs) instruction_pointer(regs) 23 + #define user_stack_pointer(regs) ((regs)->sp) 24 + #define current_pt_regs() ((struct pt_regs *) \ 25 + (THREAD_SIZE + (unsigned long)current_thread_info()) - 1) 26 + #define signal_pt_regs() ((struct pt_regs *)current->thread.esp0) 27 + #define current_user_stack_pointer() rdusp() 28 + #define task_pt_regs(task) \ 29 + ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1) 30 + 31 + extern long h8300_get_reg(struct task_struct *task, int regno); 32 + extern int h8300_put_reg(struct task_struct *task, int regno, 33 + unsigned long data); 34 + 35 + #endif /* __ASSEMBLY__ */ 36 + #endif /* _H8300_PTRACE_H */
+45
arch/h8300/include/asm/segment.h
··· 1 + #ifndef _H8300_SEGMENT_H 2 + #define _H8300_SEGMENT_H 3 + 4 + /* define constants */ 5 + #define USER_DATA (1) 6 + #ifndef __USER_DS 7 + #define __USER_DS (USER_DATA) 8 + #endif 9 + #define USER_PROGRAM (2) 10 + #define SUPER_DATA (3) 11 + #ifndef __KERNEL_DS 12 + #define __KERNEL_DS (SUPER_DATA) 13 + #endif 14 + #define SUPER_PROGRAM (4) 15 + 16 + #ifndef __ASSEMBLY__ 17 + 18 + typedef struct { 19 + unsigned long seg; 20 + } mm_segment_t; 21 + 22 + #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 23 + #define USER_DS MAKE_MM_SEG(__USER_DS) 24 + #define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS) 25 + 26 + /* 27 + * Get/set the SFC/DFC registers for MOVES instructions 28 + */ 29 + 30 + static inline mm_segment_t get_fs(void) 31 + { 32 + return USER_DS; 33 + } 34 + 35 + static inline mm_segment_t get_ds(void) 36 + { 37 + /* return the supervisor data space code */ 38 + return KERNEL_DS; 39 + } 40 + 41 + #define segment_eq(a, b) ((a).seg == (b).seg) 42 + 43 + #endif /* __ASSEMBLY__ */ 44 + 45 + #endif /* _H8300_SEGMENT_H */
+22
arch/h8300/include/asm/signal.h
··· 1 + #ifndef _H8300_SIGNAL_H 2 + #define _H8300_SIGNAL_H 3 + 4 + #include <uapi/asm/signal.h> 5 + 6 + /* Most things should be clean enough to redefine this at will, if care 7 + is taken to make libc match. */ 8 + 9 + #define _NSIG 64 10 + #define _NSIG_BPW 32 11 + #define _NSIG_WORDS (_NSIG / _NSIG_BPW) 12 + 13 + typedef unsigned long old_sigset_t; /* at least 32 bits */ 14 + 15 + typedef struct { 16 + unsigned long sig[_NSIG_WORDS]; 17 + } sigset_t; 18 + 19 + #define __ARCH_HAS_SA_RESTORER 20 + #include <asm/sigcontext.h> 21 + 22 + #endif /* _H8300_SIGNAL_H */
+1
arch/h8300/include/asm/smp.h
··· 1 + /* nothing required here yet */
+17
arch/h8300/include/asm/string.h
··· 1 + #ifndef _H8300_STRING_H_ 2 + #define _H8300_STRING_H_ 3 + 4 + #ifdef __KERNEL__ /* only set these up for kernel code */ 5 + 6 + #include <asm/setup.h> 7 + #include <asm/page.h> 8 + 9 + #define __HAVE_ARCH_MEMSET 10 + extern void *memset(void *s, int c, size_t count); 11 + 12 + #define __HAVE_ARCH_MEMCPY 13 + extern void *memcpy(void *d, const void *s, size_t count); 14 + 15 + #endif /* KERNEL */ 16 + 17 + #endif
+51
arch/h8300/include/asm/switch_to.h
··· 1 + #ifndef _H8300_SWITCH_TO_H 2 + #define _H8300_SWITCH_TO_H 3 + 4 + /* 5 + * switch_to(n) should switch tasks to task ptr, first checking that 6 + * ptr isn't the current task, in which case it does nothing. This 7 + * also clears the TS-flag if the task we switched to has used the 8 + * math co-processor latest. 9 + */ 10 + /* 11 + * switch_to() saves the extra registers, that are not saved 12 + * automatically by SAVE_SWITCH_STACK in resume(), ie. d0-d5 and 13 + * a0-a1. Some of these are used by schedule() and its predecessors 14 + * and so we might get see unexpected behaviors when a task returns 15 + * with unexpected register values. 16 + * 17 + * syscall stores these registers itself and none of them are used 18 + * by syscall after the function in the syscall has been called. 19 + * 20 + * Beware that resume now expects *next to be in d1 and the offset of 21 + * tss to be in a1. This saves a few instructions as we no longer have 22 + * to push them onto the stack and read them back right after. 23 + * 24 + * 02/17/96 - Jes Sorensen (jds@kom.auc.dk) 25 + * 26 + * Changed 96/09/19 by Andreas Schwab 27 + * pass prev in a0, next in a1, offset of tss in d1, and whether 28 + * the mm structures are shared in d2 (to avoid atc flushing). 29 + * 30 + * H8/300 Porting 2002/09/04 Yoshinori Sato 31 + */ 32 + 33 + asmlinkage void resume(void); 34 + #define switch_to(prev, next, last) \ 35 + do { \ 36 + void *_last; \ 37 + __asm__ __volatile__( \ 38 + "mov.l %1, er0\n\t" \ 39 + "mov.l %2, er1\n\t" \ 40 + "mov.l %3, er2\n\t" \ 41 + "jsr @_resume\n\t" \ 42 + "mov.l er2,%0\n\t" \ 43 + : "=r" (_last) \ 44 + : "r" (&(prev->thread)), \ 45 + "r" (&(next->thread)), \ 46 + "g" (prev) \ 47 + : "cc", "er0", "er1", "er2", "er3"); \ 48 + (last) = _last; \ 49 + } while (0) 50 + 51 + #endif /* _H8300_SWITCH_TO_H */
+56
arch/h8300/include/asm/syscall.h
··· 1 + #ifndef __ASM_H8300_SYSCALLS_32_H 2 + #define __ASM_H8300_SYSCALLS_32_H 3 + 4 + #ifdef __KERNEL__ 5 + 6 + #include <linux/compiler.h> 7 + #include <linux/linkage.h> 8 + #include <linux/types.h> 9 + #include <linux/ptrace.h> 10 + 11 + static inline int 12 + syscall_get_nr(struct task_struct *task, struct pt_regs *regs) 13 + { 14 + return regs->orig_er0; 15 + } 16 + 17 + static inline void 18 + syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, 19 + unsigned int i, unsigned int n, unsigned long *args) 20 + { 21 + BUG_ON(i + n > 6); 22 + 23 + while (n > 0) { 24 + switch (i) { 25 + case 0: 26 + *args++ = regs->er1; 27 + break; 28 + case 1: 29 + *args++ = regs->er2; 30 + break; 31 + case 2: 32 + *args++ = regs->er3; 33 + break; 34 + case 3: 35 + *args++ = regs->er4; 36 + break; 37 + case 4: 38 + *args++ = regs->er5; 39 + break; 40 + case 5: 41 + *args++ = regs->er6; 42 + break; 43 + } 44 + i++; 45 + n--; 46 + } 47 + } 48 + 49 + 50 + 51 + /* Misc syscall related bits */ 52 + asmlinkage long do_syscall_trace_enter(struct pt_regs *regs); 53 + asmlinkage void do_syscall_trace_leave(struct pt_regs *regs); 54 + 55 + #endif /* __KERNEL__ */ 56 + #endif /* __ASM_H8300_SYSCALLS_32_H */
+111
arch/h8300/include/asm/thread_info.h
··· 1 + /* thread_info.h: h8300 low-level thread information 2 + * adapted from the i386 and PPC versions by Yoshinori Sato <ysato@users.sourceforge.jp> 3 + * 4 + * Copyright (C) 2002 David Howells (dhowells@redhat.com) 5 + * - Incorporating suggestions made by Linus Torvalds and Dave Miller 6 + */ 7 + 8 + #ifndef _ASM_THREAD_INFO_H 9 + #define _ASM_THREAD_INFO_H 10 + 11 + #include <asm/page.h> 12 + #include <asm/segment.h> 13 + 14 + #ifdef __KERNEL__ 15 + 16 + #ifndef __ASSEMBLY__ 17 + 18 + /* 19 + * low level task data. 20 + * If you change this, change the TI_* offsets below to match. 21 + */ 22 + struct thread_info { 23 + struct task_struct *task; /* main task structure */ 24 + unsigned long flags; /* low level flags */ 25 + int cpu; /* cpu we're on */ 26 + int preempt_count; /* 0 => preemptable, <0 => BUG */ 27 + mm_segment_t addr_limit; 28 + struct restart_block restart_block; 29 + }; 30 + 31 + /* 32 + * macros/functions for gaining access to the thread information structure 33 + */ 34 + #define INIT_THREAD_INFO(tsk) \ 35 + { \ 36 + .task = &tsk, \ 37 + .flags = 0, \ 38 + .cpu = 0, \ 39 + .preempt_count = INIT_PREEMPT_COUNT, \ 40 + .addr_limit = KERNEL_DS, \ 41 + .restart_block = { \ 42 + .fn = do_no_restart_syscall, \ 43 + }, \ 44 + } 45 + 46 + #define init_thread_info (init_thread_union.thread_info) 47 + #define init_stack (init_thread_union.stack) 48 + 49 + 50 + /* 51 + * Size of kernel stack for each process. This must be a power of 2... 52 + */ 53 + #define THREAD_SIZE_ORDER 1 54 + #define THREAD_SIZE 8192 /* 2 pages */ 55 + 56 + 57 + /* how to get the thread information struct from C */ 58 + static inline struct thread_info *current_thread_info(void) 59 + { 60 + struct thread_info *ti; 61 + 62 + __asm__("mov.l sp, %0\n\t" 63 + "and.w %1, %T0" 64 + : "=&r"(ti) 65 + : "i" (~(THREAD_SIZE-1) & 0xffff)); 66 + return ti; 67 + } 68 + 69 + #endif /* __ASSEMBLY__ */ 70 + 71 + /* 72 + * thread information flag bit numbers 73 + */ 74 + #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 75 + #define TIF_SIGPENDING 1 /* signal pending */ 76 + #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 77 + #define TIF_SINGLESTEP 3 /* singlestepping active */ 78 + #define TIF_MEMDIE 4 /* is terminating due to OOM killer */ 79 + #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ 80 + #define TIF_NOTIFY_RESUME 6 /* callback before returning to user */ 81 + #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 82 + #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */ 83 + #define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 84 + 85 + /* as above, but as bit values */ 86 + #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 87 + #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 88 + #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 89 + #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 90 + #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) 91 + #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 92 + #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) 93 + #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 94 + 95 + /* work to do in syscall trace */ 96 + #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \ 97 + _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT) 98 + 99 + /* work to do on any return to u-space */ 100 + #define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \ 101 + _TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \ 102 + _TIF_SINGLESTEP | _TIF_NOTIFY_RESUME | \ 103 + _TIF_SYSCALL_TRACEPOINT) 104 + 105 + /* work to do on interrupt/exception return */ 106 + #define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \ 107 + _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP)) 108 + 109 + #endif /* __KERNEL__ */ 110 + 111 + #endif /* _ASM_THREAD_INFO_H */
+8
arch/h8300/include/asm/tlb.h
··· 1 + #ifndef __H8300_TLB_H__ 2 + #define __H8300_TLB_H__ 3 + 4 + #define tlb_flush(tlb) do { } while (0) 5 + 6 + #include <asm-generic/tlb.h> 7 + 8 + #endif
+41
arch/h8300/include/asm/traps.h
··· 1 + /* 2 + * linux/include/asm-h8300/traps.h 3 + * 4 + * Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + * 6 + * This file is subject to the terms and conditions of the GNU General Public 7 + * License. See the file COPYING in the main directory of this archive 8 + * for more details. 9 + */ 10 + 11 + #ifndef _H8300_TRAPS_H 12 + #define _H8300_TRAPS_H 13 + 14 + extern void _system_call(void); 15 + extern void _interrupt_entry(void); 16 + extern void _trace_break(void); 17 + extern void _nmi(void); 18 + extern void _interrupt_entry(void); 19 + 20 + extern unsigned long *_interrupt_redirect_table; 21 + 22 + #define JMP_OP 0x5a000000 23 + #define JSR_OP 0x5e000000 24 + #define VECTOR(address) ((JMP_OP)|((unsigned long)address)) 25 + #define REDIRECT(address) ((JSR_OP)|((unsigned long)address)) 26 + #define CPU_VECTOR ((unsigned long *)0x000000) 27 + #define ADDR_MASK (0xffffff) 28 + 29 + #define TRACE_VEC 5 30 + 31 + #define TRAP0_VEC 8 32 + #define TRAP1_VEC 9 33 + #define TRAP2_VEC 10 34 + #define TRAP3_VEC 11 35 + 36 + extern char _start, _etext; 37 + #define check_kernel_text(addr) \ 38 + ((addr >= (unsigned long)(&_start)) && \ 39 + (addr < (unsigned long)(&_etext))) 40 + 41 + #endif /* _H8300_TRAPS_H */
+74
arch/h8300/include/asm/user.h
··· 1 + #ifndef _H8300_USER_H 2 + #define _H8300_USER_H 3 + 4 + #include <asm/page.h> 5 + 6 + /* Core file format: The core file is written in such a way that gdb 7 + can understand it and provide useful information to the user (under 8 + linux we use the 'trad-core' bfd). There are quite a number of 9 + obstacles to being able to view the contents of the floating point 10 + registers, and until these are solved you will not be able to view the 11 + contents of them. Actually, you can read in the core file and look at 12 + the contents of the user struct to find out what the floating point 13 + registers contain. 14 + The actual file contents are as follows: 15 + UPAGE: 1 page consisting of a user struct that tells gdb what is present 16 + in the file. Directly after this is a copy of the task_struct, which 17 + is currently not used by gdb, but it may come in useful at some point. 18 + All of the registers are stored as part of the upage. The upage should 19 + always be only one page. 20 + DATA: The data area is stored. We use current->end_text to 21 + current->brk to pick up all of the user variables, plus any memory 22 + that may have been malloced. No attempt is made to determine if a page 23 + is demand-zero or if a page is totally unused, we just cover the entire 24 + range. All of the addresses are rounded in such a way that an integral 25 + number of pages is written. 26 + STACK: We need the stack information in order to get a meaningful 27 + backtrace. We need to write the data from (esp) to 28 + current->start_stack, so we round each of these off in order to be able 29 + to write an integer number of pages. 30 + The minimum core file size is 3 pages, or 12288 bytes. 31 + */ 32 + 33 + /* This is the old layout of "struct pt_regs" as of Linux 1.x, and 34 + is still the layout used by user (the new pt_regs doesn't have 35 + all registers). */ 36 + struct user_regs_struct { 37 + long er1, er2, er3, er4, er5, er6; 38 + long er0; 39 + long usp; 40 + long orig_er0; 41 + long ccr; 42 + long pc; 43 + }; 44 + 45 + /* When the kernel dumps core, it starts by dumping the user struct - 46 + this will be used by gdb to figure out where the data and stack segments 47 + are within the file, and what virtual addresses to use. */ 48 + struct user { 49 + /* We start with the registers, to mimic the way that "memory" is returned 50 + from the ptrace(3,...) function. */ 51 + struct user_regs_struct regs; /* Where the registers are actually stored */ 52 + /* ptrace does not yet supply these. Someday.... */ 53 + /* The rest of this junk is to help gdb figure out what goes where */ 54 + unsigned long int u_tsize; /* Text segment size (pages). */ 55 + unsigned long int u_dsize; /* Data segment size (pages). */ 56 + unsigned long int u_ssize; /* Stack segment size (pages). */ 57 + unsigned long start_code; /* Starting virtual address of text. */ 58 + unsigned long start_stack; /* Starting virtual address of stack area. 59 + This is actually the bottom of the stack, 60 + the top of the stack is always found in the 61 + esp register. */ 62 + long int signal; /* Signal that caused the core dump. */ 63 + int reserved; /* No longer used */ 64 + unsigned long u_ar0; /* Used by gdb to help find the values for */ 65 + /* the registers. */ 66 + unsigned long magic; /* To uniquely identify a core file */ 67 + char u_comm[32]; /* User command that was responsible */ 68 + }; 69 + #define NBPG PAGE_SIZE 70 + #define UPAGES 1 71 + #define HOST_TEXT_START_ADDR (u.start_code) 72 + #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) 73 + 74 + #endif
+30
arch/h8300/include/uapi/asm/Kbuild
··· 1 + # UAPI Header export list 2 + include include/uapi/asm-generic/Kbuild.asm 3 + 4 + header-y += auxvec.h 5 + header-y += bitsperlong.h 6 + header-y += errno.h 7 + header-y += fcntl.h 8 + header-y += ioctl.h 9 + header-y += ioctls.h 10 + header-y += ipcbuf.h 11 + header-y += kvm_para.h 12 + header-y += mman.h 13 + header-y += msgbuf.h 14 + header-y += param.h 15 + header-y += poll.h 16 + header-y += posix_types.h 17 + header-y += resource.h 18 + header-y += sembuf.h 19 + header-y += setup.h 20 + header-y += shmbuf.h 21 + header-y += siginfo.h 22 + header-y += socket.h 23 + header-y += sockios.h 24 + header-y += stat.h 25 + header-y += statfs.h 26 + header-y += swab.h 27 + header-y += termbits.h 28 + header-y += termios.h 29 + header-y += types.h 30 + header-y += unistd.h
+6
arch/h8300/include/uapi/asm/byteorder.h
··· 1 + #ifndef _H8300_BYTEORDER_H 2 + #define _H8300_BYTEORDER_H 3 + 4 + #include <linux/byteorder/big_endian.h> 5 + 6 + #endif /* _H8300_BYTEORDER_H */
+42
arch/h8300/include/uapi/asm/ptrace.h
··· 1 + #ifndef _UAPI_H8300_PTRACE_H 2 + #define _UAPI_H8300_PTRACE_H 3 + 4 + #ifndef __ASSEMBLY__ 5 + 6 + #define PT_ER1 0 7 + #define PT_ER2 1 8 + #define PT_ER3 2 9 + #define PT_ER4 3 10 + #define PT_ER5 4 11 + #define PT_ER6 5 12 + #define PT_ER0 6 13 + #define PT_USP 7 14 + #define PT_ORIG_ER0 8 15 + #define PT_CCR 9 16 + #define PT_PC 10 17 + #define PT_EXR 11 18 + 19 + /* this struct defines the way the registers are stored on the 20 + stack during a system call. */ 21 + 22 + struct pt_regs { 23 + long retpc; 24 + long er4; 25 + long er5; 26 + long er6; 27 + long er3; 28 + long er2; 29 + long er1; 30 + long orig_er0; 31 + long sp; 32 + unsigned short ccr; 33 + long er0; 34 + long vector; 35 + #if defined(__H8300S__) 36 + unsigned short exr; 37 + #endif 38 + unsigned long pc; 39 + } __attribute__((aligned(2), packed)); 40 + 41 + #endif /* __ASSEMBLY__ */ 42 + #endif /* _UAPI_H8300_PTRACE_H */
+18
arch/h8300/include/uapi/asm/sigcontext.h
··· 1 + #ifndef _ASM_H8300_SIGCONTEXT_H 2 + #define _ASM_H8300_SIGCONTEXT_H 3 + 4 + struct sigcontext { 5 + unsigned long sc_mask; /* old sigmask */ 6 + unsigned long sc_usp; /* old user stack pointer */ 7 + unsigned long sc_er0; 8 + unsigned long sc_er1; 9 + unsigned long sc_er2; 10 + unsigned long sc_er3; 11 + unsigned long sc_er4; 12 + unsigned long sc_er5; 13 + unsigned long sc_er6; 14 + unsigned short sc_ccr; 15 + unsigned long sc_pc; 16 + }; 17 + 18 + #endif
+115
arch/h8300/include/uapi/asm/signal.h
··· 1 + #ifndef _UAPI_H8300_SIGNAL_H 2 + #define _UAPI_H8300_SIGNAL_H 3 + 4 + #include <linux/types.h> 5 + 6 + /* Avoid too many header ordering problems. */ 7 + struct siginfo; 8 + 9 + #ifndef __KERNEL__ 10 + /* Here we must cater to libcs that poke about in kernel headers. */ 11 + 12 + #define NSIG 32 13 + typedef unsigned long sigset_t; 14 + 15 + #endif /* __KERNEL__ */ 16 + 17 + #define SIGHUP 1 18 + #define SIGINT 2 19 + #define SIGQUIT 3 20 + #define SIGILL 4 21 + #define SIGTRAP 5 22 + #define SIGABRT 6 23 + #define SIGIOT 6 24 + #define SIGBUS 7 25 + #define SIGFPE 8 26 + #define SIGKILL 9 27 + #define SIGUSR1 10 28 + #define SIGSEGV 11 29 + #define SIGUSR2 12 30 + #define SIGPIPE 13 31 + #define SIGALRM 14 32 + #define SIGTERM 15 33 + #define SIGSTKFLT 16 34 + #define SIGCHLD 17 35 + #define SIGCONT 18 36 + #define SIGSTOP 19 37 + #define SIGTSTP 20 38 + #define SIGTTIN 21 39 + #define SIGTTOU 22 40 + #define SIGURG 23 41 + #define SIGXCPU 24 42 + #define SIGXFSZ 25 43 + #define SIGVTALRM 26 44 + #define SIGPROF 27 45 + #define SIGWINCH 28 46 + #define SIGIO 29 47 + #define SIGPOLL SIGIO 48 + /* 49 + #define SIGLOST 29 50 + */ 51 + #define SIGPWR 30 52 + #define SIGSYS 31 53 + #define SIGUNUSED 31 54 + 55 + /* These should not be considered constants from userland. */ 56 + #define SIGRTMIN 32 57 + #define SIGRTMAX _NSIG 58 + 59 + /* 60 + * SA_FLAGS values: 61 + * 62 + * SA_ONSTACK indicates that a registered stack_t will be used. 63 + * SA_RESTART flag to get restarting signals (which were the default long ago) 64 + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. 65 + * SA_RESETHAND clears the handler when the signal is delivered. 66 + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. 67 + * SA_NODEFER prevents the current signal from being masked in the handler. 68 + * 69 + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single 70 + * Unix names RESETHAND and NODEFER respectively. 71 + */ 72 + #define SA_NOCLDSTOP 0x00000001 73 + #define SA_NOCLDWAIT 0x00000002 /* not supported yet */ 74 + #define SA_SIGINFO 0x00000004 75 + #define SA_ONSTACK 0x08000000 76 + #define SA_RESTART 0x10000000 77 + #define SA_NODEFER 0x40000000 78 + #define SA_RESETHAND 0x80000000 79 + 80 + #define SA_NOMASK SA_NODEFER 81 + #define SA_ONESHOT SA_RESETHAND 82 + 83 + #define SA_RESTORER 0x04000000 84 + 85 + #define MINSIGSTKSZ 2048 86 + #define SIGSTKSZ 8192 87 + 88 + #include <asm-generic/signal-defs.h> 89 + 90 + #ifndef __KERNEL__ 91 + /* Here we must cater to libcs that poke about in kernel headers. */ 92 + 93 + struct sigaction { 94 + union { 95 + __sighandler_t _sa_handler; 96 + void (*_sa_sigaction)(int, struct siginfo *, void *); 97 + } _u; 98 + sigset_t sa_mask; 99 + unsigned long sa_flags; 100 + void (*sa_restorer)(void); 101 + }; 102 + 103 + #define sa_handler _u._sa_handler 104 + #define sa_sigaction _u._sa_sigaction 105 + 106 + #endif /* __KERNEL__ */ 107 + 108 + typedef struct sigaltstack { 109 + void *ss_sp; 110 + int ss_flags; 111 + size_t ss_size; 112 + } stack_t; 113 + 114 + 115 + #endif /* _UAPI_H8300_SIGNAL_H */
+3
arch/h8300/include/uapi/asm/unistd.h
··· 1 + #define __ARCH_NOMMU 2 + 3 + #include <asm-generic/unistd.h>
+19
arch/h8300/kernel/Makefile
··· 1 + # 2 + # Makefile for the linux kernel. 3 + # 4 + 5 + extra-y := vmlinux.lds 6 + 7 + obj-y := process.o traps.o ptrace.o \ 8 + signal.o setup.o syscalls.o \ 9 + irq.o entry.o dma.o 10 + 11 + obj-$(CONFIG_ROMKERNEL) += head_rom.o 12 + obj-$(CONFIG_RAMKERNEL) += head_ram.o 13 + 14 + obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o 15 + obj-$(CONFIG_H8300H_SIM) += sim-console.o 16 + obj-$(CONFIG_H8S_SIM) += sim-console.o 17 + 18 + obj-$(CONFIG_CPU_H8300H) += ptrace_h.o 19 + obj-$(CONFIG_CPU_H8S) += ptrace_s.o
+67
arch/h8300/kernel/asm-offsets.c
··· 1 + /* 2 + * This program is used to generate definitions needed by 3 + * assembly language modules. 4 + * 5 + * We use the technique used in the OSF Mach kernel code: 6 + * generate asm statements containing #defines, 7 + * compile this file to assembler, and then extract the 8 + * #defines from the assembly-language output. 9 + */ 10 + 11 + #include <linux/stddef.h> 12 + #include <linux/sched.h> 13 + #include <linux/kernel_stat.h> 14 + #include <linux/ptrace.h> 15 + #include <linux/hardirq.h> 16 + #include <linux/kbuild.h> 17 + #include <asm/irq.h> 18 + #include <asm/ptrace.h> 19 + 20 + int main(void) 21 + { 22 + /* offsets into the task struct */ 23 + OFFSET(TASK_STATE, task_struct, state); 24 + OFFSET(TASK_FLAGS, task_struct, flags); 25 + OFFSET(TASK_PTRACE, task_struct, ptrace); 26 + OFFSET(TASK_BLOCKED, task_struct, blocked); 27 + OFFSET(TASK_THREAD, task_struct, thread); 28 + OFFSET(TASK_THREAD_INFO, task_struct, stack); 29 + OFFSET(TASK_MM, task_struct, mm); 30 + OFFSET(TASK_ACTIVE_MM, task_struct, active_mm); 31 + 32 + /* offsets into the irq_cpustat_t struct */ 33 + DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, 34 + __softirq_pending)); 35 + 36 + /* offsets into the thread struct */ 37 + OFFSET(THREAD_KSP, thread_struct, ksp); 38 + OFFSET(THREAD_USP, thread_struct, usp); 39 + OFFSET(THREAD_CCR, thread_struct, ccr); 40 + 41 + /* offsets into the pt_regs struct */ 42 + DEFINE(LER0, offsetof(struct pt_regs, er0) - sizeof(long)); 43 + DEFINE(LER1, offsetof(struct pt_regs, er1) - sizeof(long)); 44 + DEFINE(LER2, offsetof(struct pt_regs, er2) - sizeof(long)); 45 + DEFINE(LER3, offsetof(struct pt_regs, er3) - sizeof(long)); 46 + DEFINE(LER4, offsetof(struct pt_regs, er4) - sizeof(long)); 47 + DEFINE(LER5, offsetof(struct pt_regs, er5) - sizeof(long)); 48 + DEFINE(LER6, offsetof(struct pt_regs, er6) - sizeof(long)); 49 + DEFINE(LORIG, offsetof(struct pt_regs, orig_er0) - sizeof(long)); 50 + DEFINE(LSP, offsetof(struct pt_regs, sp) - sizeof(long)); 51 + DEFINE(LCCR, offsetof(struct pt_regs, ccr) - sizeof(long)); 52 + DEFINE(LVEC, offsetof(struct pt_regs, vector) - sizeof(long)); 53 + #if defined(CONFIG_CPU_H8S) 54 + DEFINE(LEXR, offsetof(struct pt_regs, exr) - sizeof(long)); 55 + #endif 56 + DEFINE(LRET, offsetof(struct pt_regs, pc) - sizeof(long)); 57 + 58 + DEFINE(PT_PTRACED, PT_PTRACED); 59 + 60 + /* offsets in thread_info structure */ 61 + OFFSET(TI_TASK, thread_info, task); 62 + OFFSET(TI_FLAGS, thread_info, flags); 63 + OFFSET(TI_CPU, thread_info, cpu); 64 + OFFSET(TI_PRE, thread_info, preempt_count); 65 + 66 + return 0; 67 + }
+69
arch/h8300/kernel/dma.c
··· 1 + /* 2 + * This file is subject to the terms and conditions of the GNU General Public 3 + * License. See the file COPYING in the main directory of this archive 4 + * for more details. 5 + */ 6 + 7 + #include <linux/dma-mapping.h> 8 + #include <linux/kernel.h> 9 + #include <linux/scatterlist.h> 10 + #include <linux/module.h> 11 + #include <asm/pgalloc.h> 12 + 13 + static void *dma_alloc(struct device *dev, size_t size, 14 + dma_addr_t *dma_handle, gfp_t gfp, 15 + struct dma_attrs *attrs) 16 + { 17 + void *ret; 18 + 19 + /* ignore region specifiers */ 20 + gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); 21 + 22 + if (dev == NULL || (*dev->dma_mask < 0xffffffff)) 23 + gfp |= GFP_DMA; 24 + ret = (void *)__get_free_pages(gfp, get_order(size)); 25 + 26 + if (ret != NULL) { 27 + memset(ret, 0, size); 28 + *dma_handle = virt_to_phys(ret); 29 + } 30 + return ret; 31 + } 32 + 33 + static void dma_free(struct device *dev, size_t size, 34 + void *vaddr, dma_addr_t dma_handle, 35 + struct dma_attrs *attrs) 36 + 37 + { 38 + free_pages((unsigned long)vaddr, get_order(size)); 39 + } 40 + 41 + static dma_addr_t map_page(struct device *dev, struct page *page, 42 + unsigned long offset, size_t size, 43 + enum dma_data_direction direction, 44 + struct dma_attrs *attrs) 45 + { 46 + return page_to_phys(page) + offset; 47 + } 48 + 49 + static int map_sg(struct device *dev, struct scatterlist *sgl, 50 + int nents, enum dma_data_direction direction, 51 + struct dma_attrs *attrs) 52 + { 53 + struct scatterlist *sg; 54 + int i; 55 + 56 + for_each_sg(sgl, sg, nents, i) { 57 + sg->dma_address = sg_phys(sg); 58 + } 59 + 60 + return nents; 61 + } 62 + 63 + struct dma_map_ops h8300_dma_map_ops = { 64 + .alloc = dma_alloc, 65 + .free = dma_free, 66 + .map_page = map_page, 67 + .map_sg = map_sg, 68 + }; 69 + EXPORT_SYMBOL(h8300_dma_map_ops);
+414
arch/h8300/kernel/entry.S
··· 1 + /* 2 + * 3 + * linux/arch/h8300/kernel/entry.S 4 + * 5 + * Yoshinori Sato <ysato@users.sourceforge.jp> 6 + * David McCullough <davidm@snapgear.com> 7 + * 8 + */ 9 + 10 + /* 11 + * entry.S 12 + * include exception/interrupt gateway 13 + * system call entry 14 + */ 15 + 16 + #include <linux/sys.h> 17 + #include <asm/unistd.h> 18 + #include <asm/setup.h> 19 + #include <asm/segment.h> 20 + #include <asm/linkage.h> 21 + #include <asm/asm-offsets.h> 22 + #include <asm/thread_info.h> 23 + #include <asm/errno.h> 24 + 25 + #if defined(CONFIG_CPU_H8300H) 26 + #define USERRET 8 27 + INTERRUPTS = 64 28 + .h8300h 29 + .macro SHLL2 reg 30 + shll.l \reg 31 + shll.l \reg 32 + .endm 33 + .macro SHLR2 reg 34 + shlr.l \reg 35 + shlr.l \reg 36 + .endm 37 + .macro SAVEREGS 38 + mov.l er0,@-sp 39 + mov.l er1,@-sp 40 + mov.l er2,@-sp 41 + mov.l er3,@-sp 42 + .endm 43 + .macro RESTOREREGS 44 + mov.l @sp+,er3 45 + mov.l @sp+,er2 46 + .endm 47 + .macro SAVEEXR 48 + .endm 49 + .macro RESTOREEXR 50 + .endm 51 + #endif 52 + #if defined(CONFIG_CPU_H8S) 53 + #define USERRET 10 54 + #define USEREXR 8 55 + INTERRUPTS = 128 56 + .h8300s 57 + .macro SHLL2 reg 58 + shll.l #2,\reg 59 + .endm 60 + .macro SHLR2 reg 61 + shlr.l #2,\reg 62 + .endm 63 + .macro SAVEREGS 64 + stm.l er0-er3,@-sp 65 + .endm 66 + .macro RESTOREREGS 67 + ldm.l @sp+,er2-er3 68 + .endm 69 + .macro SAVEEXR 70 + mov.w @(USEREXR:16,er0),r1 71 + mov.w r1,@(LEXR-LER3:16,sp) /* copy EXR */ 72 + .endm 73 + .macro RESTOREEXR 74 + mov.w @(LEXR-LER1:16,sp),r1 /* restore EXR */ 75 + mov.b r1l,r1h 76 + mov.w r1,@(USEREXR:16,er0) 77 + .endm 78 + #endif 79 + 80 + 81 + /* CPU context save/restore macros. */ 82 + 83 + .macro SAVE_ALL 84 + mov.l er0,@-sp 85 + stc ccr,r0l /* check kernel mode */ 86 + btst #4,r0l 87 + bne 5f 88 + 89 + /* user mode */ 90 + mov.l sp,@_sw_usp 91 + mov.l @sp,er0 /* restore saved er0 */ 92 + orc #0x10,ccr /* switch kernel stack */ 93 + mov.l @_sw_ksp,sp 94 + sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */ 95 + SAVEREGS 96 + mov.l @_sw_usp,er0 97 + mov.l @(USERRET:16,er0),er1 /* copy the RET addr */ 98 + mov.l er1,@(LRET-LER3:16,sp) 99 + SAVEEXR 100 + 101 + mov.l @(LORIG-LER3:16,sp),er0 102 + mov.l er0,@(LER0-LER3:16,sp) /* copy ER0 */ 103 + mov.w e1,r1 /* e1 highbyte = ccr */ 104 + and #0xef,r1h /* mask mode? flag */ 105 + bra 6f 106 + 5: 107 + /* kernel mode */ 108 + mov.l @sp,er0 /* restore saved er0 */ 109 + subs #2,sp /* set dummy ccr */ 110 + subs #4,sp /* set dummp sp */ 111 + SAVEREGS 112 + mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */ 113 + 6: 114 + mov.b r1h,r1l 115 + mov.b #0,r1h 116 + mov.w r1,@(LCCR-LER3:16,sp) /* set ccr */ 117 + mov.l @_sw_usp,er2 118 + mov.l er2,@(LSP-LER3:16,sp) /* set usp */ 119 + mov.l er6,@-sp /* syscall arg #6 */ 120 + mov.l er5,@-sp /* syscall arg #5 */ 121 + mov.l er4,@-sp /* syscall arg #4 */ 122 + .endm /* r1 = ccr */ 123 + 124 + .macro RESTORE_ALL 125 + mov.l @sp+,er4 126 + mov.l @sp+,er5 127 + mov.l @sp+,er6 128 + RESTOREREGS 129 + mov.w @(LCCR-LER1:16,sp),r0 /* check kernel mode */ 130 + btst #4,r0l 131 + bne 7f 132 + 133 + orc #0xc0,ccr 134 + mov.l @(LSP-LER1:16,sp),er0 135 + mov.l @(LER0-LER1:16,sp),er1 /* restore ER0 */ 136 + mov.l er1,@er0 137 + RESTOREEXR 138 + mov.w @(LCCR-LER1:16,sp),r1 /* restore the RET addr */ 139 + mov.b r1l,r1h 140 + mov.b @(LRET+1-LER1:16,sp),r1l 141 + mov.w r1,e1 142 + mov.w @(LRET+2-LER1:16,sp),r1 143 + mov.l er1,@(USERRET:16,er0) 144 + 145 + mov.l @sp+,er1 146 + add.l #(LRET-LER1),sp /* remove LORIG - LRET */ 147 + mov.l sp,@_sw_ksp 148 + andc #0xef,ccr /* switch to user mode */ 149 + mov.l er0,sp 150 + bra 8f 151 + 7: 152 + mov.l @sp+,er1 153 + add.l #10,sp 154 + 8: 155 + mov.l @sp+,er0 156 + adds #4,sp /* remove the sw created LVEC */ 157 + rte 158 + .endm 159 + 160 + .globl _system_call 161 + .globl ret_from_exception 162 + .globl ret_from_fork 163 + .globl ret_from_kernel_thread 164 + .globl ret_from_interrupt 165 + .globl _interrupt_redirect_table 166 + .globl _sw_ksp,_sw_usp 167 + .globl _resume 168 + .globl _interrupt_entry 169 + .globl _trace_break 170 + .globl _nmi 171 + 172 + #if defined(CONFIG_ROMKERNEL) 173 + .section .int_redirect,"ax" 174 + _interrupt_redirect_table: 175 + #if defined(CONFIG_CPU_H8300H) 176 + .rept 7 177 + .long 0 178 + .endr 179 + #endif 180 + #if defined(CONFIG_CPU_H8S) 181 + .rept 5 182 + .long 0 183 + .endr 184 + jmp @_trace_break 185 + .long 0 186 + #endif 187 + 188 + jsr @_interrupt_entry /* NMI */ 189 + jmp @_system_call /* TRAPA #0 (System call) */ 190 + .long 0 191 + .long 0 192 + jmp @_trace_break /* TRAPA #3 (breakpoint) */ 193 + .rept INTERRUPTS-12 194 + jsr @_interrupt_entry 195 + .endr 196 + #endif 197 + #if defined(CONFIG_RAMKERNEL) 198 + .globl _interrupt_redirect_table 199 + .section .bss 200 + _interrupt_redirect_table: 201 + .space 4 202 + #endif 203 + 204 + .section .text 205 + .align 2 206 + _interrupt_entry: 207 + SAVE_ALL 208 + /* r1l is saved ccr */ 209 + mov.l sp,er0 210 + add.l #LVEC,er0 211 + btst #4,r1l 212 + bne 1f 213 + /* user LVEC */ 214 + mov.l @_sw_usp,er0 215 + adds #4,er0 216 + 1: 217 + mov.l @er0,er0 /* LVEC address */ 218 + #if defined(CONFIG_ROMKERNEL) 219 + sub.l #_interrupt_redirect_table,er0 220 + #endif 221 + #if defined(CONFIG_RAMKERNEL) 222 + mov.l @_interrupt_redirect_table,er1 223 + sub.l er1,er0 224 + #endif 225 + SHLR2 er0 226 + dec.l #1,er0 227 + mov.l sp,er1 228 + subs #4,er1 /* adjust ret_pc */ 229 + #if defined(CONFIG_CPU_H8S) 230 + orc #7,exr 231 + #endif 232 + jsr @do_IRQ 233 + jmp @ret_from_interrupt 234 + 235 + _system_call: 236 + subs #4,sp /* dummy LVEC */ 237 + SAVE_ALL 238 + /* er0: syscall nr */ 239 + andc #0xbf,ccr 240 + mov.l er0,er4 241 + 242 + /* save top of frame */ 243 + mov.l sp,er0 244 + jsr @set_esp0 245 + mov.l sp,er2 246 + and.w #0xe000,r2 247 + mov.l @(TI_FLAGS:16,er2),er2 248 + and.w #_TIF_WORK_SYSCALL_MASK,r2 249 + beq 1f 250 + mov.l sp,er0 251 + jsr @do_syscall_trace_enter 252 + 1: 253 + cmp.l #__NR_syscalls,er4 254 + bcc badsys 255 + SHLL2 er4 256 + mov.l #_sys_call_table,er0 257 + add.l er4,er0 258 + mov.l @er0,er4 259 + beq ret_from_exception:16 260 + mov.l @(LER1:16,sp),er0 261 + mov.l @(LER2:16,sp),er1 262 + mov.l @(LER3:16,sp),er2 263 + jsr @er4 264 + mov.l er0,@(LER0:16,sp) /* save the return value */ 265 + mov.l sp,er2 266 + and.w #0xe000,r2 267 + mov.l @(TI_FLAGS:16,er2),er2 268 + and.w #_TIF_WORK_SYSCALL_MASK,r2 269 + beq 2f 270 + mov.l sp,er0 271 + jsr @do_syscall_trace_leave 272 + 2: 273 + orc #0xc0,ccr 274 + bra resume_userspace 275 + 276 + badsys: 277 + mov.l #-ENOSYS,er0 278 + mov.l er0,@(LER0:16,sp) 279 + bra resume_userspace 280 + 281 + #if !defined(CONFIG_PREEMPT) 282 + #define resume_kernel restore_all 283 + #endif 284 + 285 + ret_from_exception: 286 + #if defined(CONFIG_PREEMPT) 287 + orc #0xc0,ccr 288 + #endif 289 + ret_from_interrupt: 290 + mov.b @(LCCR+1:16,sp),r0l 291 + btst #4,r0l 292 + bne resume_kernel:16 /* return from kernel */ 293 + resume_userspace: 294 + andc #0xbf,ccr 295 + mov.l sp,er4 296 + and.w #0xe000,r4 /* er4 <- current thread info */ 297 + mov.l @(TI_FLAGS:16,er4),er1 298 + and.l #_TIF_WORK_MASK,er1 299 + beq restore_all:8 300 + work_pending: 301 + btst #TIF_NEED_RESCHED,r1l 302 + bne work_resched:8 303 + /* work notifysig */ 304 + mov.l sp,er0 305 + subs #4,er0 /* er0: pt_regs */ 306 + jsr @do_notify_resume 307 + bra resume_userspace:8 308 + work_resched: 309 + mov.l sp,er0 310 + jsr @set_esp0 311 + jsr @schedule 312 + bra resume_userspace:8 313 + restore_all: 314 + RESTORE_ALL /* Does RTE */ 315 + 316 + #if defined(CONFIG_PREEMPT) 317 + resume_kernel: 318 + mov.l @(TI_PRE_COUNT:16,er4),er0 319 + bne restore_all:8 320 + need_resched: 321 + mov.l @(TI_FLAGS:16,er4),er0 322 + btst #TIF_NEED_RESCHED,r0l 323 + beq restore_all:8 324 + mov.b @(LCCR+1:16,sp),r0l /* Interrupt Enabled? */ 325 + bmi restore_all:8 326 + mov.l sp,er0 327 + jsr @set_esp0 328 + jsr @preempt_schedule_irq 329 + bra need_resched:8 330 + #endif 331 + 332 + ret_from_fork: 333 + mov.l er2,er0 334 + jsr @schedule_tail 335 + jmp @ret_from_exception 336 + 337 + ret_from_kernel_thread: 338 + mov.l er2,er0 339 + jsr @schedule_tail 340 + mov.l @(LER4:16,sp),er0 341 + mov.l @(LER5:16,sp),er1 342 + jsr @er1 343 + jmp @ret_from_exception 344 + 345 + _resume: 346 + /* 347 + * Beware - when entering resume, offset of tss is in d1, 348 + * prev (the current task) is in a0, next (the new task) 349 + * is in a1 and d2.b is non-zero if the mm structure is 350 + * shared between the tasks, so don't change these 351 + * registers until their contents are no longer needed. 352 + */ 353 + 354 + /* save sr */ 355 + sub.w r3,r3 356 + stc ccr,r3l 357 + mov.w r3,@(THREAD_CCR+2:16,er0) 358 + 359 + /* disable interrupts */ 360 + orc #0xc0,ccr 361 + mov.l @_sw_usp,er3 362 + mov.l er3,@(THREAD_USP:16,er0) 363 + mov.l sp,@(THREAD_KSP:16,er0) 364 + 365 + /* Skip address space switching if they are the same. */ 366 + /* FIXME: what did we hack out of here, this does nothing! */ 367 + 368 + mov.l @(THREAD_USP:16,er1),er0 369 + mov.l er0,@_sw_usp 370 + mov.l @(THREAD_KSP:16,er1),sp 371 + 372 + /* restore status register */ 373 + mov.w @(THREAD_CCR+2:16,er1),r3 374 + 375 + ldc r3l,ccr 376 + rts 377 + 378 + _trace_break: 379 + subs #4,sp 380 + SAVE_ALL 381 + sub.l er1,er1 382 + dec.l #1,er1 383 + mov.l er1,@(LORIG,sp) 384 + mov.l sp,er0 385 + jsr @set_esp0 386 + mov.l @_sw_usp,er0 387 + mov.l @er0,er1 388 + mov.w @(-2:16,er1),r2 389 + cmp.w #0x5730,r2 390 + beq 1f 391 + subs #2,er1 392 + mov.l er1,@er0 393 + 1: 394 + and.w #0xff,e1 395 + mov.l er1,er0 396 + jsr @trace_trap 397 + jmp @ret_from_exception 398 + 399 + _nmi: 400 + subs #4, sp 401 + mov.l er0, @-sp 402 + mov.l @_interrupt_redirect_table, er0 403 + add.l #8*4, er0 404 + mov.l er0, @(4,sp) 405 + mov.l @sp+, er0 406 + jmp @_interrupt_entry 407 + 408 + .section .bss 409 + _sw_ksp: 410 + .space 4 411 + _sw_usp: 412 + .space 4 413 + 414 + .end
+36
arch/h8300/kernel/h8300_ksyms.c
··· 1 + #include <linux/module.h> 2 + #include <linux/linkage.h> 3 + 4 + /* 5 + * libgcc functions - functions that are used internally by the 6 + * compiler... (prototypes are not correct though, but that 7 + * doesn't really matter since they're not versioned). 8 + */ 9 + asmlinkage long __ucmpdi2(long long, long long); 10 + asmlinkage long long __ashldi3(long long, int); 11 + asmlinkage long long __ashrdi3(long long, int); 12 + asmlinkage long long __lshrdi3(long long, int); 13 + asmlinkage long __divsi3(long, long); 14 + asmlinkage long __modsi3(long, long); 15 + asmlinkage unsigned long __umodsi3(unsigned long, unsigned long); 16 + asmlinkage long long __muldi3(long long, long long); 17 + asmlinkage long __mulsi3(long, long); 18 + asmlinkage long __udivsi3(long, long); 19 + asmlinkage void *memcpy(void *, const void *, size_t); 20 + asmlinkage void *memset(void *, int, size_t); 21 + asmlinkage long strncpy_from_user(void *to, void *from, size_t n); 22 + 23 + /* gcc lib functions */ 24 + EXPORT_SYMBOL(__ucmpdi2); 25 + EXPORT_SYMBOL(__ashldi3); 26 + EXPORT_SYMBOL(__ashrdi3); 27 + EXPORT_SYMBOL(__lshrdi3); 28 + EXPORT_SYMBOL(__divsi3); 29 + EXPORT_SYMBOL(__modsi3); 30 + EXPORT_SYMBOL(__umodsi3); 31 + EXPORT_SYMBOL(__muldi3); 32 + EXPORT_SYMBOL(__mulsi3); 33 + EXPORT_SYMBOL(__udivsi3); 34 + EXPORT_SYMBOL(memcpy); 35 + EXPORT_SYMBOL(memset); 36 + EXPORT_SYMBOL(strncpy_from_user);
+60
arch/h8300/kernel/head_ram.S
··· 1 + 2 + #include <linux/sys.h> 3 + #include <linux/init.h> 4 + #include <asm/unistd.h> 5 + #include <asm/setup.h> 6 + #include <asm/segment.h> 7 + #include <asm/linkage.h> 8 + #include <asm/asm-offsets.h> 9 + #include <asm/thread_info.h> 10 + #include <asm/errno.h> 11 + 12 + #if defined(CONFIG_CPU_H8300H) 13 + .h8300h 14 + #define SYSCR 0xfee012 15 + #define IRAMTOP 0xffff20 16 + #endif 17 + #if defined(CONFIG_CPU_H8S) 18 + .h8300s 19 + #define INTCR 0xffff31 20 + #define IRAMTOP 0xffc000 21 + #endif 22 + 23 + __HEAD 24 + .global _start 25 + _start: 26 + mov.l #IRAMTOP,sp 27 + /* .bss clear */ 28 + mov.l #_sbss,er5 29 + mov.l #_ebss,er4 30 + sub.l er5,er4 31 + shlr er4 32 + shlr er4 33 + sub.l er2,er2 34 + 1: 35 + mov.l er2,@er5 36 + adds #4,er5 37 + dec.l #1,er4 38 + bne 1b 39 + jsr @h8300_fdt_init 40 + 41 + /* linux kernel start */ 42 + #if defined(CONFIG_CPU_H8300H) 43 + ldc #0xd0,ccr /* running kernel */ 44 + mov.l #SYSCR,er0 45 + bclr #3,@er0 46 + #endif 47 + #if defined(CONFIG_CPU_H8S) 48 + ldc #0x07,exr 49 + bclr #4,@INTCR:8 50 + bset #5,@INTCR:8 /* Interrupt mode 2 */ 51 + ldc #0x90,ccr /* running kernel */ 52 + #endif 53 + mov.l #init_thread_union,sp 54 + add.l #0x2000,sp 55 + jsr @start_kernel 56 + 57 + 1: 58 + bra 1b 59 + 60 + .end
+110
arch/h8300/kernel/head_rom.S
··· 1 + #include <linux/init.h> 2 + #include <asm/thread_info.h> 3 + 4 + #if defined(CONFIG_CPU_H8300H) 5 + .h8300h 6 + #define SYSCR 0xfee012 7 + #define IRAMTOP 0xffff20 8 + #define NR_INT 64 9 + #endif 10 + #if defined(CONFIG_CPU_H8S) 11 + .h8300s 12 + #define INTCR 0xffff31 13 + #define IRAMTOP 0xffc000 14 + #define NR_INT 128 15 + #endif 16 + 17 + __HEAD 18 + .global _start 19 + _start: 20 + mov.l #IRAMTOP,sp 21 + #if !defined(CONFIG_H8300H_SIM) && \ 22 + !defined(CONFIG_H8S_SIM) 23 + jsr @lowlevel_init 24 + 25 + /* copy .data */ 26 + mov.l #_begin_data,er5 27 + mov.l #_sdata,er6 28 + mov.l #_edata,er4 29 + sub.l er6,er4 30 + shlr.l er4 31 + shlr.l er4 32 + 1: 33 + mov.l @er5+,er0 34 + mov.l er0,@er6 35 + adds #4,er6 36 + dec.l #1,er4 37 + bne 1b 38 + /* .bss clear */ 39 + mov.l #_sbss,er5 40 + mov.l #_ebss,er4 41 + sub.l er5,er4 42 + shlr er4 43 + shlr er4 44 + sub.l er0,er0 45 + 1: 46 + mov.l er0,@er5 47 + adds #4,er5 48 + dec.l #1,er4 49 + bne 1b 50 + #else 51 + /* get cmdline from gdb */ 52 + jsr @0xcc 53 + ;; er0 - argc 54 + ;; er1 - argv 55 + mov.l #command_line,er3 56 + adds #4,er1 57 + dec.l #1,er0 58 + beq 4f 59 + 1: 60 + mov.l @er1+,er2 61 + 2: 62 + mov.b @er2+,r4l 63 + beq 3f 64 + mov.b r4l,@er3 65 + adds #1,er3 66 + bra 2b 67 + 3: 68 + mov.b #' ',r4l 69 + mov.b r4l,@er3 70 + adds #1,er3 71 + dec.l #1,er0 72 + bne 1b 73 + subs #1,er3 74 + mov.b #0,r4l 75 + mov.b r4l,@er3 76 + 4: 77 + #endif 78 + sub.l er0,er0 79 + jsr @h8300_fdt_init 80 + /* linux kernel start */ 81 + #if defined(CONFIG_CPU_H8300H) 82 + ldc #0xd0,ccr /* running kernel */ 83 + mov.l #SYSCR,er0 84 + bclr #3,@er0 85 + #endif 86 + #if defined(CONFIG_CPU_H8S) 87 + ldc #0x07,exr 88 + bclr #4,@INTCR:8 89 + bset #5,@INTCR:8 /* Interrupt mode 2 */ 90 + ldc #0x90,ccr /* running kernel */ 91 + #endif 92 + mov.l #init_thread_union,sp 93 + add.l #0x2000,sp 94 + jsr @start_kernel 95 + 96 + 1: 97 + bra 1b 98 + 99 + #if defined(CONFIG_ROMKERNEL) 100 + /* interrupt vector */ 101 + .section .vectors,"ax" 102 + .long _start 103 + .long _start 104 + vector = 2 105 + .rept NR_INT - 2 106 + .long _interrupt_redirect_table+vector*4 107 + vector = vector + 1 108 + .endr 109 + #endif 110 + .end
+97
arch/h8300/kernel/irq.c
··· 1 + /* 2 + * linux/arch/h8300/kernel/irq.c 3 + * 4 + * Copyright 2014-2015 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + */ 6 + 7 + #include <linux/init.h> 8 + #include <linux/interrupt.h> 9 + #include <linux/irq.h> 10 + #include <linux/irqdomain.h> 11 + #include <linux/of_irq.h> 12 + #include <asm/traps.h> 13 + 14 + #ifdef CONFIG_RAMKERNEL 15 + typedef void (*h8300_vector)(void); 16 + 17 + static const h8300_vector __initconst trap_table[] = { 18 + 0, 0, 0, 0, 19 + _trace_break, 20 + 0, 0, 21 + _nmi, 22 + _system_call, 23 + 0, 0, 24 + _trace_break, 25 + }; 26 + 27 + static unsigned long __init *get_vector_address(void) 28 + { 29 + unsigned long *rom_vector = CPU_VECTOR; 30 + unsigned long base, tmp; 31 + int vec_no; 32 + 33 + base = rom_vector[EXT_IRQ0] & ADDR_MASK; 34 + 35 + /* check romvector format */ 36 + for (vec_no = EXT_IRQ0 + 1; vec_no <= EXT_IRQ0+EXT_IRQS; vec_no++) { 37 + if ((base+(vec_no - EXT_IRQ0)*4) != 38 + (rom_vector[vec_no] & ADDR_MASK)) 39 + return NULL; 40 + } 41 + 42 + /* ramvector base address */ 43 + base -= EXT_IRQ0*4; 44 + 45 + /* writerble? */ 46 + tmp = ~(*(volatile unsigned long *)base); 47 + (*(volatile unsigned long *)base) = tmp; 48 + if ((*(volatile unsigned long *)base) != tmp) 49 + return NULL; 50 + return (unsigned long *)base; 51 + } 52 + 53 + static void __init setup_vector(void) 54 + { 55 + int i; 56 + unsigned long *ramvec, *ramvec_p; 57 + const h8300_vector *trap_entry; 58 + 59 + ramvec = get_vector_address(); 60 + if (ramvec == NULL) 61 + panic("interrupt vector serup failed."); 62 + else 63 + pr_debug("virtual vector at 0x%p\n", ramvec); 64 + 65 + /* create redirect table */ 66 + ramvec_p = ramvec; 67 + trap_entry = trap_table; 68 + for (i = 0; i < NR_IRQS; i++) { 69 + if (i < 12) { 70 + if (*trap_entry) 71 + *ramvec_p = VECTOR(*trap_entry); 72 + ramvec_p++; 73 + trap_entry++; 74 + } else 75 + *ramvec_p++ = REDIRECT(_interrupt_entry); 76 + } 77 + _interrupt_redirect_table = ramvec; 78 + } 79 + #else 80 + void setup_vector(void) 81 + { 82 + /* noting do */ 83 + } 84 + #endif 85 + 86 + void __init init_IRQ(void) 87 + { 88 + setup_vector(); 89 + irqchip_init(); 90 + } 91 + 92 + asmlinkage void do_IRQ(int irq) 93 + { 94 + irq_enter(); 95 + generic_handle_irq(irq); 96 + irq_exit(); 97 + }
+70
arch/h8300/kernel/module.c
··· 1 + #include <linux/moduleloader.h> 2 + #include <linux/elf.h> 3 + #include <linux/vmalloc.h> 4 + #include <linux/fs.h> 5 + #include <linux/string.h> 6 + #include <linux/kernel.h> 7 + 8 + int apply_relocate_add(Elf32_Shdr *sechdrs, 9 + const char *strtab, 10 + unsigned int symindex, 11 + unsigned int relsec, 12 + struct module *me) 13 + { 14 + unsigned int i; 15 + Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr; 16 + 17 + pr_debug("Applying relocate section %u to %u\n", relsec, 18 + sechdrs[relsec].sh_info); 19 + for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rela); i++) { 20 + /* This is where to make the change */ 21 + uint32_t *loc = 22 + (uint32_t *)(sechdrs[sechdrs[relsec].sh_info].sh_addr 23 + + rela[i].r_offset); 24 + /* This is the symbol it is referring to. Note that all 25 + undefined symbols have been resolved. */ 26 + Elf32_Sym *sym = (Elf32_Sym *)sechdrs[symindex].sh_addr 27 + + ELF32_R_SYM(rela[i].r_info); 28 + uint32_t v = sym->st_value + rela[i].r_addend; 29 + 30 + switch (ELF32_R_TYPE(rela[i].r_info)) { 31 + case R_H8_DIR24R8: 32 + loc = (uint32_t *)((uint32_t)loc - 1); 33 + *loc = (*loc & 0xff000000) | ((*loc & 0xffffff) + v); 34 + break; 35 + case R_H8_DIR24A8: 36 + if (ELF32_R_SYM(rela[i].r_info)) 37 + *loc += v; 38 + break; 39 + case R_H8_DIR32: 40 + case R_H8_DIR32A16: 41 + *loc += v; 42 + break; 43 + case R_H8_PCREL16: 44 + v -= (unsigned long)loc + 2; 45 + if ((Elf32_Sword)v > 0x7fff || 46 + (Elf32_Sword)v < -(Elf32_Sword)0x8000) 47 + goto overflow; 48 + else 49 + *(unsigned short *)loc = v; 50 + break; 51 + case R_H8_PCREL8: 52 + v -= (unsigned long)loc + 1; 53 + if ((Elf32_Sword)v > 0x7f || 54 + (Elf32_Sword)v < -(Elf32_Sword)0x80) 55 + goto overflow; 56 + else 57 + *(unsigned char *)loc = v; 58 + break; 59 + default: 60 + pr_err("module %s: Unknown relocation: %u\n", 61 + me->name, ELF32_R_TYPE(rela[i].r_info)); 62 + return -ENOEXEC; 63 + } 64 + } 65 + return 0; 66 + overflow: 67 + pr_err("module %s: relocation offset overflow: %08x\n", 68 + me->name, rela[i].r_offset); 69 + return -ENOEXEC; 70 + }
+171
arch/h8300/kernel/process.c
··· 1 + /* 2 + * linux/arch/h8300/kernel/process.c 3 + * 4 + * Yoshinori Sato <ysato@users.sourceforge.jp> 5 + * 6 + * Based on: 7 + * 8 + * linux/arch/m68knommu/kernel/process.c 9 + * 10 + * Copyright (C) 1998 D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>, 11 + * Kenneth Albanowski <kjahds@kjahds.com>, 12 + * The Silver Hammer Group, Ltd. 13 + * 14 + * linux/arch/m68k/kernel/process.c 15 + * 16 + * Copyright (C) 1995 Hamish Macdonald 17 + * 18 + * 68060 fixes by Jesper Skov 19 + */ 20 + 21 + /* 22 + * This file handles the architecture-dependent parts of process handling.. 23 + */ 24 + 25 + #include <linux/errno.h> 26 + #include <linux/module.h> 27 + #include <linux/sched.h> 28 + #include <linux/kernel.h> 29 + #include <linux/mm.h> 30 + #include <linux/smp.h> 31 + #include <linux/stddef.h> 32 + #include <linux/unistd.h> 33 + #include <linux/ptrace.h> 34 + #include <linux/user.h> 35 + #include <linux/interrupt.h> 36 + #include <linux/reboot.h> 37 + #include <linux/fs.h> 38 + #include <linux/slab.h> 39 + #include <linux/rcupdate.h> 40 + 41 + #include <asm/uaccess.h> 42 + #include <asm/traps.h> 43 + #include <asm/setup.h> 44 + #include <asm/pgtable.h> 45 + 46 + void (*pm_power_off)(void) = NULL; 47 + EXPORT_SYMBOL(pm_power_off); 48 + 49 + asmlinkage void ret_from_fork(void); 50 + asmlinkage void ret_from_kernel_thread(void); 51 + 52 + /* 53 + * The idle loop on an H8/300.. 54 + */ 55 + void arch_cpu_idle(void) 56 + { 57 + local_irq_enable(); 58 + __asm__("sleep"); 59 + } 60 + 61 + void machine_restart(char *__unused) 62 + { 63 + local_irq_disable(); 64 + __asm__("jmp @@0"); 65 + } 66 + 67 + void machine_halt(void) 68 + { 69 + local_irq_disable(); 70 + __asm__("sleep"); 71 + for (;;) 72 + ; 73 + } 74 + 75 + void machine_power_off(void) 76 + { 77 + local_irq_disable(); 78 + __asm__("sleep"); 79 + for (;;) 80 + ; 81 + } 82 + 83 + void show_regs(struct pt_regs *regs) 84 + { 85 + show_regs_print_info(KERN_DEFAULT); 86 + 87 + pr_notice("\n"); 88 + pr_notice("PC: %08lx Status: %02x\n", 89 + regs->pc, regs->ccr); 90 + pr_notice("ORIG_ER0: %08lx ER0: %08lx ER1: %08lx\n", 91 + regs->orig_er0, regs->er0, regs->er1); 92 + pr_notice("ER2: %08lx ER3: %08lx ER4: %08lx ER5: %08lx\n", 93 + regs->er2, regs->er3, regs->er4, regs->er5); 94 + pr_notice("ER6' %08lx ", regs->er6); 95 + if (user_mode(regs)) 96 + printk("USP: %08lx\n", rdusp()); 97 + else 98 + printk("\n"); 99 + } 100 + 101 + void flush_thread(void) 102 + { 103 + } 104 + 105 + int copy_thread(unsigned long clone_flags, 106 + unsigned long usp, unsigned long topstk, 107 + struct task_struct *p) 108 + { 109 + struct pt_regs *childregs; 110 + 111 + childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1; 112 + 113 + if (unlikely(p->flags & PF_KTHREAD)) { 114 + memset(childregs, 0, sizeof(struct pt_regs)); 115 + childregs->retpc = (unsigned long) ret_from_kernel_thread; 116 + childregs->er4 = topstk; /* arg */ 117 + childregs->er5 = usp; /* fn */ 118 + } else { 119 + *childregs = *current_pt_regs(); 120 + childregs->er0 = 0; 121 + childregs->retpc = (unsigned long) ret_from_fork; 122 + p->thread.usp = usp ?: rdusp(); 123 + } 124 + p->thread.ksp = (unsigned long)childregs; 125 + 126 + return 0; 127 + } 128 + 129 + unsigned long thread_saved_pc(struct task_struct *tsk) 130 + { 131 + return ((struct pt_regs *)tsk->thread.esp0)->pc; 132 + } 133 + 134 + unsigned long get_wchan(struct task_struct *p) 135 + { 136 + unsigned long fp, pc; 137 + unsigned long stack_page; 138 + int count = 0; 139 + 140 + if (!p || p == current || p->state == TASK_RUNNING) 141 + return 0; 142 + 143 + stack_page = (unsigned long)p; 144 + fp = ((struct pt_regs *)p->thread.ksp)->er6; 145 + do { 146 + if (fp < stack_page+sizeof(struct thread_info) || 147 + fp >= 8184+stack_page) 148 + return 0; 149 + pc = ((unsigned long *)fp)[1]; 150 + if (!in_sched_functions(pc)) 151 + return pc; 152 + fp = *(unsigned long *) fp; 153 + } while (count++ < 16); 154 + return 0; 155 + } 156 + 157 + /* generic sys_clone is not enough registers */ 158 + asmlinkage int sys_clone(unsigned long __user *args) 159 + { 160 + unsigned long clone_flags; 161 + unsigned long newsp; 162 + uintptr_t parent_tidptr; 163 + uintptr_t child_tidptr; 164 + 165 + get_user(clone_flags, &args[0]); 166 + get_user(newsp, &args[1]); 167 + get_user(parent_tidptr, &args[2]); 168 + get_user(child_tidptr, &args[3]); 169 + return do_fork(clone_flags, newsp, 0, 170 + (int __user *)parent_tidptr, (int __user *)child_tidptr); 171 + }
+203
arch/h8300/kernel/ptrace.c
··· 1 + /* 2 + * linux/arch/h8300/kernel/ptrace.c 3 + * 4 + * Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + * 6 + * This file is subject to the terms and conditions of the GNU General 7 + * Public License. See the file COPYING in the main directory of 8 + * this archive for more details. 9 + */ 10 + 11 + #include <linux/kernel.h> 12 + #include <linux/errno.h> 13 + #include <linux/ptrace.h> 14 + #include <linux/audit.h> 15 + #include <linux/tracehook.h> 16 + #include <linux/regset.h> 17 + #include <linux/elf.h> 18 + 19 + #define CCR_MASK 0x6f /* mode/imask not set */ 20 + #define EXR_MASK 0x80 /* modify only T */ 21 + 22 + #define PT_REG(r) offsetof(struct pt_regs, r) 23 + 24 + extern void user_disable_single_step(struct task_struct *child); 25 + 26 + /* Mapping from PT_xxx to the stack offset at which the register is 27 + saved. Notice that usp has no stack-slot and needs to be treated 28 + specially (see get_reg/put_reg below). */ 29 + static const int register_offset[] = { 30 + PT_REG(er1), PT_REG(er2), PT_REG(er3), PT_REG(er4), 31 + PT_REG(er5), PT_REG(er6), PT_REG(er0), -1, 32 + PT_REG(orig_er0), PT_REG(ccr), PT_REG(pc), 33 + #if defined(CONFIG_CPU_H8S) 34 + PT_REG(exr), 35 + #endif 36 + }; 37 + 38 + /* read register */ 39 + long h8300_get_reg(struct task_struct *task, int regno) 40 + { 41 + switch (regno) { 42 + case PT_USP: 43 + return task->thread.usp + sizeof(long)*2; 44 + case PT_CCR: 45 + case PT_EXR: 46 + return *(unsigned short *)(task->thread.esp0 + 47 + register_offset[regno]); 48 + default: 49 + return *(unsigned long *)(task->thread.esp0 + 50 + register_offset[regno]); 51 + } 52 + } 53 + 54 + int h8300_put_reg(struct task_struct *task, int regno, unsigned long data) 55 + { 56 + unsigned short oldccr; 57 + unsigned short oldexr; 58 + 59 + switch (regno) { 60 + case PT_USP: 61 + task->thread.usp = data - sizeof(long)*2; 62 + case PT_CCR: 63 + oldccr = *(unsigned short *)(task->thread.esp0 + 64 + register_offset[regno]); 65 + oldccr &= ~CCR_MASK; 66 + data &= CCR_MASK; 67 + data |= oldccr; 68 + *(unsigned short *)(task->thread.esp0 + 69 + register_offset[regno]) = data; 70 + break; 71 + case PT_EXR: 72 + oldexr = *(unsigned short *)(task->thread.esp0 + 73 + register_offset[regno]); 74 + oldccr &= ~EXR_MASK; 75 + data &= EXR_MASK; 76 + data |= oldexr; 77 + *(unsigned short *)(task->thread.esp0 + 78 + register_offset[regno]) = data; 79 + break; 80 + default: 81 + *(unsigned long *)(task->thread.esp0 + 82 + register_offset[regno]) = data; 83 + break; 84 + } 85 + return 0; 86 + } 87 + 88 + static int regs_get(struct task_struct *target, 89 + const struct user_regset *regset, 90 + unsigned int pos, unsigned int count, 91 + void *kbuf, void __user *ubuf) 92 + { 93 + int r; 94 + struct user_regs_struct regs; 95 + long *reg = (long *)&regs; 96 + 97 + /* build user regs in buffer */ 98 + for (r = 0; r < ARRAY_SIZE(register_offset); r++) 99 + *reg++ = h8300_get_reg(target, r); 100 + 101 + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, 102 + &regs, 0, sizeof(regs)); 103 + } 104 + 105 + static int regs_set(struct task_struct *target, 106 + const struct user_regset *regset, 107 + unsigned int pos, unsigned int count, 108 + const void *kbuf, const void __user *ubuf) 109 + { 110 + int r; 111 + int ret; 112 + struct user_regs_struct regs; 113 + long *reg; 114 + 115 + /* build user regs in buffer */ 116 + for (reg = (long *)&regs, r = 0; r < ARRAY_SIZE(register_offset); r++) 117 + *reg++ = h8300_get_reg(target, r); 118 + 119 + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 120 + &regs, 0, sizeof(regs)); 121 + if (ret) 122 + return ret; 123 + 124 + /* write back to pt_regs */ 125 + for (reg = (long *)&regs, r = 0; r < ARRAY_SIZE(register_offset); r++) 126 + h8300_put_reg(target, r, *reg++); 127 + return 0; 128 + } 129 + 130 + enum h8300_regset { 131 + REGSET_GENERAL, 132 + }; 133 + 134 + static const struct user_regset h8300_regsets[] = { 135 + [REGSET_GENERAL] = { 136 + .core_note_type = NT_PRSTATUS, 137 + .n = ELF_NGREG, 138 + .size = sizeof(long), 139 + .align = sizeof(long), 140 + .get = regs_get, 141 + .set = regs_set, 142 + }, 143 + }; 144 + 145 + static const struct user_regset_view user_h8300_native_view = { 146 + .name = "h8300", 147 + .e_machine = EM_H8_300, 148 + .regsets = h8300_regsets, 149 + .n = ARRAY_SIZE(h8300_regsets), 150 + }; 151 + 152 + const struct user_regset_view *task_user_regset_view(struct task_struct *task) 153 + { 154 + return &user_h8300_native_view; 155 + } 156 + 157 + void ptrace_disable(struct task_struct *child) 158 + { 159 + user_disable_single_step(child); 160 + } 161 + 162 + long arch_ptrace(struct task_struct *child, long request, 163 + unsigned long addr, unsigned long data) 164 + { 165 + int ret; 166 + 167 + switch (request) { 168 + default: 169 + ret = ptrace_request(child, request, addr, data); 170 + break; 171 + } 172 + return ret; 173 + } 174 + 175 + asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) 176 + { 177 + long ret = 0; 178 + 179 + if (test_thread_flag(TIF_SYSCALL_TRACE) && 180 + tracehook_report_syscall_entry(regs)) 181 + /* 182 + * Tracing decided this syscall should not happen. 183 + * We'll return a bogus call number to get an ENOSYS 184 + * error, but leave the original number in regs->regs[0]. 185 + */ 186 + ret = -1L; 187 + 188 + audit_syscall_entry(regs->er1, regs->er2, regs->er3, 189 + regs->er4, regs->er5); 190 + 191 + return ret ?: regs->er0; 192 + } 193 + 194 + asmlinkage void do_syscall_trace_leave(struct pt_regs *regs) 195 + { 196 + int step; 197 + 198 + audit_syscall_exit(regs); 199 + 200 + step = test_thread_flag(TIF_SINGLESTEP); 201 + if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 202 + tracehook_report_syscall_exit(regs, step); 203 + }
+256
arch/h8300/kernel/ptrace_h.c
··· 1 + /* 2 + * ptrace cpu depend helper functions 3 + * 4 + * Copyright 2003, 2015 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + * 6 + * This file is subject to the terms and conditions of the GNU General 7 + * Public License. See the file COPYING in the main directory of 8 + * this archive for more details. 9 + */ 10 + 11 + #include <linux/linkage.h> 12 + #include <linux/sched.h> 13 + #include <asm/ptrace.h> 14 + 15 + #define BREAKINST 0x5730 /* trapa #3 */ 16 + 17 + /* disable singlestep */ 18 + void user_disable_single_step(struct task_struct *child) 19 + { 20 + if ((long)child->thread.breakinfo.addr != -1L) { 21 + *(child->thread.breakinfo.addr) = child->thread.breakinfo.inst; 22 + child->thread.breakinfo.addr = (unsigned short *)-1L; 23 + } 24 + } 25 + 26 + /* calculate next pc */ 27 + enum jump_type {none, /* normal instruction */ 28 + jabs, /* absolute address jump */ 29 + ind, /* indirect address jump */ 30 + ret, /* return to subrutine */ 31 + reg, /* register indexed jump */ 32 + relb, /* pc relative jump (byte offset) */ 33 + relw, /* pc relative jump (word offset) */ 34 + }; 35 + 36 + /* opcode decode table define 37 + ptn: opcode pattern 38 + msk: opcode bitmask 39 + len: instruction length (<0 next table index) 40 + jmp: jump operation mode */ 41 + struct optable { 42 + unsigned char bitpattern; 43 + unsigned char bitmask; 44 + signed char length; 45 + signed char type; 46 + } __packed __aligned(1); 47 + 48 + #define OPTABLE(ptn, msk, len, jmp) \ 49 + { \ 50 + .bitpattern = ptn, \ 51 + .bitmask = msk, \ 52 + .length = len, \ 53 + .type = jmp, \ 54 + } 55 + 56 + static const struct optable optable_0[] = { 57 + OPTABLE(0x00, 0xff, 1, none), /* 0x00 */ 58 + OPTABLE(0x01, 0xff, -1, none), /* 0x01 */ 59 + OPTABLE(0x02, 0xfe, 1, none), /* 0x02-0x03 */ 60 + OPTABLE(0x04, 0xee, 1, none), /* 0x04-0x05/0x14-0x15 */ 61 + OPTABLE(0x06, 0xfe, 1, none), /* 0x06-0x07 */ 62 + OPTABLE(0x08, 0xea, 1, none), /* 0x08-0x09/0x0c-0x0d/0x18-0x19/0x1c-0x1d */ 63 + OPTABLE(0x0a, 0xee, 1, none), /* 0x0a-0x0b/0x1a-0x1b */ 64 + OPTABLE(0x0e, 0xee, 1, none), /* 0x0e-0x0f/0x1e-0x1f */ 65 + OPTABLE(0x10, 0xfc, 1, none), /* 0x10-0x13 */ 66 + OPTABLE(0x16, 0xfe, 1, none), /* 0x16-0x17 */ 67 + OPTABLE(0x20, 0xe0, 1, none), /* 0x20-0x3f */ 68 + OPTABLE(0x40, 0xf0, 1, relb), /* 0x40-0x4f */ 69 + OPTABLE(0x50, 0xfc, 1, none), /* 0x50-0x53 */ 70 + OPTABLE(0x54, 0xfd, 1, ret), /* 0x54/0x56 */ 71 + OPTABLE(0x55, 0xff, 1, relb), /* 0x55 */ 72 + OPTABLE(0x57, 0xff, 1, none), /* 0x57 */ 73 + OPTABLE(0x58, 0xfb, 2, relw), /* 0x58/0x5c */ 74 + OPTABLE(0x59, 0xfb, 1, reg), /* 0x59/0x5b */ 75 + OPTABLE(0x5a, 0xfb, 2, jabs), /* 0x5a/0x5e */ 76 + OPTABLE(0x5b, 0xfb, 2, ind), /* 0x5b/0x5f */ 77 + OPTABLE(0x60, 0xe8, 1, none), /* 0x60-0x67/0x70-0x77 */ 78 + OPTABLE(0x68, 0xfa, 1, none), /* 0x68-0x69/0x6c-0x6d */ 79 + OPTABLE(0x6a, 0xfe, -2, none), /* 0x6a-0x6b */ 80 + OPTABLE(0x6e, 0xfe, 2, none), /* 0x6e-0x6f */ 81 + OPTABLE(0x78, 0xff, 4, none), /* 0x78 */ 82 + OPTABLE(0x79, 0xff, 2, none), /* 0x79 */ 83 + OPTABLE(0x7a, 0xff, 3, none), /* 0x7a */ 84 + OPTABLE(0x7b, 0xff, 2, none), /* 0x7b */ 85 + OPTABLE(0x7c, 0xfc, 2, none), /* 0x7c-0x7f */ 86 + OPTABLE(0x80, 0x80, 1, none), /* 0x80-0xff */ 87 + }; 88 + 89 + static const struct optable optable_1[] = { 90 + OPTABLE(0x00, 0xff, -3, none), /* 0x0100 */ 91 + OPTABLE(0x40, 0xf0, -3, none), /* 0x0140-0x14f */ 92 + OPTABLE(0x80, 0xf0, 1, none), /* 0x0180-0x018f */ 93 + OPTABLE(0xc0, 0xc0, 2, none), /* 0x01c0-0x01ff */ 94 + }; 95 + 96 + static const struct optable optable_2[] = { 97 + OPTABLE(0x00, 0x20, 2, none), /* 0x6a0?/0x6a8?/0x6b0?/0x6b8? */ 98 + OPTABLE(0x20, 0x20, 3, none), /* 0x6a2?/0x6aa?/0x6b2?/0x6ba? */ 99 + }; 100 + 101 + static const struct optable optable_3[] = { 102 + OPTABLE(0x69, 0xfb, 2, none), /* 0x010069/0x01006d/014069/0x01406d */ 103 + OPTABLE(0x6b, 0xff, -4, none), /* 0x01006b/0x01406b */ 104 + OPTABLE(0x6f, 0xff, 3, none), /* 0x01006f/0x01406f */ 105 + OPTABLE(0x78, 0xff, 5, none), /* 0x010078/0x014078 */ 106 + }; 107 + 108 + static const struct optable optable_4[] = { 109 + /* 0x0100690?/0x01006d0?/0140690?/0x01406d0?/ 110 + 0x0100698?/0x01006d8?/0140698?/0x01406d8? */ 111 + OPTABLE(0x00, 0x78, 3, none), 112 + /* 0x0100692?/0x01006d2?/0140692?/0x01406d2?/ 113 + 0x010069a?/0x01006da?/014069a?/0x01406da? */ 114 + OPTABLE(0x20, 0x78, 4, none), 115 + }; 116 + 117 + static const struct optables_list { 118 + const struct optable *ptr; 119 + int size; 120 + } optables[] = { 121 + #define OPTABLES(no) \ 122 + { \ 123 + .ptr = optable_##no, \ 124 + .size = sizeof(optable_##no) / sizeof(struct optable), \ 125 + } 126 + OPTABLES(0), 127 + OPTABLES(1), 128 + OPTABLES(2), 129 + OPTABLES(3), 130 + OPTABLES(4), 131 + 132 + }; 133 + 134 + const unsigned char condmask[] = { 135 + 0x00, 0x40, 0x01, 0x04, 0x02, 0x08, 0x10, 0x20 136 + }; 137 + 138 + static int isbranch(struct task_struct *task, int reson) 139 + { 140 + unsigned char cond = h8300_get_reg(task, PT_CCR); 141 + 142 + /* encode complex conditions */ 143 + /* B4: N^V 144 + B5: Z|(N^V) 145 + B6: C|Z */ 146 + __asm__("bld #3,%w0\n\t" 147 + "bxor #1,%w0\n\t" 148 + "bst #4,%w0\n\t" 149 + "bor #2,%w0\n\t" 150 + "bst #5,%w0\n\t" 151 + "bld #2,%w0\n\t" 152 + "bor #0,%w0\n\t" 153 + "bst #6,%w0\n\t" 154 + : "=&r"(cond) : "0"(cond) : "cc"); 155 + cond &= condmask[reson >> 1]; 156 + if (!(reson & 1)) 157 + return cond == 0; 158 + else 159 + return cond != 0; 160 + } 161 + 162 + static unsigned short *decode(struct task_struct *child, 163 + const struct optable *op, 164 + char *fetch_p, unsigned short *pc, 165 + unsigned char inst) 166 + { 167 + unsigned long addr; 168 + unsigned long *sp; 169 + int regno; 170 + 171 + switch (op->type) { 172 + case none: 173 + return (unsigned short *)pc + op->length; 174 + case jabs: 175 + addr = *(unsigned long *)pc; 176 + return (unsigned short *)(addr & 0x00ffffff); 177 + case ind: 178 + addr = *pc & 0xff; 179 + return (unsigned short *)(*(unsigned long *)addr); 180 + case ret: 181 + sp = (unsigned long *)h8300_get_reg(child, PT_USP); 182 + /* user stack frames 183 + | er0 | temporary saved 184 + +--------+ 185 + | exp | exception stack frames 186 + +--------+ 187 + | ret pc | userspace return address 188 + */ 189 + return (unsigned short *)(*(sp+2) & 0x00ffffff); 190 + case reg: 191 + regno = (*pc >> 4) & 0x07; 192 + if (regno == 0) 193 + addr = h8300_get_reg(child, PT_ER0); 194 + else 195 + addr = h8300_get_reg(child, regno-1 + PT_ER1); 196 + return (unsigned short *)addr; 197 + case relb: 198 + if (inst == 0x55 || isbranch(child, inst & 0x0f)) 199 + pc = (unsigned short *)((unsigned long)pc + 200 + ((signed char)(*fetch_p))); 201 + return pc+1; /* skip myself */ 202 + case relw: 203 + if (inst == 0x5c || isbranch(child, (*fetch_p & 0xf0) >> 4)) 204 + pc = (unsigned short *)((unsigned long)pc + 205 + ((signed short)(*(pc+1)))); 206 + return pc+2; /* skip myself */ 207 + default: 208 + return NULL; 209 + } 210 + } 211 + 212 + static unsigned short *nextpc(struct task_struct *child, unsigned short *pc) 213 + { 214 + const struct optable *op; 215 + unsigned char *fetch_p; 216 + int op_len; 217 + unsigned char inst; 218 + 219 + op = optables[0].ptr; 220 + op_len = optables[0].size; 221 + fetch_p = (unsigned char *)pc; 222 + inst = *fetch_p++; 223 + do { 224 + if ((inst & op->bitmask) == op->bitpattern) { 225 + if (op->length < 0) { 226 + op = optables[-op->length].ptr; 227 + op_len = optables[-op->length].size + 1; 228 + inst = *fetch_p++; 229 + } else 230 + return decode(child, op, fetch_p, pc, inst); 231 + } else 232 + op++; 233 + } while (--op_len > 0); 234 + return NULL; 235 + } 236 + 237 + /* Set breakpoint(s) to simulate a single step from the current PC. */ 238 + 239 + void user_enable_single_step(struct task_struct *child) 240 + { 241 + unsigned short *next; 242 + 243 + next = nextpc(child, (unsigned short *)h8300_get_reg(child, PT_PC)); 244 + child->thread.breakinfo.addr = next; 245 + child->thread.breakinfo.inst = *next; 246 + *next = BREAKINST; 247 + } 248 + 249 + asmlinkage void trace_trap(unsigned long bp) 250 + { 251 + if ((unsigned long)current->thread.breakinfo.addr == bp) { 252 + user_disable_single_step(current); 253 + force_sig(SIGTRAP, current); 254 + } else 255 + force_sig(SIGILL, current); 256 + }
+44
arch/h8300/kernel/ptrace_s.c
··· 1 + /* 2 + * linux/arch/h8300/kernel/ptrace_h8s.c 3 + * ptrace cpu depend helper functions 4 + * 5 + * Yoshinori Sato <ysato@users.sourceforge.jp> 6 + * 7 + * This file is subject to the terms and conditions of the GNU General 8 + * Public License. See the file COPYING in the main directory of 9 + * this archive for more details. 10 + */ 11 + 12 + #include <linux/linkage.h> 13 + #include <linux/sched.h> 14 + #include <linux/errno.h> 15 + #include <asm/ptrace.h> 16 + 17 + #define CCR_MASK 0x6f 18 + #define EXR_TRACE 0x80 19 + 20 + /* disable singlestep */ 21 + void user_disable_single_step(struct task_struct *child) 22 + { 23 + unsigned char exr; 24 + 25 + exr = h8300_get_reg(child, PT_EXR); 26 + exr &= ~EXR_TRACE; 27 + h8300_put_reg(child, PT_EXR, exr); 28 + } 29 + 30 + /* enable singlestep */ 31 + void user_enable_single_step(struct task_struct *child) 32 + { 33 + unsigned char exr; 34 + 35 + exr = h8300_get_reg(child, PT_EXR); 36 + exr |= EXR_TRACE; 37 + h8300_put_reg(child, PT_EXR, exr); 38 + } 39 + 40 + asmlinkage void trace_trap(unsigned long bp) 41 + { 42 + (void)bp; 43 + force_sig(SIGTRAP, current); 44 + }
+255
arch/h8300/kernel/setup.c
··· 1 + /* 2 + * linux/arch/h8300/kernel/setup.c 3 + * 4 + * Copyright (C) 2001-2014 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + */ 6 + 7 + /* 8 + * This file handles the architecture-dependent parts of system setup 9 + */ 10 + 11 + #include <linux/kernel.h> 12 + #include <linux/sched.h> 13 + #include <linux/delay.h> 14 + #include <linux/interrupt.h> 15 + #include <linux/mm.h> 16 + #include <linux/fs.h> 17 + #include <linux/console.h> 18 + #include <linux/errno.h> 19 + #include <linux/string.h> 20 + #include <linux/bootmem.h> 21 + #include <linux/seq_file.h> 22 + #include <linux/init.h> 23 + #include <linux/platform_device.h> 24 + #include <linux/module.h> 25 + #include <linux/of.h> 26 + #include <linux/of_fdt.h> 27 + #include <linux/of_platform.h> 28 + #include <linux/of_address.h> 29 + #include <linux/clk-provider.h> 30 + #include <linux/memblock.h> 31 + #include <linux/screen_info.h> 32 + 33 + #include <asm/setup.h> 34 + #include <asm/irq.h> 35 + #include <asm/pgtable.h> 36 + #include <asm/sections.h> 37 + #include <asm/page.h> 38 + 39 + #if defined(CONFIG_CPU_H8300H) 40 + #define CPU "H8/300H" 41 + #elif defined(CONFIG_CPU_H8S) 42 + #define CPU "H8S" 43 + #else 44 + #define CPU "Unknown" 45 + #endif 46 + 47 + unsigned long memory_start; 48 + unsigned long memory_end; 49 + EXPORT_SYMBOL(memory_end); 50 + static unsigned long freq; 51 + extern char __dtb_start[]; 52 + 53 + #ifdef CONFIG_VT 54 + struct screen_info screen_info; 55 + #endif 56 + 57 + char __initdata command_line[COMMAND_LINE_SIZE]; 58 + 59 + void sim_console_register(void); 60 + 61 + void __init h8300_fdt_init(void *fdt, char *bootargs) 62 + { 63 + if (!fdt) 64 + fdt = __dtb_start; 65 + else 66 + strcpy(command_line, bootargs); 67 + 68 + early_init_dt_scan(fdt); 69 + memblock_allow_resize(); 70 + } 71 + 72 + static void __init bootmem_init(void) 73 + { 74 + int bootmap_size; 75 + unsigned long ram_start_pfn; 76 + unsigned long free_ram_start_pfn; 77 + unsigned long ram_end_pfn; 78 + struct memblock_region *region; 79 + 80 + memory_end = memory_start = 0; 81 + 82 + /* Find main memory where is the kernel */ 83 + for_each_memblock(memory, region) { 84 + memory_start = region->base; 85 + memory_end = region->base + region->size; 86 + } 87 + 88 + if (!memory_end) 89 + panic("No memory!"); 90 + 91 + ram_start_pfn = PFN_UP(memory_start); 92 + /* free_ram_start_pfn is first page after kernel */ 93 + free_ram_start_pfn = PFN_UP(__pa(_end)); 94 + ram_end_pfn = PFN_DOWN(memblock_end_of_DRAM()); 95 + 96 + max_pfn = ram_end_pfn; 97 + 98 + /* 99 + * give all the memory to the bootmap allocator, tell it to put the 100 + * boot mem_map at the start of memory 101 + */ 102 + bootmap_size = init_bootmem_node(NODE_DATA(0), 103 + free_ram_start_pfn, 104 + 0, 105 + ram_end_pfn); 106 + /* 107 + * free the usable memory, we have to make sure we do not free 108 + * the bootmem bitmap so we then reserve it after freeing it :-) 109 + */ 110 + free_bootmem(PFN_PHYS(free_ram_start_pfn), 111 + (ram_end_pfn - free_ram_start_pfn) << PAGE_SHIFT); 112 + reserve_bootmem(PFN_PHYS(free_ram_start_pfn), bootmap_size, 113 + BOOTMEM_DEFAULT); 114 + 115 + for_each_memblock(reserved, region) { 116 + reserve_bootmem(region->base, region->size, BOOTMEM_DEFAULT); 117 + } 118 + } 119 + 120 + void __init setup_arch(char **cmdline_p) 121 + { 122 + unflatten_and_copy_device_tree(); 123 + 124 + init_mm.start_code = (unsigned long) _stext; 125 + init_mm.end_code = (unsigned long) _etext; 126 + init_mm.end_data = (unsigned long) _edata; 127 + init_mm.brk = (unsigned long) 0; 128 + 129 + pr_notice("\r\n\nuClinux " CPU "\n"); 130 + pr_notice("Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n"); 131 + 132 + if (*command_line) 133 + strcpy(boot_command_line, command_line); 134 + *cmdline_p = boot_command_line; 135 + 136 + parse_early_param(); 137 + 138 + bootmem_init(); 139 + #if defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM) 140 + sim_console_register(); 141 + #endif 142 + 143 + early_platform_driver_probe("earlyprintk", 1, 0); 144 + /* 145 + * get kmalloc into gear 146 + */ 147 + paging_init(); 148 + } 149 + 150 + /* 151 + * Get CPU information for use by the procfs. 152 + */ 153 + 154 + static int show_cpuinfo(struct seq_file *m, void *v) 155 + { 156 + char *cpu; 157 + 158 + cpu = CPU; 159 + 160 + seq_printf(m, "CPU:\t\t%s\n" 161 + "Clock:\t\t%lu.%1luMHz\n" 162 + "BogoMips:\t%lu.%02lu\n" 163 + "Calibration:\t%lu loops\n", 164 + cpu, 165 + freq/1000, freq%1000, 166 + (loops_per_jiffy*HZ)/500000, 167 + ((loops_per_jiffy*HZ)/5000)%100, 168 + (loops_per_jiffy*HZ)); 169 + 170 + return 0; 171 + } 172 + 173 + static void *c_start(struct seq_file *m, loff_t *pos) 174 + { 175 + return *pos < num_possible_cpus() ? 176 + ((void *) 0x12345678) : NULL; 177 + } 178 + 179 + static void *c_next(struct seq_file *m, void *v, loff_t *pos) 180 + { 181 + ++*pos; 182 + return c_start(m, pos); 183 + } 184 + 185 + static void c_stop(struct seq_file *m, void *v) 186 + { 187 + } 188 + 189 + const struct seq_operations cpuinfo_op = { 190 + .start = c_start, 191 + .next = c_next, 192 + .stop = c_stop, 193 + .show = show_cpuinfo, 194 + }; 195 + 196 + static int __init device_probe(void) 197 + { 198 + of_platform_populate(NULL, NULL, NULL, NULL); 199 + 200 + return 0; 201 + } 202 + 203 + device_initcall(device_probe); 204 + 205 + #if defined(CONFIG_CPU_H8300H) 206 + #define get_wait(base, addr) ({ \ 207 + int baddr; \ 208 + baddr = ((addr) / 0x200000 * 2); \ 209 + w *= (ctrl_inw((unsigned long)(base) + 2) & (3 << baddr)) + 1; \ 210 + }) 211 + #endif 212 + #if defined(CONFIG_CPU_H8S) 213 + #define get_wait(base, addr) ({ \ 214 + int baddr; \ 215 + baddr = ((addr) / 0x200000 * 16); \ 216 + w *= (ctrl_inl((unsigned long)(base) + 2) & (7 << baddr)) + 1; \ 217 + }) 218 + #endif 219 + 220 + static __init int access_timing(void) 221 + { 222 + struct device_node *bsc; 223 + void __iomem *base; 224 + unsigned long addr = (unsigned long)&__delay; 225 + int bit = 1 << (addr / 0x200000); 226 + int w; 227 + 228 + bsc = of_find_compatible_node(NULL, NULL, "renesas,h8300-bsc"); 229 + base = of_iomap(bsc, 0); 230 + w = (ctrl_inb((unsigned long)base + 0) & bit)?2:1; 231 + if (ctrl_inb((unsigned long)base + 1) & bit) 232 + w *= get_wait(base, addr); 233 + else 234 + w *= 2; 235 + return w * 3 / 2; 236 + } 237 + 238 + void __init calibrate_delay(void) 239 + { 240 + struct device_node *cpu; 241 + int freq; 242 + 243 + cpu = of_find_compatible_node(NULL, NULL, "renesas,h8300"); 244 + of_property_read_s32(cpu, "clock-frequency", &freq); 245 + loops_per_jiffy = freq / HZ / (access_timing() * 2); 246 + pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n", 247 + loops_per_jiffy / (500000 / HZ), 248 + (loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy); 249 + } 250 + 251 + 252 + void __init time_init(void) 253 + { 254 + of_clk_init(NULL); 255 + }
+289
arch/h8300/kernel/signal.c
··· 1 + /* 2 + * linux/arch/h8300/kernel/signal.c 3 + * 4 + * Copyright (C) 1991, 1992 Linus Torvalds 5 + * 6 + * This file is subject to the terms and conditions of the GNU General Public 7 + * License. See the file COPYING in the main directory of this archive 8 + * for more details. 9 + */ 10 + 11 + /* 12 + * uClinux H8/300 support by Yoshinori Sato <ysato@users.sourceforge.jp> 13 + * and David McCullough <davidm@snapgear.com> 14 + * 15 + * Based on 16 + * Linux/m68k by Hamish Macdonald 17 + */ 18 + 19 + /* 20 + * ++roman (07/09/96): implemented signal stacks (specially for tosemu on 21 + * Atari :-) Current limitation: Only one sigstack can be active at one time. 22 + * If a second signal with SA_ONSTACK set arrives while working on a sigstack, 23 + * SA_ONSTACK is ignored. This behaviour avoids lots of trouble with nested 24 + * signal handlers! 25 + */ 26 + 27 + #include <linux/sched.h> 28 + #include <linux/mm.h> 29 + #include <linux/kernel.h> 30 + #include <linux/signal.h> 31 + #include <linux/syscalls.h> 32 + #include <linux/errno.h> 33 + #include <linux/wait.h> 34 + #include <linux/ptrace.h> 35 + #include <linux/unistd.h> 36 + #include <linux/stddef.h> 37 + #include <linux/highuid.h> 38 + #include <linux/personality.h> 39 + #include <linux/tty.h> 40 + #include <linux/binfmts.h> 41 + #include <linux/tracehook.h> 42 + 43 + #include <asm/setup.h> 44 + #include <asm/uaccess.h> 45 + #include <asm/pgtable.h> 46 + #include <asm/traps.h> 47 + #include <asm/ucontext.h> 48 + 49 + /* 50 + * Do a signal return; undo the signal stack. 51 + * 52 + * Keep the return code on the stack quadword aligned! 53 + * That makes the cache flush below easier. 54 + */ 55 + 56 + struct rt_sigframe { 57 + long dummy_er0; 58 + long dummy_vector; 59 + #if defined(CONFIG_CPU_H8S) 60 + short dummy_exr; 61 + #endif 62 + long dummy_pc; 63 + char *pretcode; 64 + struct siginfo *pinfo; 65 + void *puc; 66 + unsigned char retcode[8]; 67 + struct siginfo info; 68 + struct ucontext uc; 69 + int sig; 70 + } __packed __aligned(2); 71 + 72 + static inline int 73 + restore_sigcontext(struct sigcontext *usc, int *pd0) 74 + { 75 + struct pt_regs *regs = current_pt_regs(); 76 + int err = 0; 77 + unsigned int ccr; 78 + unsigned int usp; 79 + unsigned int er0; 80 + 81 + /* Always make any pending restarted system calls return -EINTR */ 82 + current_thread_info()->restart_block.fn = do_no_restart_syscall; 83 + 84 + /* restore passed registers */ 85 + #define COPY(r) do { err |= get_user(regs->r, &usc->sc_##r); } while (0) 86 + COPY(er1); 87 + COPY(er2); 88 + COPY(er3); 89 + COPY(er5); 90 + COPY(pc); 91 + ccr = regs->ccr & 0x10; 92 + COPY(ccr); 93 + #undef COPY 94 + regs->ccr &= 0xef; 95 + regs->ccr |= ccr; 96 + regs->orig_er0 = -1; /* disable syscall checks */ 97 + err |= __get_user(usp, &usc->sc_usp); 98 + wrusp(usp); 99 + 100 + err |= __get_user(er0, &usc->sc_er0); 101 + *pd0 = er0; 102 + return err; 103 + } 104 + 105 + asmlinkage int sys_rt_sigreturn(void) 106 + { 107 + unsigned long usp = rdusp(); 108 + struct rt_sigframe *frame = (struct rt_sigframe *)(usp - 4); 109 + sigset_t set; 110 + int er0; 111 + 112 + if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) 113 + goto badframe; 114 + if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) 115 + goto badframe; 116 + 117 + set_current_blocked(&set); 118 + 119 + if (restore_sigcontext(&frame->uc.uc_mcontext, &er0)) 120 + goto badframe; 121 + 122 + if (restore_altstack(&frame->uc.uc_stack)) 123 + goto badframe; 124 + 125 + return er0; 126 + 127 + badframe: 128 + force_sig(SIGSEGV, current); 129 + return 0; 130 + } 131 + 132 + static int setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, 133 + unsigned long mask) 134 + { 135 + int err = 0; 136 + 137 + err |= __put_user(regs->er0, &sc->sc_er0); 138 + err |= __put_user(regs->er1, &sc->sc_er1); 139 + err |= __put_user(regs->er2, &sc->sc_er2); 140 + err |= __put_user(regs->er3, &sc->sc_er3); 141 + err |= __put_user(regs->er4, &sc->sc_er4); 142 + err |= __put_user(regs->er5, &sc->sc_er5); 143 + err |= __put_user(regs->er6, &sc->sc_er6); 144 + err |= __put_user(rdusp(), &sc->sc_usp); 145 + err |= __put_user(regs->pc, &sc->sc_pc); 146 + err |= __put_user(regs->ccr, &sc->sc_ccr); 147 + err |= __put_user(mask, &sc->sc_mask); 148 + 149 + return err; 150 + } 151 + 152 + static inline void __user * 153 + get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size) 154 + { 155 + return (void __user *)((sigsp(rdusp(), ksig) - frame_size) & -8UL); 156 + } 157 + 158 + static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, 159 + struct pt_regs *regs) 160 + { 161 + struct rt_sigframe *frame; 162 + int err = 0; 163 + unsigned char *ret; 164 + 165 + frame = get_sigframe(ksig, regs, sizeof(*frame)); 166 + 167 + if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 168 + return -EFAULT; 169 + 170 + if (ksig->ka.sa.sa_flags & SA_SIGINFO) 171 + err |= copy_siginfo_to_user(&frame->info, &ksig->info); 172 + 173 + /* Create the ucontext. */ 174 + err |= __put_user(0, &frame->uc.uc_flags); 175 + err |= __put_user(0, &frame->uc.uc_link); 176 + err |= __save_altstack(&frame->uc.uc_stack, rdusp()); 177 + err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]); 178 + err |= copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); 179 + if (err) 180 + return -EFAULT; 181 + 182 + /* Set up to return from userspace. */ 183 + ret = frame->retcode; 184 + if (ksig->ka.sa.sa_flags & SA_RESTORER) 185 + ret = (unsigned char *)(ksig->ka.sa.sa_restorer); 186 + else { 187 + /* sub.l er0,er0; mov.b #__NR_rt_sigreturn,r0l; trapa #0 */ 188 + err |= __put_user(0x1a80f800 + (__NR_rt_sigreturn & 0xff), 189 + (unsigned long *)(frame->retcode + 0)); 190 + err |= __put_user(0x5700, 191 + (unsigned short *)(frame->retcode + 4)); 192 + } 193 + err |= __put_user(ret, &frame->pretcode); 194 + 195 + if (err) 196 + return -EFAULT; 197 + 198 + /* Set up registers for signal handler */ 199 + wrusp((unsigned long) frame); 200 + regs->pc = (unsigned long) ksig->ka.sa.sa_handler; 201 + regs->er0 = ksig->sig; 202 + regs->er1 = (unsigned long)&(frame->info); 203 + regs->er2 = (unsigned long)&frame->uc; 204 + regs->er5 = current->mm->start_data; /* GOT base */ 205 + 206 + return 0; 207 + } 208 + 209 + static void 210 + handle_restart(struct pt_regs *regs, struct k_sigaction *ka) 211 + { 212 + switch (regs->er0) { 213 + case -ERESTARTNOHAND: 214 + if (!ka) 215 + goto do_restart; 216 + regs->er0 = -EINTR; 217 + break; 218 + case -ERESTART_RESTARTBLOCK: 219 + if (!ka) { 220 + regs->er0 = __NR_restart_syscall; 221 + regs->pc -= 2; 222 + } else 223 + regs->er0 = -EINTR; 224 + break; 225 + case -ERESTARTSYS: 226 + if (!(ka->sa.sa_flags & SA_RESTART)) { 227 + regs->er0 = -EINTR; 228 + break; 229 + } 230 + /* fallthrough */ 231 + case -ERESTARTNOINTR: 232 + do_restart: 233 + regs->er0 = regs->orig_er0; 234 + regs->pc -= 2; 235 + break; 236 + } 237 + } 238 + 239 + /* 240 + * OK, we're invoking a handler 241 + */ 242 + static void 243 + handle_signal(struct ksignal *ksig, struct pt_regs *regs) 244 + { 245 + sigset_t *oldset = sigmask_to_save(); 246 + int ret; 247 + /* are we from a system call? */ 248 + if (regs->orig_er0 >= 0) 249 + handle_restart(regs, &ksig->ka); 250 + 251 + ret = setup_rt_frame(ksig, oldset, regs); 252 + 253 + signal_setup_done(ret, ksig, 0); 254 + } 255 + 256 + /* 257 + * Note that 'init' is a special process: it doesn't get signals it doesn't 258 + * want to handle. Thus you cannot kill init even with a SIGKILL even by 259 + * mistake. 260 + */ 261 + static void do_signal(struct pt_regs *regs) 262 + { 263 + struct ksignal ksig; 264 + 265 + current->thread.esp0 = (unsigned long) regs; 266 + 267 + if (get_signal(&ksig)) { 268 + /* Whee! Actually deliver the signal. */ 269 + handle_signal(&ksig, regs); 270 + return; 271 + } 272 + /* Did we come from a system call? */ 273 + if (regs->orig_er0 >= 0) 274 + handle_restart(regs, NULL); 275 + 276 + /* If there's no signal to deliver, we just restore the saved mask. */ 277 + restore_saved_sigmask(); 278 + } 279 + 280 + asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags) 281 + { 282 + if (thread_info_flags & _TIF_SIGPENDING) 283 + do_signal(regs); 284 + 285 + if (thread_info_flags & _TIF_NOTIFY_RESUME) { 286 + clear_thread_flag(TIF_NOTIFY_RESUME); 287 + tracehook_notify_resume(regs); 288 + } 289 + }
+79
arch/h8300/kernel/sim-console.c
··· 1 + /* 2 + * arch/h8300/kernel/early_printk.c 3 + * 4 + * Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + * 6 + * This file is subject to the terms and conditions of the GNU General Public 7 + * License. See the file "COPYING" in the main directory of this archive 8 + * for more details. 9 + */ 10 + #include <linux/console.h> 11 + #include <linux/tty.h> 12 + #include <linux/init.h> 13 + #include <linux/io.h> 14 + #include <linux/platform_device.h> 15 + 16 + static void sim_write(struct console *co, const char *ptr, 17 + unsigned len) 18 + { 19 + register const int fd __asm__("er0") = 1; /* stdout */ 20 + register const char *_ptr __asm__("er1") = ptr; 21 + register const unsigned _len __asm__("er2") = len; 22 + 23 + __asm__(".byte 0x5e,0x00,0x00,0xc7\n\t" /* jsr @0xc7 (sys_write) */ 24 + : : "g"(fd), "g"(_ptr), "g"(_len)); 25 + } 26 + 27 + static struct console sim_console = { 28 + .name = "sim_console", 29 + .write = sim_write, 30 + .setup = NULL, 31 + .flags = CON_PRINTBUFFER, 32 + .index = -1, 33 + }; 34 + 35 + static char sim_console_buf[32]; 36 + 37 + static int sim_probe(struct platform_device *pdev) 38 + { 39 + if (sim_console.data) 40 + return -EEXIST; 41 + 42 + if (!strstr(sim_console_buf, "keep")) 43 + sim_console.flags |= CON_BOOT; 44 + 45 + register_console(&sim_console); 46 + return 0; 47 + } 48 + 49 + static int sim_remove(struct platform_device *pdev) 50 + { 51 + return 0; 52 + } 53 + 54 + static struct platform_driver sim_driver = { 55 + .probe = sim_probe, 56 + .remove = sim_remove, 57 + .driver = { 58 + .name = "h8300-sim", 59 + .owner = THIS_MODULE, 60 + }, 61 + }; 62 + 63 + early_platform_init_buffer("earlyprintk", &sim_driver, 64 + sim_console_buf, ARRAY_SIZE(sim_console_buf)); 65 + 66 + static struct platform_device sim_console_device = { 67 + .name = "h8300-sim", 68 + .id = 0, 69 + }; 70 + 71 + static struct platform_device *devices[] __initdata = { 72 + &sim_console_device, 73 + }; 74 + 75 + void __init sim_console_register(void) 76 + { 77 + early_platform_add_devices(devices, 78 + ARRAY_SIZE(devices)); 79 + }
+14
arch/h8300/kernel/syscalls.c
··· 1 + #include <linux/syscalls.h> 2 + #include <linux/signal.h> 3 + #include <linux/unistd.h> 4 + 5 + #undef __SYSCALL 6 + #define __SYSCALL(nr, call) [nr] = (call), 7 + 8 + #define sys_mmap2 sys_mmap_pgoff 9 + 10 + asmlinkage int sys_rt_sigreturn(void); 11 + 12 + void *_sys_call_table[__NR_syscalls] = { 13 + #include <asm/unistd.h> 14 + };
+161
arch/h8300/kernel/traps.c
··· 1 + /* 2 + * linux/arch/h8300/boot/traps.c -- general exception handling code 3 + * H8/300 support Yoshinori Sato <ysato@users.sourceforge.jp> 4 + * 5 + * Cloned from Linux/m68k. 6 + * 7 + * No original Copyright holder listed, 8 + * Probable original (C) Roman Zippel (assigned DJD, 1999) 9 + * 10 + * Copyright 1999-2000 D. Jeff Dionne, <jeff@rt-control.com> 11 + * 12 + * This file is subject to the terms and conditions of the GNU General Public 13 + * License. See the file COPYING in the main directory of this archive 14 + * for more details. 15 + */ 16 + 17 + #include <linux/types.h> 18 + #include <linux/sched.h> 19 + #include <linux/kernel.h> 20 + #include <linux/errno.h> 21 + #include <linux/init.h> 22 + #include <linux/module.h> 23 + #include <linux/bug.h> 24 + 25 + #include <asm/irq.h> 26 + #include <asm/traps.h> 27 + #include <asm/page.h> 28 + 29 + static DEFINE_SPINLOCK(die_lock); 30 + 31 + /* 32 + * this must be called very early as the kernel might 33 + * use some instruction that are emulated on the 060 34 + */ 35 + 36 + void __init base_trap_init(void) 37 + { 38 + } 39 + 40 + void __init trap_init(void) 41 + { 42 + } 43 + 44 + asmlinkage void set_esp0(unsigned long ssp) 45 + { 46 + current->thread.esp0 = ssp; 47 + } 48 + 49 + /* 50 + * Generic dumping code. Used for panic and debug. 51 + */ 52 + 53 + static void dump(struct pt_regs *fp) 54 + { 55 + unsigned long *sp; 56 + unsigned char *tp; 57 + int i; 58 + 59 + pr_info("\nCURRENT PROCESS:\n\n"); 60 + pr_info("COMM=%s PID=%d\n", current->comm, current->pid); 61 + if (current->mm) { 62 + pr_info("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n", 63 + (int) current->mm->start_code, 64 + (int) current->mm->end_code, 65 + (int) current->mm->start_data, 66 + (int) current->mm->end_data, 67 + (int) current->mm->end_data, 68 + (int) current->mm->brk); 69 + pr_info("USER-STACK=%08x KERNEL-STACK=%08lx\n\n", 70 + (int) current->mm->start_stack, 71 + (int) PAGE_SIZE+(unsigned long)current); 72 + } 73 + 74 + show_regs(fp); 75 + pr_info("\nCODE:"); 76 + tp = ((unsigned char *) fp->pc) - 0x20; 77 + for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) { 78 + if ((i % 0x10) == 0) 79 + pr_info("\n%08x: ", (int) (tp + i)); 80 + pr_info("%08x ", (int) *sp++); 81 + } 82 + pr_info("\n"); 83 + 84 + pr_info("\nKERNEL STACK:"); 85 + tp = ((unsigned char *) fp) - 0x40; 86 + for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) { 87 + if ((i % 0x10) == 0) 88 + pr_info("\n%08x: ", (int) (tp + i)); 89 + pr_info("%08x ", (int) *sp++); 90 + } 91 + pr_info("\n"); 92 + if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE)) 93 + pr_info("(Possibly corrupted stack page??)\n"); 94 + 95 + pr_info("\n\n"); 96 + } 97 + 98 + void die(const char *str, struct pt_regs *fp, unsigned long err) 99 + { 100 + static int diecount; 101 + 102 + oops_enter(); 103 + 104 + console_verbose(); 105 + spin_lock_irq(&die_lock); 106 + report_bug(fp->pc, fp); 107 + pr_crit("%s: %04lx [#%d] ", str, err & 0xffff, ++diecount); 108 + dump(fp); 109 + 110 + spin_unlock_irq(&die_lock); 111 + do_exit(SIGSEGV); 112 + } 113 + 114 + static int kstack_depth_to_print = 24; 115 + 116 + void show_stack(struct task_struct *task, unsigned long *esp) 117 + { 118 + unsigned long *stack, addr; 119 + int i; 120 + 121 + if (esp == NULL) 122 + esp = (unsigned long *) &esp; 123 + 124 + stack = esp; 125 + 126 + pr_info("Stack from %08lx:", (unsigned long)stack); 127 + for (i = 0; i < kstack_depth_to_print; i++) { 128 + if (((unsigned long)stack & (THREAD_SIZE - 1)) == 0) 129 + break; 130 + if (i % 8 == 0) 131 + pr_info("\n "); 132 + pr_info(" %08lx", *stack++); 133 + } 134 + 135 + pr_info("\nCall Trace:"); 136 + i = 0; 137 + stack = esp; 138 + while (((unsigned long)stack & (THREAD_SIZE - 1)) != 0) { 139 + addr = *stack++; 140 + /* 141 + * If the address is either in the text segment of the 142 + * kernel, or in the region which contains vmalloc'ed 143 + * memory, it *may* be the address of a calling 144 + * routine; if so, print it so that someone tracing 145 + * down the cause of the crash will be able to figure 146 + * out the call path that was taken. 147 + */ 148 + if (check_kernel_text(addr)) { 149 + if (i % 4 == 0) 150 + pr_info("\n "); 151 + pr_info(" [<%08lx>]", addr); 152 + i++; 153 + } 154 + } 155 + pr_info("\n"); 156 + } 157 + 158 + void show_trace_task(struct task_struct *tsk) 159 + { 160 + show_stack(tsk, (unsigned long *)tsk->thread.esp0); 161 + }
+67
arch/h8300/kernel/vmlinux.lds.S
··· 1 + #include <asm-generic/vmlinux.lds.h> 2 + #include <asm/page.h> 3 + 4 + #define ROMTOP 0x000000 5 + #define RAMTOP 0x400000 6 + 7 + jiffies = jiffies_64 + 4; 8 + 9 + ENTRY(_start) 10 + 11 + SECTIONS 12 + { 13 + #if defined(CONFIG_ROMKERNEL) 14 + . = ROMTOP; 15 + .vectors : 16 + { 17 + _vector = . ; 18 + *(.vector*) 19 + } 20 + #else 21 + . = RAMTOP; 22 + _ramstart = .; 23 + . = . + CONFIG_OFFSET; 24 + #endif 25 + _text = .; 26 + HEAD_TEXT_SECTION 27 + .text : { 28 + _stext = . ; 29 + TEXT_TEXT 30 + SCHED_TEXT 31 + LOCK_TEXT 32 + #if defined(CONFIG_ROMKERNEL) 33 + *(.int_redirect) 34 + #endif 35 + _etext = . ; 36 + } 37 + EXCEPTION_TABLE(16) 38 + NOTES 39 + RO_DATA_SECTION(4) 40 + ROMEND = .; 41 + #if defined(CONFIG_ROMKERNEL) 42 + . = RAMTOP; 43 + _ramstart = .; 44 + #define ADDR(x) ROMEND 45 + #else 46 + #endif 47 + _sdata = . ; 48 + __data_start = . ; 49 + RW_DATA_SECTION(0,0,0) 50 + #if defined(CONFIG_ROMKERNEL) 51 + #undef ADDR 52 + #endif 53 + . = ALIGN(0x4) ; 54 + __init_begin = .; 55 + INIT_TEXT_SECTION(4) 56 + INIT_DATA_SECTION(4) 57 + SECURITY_INIT 58 + __init_end = .; 59 + _edata = . ; 60 + _begin_data = LOADADDR(.data); 61 + _sbss =.; 62 + BSS_SECTION(0, 0 ,0) 63 + _ebss =.; 64 + _ramend = .; 65 + _end = .; 66 + DISCARDS 67 + }
+8
arch/h8300/lib/Makefile
··· 1 + # 2 + # Makefile for H8/300-specific library files.. 3 + # 4 + 5 + lib-y = memcpy.o memset.o abs.o strncpy.o \ 6 + mulsi3.o udivsi3.o muldi3.o moddivsi3.o \ 7 + ashldi3.o lshrdi3.o ashrdi3.o ucmpdi2.o \ 8 + delay.o
+20
arch/h8300/lib/abs.S
··· 1 + ;;; abs.S 2 + 3 + #include <asm/linkage.h> 4 + 5 + #if defined(CONFIG_CPU_H8300H) 6 + .h8300h 7 + #endif 8 + #if defined(CONFIG_CPU_H8S) 9 + .h8300s 10 + #endif 11 + .text 12 + .global _abs 13 + 14 + ;;; int abs(int n) 15 + _abs: 16 + mov.l er0,er0 17 + bpl 1f 18 + neg.l er0 19 + 1: 20 + rts
+24
arch/h8300/lib/ashldi3.c
··· 1 + #include "libgcc.h" 2 + 3 + DWtype 4 + __ashldi3(DWtype u, word_type b) 5 + { 6 + const DWunion uu = {.ll = u}; 7 + const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b; 8 + DWunion w; 9 + 10 + if (b == 0) 11 + return u; 12 + 13 + if (bm <= 0) { 14 + w.s.low = 0; 15 + w.s.high = (UWtype) uu.s.low << -bm; 16 + } else { 17 + const UWtype carries = (UWtype) uu.s.low >> bm; 18 + 19 + w.s.low = (UWtype) uu.s.low << b; 20 + w.s.high = ((UWtype) uu.s.high << b) | carries; 21 + } 22 + 23 + return w.ll; 24 + }
+24
arch/h8300/lib/ashrdi3.c
··· 1 + #include "libgcc.h" 2 + 3 + DWtype __ashrdi3(DWtype u, word_type b) 4 + { 5 + const DWunion uu = {.ll = u}; 6 + const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b; 7 + DWunion w; 8 + 9 + if (b == 0) 10 + return u; 11 + 12 + if (bm <= 0) { 13 + /* w.s.high = 1..1 or 0..0 */ 14 + w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1); 15 + w.s.low = uu.s.high >> -bm; 16 + } else { 17 + const UWtype carries = (UWtype) uu.s.high << bm; 18 + 19 + w.s.high = uu.s.high >> b; 20 + w.s.low = ((UWtype) uu.s.low >> b) | carries; 21 + } 22 + 23 + return w.ll; 24 + }
+40
arch/h8300/lib/delay.c
··· 1 + /* 2 + * delay loops 3 + * 4 + * Copyright (C) 2015 Yoshinori Sato 5 + */ 6 + 7 + #include <linux/module.h> 8 + #include <linux/delay.h> 9 + #include <asm/param.h> 10 + #include <asm/processor.h> 11 + #include <asm/timex.h> 12 + 13 + void __delay(unsigned long cycles) 14 + { 15 + __asm__ volatile ("1: dec.l #1,%0\n\t" 16 + "bne 1b":"=r"(cycles):"0"(cycles)); 17 + } 18 + EXPORT_SYMBOL(__delay); 19 + 20 + void __const_udelay(unsigned long xloops) 21 + { 22 + u64 loops; 23 + 24 + loops = (u64)xloops * loops_per_jiffy * HZ; 25 + 26 + __delay(loops >> 32); 27 + } 28 + EXPORT_SYMBOL(__const_udelay); 29 + 30 + void __udelay(unsigned long usecs) 31 + { 32 + __const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */ 33 + } 34 + EXPORT_SYMBOL(__udelay); 35 + 36 + void __ndelay(unsigned long nsecs) 37 + { 38 + __const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */ 39 + } 40 + EXPORT_SYMBOL(__ndelay);
+77
arch/h8300/lib/libgcc.h
··· 1 + #ifndef __H8300_LIBGCC_H__ 2 + #define __H8300_LIBGCC_H__ 3 + 4 + #ifdef __ASSEMBLY__ 5 + #define A0 r0 6 + #define A0L r0l 7 + #define A0H r0h 8 + 9 + #define A1 r1 10 + #define A1L r1l 11 + #define A1H r1h 12 + 13 + #define A2 r2 14 + #define A2L r2l 15 + #define A2H r2h 16 + 17 + #define A3 r3 18 + #define A3L r3l 19 + #define A3H r3h 20 + 21 + #define S0 r4 22 + #define S0L r4l 23 + #define S0H r4h 24 + 25 + #define S1 r5 26 + #define S1L r5l 27 + #define S1H r5h 28 + 29 + #define S2 r6 30 + #define S2L r6l 31 + #define S2H r6h 32 + 33 + #define PUSHP push.l 34 + #define POPP pop.l 35 + 36 + #define A0P er0 37 + #define A1P er1 38 + #define A2P er2 39 + #define A3P er3 40 + #define S0P er4 41 + #define S1P er5 42 + #define S2P er6 43 + 44 + #define A0E e0 45 + #define A1E e1 46 + #define A2E e2 47 + #define A3E e3 48 + #else 49 + #define Wtype SItype 50 + #define UWtype USItype 51 + #define HWtype SItype 52 + #define UHWtype USItype 53 + #define DWtype DItype 54 + #define UDWtype UDItype 55 + #define UWtype USItype 56 + #define Wtype SItype 57 + #define UWtype USItype 58 + #define W_TYPE_SIZE (4 * BITS_PER_UNIT) 59 + #define BITS_PER_UNIT (8) 60 + 61 + typedef int SItype __attribute__ ((mode (SI))); 62 + typedef unsigned int USItype __attribute__ ((mode (SI))); 63 + typedef int DItype __attribute__ ((mode (DI))); 64 + typedef unsigned int UDItype __attribute__ ((mode (DI))); 65 + struct DWstruct { 66 + Wtype high, low; 67 + }; 68 + typedef union { 69 + struct DWstruct s; 70 + DWtype ll; 71 + } DWunion; 72 + 73 + typedef int word_type __attribute__ ((mode (__word__))); 74 + 75 + #endif 76 + 77 + #endif
+23
arch/h8300/lib/lshrdi3.c
··· 1 + #include "libgcc.h" 2 + 3 + DWtype __lshrdi3(DWtype u, word_type b) 4 + { 5 + const DWunion uu = {.ll = u}; 6 + const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b; 7 + DWunion w; 8 + 9 + if (b == 0) 10 + return u; 11 + 12 + if (bm <= 0) { 13 + w.s.high = 0; 14 + w.s.low = (UWtype) uu.s.high >> -bm; 15 + } else { 16 + const UWtype carries = (UWtype) uu.s.high << bm; 17 + 18 + w.s.high = (UWtype) uu.s.high >> b; 19 + w.s.low = ((UWtype) uu.s.low >> b) | carries; 20 + } 21 + 22 + return w.ll; 23 + }
+85
arch/h8300/lib/memcpy.S
··· 1 + ;;; memcpy.S 2 + 3 + #include <asm/linkage.h> 4 + 5 + #if defined(CONFIG_CPU_H8300H) 6 + .h8300h 7 + #endif 8 + #if defined(CONFIG_CPU_H8S) 9 + .h8300s 10 + #endif 11 + .text 12 + .global memcpy 13 + 14 + ;;; void *memcpy(void *to, void *from, size_t n) 15 + memcpy: 16 + mov.l er2,er2 17 + bne 1f 18 + rts 19 + 1: 20 + ;; address check 21 + bld #0,r0l 22 + bxor #0,r1l 23 + bcs 4f 24 + mov.l er4,@-sp 25 + mov.l er0,@-sp 26 + btst #0,r0l 27 + beq 1f 28 + ;; (aligned even) odd address 29 + mov.b @er1,r3l 30 + mov.b r3l,@er0 31 + adds #1,er1 32 + adds #1,er0 33 + dec.l #1,er2 34 + beq 3f 35 + 1: 36 + ;; n < sizeof(unsigned long) check 37 + sub.l er4,er4 38 + adds #4,er4 ; loop count check value 39 + cmp.l er4,er2 40 + blo 2f 41 + ;; unsigned long copy 42 + 1: 43 + mov.l @er1,er3 44 + mov.l er3,@er0 45 + adds #4,er0 46 + adds #4,er1 47 + subs #4,er2 48 + cmp.l er4,er2 49 + bcc 1b 50 + ;; rest 51 + 2: 52 + mov.l er2,er2 53 + beq 3f 54 + 1: 55 + mov.b @er1,r3l 56 + mov.b r3l,@er0 57 + adds #1,er1 58 + adds #1,er0 59 + dec.l #1,er2 60 + bne 1b 61 + 3: 62 + mov.l @sp+,er0 63 + mov.l @sp+,er4 64 + rts 65 + 66 + ;; odd <- even / even <- odd 67 + 4: 68 + mov.l er4,er3 69 + mov.l er2,er4 70 + mov.l er5,er2 71 + mov.l er1,er5 72 + mov.l er6,er1 73 + mov.l er0,er6 74 + 1: 75 + eepmov.w 76 + mov.w r4,r4 77 + bne 1b 78 + dec.w #1,e4 79 + bpl 1b 80 + mov.l er1,er6 81 + mov.l er2,er5 82 + mov.l er3,er4 83 + rts 84 + 85 + .end
+69
arch/h8300/lib/memset.S
··· 1 + /* memset.S */ 2 + 3 + #include <asm/linkage.h> 4 + 5 + #if defined(CONFIG_CPU_H8300H) 6 + .h8300h 7 + #endif 8 + #if defined(CONFIG_CPU_H8S) 9 + .h8300s 10 + #endif 11 + .text 12 + 13 + .global memset 14 + .global clear_user 15 + 16 + ;;void *memset(*ptr, int c, size_t count) 17 + ;; ptr = er0 18 + ;; c = er1(r1l) 19 + ;; count = er2 20 + memset: 21 + btst #0,r0l 22 + beq 2f 23 + 24 + ;; odd address 25 + 1: 26 + mov.b r1l,@er0 27 + adds #1,er0 28 + dec.l #1,er2 29 + beq 6f 30 + 31 + ;; even address 32 + 2: 33 + mov.l er2,er3 34 + cmp.l #4,er2 35 + blo 4f 36 + ;; count>=4 -> count/4 37 + #if defined(CONFIG_CPU_H8300H) 38 + shlr.l er2 39 + shlr.l er2 40 + #endif 41 + #if defined(CONFIG_CPU_H8S) 42 + shlr.l #2,er2 43 + #endif 44 + ;; byte -> long 45 + mov.b r1l,r1h 46 + mov.w r1,e1 47 + 3: 48 + mov.l er1,@er0 49 + adds #4,er0 50 + dec.l #1,er2 51 + bne 3b 52 + 4: 53 + ;; count % 4 54 + and.b #3,r3l 55 + beq 6f 56 + 5: 57 + mov.b r1l,@er0 58 + adds #1,er0 59 + dec.b r3l 60 + bne 5b 61 + 6: 62 + rts 63 + 64 + clear_user: 65 + mov.l er1, er2 66 + sub.l er1, er1 67 + bra memset 68 + 69 + .end
+72
arch/h8300/lib/moddivsi3.S
··· 1 + #include "libgcc.h" 2 + 3 + ; numerator in A0/A1 4 + ; denominator in A2/A3 5 + .global __modsi3 6 + __modsi3: 7 + PUSHP S2P 8 + bsr modnorm 9 + bsr __divsi3 10 + mov.l er3,er0 11 + bra exitdiv 12 + 13 + .global __umodsi3 14 + __umodsi3: 15 + bsr __udivsi3:16 16 + mov.l er3,er0 17 + rts 18 + 19 + .global __divsi3 20 + __divsi3: 21 + PUSHP S2P 22 + bsr divnorm 23 + bsr __udivsi3:16 24 + 25 + ; examine what the sign should be 26 + exitdiv: 27 + btst #3,S2L 28 + beq reti 29 + 30 + ; should be -ve 31 + neg.l A0P 32 + 33 + reti: 34 + POPP S2P 35 + rts 36 + 37 + divnorm: 38 + mov.l A0P,A0P ; is the numerator -ve 39 + stc ccr,S2L ; keep the sign in bit 3 of S2L 40 + bge postive 41 + 42 + neg.l A0P ; negate arg 43 + 44 + postive: 45 + mov.l A1P,A1P ; is the denominator -ve 46 + bge postive2 47 + 48 + neg.l A1P ; negate arg 49 + xor.b #0x08,S2L ; toggle the result sign 50 + 51 + postive2: 52 + rts 53 + 54 + ;; Basically the same, except that the sign of the divisor determines 55 + ;; the sign. 56 + modnorm: 57 + mov.l A0P,A0P ; is the numerator -ve 58 + stc ccr,S2L ; keep the sign in bit 3 of S2L 59 + bge mpostive 60 + 61 + neg.l A0P ; negate arg 62 + 63 + mpostive: 64 + mov.l A1P,A1P ; is the denominator -ve 65 + bge mpostive2 66 + 67 + neg.l A1P ; negate arg 68 + 69 + mpostive2: 70 + rts 71 + 72 + .end
+72
arch/h8300/lib/modsi3.S
··· 1 + #include "libgcc.h" 2 + 3 + ; numerator in A0/A1 4 + ; denominator in A2/A3 5 + .global __modsi3 6 + __modsi3: 7 + PUSHP S2P 8 + bsr modnorm 9 + bsr __divsi3 10 + mov.l er3,er0 11 + bra exitdiv 12 + 13 + .global __umodsi3 14 + __umodsi3: 15 + bsr __udivsi3 16 + mov.l er3,er0 17 + rts 18 + 19 + .global __divsi3 20 + __divsi3: 21 + PUSHP S2P 22 + jsr divnorm 23 + bsr __udivsi3 24 + 25 + ; examine what the sign should be 26 + exitdiv: 27 + btst #3,S2L 28 + beq reti 29 + 30 + ; should be -ve 31 + neg.l A0P 32 + 33 + reti: 34 + POPP S2P 35 + rts 36 + 37 + divnorm: 38 + mov.l A0P,A0P ; is the numerator -ve 39 + stc ccr,S2L ; keep the sign in bit 3 of S2L 40 + bge postive 41 + 42 + neg.l A0P ; negate arg 43 + 44 + postive: 45 + mov.l A1P,A1P ; is the denominator -ve 46 + bge postive2 47 + 48 + neg.l A1P ; negate arg 49 + xor.b #0x08,S2L ; toggle the result sign 50 + 51 + postive2: 52 + rts 53 + 54 + ;; Basically the same, except that the sign of the divisor determines 55 + ;; the sign. 56 + modnorm: 57 + mov.l A0P,A0P ; is the numerator -ve 58 + stc ccr,S2L ; keep the sign in bit 3 of S2L 59 + bge mpostive 60 + 61 + neg.l A0P ; negate arg 62 + 63 + mpostive: 64 + mov.l A1P,A1P ; is the denominator -ve 65 + bge mpostive2 66 + 67 + neg.l A1P ; negate arg 68 + 69 + mpostive2: 70 + rts 71 + 72 + .end
+44
arch/h8300/lib/muldi3.c
··· 1 + #include "libgcc.h" 2 + 3 + #define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2)) 4 + #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1)) 5 + #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2)) 6 + 7 + #define umul_ppmm(w1, w0, u, v) \ 8 + do { \ 9 + UWtype __x0, __x1, __x2, __x3; \ 10 + UHWtype __ul, __vl, __uh, __vh; \ 11 + __ul = __ll_lowpart(u); \ 12 + __uh = __ll_highpart(u); \ 13 + __vl = __ll_lowpart(v); \ 14 + __vh = __ll_highpart(v); \ 15 + __x0 = (UWtype) __ul * __vl; \ 16 + __x1 = (UWtype) __ul * __vh; \ 17 + __x2 = (UWtype) __uh * __vl; \ 18 + __x3 = (UWtype) __uh * __vh; \ 19 + __x1 += __ll_highpart(__x0); \ 20 + __x1 += __x2; \ 21 + if (__x1 < __x2) \ 22 + __x3 += __ll_B; \ 23 + (w1) = __x3 + __ll_highpart(__x1); \ 24 + (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0); \ 25 + } while (0) 26 + 27 + #define __umulsidi3(u, v) ( \ 28 + { \ 29 + DWunion __w; \ 30 + umul_ppmm(__w.s.high, __w.s.low, u, v); \ 31 + __w.ll; } \ 32 + ) 33 + 34 + DWtype __muldi3(DWtype u, DWtype v) 35 + { 36 + const DWunion uu = {.ll = u}; 37 + const DWunion vv = {.ll = v}; 38 + DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; 39 + 40 + w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high 41 + + (UWtype) uu.s.high * (UWtype) vv.s.low); 42 + 43 + return w.ll; 44 + }
+38
arch/h8300/lib/mulsi3.S
··· 1 + ; 2 + ; mulsi3 for H8/300H - based on Renesas SH implementation 3 + ; 4 + ; by Toshiyasu Morita 5 + ; 6 + ; Old code: 7 + ; 8 + ; 16b * 16b = 372 states (worst case) 9 + ; 32b * 32b = 724 states (worst case) 10 + ; 11 + ; New code: 12 + ; 13 + ; 16b * 16b = 48 states 14 + ; 16b * 32b = 72 states 15 + ; 32b * 32b = 92 states 16 + ; 17 + 18 + .global __mulsi3 19 + __mulsi3: 20 + mov.w r1,r2 ; ( 2 states) b * d 21 + mulxu r0,er2 ; (22 states) 22 + 23 + mov.w e0,r3 ; ( 2 states) a * d 24 + beq L_skip1 ; ( 4 states) 25 + mulxu r1,er3 ; (22 states) 26 + add.w r3,e2 ; ( 2 states) 27 + 28 + L_skip1: 29 + mov.w e1,r3 ; ( 2 states) c * b 30 + beq L_skip2 ; ( 4 states) 31 + mulxu r0,er3 ; (22 states) 32 + add.w r3,e2 ; ( 2 states) 33 + 34 + L_skip2: 35 + mov.l er2,er0 ; ( 2 states) 36 + rts ; (10 states) 37 + 38 + .end
+34
arch/h8300/lib/strncpy.S
··· 1 + ;;; strncpy.S 2 + 3 + #include <asm/linkage.h> 4 + 5 + .text 6 + .global strncpy_from_user 7 + 8 + ;;; long strncpy_from_user(void *to, void *from, size_t n) 9 + strncpy_from_user: 10 + mov.l er2,er2 11 + bne 1f 12 + sub.l er0,er0 13 + rts 14 + 1: 15 + mov.l er4,@-sp 16 + sub.l er3,er3 17 + 2: 18 + mov.b @er1+,r4l 19 + mov.b r4l,@er0 20 + adds #1,er0 21 + beq 3f 22 + inc.l #1,er3 23 + dec.l #1,er2 24 + bne 2b 25 + 3: 26 + dec.l #1,er2 27 + 4: 28 + mov.b r4l,@er0 29 + adds #1,er0 30 + dec.l #1,er2 31 + bne 4b 32 + mov.l er3,er0 33 + mov.l @sp+,er4 34 + rts
+17
arch/h8300/lib/ucmpdi2.c
··· 1 + #include "libgcc.h" 2 + 3 + word_type __ucmpdi2(DWtype a, DWtype b) 4 + { 5 + const DWunion au = {.ll = a}; 6 + const DWunion bu = {.ll = b}; 7 + 8 + if ((UWtype) au.s.high < (UWtype) bu.s.high) 9 + return 0; 10 + else if ((UWtype) au.s.high > (UWtype) bu.s.high) 11 + return 2; 12 + if ((UWtype) au.s.low < (UWtype) bu.s.low) 13 + return 0; 14 + else if ((UWtype) au.s.low > (UWtype) bu.s.low) 15 + return 2; 16 + return 1; 17 + }
+76
arch/h8300/lib/udivsi3.S
··· 1 + #include "libgcc.h" 2 + 3 + ;; This function also computes the remainder and stores it in er3. 4 + .global __udivsi3 5 + __udivsi3: 6 + mov.w A1E,A1E ; denominator top word 0? 7 + bne DenHighNonZero 8 + 9 + ; do it the easy way, see page 107 in manual 10 + mov.w A0E,A2 11 + extu.l A2P 12 + divxu.w A1,A2P 13 + mov.w A2E,A0E 14 + divxu.w A1,A0P 15 + mov.w A0E,A3 16 + mov.w A2,A0E 17 + extu.l A3P 18 + rts 19 + 20 + ; er0 = er0 / er1 21 + ; er3 = er0 % er1 22 + ; trashes er1 er2 23 + ; expects er1 >= 2^16 24 + DenHighNonZero: 25 + mov.l er0,er3 26 + mov.l er1,er2 27 + #ifdef CONFIG_CPU_H8300H 28 + divmod_L21: 29 + shlr.l er0 30 + shlr.l er2 ; make divisor < 2^16 31 + mov.w e2,e2 32 + bne divmod_L21 33 + #else 34 + shlr.l #2,er2 ; make divisor < 2^16 35 + mov.w e2,e2 36 + beq divmod_L22A 37 + divmod_L21: 38 + shlr.l #2,er0 39 + divmod_L22: 40 + shlr.l #2,er2 ; make divisor < 2^16 41 + mov.w e2,e2 42 + bne divmod_L21 43 + divmod_L22A: 44 + rotxl.w r2 45 + bcs divmod_L23 46 + shlr.l er0 47 + bra divmod_L24 48 + divmod_L23: 49 + rotxr.w r2 50 + shlr.l #2,er0 51 + divmod_L24: 52 + #endif 53 + ;; At this point, 54 + ;; er0 contains shifted dividend 55 + ;; er1 contains divisor 56 + ;; er2 contains shifted divisor 57 + ;; er3 contains dividend, later remainder 58 + divxu.w r2,er0 ; r0 now contains the approximate quotient (AQ) 59 + extu.l er0 60 + beq divmod_L25 61 + subs #1,er0 ; er0 = AQ - 1 62 + mov.w e1,r2 63 + mulxu.w r0,er2 ; er2 = upper (AQ - 1) * divisor 64 + sub.w r2,e3 ; dividend - 65536 * er2 65 + mov.w r1,r2 66 + mulxu.w r0,er2 ; compute er3 = remainder (tentative) 67 + sub.l er2,er3 ; er3 = dividend - (AQ - 1) * divisor 68 + divmod_L25: 69 + cmp.l er1,er3 ; is divisor < remainder? 70 + blo divmod_L26 71 + adds #1,er0 72 + sub.l er1,er3 ; correct the remainder 73 + divmod_L26: 74 + rts 75 + 76 + .end
+5
arch/h8300/mm/Makefile
··· 1 + # 2 + # Makefile for the linux h8300-specific parts of the memory manager. 3 + # 4 + 5 + obj-y := init.o fault.o memory.o
+57
arch/h8300/mm/fault.c
··· 1 + /* 2 + * linux/arch/h8300/mm/fault.c 3 + * 4 + * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>, 5 + * Copyright (C) 2000 Lineo, Inc. (www.lineo.com) 6 + * 7 + * Based on: 8 + * 9 + * linux/arch/m68knommu/mm/fault.c 10 + * linux/arch/m68k/mm/fault.c 11 + * 12 + * Copyright (C) 1995 Hamish Macdonald 13 + */ 14 + 15 + #include <linux/mman.h> 16 + #include <linux/mm.h> 17 + #include <linux/kernel.h> 18 + #include <linux/ptrace.h> 19 + 20 + #include <asm/pgtable.h> 21 + 22 + void die(const char *str, struct pt_regs *fp, unsigned long err); 23 + 24 + /* 25 + * This routine handles page faults. It determines the problem, and 26 + * then passes it off to one of the appropriate routines. 27 + * 28 + * error_code: 29 + * bit 0 == 0 means no page found, 1 means protection fault 30 + * bit 1 == 0 means read, 1 means write 31 + * 32 + * If this routine detects a bad access, it returns 1, otherwise it 33 + * returns 0. 34 + */ 35 + asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address, 36 + unsigned long error_code) 37 + { 38 + #ifdef DEBUG 39 + pr_debug("regs->sr=%#x, regs->pc=%#lx, address=%#lx, %ld\n", 40 + regs->sr, regs->pc, address, error_code); 41 + #endif 42 + 43 + /* 44 + * Oops. The kernel tried to access some bad page. We'll have to 45 + * terminate things with extreme prejudice. 46 + */ 47 + if ((unsigned long) address < PAGE_SIZE) 48 + pr_alert("Unable to handle kernel NULL pointer dereference"); 49 + else 50 + pr_alert("Unable to handle kernel access"); 51 + printk(" at virtual address %08lx\n", address); 52 + if (!user_mode(regs)) 53 + die("Oops", regs, error_code); 54 + do_exit(SIGKILL); 55 + 56 + return 1; 57 + }
+128
arch/h8300/mm/init.c
··· 1 + /* 2 + * linux/arch/h8300/mm/init.c 3 + * 4 + * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>, 5 + * Kenneth Albanowski <kjahds@kjahds.com>, 6 + * Copyright (C) 2000 Lineo, Inc. (www.lineo.com) 7 + * 8 + * Based on: 9 + * 10 + * linux/arch/m68knommu/mm/init.c 11 + * linux/arch/m68k/mm/init.c 12 + * 13 + * Copyright (C) 1995 Hamish Macdonald 14 + * 15 + * JAN/1999 -- hacked to support ColdFire (gerg@snapgear.com) 16 + * DEC/2000 -- linux 2.4 support <davidm@snapgear.com> 17 + */ 18 + 19 + #include <linux/signal.h> 20 + #include <linux/sched.h> 21 + #include <linux/kernel.h> 22 + #include <linux/errno.h> 23 + #include <linux/string.h> 24 + #include <linux/types.h> 25 + #include <linux/ptrace.h> 26 + #include <linux/mman.h> 27 + #include <linux/mm.h> 28 + #include <linux/swap.h> 29 + #include <linux/init.h> 30 + #include <linux/highmem.h> 31 + #include <linux/pagemap.h> 32 + #include <linux/bootmem.h> 33 + #include <linux/gfp.h> 34 + 35 + #include <asm/setup.h> 36 + #include <asm/segment.h> 37 + #include <asm/page.h> 38 + #include <asm/pgtable.h> 39 + #include <asm/sections.h> 40 + 41 + /* 42 + * BAD_PAGE is the page that is used for page faults when linux 43 + * is out-of-memory. Older versions of linux just did a 44 + * do_exit(), but using this instead means there is less risk 45 + * for a process dying in kernel mode, possibly leaving a inode 46 + * unused etc.. 47 + * 48 + * BAD_PAGETABLE is the accompanying page-table: it is initialized 49 + * to point to BAD_PAGE entries. 50 + * 51 + * ZERO_PAGE is a special page that is used for zero-initialized 52 + * data and COW. 53 + */ 54 + static unsigned long empty_bad_page_table; 55 + static unsigned long empty_bad_page; 56 + unsigned long empty_zero_page; 57 + 58 + /* 59 + * paging_init() continues the virtual memory environment setup which 60 + * was begun by the code in arch/head.S. 61 + * The parameters are pointers to where to stick the starting and ending 62 + * addresses of available kernel virtual memory. 63 + */ 64 + void __init paging_init(void) 65 + { 66 + /* 67 + * Make sure start_mem is page aligned, otherwise bootmem and 68 + * page_alloc get different views og the world. 69 + */ 70 + unsigned long start_mem = PAGE_ALIGN(memory_start); 71 + unsigned long end_mem = memory_end & PAGE_MASK; 72 + 73 + pr_debug("start_mem is %#lx\nvirtual_end is %#lx\n", 74 + start_mem, end_mem); 75 + 76 + /* 77 + * Initialize the bad page table and bad page to point 78 + * to a couple of allocated pages. 79 + */ 80 + empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE); 81 + empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE); 82 + empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE); 83 + memset((void *)empty_zero_page, 0, PAGE_SIZE); 84 + 85 + /* 86 + * Set up SFC/DFC registers (user data space). 87 + */ 88 + set_fs(USER_DS); 89 + 90 + pr_debug("before free_area_init\n"); 91 + 92 + pr_debug("free_area_init -> start_mem is %#lx\nvirtual_end is %#lx\n", 93 + start_mem, end_mem); 94 + 95 + { 96 + unsigned long zones_size[MAX_NR_ZONES] = {0, }; 97 + 98 + zones_size[ZONE_NORMAL] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT; 99 + free_area_init(zones_size); 100 + } 101 + } 102 + 103 + void __init mem_init(void) 104 + { 105 + pr_devel("Mem_init: start=%lx, end=%lx\n", memory_start, memory_end); 106 + 107 + high_memory = (void *) (memory_end & PAGE_MASK); 108 + max_mapnr = MAP_NR(high_memory); 109 + 110 + /* this will put all low memory onto the freelists */ 111 + free_all_bootmem(); 112 + 113 + mem_init_print_info(NULL); 114 + } 115 + 116 + 117 + #ifdef CONFIG_BLK_DEV_INITRD 118 + void free_initrd_mem(unsigned long start, unsigned long end) 119 + { 120 + free_reserved_area((void *)start, (void *)end, -1, "initrd"); 121 + } 122 + #endif 123 + 124 + void 125 + free_initmem(void) 126 + { 127 + free_initmem_default(-1); 128 + }
+53
arch/h8300/mm/memory.c
··· 1 + /* 2 + * linux/arch/h8300/mm/memory.c 3 + * 4 + * Copyright (C) 2002 Yoshinori Sato <ysato@users.sourceforge.jp>, 5 + * 6 + * Based on: 7 + * 8 + * linux/arch/m68knommu/mm/memory.c 9 + * 10 + * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>, 11 + * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com) 12 + * 13 + * Based on: 14 + * 15 + * linux/arch/m68k/mm/memory.c 16 + * 17 + * Copyright (C) 1995 Hamish Macdonald 18 + */ 19 + 20 + #include <linux/mm.h> 21 + #include <linux/kernel.h> 22 + #include <linux/string.h> 23 + #include <linux/types.h> 24 + 25 + #include <asm/setup.h> 26 + #include <asm/segment.h> 27 + #include <asm/page.h> 28 + #include <asm/pgtable.h> 29 + #include <asm/traps.h> 30 + #include <asm/io.h> 31 + 32 + void cache_clear(unsigned long paddr, int len) 33 + { 34 + } 35 + 36 + 37 + void cache_push(unsigned long paddr, int len) 38 + { 39 + } 40 + 41 + void cache_push_v(unsigned long vaddr, int len) 42 + { 43 + } 44 + 45 + /* 46 + * Map some physical address range into the kernel address space. 47 + */ 48 + 49 + unsigned long kernel_map(unsigned long paddr, unsigned long size, 50 + int nocacheflag, unsigned long *memavailp) 51 + { 52 + return paddr; 53 + }
+1
drivers/clk/Makefile
··· 73 73 obj-$(CONFIG_COMMON_CLK_VERSATILE) += versatile/ 74 74 obj-$(CONFIG_X86) += x86/ 75 75 obj-$(CONFIG_ARCH_ZYNQ) += zynq/ 76 + obj-$(CONFIG_H8300) += h8300/
+2
drivers/clk/h8300/Makefile
··· 1 + obj-y += clk-div.o 2 + obj-$(CONFIG_H8S2678) += clk-h8s2678.o
+53
drivers/clk/h8300/clk-div.c
··· 1 + /* 2 + * H8/300 divide clock driver 3 + * 4 + * Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + */ 6 + 7 + #include <linux/clk.h> 8 + #include <linux/clkdev.h> 9 + #include <linux/clk-provider.h> 10 + #include <linux/err.h> 11 + #include <linux/of.h> 12 + #include <linux/of_address.h> 13 + 14 + static DEFINE_SPINLOCK(clklock); 15 + 16 + static void __init h8300_div_clk_setup(struct device_node *node) 17 + { 18 + unsigned int num_parents; 19 + struct clk *clk; 20 + const char *clk_name = node->name; 21 + const char *parent_name; 22 + void __iomem *divcr = NULL; 23 + int width; 24 + 25 + num_parents = of_clk_get_parent_count(node); 26 + if (num_parents < 1) { 27 + pr_err("%s: no parent found", clk_name); 28 + return; 29 + } 30 + 31 + divcr = of_iomap(node, 0); 32 + if (divcr == NULL) { 33 + pr_err("%s: failed to map divide register", clk_name); 34 + goto error; 35 + } 36 + 37 + parent_name = of_clk_get_parent_name(node, 0); 38 + of_property_read_u32(node, "renesas,width", &width); 39 + clk = clk_register_divider(NULL, clk_name, parent_name, 40 + CLK_SET_RATE_GATE, divcr, 0, width, 41 + CLK_DIVIDER_POWER_OF_TWO, &clklock); 42 + if (!IS_ERR(clk)) { 43 + of_clk_add_provider(node, of_clk_src_simple_get, clk); 44 + return; 45 + } 46 + pr_err("%s: failed to register %s div clock (%ld)\n", 47 + __func__, clk_name, PTR_ERR(clk)); 48 + error: 49 + if (divcr) 50 + iounmap(divcr); 51 + } 52 + 53 + CLK_OF_DECLARE(h8300_div_clk, "renesas,h8300-div-clock", h8300_div_clk_setup);
+146
drivers/clk/h8300/clk-h8s2678.c
··· 1 + /* 2 + * H8S2678 clock driver 3 + * 4 + * Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + */ 6 + 7 + #include <linux/clk.h> 8 + #include <linux/clkdev.h> 9 + #include <linux/clk-provider.h> 10 + #include <linux/err.h> 11 + #include <linux/device.h> 12 + #include <linux/of_address.h> 13 + 14 + static DEFINE_SPINLOCK(clklock); 15 + 16 + #define MAX_FREQ 33333333 17 + #define MIN_FREQ 8000000 18 + 19 + struct pll_clock { 20 + struct clk_hw hw; 21 + void __iomem *sckcr; 22 + void __iomem *pllcr; 23 + }; 24 + 25 + #define to_pll_clock(_hw) container_of(_hw, struct pll_clock, hw) 26 + 27 + static unsigned long pll_recalc_rate(struct clk_hw *hw, 28 + unsigned long parent_rate) 29 + { 30 + struct pll_clock *pll_clock = to_pll_clock(hw); 31 + int mul = 1 << (ctrl_inb((unsigned long)pll_clock->pllcr) & 3); 32 + 33 + return parent_rate * mul; 34 + } 35 + 36 + static long pll_round_rate(struct clk_hw *hw, unsigned long rate, 37 + unsigned long *prate) 38 + { 39 + int i, m = -1; 40 + long offset[3]; 41 + 42 + if (rate > MAX_FREQ) 43 + rate = MAX_FREQ; 44 + if (rate < MIN_FREQ) 45 + rate = MIN_FREQ; 46 + 47 + for (i = 0; i < 3; i++) 48 + offset[i] = abs(rate - (*prate * (1 << i))); 49 + for (i = 0; i < 3; i++) 50 + if (m < 0) 51 + m = i; 52 + else 53 + m = (offset[i] < offset[m])?i:m; 54 + 55 + return *prate * (1 << m); 56 + } 57 + 58 + static int pll_set_rate(struct clk_hw *hw, unsigned long rate, 59 + unsigned long parent_rate) 60 + { 61 + int pll; 62 + unsigned char val; 63 + unsigned long flags; 64 + struct pll_clock *pll_clock = to_pll_clock(hw); 65 + 66 + pll = ((rate / parent_rate) / 2) & 0x03; 67 + spin_lock_irqsave(&clklock, flags); 68 + val = ctrl_inb((unsigned long)pll_clock->sckcr); 69 + val |= 0x08; 70 + ctrl_outb(val, (unsigned long)pll_clock->sckcr); 71 + val = ctrl_inb((unsigned long)pll_clock->pllcr); 72 + val &= ~0x03; 73 + val |= pll; 74 + ctrl_outb(val, (unsigned long)pll_clock->pllcr); 75 + spin_unlock_irqrestore(&clklock, flags); 76 + return 0; 77 + } 78 + 79 + static const struct clk_ops pll_ops = { 80 + .recalc_rate = pll_recalc_rate, 81 + .round_rate = pll_round_rate, 82 + .set_rate = pll_set_rate, 83 + }; 84 + 85 + static void __init h8s2678_pll_clk_setup(struct device_node *node) 86 + { 87 + unsigned int num_parents; 88 + struct clk *clk; 89 + const char *clk_name = node->name; 90 + const char *parent_name; 91 + struct pll_clock *pll_clock; 92 + struct clk_init_data init; 93 + 94 + num_parents = of_clk_get_parent_count(node); 95 + if (num_parents < 1) { 96 + pr_err("%s: no parent found", clk_name); 97 + return; 98 + } 99 + 100 + 101 + pll_clock = kzalloc(sizeof(struct pll_clock), GFP_KERNEL); 102 + if (!pll_clock) { 103 + pr_err("%s: failed to alloc memory", clk_name); 104 + return; 105 + } 106 + 107 + pll_clock->sckcr = of_iomap(node, 0); 108 + if (pll_clock->sckcr == NULL) { 109 + pr_err("%s: failed to map divide register", clk_name); 110 + goto free_clock; 111 + } 112 + 113 + pll_clock->pllcr = of_iomap(node, 1); 114 + if (pll_clock->pllcr == NULL) { 115 + pr_err("%s: failed to map multiply register", clk_name); 116 + goto unmap_sckcr; 117 + } 118 + 119 + parent_name = of_clk_get_parent_name(node, 0); 120 + init.name = clk_name; 121 + init.ops = &pll_ops; 122 + init.flags = CLK_IS_BASIC; 123 + init.parent_names = &parent_name; 124 + init.num_parents = 1; 125 + pll_clock->hw.init = &init; 126 + 127 + clk = clk_register(NULL, &pll_clock->hw); 128 + if (IS_ERR(clk)) { 129 + pr_err("%s: failed to register %s div clock (%ld)\n", 130 + __func__, clk_name, PTR_ERR(clk)); 131 + goto unmap_pllcr; 132 + } 133 + 134 + of_clk_add_provider(node, of_clk_src_simple_get, clk); 135 + return; 136 + 137 + unmap_pllcr: 138 + iounmap(pll_clock->pllcr); 139 + unmap_sckcr: 140 + iounmap(pll_clock->sckcr); 141 + free_clock: 142 + kfree(pll_clock); 143 + } 144 + 145 + CLK_OF_DECLARE(h8s2678_div_clk, "renesas,h8s2678-pll-clock", 146 + h8s2678_pll_clk_setup);
+7
drivers/clocksource/Kconfig
··· 275 275 help 276 276 This enables OST0 support available on PXA and SA-11x0 277 277 platforms. 278 + 279 + config H8300_TMR16 280 + bool 281 + 282 + config H8300_TPU 283 + bool 284 + 278 285 endmenu
+3
drivers/clocksource/Makefile
··· 55 55 obj-$(CONFIG_CLKSRC_VERSATILE) += versatile.o 56 56 obj-$(CONFIG_CLKSRC_MIPS_GIC) += mips-gic-timer.o 57 57 obj-$(CONFIG_ASM9260_TIMER) += asm9260_timer.o 58 + obj-$(CONFIG_H8300) += h8300_timer8.o 59 + obj-$(CONFIG_H8300_TMR16) += h8300_timer16.o 60 + obj-$(CONFIG_H8300_TPU) += h8300_tpu.o
+254
drivers/clocksource/h8300_timer16.c
··· 1 + /* 2 + * H8/300 16bit Timer driver 3 + * 4 + * Copyright 2015 Yoshinori Sato <ysato@users.sourcefoge.jp> 5 + */ 6 + 7 + #include <linux/errno.h> 8 + #include <linux/kernel.h> 9 + #include <linux/param.h> 10 + #include <linux/string.h> 11 + #include <linux/slab.h> 12 + #include <linux/interrupt.h> 13 + #include <linux/init.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/clocksource.h> 16 + #include <linux/module.h> 17 + #include <linux/clk.h> 18 + #include <linux/io.h> 19 + #include <linux/of.h> 20 + 21 + #include <asm/segment.h> 22 + #include <asm/irq.h> 23 + 24 + #define TSTR 0 25 + #define TSNC 1 26 + #define TMDR 2 27 + #define TOLR 3 28 + #define TISRA 4 29 + #define TISRB 5 30 + #define TISRC 6 31 + 32 + #define TCR 0 33 + #define TIOR 1 34 + #define TCNT 2 35 + #define GRA 4 36 + #define GRB 6 37 + 38 + #define FLAG_REPROGRAM (1 << 0) 39 + #define FLAG_SKIPEVENT (1 << 1) 40 + #define FLAG_IRQCONTEXT (1 << 2) 41 + #define FLAG_STARTED (1 << 3) 42 + 43 + #define ONESHOT 0 44 + #define PERIODIC 1 45 + 46 + #define RELATIVE 0 47 + #define ABSOLUTE 1 48 + 49 + struct timer16_priv { 50 + struct platform_device *pdev; 51 + struct clocksource cs; 52 + struct irqaction irqaction; 53 + unsigned long total_cycles; 54 + unsigned long mapbase; 55 + unsigned long mapcommon; 56 + unsigned long flags; 57 + unsigned short gra; 58 + unsigned short cs_enabled; 59 + unsigned char enb; 60 + unsigned char imfa; 61 + unsigned char imiea; 62 + unsigned char ovf; 63 + raw_spinlock_t lock; 64 + struct clk *clk; 65 + }; 66 + 67 + static unsigned long timer16_get_counter(struct timer16_priv *p) 68 + { 69 + unsigned long v1, v2, v3; 70 + int o1, o2; 71 + 72 + o1 = ctrl_inb(p->mapcommon + TISRC) & p->ovf; 73 + 74 + /* Make sure the timer value is stable. Stolen from acpi_pm.c */ 75 + do { 76 + o2 = o1; 77 + v1 = ctrl_inw(p->mapbase + TCNT); 78 + v2 = ctrl_inw(p->mapbase + TCNT); 79 + v3 = ctrl_inw(p->mapbase + TCNT); 80 + o1 = ctrl_inb(p->mapcommon + TISRC) & p->ovf; 81 + } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3) 82 + || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); 83 + 84 + v2 |= 0x10000; 85 + return v2; 86 + } 87 + 88 + 89 + static irqreturn_t timer16_interrupt(int irq, void *dev_id) 90 + { 91 + struct timer16_priv *p = (struct timer16_priv *)dev_id; 92 + 93 + ctrl_outb(ctrl_inb(p->mapcommon + TISRA) & ~p->imfa, 94 + p->mapcommon + TISRA); 95 + p->total_cycles += 0x10000; 96 + 97 + return IRQ_HANDLED; 98 + } 99 + 100 + static inline struct timer16_priv *cs_to_priv(struct clocksource *cs) 101 + { 102 + return container_of(cs, struct timer16_priv, cs); 103 + } 104 + 105 + static cycle_t timer16_clocksource_read(struct clocksource *cs) 106 + { 107 + struct timer16_priv *p = cs_to_priv(cs); 108 + unsigned long flags, raw; 109 + unsigned long value; 110 + 111 + raw_spin_lock_irqsave(&p->lock, flags); 112 + value = p->total_cycles; 113 + raw = timer16_get_counter(p); 114 + raw_spin_unlock_irqrestore(&p->lock, flags); 115 + 116 + return value + raw; 117 + } 118 + 119 + static int timer16_enable(struct clocksource *cs) 120 + { 121 + struct timer16_priv *p = cs_to_priv(cs); 122 + 123 + WARN_ON(p->cs_enabled); 124 + 125 + p->total_cycles = 0; 126 + ctrl_outw(0x0000, p->mapbase + TCNT); 127 + ctrl_outb(0x83, p->mapbase + TCR); 128 + ctrl_outb(ctrl_inb(p->mapcommon + TSTR) | p->enb, 129 + p->mapcommon + TSTR); 130 + 131 + p->cs_enabled = true; 132 + return 0; 133 + } 134 + 135 + static void timer16_disable(struct clocksource *cs) 136 + { 137 + struct timer16_priv *p = cs_to_priv(cs); 138 + 139 + WARN_ON(!p->cs_enabled); 140 + 141 + ctrl_outb(ctrl_inb(p->mapcommon + TSTR) & ~p->enb, 142 + p->mapcommon + TSTR); 143 + 144 + p->cs_enabled = false; 145 + } 146 + 147 + #define REG_CH 0 148 + #define REG_COMM 1 149 + 150 + static int timer16_setup(struct timer16_priv *p, struct platform_device *pdev) 151 + { 152 + struct resource *res[2]; 153 + int ret, irq; 154 + unsigned int ch; 155 + 156 + memset(p, 0, sizeof(*p)); 157 + p->pdev = pdev; 158 + 159 + res[REG_CH] = platform_get_resource(p->pdev, 160 + IORESOURCE_MEM, REG_CH); 161 + res[REG_COMM] = platform_get_resource(p->pdev, 162 + IORESOURCE_MEM, REG_COMM); 163 + if (!res[REG_CH] || !res[REG_COMM]) { 164 + dev_err(&p->pdev->dev, "failed to get I/O memory\n"); 165 + return -ENXIO; 166 + } 167 + irq = platform_get_irq(p->pdev, 0); 168 + if (irq < 0) { 169 + dev_err(&p->pdev->dev, "failed to get irq\n"); 170 + return irq; 171 + } 172 + 173 + p->clk = clk_get(&p->pdev->dev, "fck"); 174 + if (IS_ERR(p->clk)) { 175 + dev_err(&p->pdev->dev, "can't get clk\n"); 176 + return PTR_ERR(p->clk); 177 + } 178 + of_property_read_u32(p->pdev->dev.of_node, "renesas,channel", &ch); 179 + 180 + p->pdev = pdev; 181 + p->mapbase = res[REG_CH]->start; 182 + p->mapcommon = res[REG_COMM]->start; 183 + p->enb = 1 << ch; 184 + p->imfa = 1 << ch; 185 + p->imiea = 1 << (4 + ch); 186 + p->cs.name = pdev->name; 187 + p->cs.rating = 200; 188 + p->cs.read = timer16_clocksource_read; 189 + p->cs.enable = timer16_enable; 190 + p->cs.disable = timer16_disable; 191 + p->cs.mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); 192 + p->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS; 193 + 194 + ret = request_irq(irq, timer16_interrupt, 195 + IRQF_TIMER, pdev->name, p); 196 + if (ret < 0) { 197 + dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); 198 + return ret; 199 + } 200 + 201 + clocksource_register_hz(&p->cs, clk_get_rate(p->clk) / 8); 202 + 203 + return 0; 204 + } 205 + 206 + static int timer16_probe(struct platform_device *pdev) 207 + { 208 + struct timer16_priv *p = platform_get_drvdata(pdev); 209 + 210 + if (p) { 211 + dev_info(&pdev->dev, "kept as earlytimer\n"); 212 + return 0; 213 + } 214 + 215 + p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); 216 + if (!p) 217 + return -ENOMEM; 218 + 219 + return timer16_setup(p, pdev); 220 + } 221 + 222 + static int timer16_remove(struct platform_device *pdev) 223 + { 224 + return -EBUSY; 225 + } 226 + 227 + static const struct of_device_id timer16_of_table[] = { 228 + { .compatible = "renesas,16bit-timer" }, 229 + { } 230 + }; 231 + static struct platform_driver timer16_driver = { 232 + .probe = timer16_probe, 233 + .remove = timer16_remove, 234 + .driver = { 235 + .name = "h8300h-16timer", 236 + .of_match_table = of_match_ptr(timer16_of_table), 237 + } 238 + }; 239 + 240 + static int __init timer16_init(void) 241 + { 242 + return platform_driver_register(&timer16_driver); 243 + } 244 + 245 + static void __exit timer16_exit(void) 246 + { 247 + platform_driver_unregister(&timer16_driver); 248 + } 249 + 250 + subsys_initcall(timer16_init); 251 + module_exit(timer16_exit); 252 + MODULE_AUTHOR("Yoshinori Sato"); 253 + MODULE_DESCRIPTION("H8/300H 16bit Timer Driver"); 254 + MODULE_LICENSE("GPL v2");
+313
drivers/clocksource/h8300_timer8.c
··· 1 + /* 2 + * linux/arch/h8300/kernel/cpu/timer/timer8.c 3 + * 4 + * Yoshinori Sato <ysato@users.sourcefoge.jp> 5 + * 6 + * 8bit Timer driver 7 + * 8 + */ 9 + 10 + #include <linux/errno.h> 11 + #include <linux/sched.h> 12 + #include <linux/kernel.h> 13 + #include <linux/interrupt.h> 14 + #include <linux/init.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/slab.h> 17 + #include <linux/clockchips.h> 18 + #include <linux/module.h> 19 + #include <linux/clk.h> 20 + #include <linux/io.h> 21 + #include <linux/of.h> 22 + 23 + #include <asm/irq.h> 24 + 25 + #define _8TCR 0 26 + #define _8TCSR 2 27 + #define TCORA 4 28 + #define TCORB 6 29 + #define _8TCNT 8 30 + 31 + #define FLAG_REPROGRAM (1 << 0) 32 + #define FLAG_SKIPEVENT (1 << 1) 33 + #define FLAG_IRQCONTEXT (1 << 2) 34 + #define FLAG_STARTED (1 << 3) 35 + 36 + #define ONESHOT 0 37 + #define PERIODIC 1 38 + 39 + #define RELATIVE 0 40 + #define ABSOLUTE 1 41 + 42 + struct timer8_priv { 43 + struct platform_device *pdev; 44 + struct clock_event_device ced; 45 + struct irqaction irqaction; 46 + unsigned long mapbase; 47 + raw_spinlock_t lock; 48 + unsigned long flags; 49 + unsigned int rate; 50 + unsigned int tcora; 51 + struct clk *pclk; 52 + }; 53 + 54 + static unsigned long timer8_get_counter(struct timer8_priv *p) 55 + { 56 + unsigned long v1, v2, v3; 57 + int o1, o2; 58 + 59 + o1 = ctrl_inb(p->mapbase + _8TCSR) & 0x20; 60 + 61 + /* Make sure the timer value is stable. Stolen from acpi_pm.c */ 62 + do { 63 + o2 = o1; 64 + v1 = ctrl_inw(p->mapbase + _8TCNT); 65 + v2 = ctrl_inw(p->mapbase + _8TCNT); 66 + v3 = ctrl_inw(p->mapbase + _8TCNT); 67 + o1 = ctrl_inb(p->mapbase + _8TCSR) & 0x20; 68 + } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3) 69 + || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); 70 + 71 + v2 |= o1 << 10; 72 + return v2; 73 + } 74 + 75 + static irqreturn_t timer8_interrupt(int irq, void *dev_id) 76 + { 77 + struct timer8_priv *p = dev_id; 78 + 79 + ctrl_outb(ctrl_inb(p->mapbase + _8TCSR) & ~0x40, 80 + p->mapbase + _8TCSR); 81 + p->flags |= FLAG_IRQCONTEXT; 82 + ctrl_outw(p->tcora, p->mapbase + TCORA); 83 + if (!(p->flags & FLAG_SKIPEVENT)) { 84 + if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) 85 + ctrl_outw(0x0000, p->mapbase + _8TCR); 86 + p->ced.event_handler(&p->ced); 87 + } 88 + p->flags &= ~(FLAG_SKIPEVENT | FLAG_IRQCONTEXT); 89 + 90 + return IRQ_HANDLED; 91 + } 92 + 93 + static void timer8_set_next(struct timer8_priv *p, unsigned long delta) 94 + { 95 + unsigned long flags; 96 + unsigned long now; 97 + 98 + raw_spin_lock_irqsave(&p->lock, flags); 99 + if (delta >= 0x10000) 100 + dev_warn(&p->pdev->dev, "delta out of range\n"); 101 + now = timer8_get_counter(p); 102 + p->tcora = delta; 103 + ctrl_outb(ctrl_inb(p->mapbase + _8TCR) | 0x40, p->mapbase + _8TCR); 104 + if (delta > now) 105 + ctrl_outw(delta, p->mapbase + TCORA); 106 + else 107 + ctrl_outw(now + 1, p->mapbase + TCORA); 108 + 109 + raw_spin_unlock_irqrestore(&p->lock, flags); 110 + } 111 + 112 + static int timer8_enable(struct timer8_priv *p) 113 + { 114 + p->rate = clk_get_rate(p->pclk) / 64; 115 + ctrl_outw(0xffff, p->mapbase + TCORA); 116 + ctrl_outw(0x0000, p->mapbase + _8TCNT); 117 + ctrl_outw(0x0c02, p->mapbase + _8TCR); 118 + 119 + return 0; 120 + } 121 + 122 + static int timer8_start(struct timer8_priv *p) 123 + { 124 + int ret = 0; 125 + unsigned long flags; 126 + 127 + raw_spin_lock_irqsave(&p->lock, flags); 128 + 129 + if (!(p->flags & FLAG_STARTED)) 130 + ret = timer8_enable(p); 131 + 132 + if (ret) 133 + goto out; 134 + p->flags |= FLAG_STARTED; 135 + 136 + out: 137 + raw_spin_unlock_irqrestore(&p->lock, flags); 138 + 139 + return ret; 140 + } 141 + 142 + static void timer8_stop(struct timer8_priv *p) 143 + { 144 + unsigned long flags; 145 + 146 + raw_spin_lock_irqsave(&p->lock, flags); 147 + 148 + ctrl_outw(0x0000, p->mapbase + _8TCR); 149 + 150 + raw_spin_unlock_irqrestore(&p->lock, flags); 151 + } 152 + 153 + static inline struct timer8_priv *ced_to_priv(struct clock_event_device *ced) 154 + { 155 + return container_of(ced, struct timer8_priv, ced); 156 + } 157 + 158 + static void timer8_clock_event_start(struct timer8_priv *p, int periodic) 159 + { 160 + struct clock_event_device *ced = &p->ced; 161 + 162 + timer8_start(p); 163 + 164 + ced->shift = 32; 165 + ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift); 166 + ced->max_delta_ns = clockevent_delta2ns(0xffff, ced); 167 + ced->min_delta_ns = clockevent_delta2ns(0x0001, ced); 168 + 169 + timer8_set_next(p, periodic?(p->rate + HZ/2) / HZ:0x10000); 170 + } 171 + 172 + static void timer8_clock_event_mode(enum clock_event_mode mode, 173 + struct clock_event_device *ced) 174 + { 175 + struct timer8_priv *p = ced_to_priv(ced); 176 + 177 + switch (mode) { 178 + case CLOCK_EVT_MODE_PERIODIC: 179 + dev_info(&p->pdev->dev, "used for periodic clock events\n"); 180 + timer8_stop(p); 181 + timer8_clock_event_start(p, PERIODIC); 182 + break; 183 + case CLOCK_EVT_MODE_ONESHOT: 184 + dev_info(&p->pdev->dev, "used for oneshot clock events\n"); 185 + timer8_stop(p); 186 + timer8_clock_event_start(p, ONESHOT); 187 + break; 188 + case CLOCK_EVT_MODE_SHUTDOWN: 189 + case CLOCK_EVT_MODE_UNUSED: 190 + timer8_stop(p); 191 + break; 192 + default: 193 + break; 194 + } 195 + } 196 + 197 + static int timer8_clock_event_next(unsigned long delta, 198 + struct clock_event_device *ced) 199 + { 200 + struct timer8_priv *p = ced_to_priv(ced); 201 + 202 + BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT); 203 + timer8_set_next(p, delta - 1); 204 + 205 + return 0; 206 + } 207 + 208 + static int timer8_setup(struct timer8_priv *p, 209 + struct platform_device *pdev) 210 + { 211 + struct resource *res; 212 + int irq; 213 + int ret; 214 + 215 + memset(p, 0, sizeof(*p)); 216 + p->pdev = pdev; 217 + 218 + res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); 219 + if (!res) { 220 + dev_err(&p->pdev->dev, "failed to get I/O memory\n"); 221 + return -ENXIO; 222 + } 223 + 224 + irq = platform_get_irq(p->pdev, 0); 225 + if (irq < 0) { 226 + dev_err(&p->pdev->dev, "failed to get irq\n"); 227 + return -ENXIO; 228 + } 229 + 230 + p->mapbase = res->start; 231 + 232 + p->irqaction.name = dev_name(&p->pdev->dev); 233 + p->irqaction.handler = timer8_interrupt; 234 + p->irqaction.dev_id = p; 235 + p->irqaction.flags = IRQF_TIMER; 236 + 237 + p->pclk = clk_get(&p->pdev->dev, "fck"); 238 + if (IS_ERR(p->pclk)) { 239 + dev_err(&p->pdev->dev, "can't get clk\n"); 240 + return PTR_ERR(p->pclk); 241 + } 242 + 243 + p->ced.name = pdev->name; 244 + p->ced.features = CLOCK_EVT_FEAT_PERIODIC | 245 + CLOCK_EVT_FEAT_ONESHOT; 246 + p->ced.rating = 200; 247 + p->ced.cpumask = cpumask_of(0); 248 + p->ced.set_next_event = timer8_clock_event_next; 249 + p->ced.set_mode = timer8_clock_event_mode; 250 + 251 + ret = setup_irq(irq, &p->irqaction); 252 + if (ret < 0) { 253 + dev_err(&p->pdev->dev, 254 + "failed to request irq %d\n", irq); 255 + return ret; 256 + } 257 + clockevents_register_device(&p->ced); 258 + platform_set_drvdata(pdev, p); 259 + 260 + return 0; 261 + } 262 + 263 + static int timer8_probe(struct platform_device *pdev) 264 + { 265 + struct timer8_priv *p = platform_get_drvdata(pdev); 266 + 267 + if (p) { 268 + dev_info(&pdev->dev, "kept as earlytimer\n"); 269 + return 0; 270 + } 271 + 272 + p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); 273 + if (!p) 274 + return -ENOMEM; 275 + 276 + return timer8_setup(p, pdev); 277 + } 278 + 279 + static int timer8_remove(struct platform_device *pdev) 280 + { 281 + return -EBUSY; 282 + } 283 + 284 + static const struct of_device_id timer8_of_table[] __maybe_unused = { 285 + { .compatible = "renesas,8bit-timer" }, 286 + { } 287 + }; 288 + 289 + MODULE_DEVICE_TABLE(of, timer8_of_table); 290 + static struct platform_driver timer8_driver = { 291 + .probe = timer8_probe, 292 + .remove = timer8_remove, 293 + .driver = { 294 + .name = "h8300-8timer", 295 + .of_match_table = of_match_ptr(timer8_of_table), 296 + } 297 + }; 298 + 299 + static int __init timer8_init(void) 300 + { 301 + return platform_driver_register(&timer8_driver); 302 + } 303 + 304 + static void __exit timer8_exit(void) 305 + { 306 + platform_driver_unregister(&timer8_driver); 307 + } 308 + 309 + subsys_initcall(timer8_init); 310 + module_exit(timer8_exit); 311 + MODULE_AUTHOR("Yoshinori Sato"); 312 + MODULE_DESCRIPTION("H8/300 8bit Timer Driver"); 313 + MODULE_LICENSE("GPL v2");
+207
drivers/clocksource/h8300_tpu.c
··· 1 + /* 2 + * H8/300 TPU Driver 3 + * 4 + * Copyright 2015 Yoshinori Sato <ysato@users.sourcefoge.jp> 5 + * 6 + */ 7 + 8 + #include <linux/errno.h> 9 + #include <linux/sched.h> 10 + #include <linux/kernel.h> 11 + #include <linux/interrupt.h> 12 + #include <linux/init.h> 13 + #include <linux/platform_device.h> 14 + #include <linux/slab.h> 15 + #include <linux/clocksource.h> 16 + #include <linux/module.h> 17 + #include <linux/clk.h> 18 + #include <linux/io.h> 19 + #include <linux/of.h> 20 + 21 + #include <asm/irq.h> 22 + 23 + #define TCR 0 24 + #define TMDR 1 25 + #define TIOR 2 26 + #define TER 4 27 + #define TSR 5 28 + #define TCNT 6 29 + #define TGRA 8 30 + #define TGRB 10 31 + #define TGRC 12 32 + #define TGRD 14 33 + 34 + struct tpu_priv { 35 + struct platform_device *pdev; 36 + struct clocksource cs; 37 + struct clk *clk; 38 + unsigned long mapbase1; 39 + unsigned long mapbase2; 40 + raw_spinlock_t lock; 41 + unsigned int cs_enabled; 42 + }; 43 + 44 + static inline unsigned long read_tcnt32(struct tpu_priv *p) 45 + { 46 + unsigned long tcnt; 47 + 48 + tcnt = ctrl_inw(p->mapbase1 + TCNT) << 16; 49 + tcnt |= ctrl_inw(p->mapbase2 + TCNT); 50 + return tcnt; 51 + } 52 + 53 + static int tpu_get_counter(struct tpu_priv *p, unsigned long long *val) 54 + { 55 + unsigned long v1, v2, v3; 56 + int o1, o2; 57 + 58 + o1 = ctrl_inb(p->mapbase1 + TSR) & 0x10; 59 + 60 + /* Make sure the timer value is stable. Stolen from acpi_pm.c */ 61 + do { 62 + o2 = o1; 63 + v1 = read_tcnt32(p); 64 + v2 = read_tcnt32(p); 65 + v3 = read_tcnt32(p); 66 + o1 = ctrl_inb(p->mapbase1 + TSR) & 0x10; 67 + } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3) 68 + || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); 69 + 70 + *val = v2; 71 + return o1; 72 + } 73 + 74 + static inline struct tpu_priv *cs_to_priv(struct clocksource *cs) 75 + { 76 + return container_of(cs, struct tpu_priv, cs); 77 + } 78 + 79 + static cycle_t tpu_clocksource_read(struct clocksource *cs) 80 + { 81 + struct tpu_priv *p = cs_to_priv(cs); 82 + unsigned long flags; 83 + unsigned long long value; 84 + 85 + raw_spin_lock_irqsave(&p->lock, flags); 86 + if (tpu_get_counter(p, &value)) 87 + value += 0x100000000; 88 + raw_spin_unlock_irqrestore(&p->lock, flags); 89 + 90 + return value; 91 + } 92 + 93 + static int tpu_clocksource_enable(struct clocksource *cs) 94 + { 95 + struct tpu_priv *p = cs_to_priv(cs); 96 + 97 + WARN_ON(p->cs_enabled); 98 + 99 + ctrl_outw(0, p->mapbase1 + TCNT); 100 + ctrl_outw(0, p->mapbase2 + TCNT); 101 + ctrl_outb(0x0f, p->mapbase1 + TCR); 102 + ctrl_outb(0x03, p->mapbase2 + TCR); 103 + 104 + p->cs_enabled = true; 105 + return 0; 106 + } 107 + 108 + static void tpu_clocksource_disable(struct clocksource *cs) 109 + { 110 + struct tpu_priv *p = cs_to_priv(cs); 111 + 112 + WARN_ON(!p->cs_enabled); 113 + 114 + ctrl_outb(0, p->mapbase1 + TCR); 115 + ctrl_outb(0, p->mapbase2 + TCR); 116 + p->cs_enabled = false; 117 + } 118 + 119 + #define CH_L 0 120 + #define CH_H 1 121 + 122 + static int __init tpu_setup(struct tpu_priv *p, struct platform_device *pdev) 123 + { 124 + struct resource *res[2]; 125 + 126 + memset(p, 0, sizeof(*p)); 127 + p->pdev = pdev; 128 + 129 + res[CH_L] = platform_get_resource(p->pdev, IORESOURCE_MEM, CH_L); 130 + res[CH_H] = platform_get_resource(p->pdev, IORESOURCE_MEM, CH_H); 131 + if (!res[CH_L] || !res[CH_H]) { 132 + dev_err(&p->pdev->dev, "failed to get I/O memory\n"); 133 + return -ENXIO; 134 + } 135 + 136 + p->clk = clk_get(&p->pdev->dev, "fck"); 137 + if (IS_ERR(p->clk)) { 138 + dev_err(&p->pdev->dev, "can't get clk\n"); 139 + return PTR_ERR(p->clk); 140 + } 141 + 142 + p->mapbase1 = res[CH_L]->start; 143 + p->mapbase2 = res[CH_H]->start; 144 + 145 + p->cs.name = pdev->name; 146 + p->cs.rating = 200; 147 + p->cs.read = tpu_clocksource_read; 148 + p->cs.enable = tpu_clocksource_enable; 149 + p->cs.disable = tpu_clocksource_disable; 150 + p->cs.mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); 151 + p->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS; 152 + clocksource_register_hz(&p->cs, clk_get_rate(p->clk) / 64); 153 + platform_set_drvdata(pdev, p); 154 + 155 + return 0; 156 + } 157 + 158 + static int tpu_probe(struct platform_device *pdev) 159 + { 160 + struct tpu_priv *p = platform_get_drvdata(pdev); 161 + 162 + if (p) { 163 + dev_info(&pdev->dev, "kept as earlytimer\n"); 164 + return 0; 165 + } 166 + 167 + p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); 168 + if (!p) 169 + return -ENOMEM; 170 + 171 + return tpu_setup(p, pdev); 172 + } 173 + 174 + static int tpu_remove(struct platform_device *pdev) 175 + { 176 + return -EBUSY; 177 + } 178 + 179 + static const struct of_device_id tpu_of_table[] = { 180 + { .compatible = "renesas,tpu" }, 181 + { } 182 + }; 183 + 184 + static struct platform_driver tpu_driver = { 185 + .probe = tpu_probe, 186 + .remove = tpu_remove, 187 + .driver = { 188 + .name = "h8s-tpu", 189 + .of_match_table = of_match_ptr(tpu_of_table), 190 + } 191 + }; 192 + 193 + static int __init tpu_init(void) 194 + { 195 + return platform_driver_register(&tpu_driver); 196 + } 197 + 198 + static void __exit tpu_exit(void) 199 + { 200 + platform_driver_unregister(&tpu_driver); 201 + } 202 + 203 + subsys_initcall(tpu_init); 204 + module_exit(tpu_exit); 205 + MODULE_AUTHOR("Yoshinori Sato"); 206 + MODULE_DESCRIPTION("H8S Timer Pulse Unit Driver"); 207 + MODULE_LICENSE("GPL v2");
+8
drivers/irqchip/Kconfig
··· 159 159 config MIPS_GIC 160 160 bool 161 161 select MIPS_CM 162 + 163 + config RENESAS_H8300H_INTC 164 + bool 165 + select IRQ_DOMAIN 166 + 167 + config RENESAS_H8S_INTC 168 + bool 169 + select IRQ_DOMAIN
+2
drivers/irqchip/Makefile
··· 47 47 obj-$(CONFIG_MIPS_GIC) += irq-mips-gic.o 48 48 obj-$(CONFIG_ARCH_MEDIATEK) += irq-mtk-sysirq.o 49 49 obj-$(CONFIG_ARCH_DIGICOLOR) += irq-digicolor.o 50 + obj-$(CONFIG_RENESAS_H8300H_INTC) += irq-renesas-h8300h.o 51 + obj-$(CONFIG_RENESAS_H8S_INTC) += irq-renesas-h8s.o
+95
drivers/irqchip/irq-renesas-h8300h.c
··· 1 + /* 2 + * H8/300H interrupt controller driver 3 + * 4 + * Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + */ 6 + 7 + #include <linux/init.h> 8 + #include <linux/irq.h> 9 + #include <linux/irqchip.h> 10 + #include <linux/of_address.h> 11 + #include <linux/of_irq.h> 12 + #include <asm/io.h> 13 + 14 + #include "irqchip.h" 15 + 16 + static const char ipr_bit[] = { 17 + 7, 6, 5, 5, 18 + 4, 4, 4, 4, 3, 3, 3, 3, 19 + 2, 2, 2, 2, 1, 1, 1, 1, 20 + 0, 0, 0, 0, 15, 15, 15, 15, 21 + 14, 14, 14, 14, 13, 13, 13, 13, 22 + -1, -1, -1, -1, 11, 11, 11, 11, 23 + 10, 10, 10, 10, 9, 9, 9, 9, 24 + }; 25 + 26 + static void *intc_baseaddr; 27 + 28 + #define IPR ((unsigned long)intc_baseaddr + 6) 29 + 30 + static void h8300h_disable_irq(struct irq_data *data) 31 + { 32 + int bit; 33 + int irq = data->irq - 12; 34 + 35 + bit = ipr_bit[irq]; 36 + if (bit >= 0) { 37 + if (bit < 8) 38 + ctrl_bclr(bit & 7, IPR); 39 + else 40 + ctrl_bclr(bit & 7, (IPR+1)); 41 + } 42 + } 43 + 44 + static void h8300h_enable_irq(struct irq_data *data) 45 + { 46 + int bit; 47 + int irq = data->irq - 12; 48 + 49 + bit = ipr_bit[irq]; 50 + if (bit >= 0) { 51 + if (bit < 8) 52 + ctrl_bset(bit & 7, IPR); 53 + else 54 + ctrl_bset(bit & 7, (IPR+1)); 55 + } 56 + } 57 + 58 + struct irq_chip h8300h_irq_chip = { 59 + .name = "H8/300H-INTC", 60 + .irq_enable = h8300h_enable_irq, 61 + .irq_disable = h8300h_disable_irq, 62 + }; 63 + 64 + static int irq_map(struct irq_domain *h, unsigned int virq, 65 + irq_hw_number_t hw_irq_num) 66 + { 67 + irq_set_chip_and_handler(virq, &h8300h_irq_chip, handle_simple_irq); 68 + 69 + return 0; 70 + } 71 + 72 + static struct irq_domain_ops irq_ops = { 73 + .map = irq_map, 74 + .xlate = irq_domain_xlate_onecell, 75 + }; 76 + 77 + static int __init h8300h_intc_of_init(struct device_node *intc, 78 + struct device_node *parent) 79 + { 80 + struct irq_domain *domain; 81 + 82 + intc_baseaddr = of_iomap(intc, 0); 83 + BUG_ON(!intc_baseaddr); 84 + 85 + /* All interrupt priority low */ 86 + ctrl_outb(0x00, IPR + 0); 87 + ctrl_outb(0x00, IPR + 1); 88 + 89 + domain = irq_domain_add_linear(intc, NR_IRQS, &irq_ops, NULL); 90 + BUG_ON(!domain); 91 + irq_set_default_host(domain); 92 + return 0; 93 + } 94 + 95 + IRQCHIP_DECLARE(h8300h_intc, "renesas,h8300h-intc", h8300h_intc_of_init);
+101
drivers/irqchip/irq-renesas-h8s.c
··· 1 + /* 2 + * H8S interrupt contoller driver 3 + * 4 + * Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + */ 6 + 7 + #include <linux/irq.h> 8 + #include <linux/of_address.h> 9 + #include <linux/of_irq.h> 10 + #include <asm/io.h> 11 + #include "irqchip.h" 12 + 13 + static void *intc_baseaddr; 14 + #define IPRA ((unsigned long)intc_baseaddr) 15 + 16 + static const unsigned char ipr_table[] = { 17 + 0x03, 0x02, 0x01, 0x00, 0x13, 0x12, 0x11, 0x10, /* 16 - 23 */ 18 + 0x23, 0x22, 0x21, 0x20, 0x33, 0x32, 0x31, 0x30, /* 24 - 31 */ 19 + 0x43, 0x42, 0x41, 0x40, 0x53, 0x53, 0x52, 0x52, /* 32 - 39 */ 20 + 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, /* 40 - 47 */ 21 + 0x50, 0x50, 0x50, 0x50, 0x63, 0x63, 0x63, 0x63, /* 48 - 55 */ 22 + 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, /* 56 - 63 */ 23 + 0x61, 0x61, 0x61, 0x61, 0x60, 0x60, 0x60, 0x60, /* 64 - 71 */ 24 + 0x73, 0x73, 0x73, 0x73, 0x72, 0x72, 0x72, 0x72, /* 72 - 79 */ 25 + 0x71, 0x71, 0x71, 0x71, 0x70, 0x83, 0x82, 0x81, /* 80 - 87 */ 26 + 0x80, 0x80, 0x80, 0x80, 0x93, 0x93, 0x93, 0x93, /* 88 - 95 */ 27 + 0x92, 0x92, 0x92, 0x92, 0x91, 0x91, 0x91, 0x91, /* 96 - 103 */ 28 + 0x90, 0x90, 0x90, 0x90, 0xa3, 0xa3, 0xa3, 0xa3, /* 104 - 111 */ 29 + 0xa2, 0xa2, 0xa2, 0xa2, 0xa1, 0xa1, 0xa1, 0xa1, /* 112 - 119 */ 30 + 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, /* 120 - 127 */ 31 + }; 32 + 33 + static void h8s_disable_irq(struct irq_data *data) 34 + { 35 + int pos; 36 + unsigned int addr; 37 + unsigned short pri; 38 + int irq = data->irq; 39 + 40 + addr = IPRA + ((ipr_table[irq - 16] & 0xf0) >> 3); 41 + pos = (ipr_table[irq - 16] & 0x0f) * 4; 42 + pri = ~(0x000f << pos); 43 + pri &= ctrl_inw(addr); 44 + ctrl_outw(pri, addr); 45 + } 46 + 47 + static void h8s_enable_irq(struct irq_data *data) 48 + { 49 + int pos; 50 + unsigned int addr; 51 + unsigned short pri; 52 + int irq = data->irq; 53 + 54 + addr = IPRA + ((ipr_table[irq - 16] & 0xf0) >> 3); 55 + pos = (ipr_table[irq - 16] & 0x0f) * 4; 56 + pri = ~(0x000f << pos); 57 + pri &= ctrl_inw(addr); 58 + pri |= 1 << pos; 59 + ctrl_outw(pri, addr); 60 + } 61 + 62 + struct irq_chip h8s_irq_chip = { 63 + .name = "H8S-INTC", 64 + .irq_enable = h8s_enable_irq, 65 + .irq_disable = h8s_disable_irq, 66 + }; 67 + 68 + static __init int irq_map(struct irq_domain *h, unsigned int virq, 69 + irq_hw_number_t hw_irq_num) 70 + { 71 + irq_set_chip_and_handler(virq, &h8s_irq_chip, handle_simple_irq); 72 + 73 + return 0; 74 + } 75 + 76 + static struct irq_domain_ops irq_ops = { 77 + .map = irq_map, 78 + .xlate = irq_domain_xlate_onecell, 79 + }; 80 + 81 + static int __init h8s_intc_of_init(struct device_node *intc, 82 + struct device_node *parent) 83 + { 84 + struct irq_domain *domain; 85 + int n; 86 + 87 + intc_baseaddr = of_iomap(intc, 0); 88 + BUG_ON(!intc_baseaddr); 89 + 90 + /* All interrupt priority is 0 (disable) */ 91 + /* IPRA to IPRK */ 92 + for (n = 0; n <= 'k' - 'a'; n++) 93 + ctrl_outw(0x0000, IPRA + (n * 2)); 94 + 95 + domain = irq_domain_add_linear(intc, NR_IRQS, &irq_ops, NULL); 96 + BUG_ON(!domain); 97 + irq_set_default_host(domain); 98 + return 0; 99 + } 100 + 101 + IRQCHIP_DECLARE(h8s_intc, "renesas,h8s-intc", h8s_intc_of_init);
+1 -1
drivers/tty/serial/Kconfig
··· 728 728 729 729 config SERIAL_SH_SCI 730 730 tristate "SuperH SCI(F) serial port support" 731 - depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST 731 + depends on SUPERH || ARCH_SHMOBILE || H8300 || COMPILE_TEST 732 732 select SERIAL_CORE 733 733 734 734 config SERIAL_SH_SCI_NR_UARTS
+19 -21
drivers/tty/serial/sh-sci.c
··· 84 84 int overrun_bit; 85 85 unsigned int error_mask; 86 86 unsigned int sampling_rate; 87 - 87 + resource_size_t reg_size; 88 88 89 89 /* Break timer */ 90 90 struct timer_list break_timer; ··· 2073 2073 return NULL; 2074 2074 } 2075 2075 2076 - static inline unsigned long sci_port_size(struct uart_port *port) 2077 - { 2078 - /* 2079 - * Pick an arbitrary size that encapsulates all of the base 2080 - * registers by default. This can be optimized later, or derived 2081 - * from platform resource data at such a time that ports begin to 2082 - * behave more erratically. 2083 - */ 2084 - if (port->type == PORT_HSCIF) 2085 - return 96; 2086 - else 2087 - return 64; 2088 - } 2089 - 2090 2076 static int sci_remap_port(struct uart_port *port) 2091 2077 { 2092 - unsigned long size = sci_port_size(port); 2078 + struct sci_port *sport = to_sci_port(port); 2093 2079 2094 2080 /* 2095 2081 * Nothing to do if there's already an established membase. ··· 2084 2098 return 0; 2085 2099 2086 2100 if (port->flags & UPF_IOREMAP) { 2087 - port->membase = ioremap_nocache(port->mapbase, size); 2101 + port->membase = ioremap_nocache(port->mapbase, sport->reg_size); 2088 2102 if (unlikely(!port->membase)) { 2089 2103 dev_err(port->dev, "can't remap port#%d\n", port->line); 2090 2104 return -ENXIO; ··· 2103 2117 2104 2118 static void sci_release_port(struct uart_port *port) 2105 2119 { 2120 + struct sci_port *sport = to_sci_port(port); 2121 + 2106 2122 if (port->flags & UPF_IOREMAP) { 2107 2123 iounmap(port->membase); 2108 2124 port->membase = NULL; 2109 2125 } 2110 2126 2111 - release_mem_region(port->mapbase, sci_port_size(port)); 2127 + release_mem_region(port->mapbase, sport->reg_size); 2112 2128 } 2113 2129 2114 2130 static int sci_request_port(struct uart_port *port) 2115 2131 { 2116 - unsigned long size = sci_port_size(port); 2117 2132 struct resource *res; 2133 + struct sci_port *sport = to_sci_port(port); 2118 2134 int ret; 2119 2135 2120 - res = request_mem_region(port->mapbase, size, dev_name(port->dev)); 2121 - if (unlikely(res == NULL)) 2136 + res = request_mem_region(port->mapbase, sport->reg_size, 2137 + dev_name(port->dev)); 2138 + if (unlikely(res == NULL)) { 2139 + dev_err(port->dev, "request_mem_region failed."); 2122 2140 return -EBUSY; 2141 + } 2123 2142 2124 2143 ret = sci_remap_port(port); 2125 2144 if (unlikely(ret != 0)) { ··· 2198 2207 return -ENOMEM; 2199 2208 2200 2209 port->mapbase = res->start; 2210 + sci_port->reg_size = resource_size(res); 2201 2211 2202 2212 for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i) 2203 2213 sci_port->irqs[i] = platform_get_irq(dev, i); ··· 2526 2534 .data = &(const struct sci_port_info) { 2527 2535 .type = PORT_HSCIF, 2528 2536 .regtype = SCIx_HSCIF_REGTYPE, 2537 + }, 2538 + }, { 2539 + .compatible = "renesas,sci", 2540 + .data = &(const struct sci_port_info) { 2541 + .type = PORT_SCI, 2542 + .regtype = SCIx_SCI_REGTYPE, 2529 2543 }, 2530 2544 }, { 2531 2545 /* Terminator */
+1
include/asm-generic/asm-offsets.h
··· 1 + #include <generated/asm-offsets.h>
+1
include/uapi/linux/elf-em.h
··· 25 25 #define EM_ARM 40 /* ARM 32 bit */ 26 26 #define EM_SH 42 /* SuperH */ 27 27 #define EM_SPARCV9 43 /* SPARC v9 64-bit */ 28 + #define EM_H8_300 46 /* Renesas H8/300 */ 28 29 #define EM_IA_64 50 /* HP/Intel IA-64 */ 29 30 #define EM_X86_64 62 /* AMD x86-64 */ 30 31 #define EM_S390 22 /* IBM S/390 */
+1 -1
scripts/mksysmap
··· 41 41 # so we just ignore them to let readprofile continue to work. 42 42 # (At least sparc64 has __crc_ in the middle). 43 43 44 - $NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $2 44 + $NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > $2