Commit 16477cdf authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'asm-generic-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic

Pull asm-generic updates from Arnd Bergmann:
 "The asm-generic tree contains three separate changes for linux-5.19:

   - The h8300 architecture is retired after it has been effectively
     unmaintained for a number of years. This is the last architecture
     we supported that has no MMU implementation, but there are still a
     few architectures (arm, m68k, riscv, sh and xtensa) that support
     CPUs with and without an MMU.

   - A series to add a generic ticket spinlock that can be shared by
     most architectures with a working cmpxchg or ll/sc type atomic,
     including the conversion of riscv, csky and openrisc. This series
     is also a prerequisite for the loongarch64 architecture port that
     will come as a separate pull request.

   - A cleanup of some exported uapi header files to ensure they can be
     included from user space without relying on other kernel headers"

* tag 'asm-generic-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
  h8300: remove stale bindings and symlink
  sparc: add asm/stat.h to UAPI compile-test coverage
  powerpc: add asm/stat.h to UAPI compile-test coverage
  mips: add asm/stat.h to UAPI compile-test coverage
  riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage
  kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h>
  agpgart.h: do not include <stdlib.h> from exported header
  csky: Move to generic ticket-spinlock
  RISC-V: Move to queued RW locks
  RISC-V: Move to generic spinlocks
  openrisc: Move to ticket-spinlock
  asm-generic: qrwlock: Document the spinlock fairness requirements
  asm-generic: qspinlock: Indicate the use of mixed-size atomics
  asm-generic: ticket-lock: New generic ticket-based spinlock
  remove the h8300 architecture
parents ecf0aa53 b2441b3b
* Renesas H8/300 divider clock
Required Properties:
- compatible: Must be "renesas,h8300-div-clock"
- clocks: Reference to the parent clocks ("extal1" and "extal2")
- #clock-cells: Must be 1
- reg: Base address and length of the divide rate selector
- renesas,width: bit width of selector
Example
-------
cclk: cclk {
compatible = "renesas,h8300-div-clock";
clocks = <&xclk>;
#clock-cells = <0>;
reg = <0xfee01b 2>;
renesas,width = <2>;
};
Renesas H8S2678 PLL clock
This device is Clock multiplyer
Required Properties:
- compatible: Must be "renesas,h8s2678-pll-clock"
- clocks: Reference to the parent clocks
- #clock-cells: Must be 0
- reg: Two rate selector (Multiply / Divide) register address
Example
-------
pllclk: pllclk {
compatible = "renesas,h8s2678-pll-clock";
clocks = <&xclk>;
#clock-cells = <0>;
reg = <0xfee03b 2>, <0xfee045 2>;
};
* H8/300 CPU bindings
Required properties:
- compatible: Compatible property value should be "renesas,h8300".
- clock-frequency: Contains the clock frequency for CPU, in Hz.
Example:
cpu@0 {
compatible = "renesas,h8300";
clock-frequency = <20000000>;
};
* H8/300H Interrupt controller
Required properties:
- compatible: has to be "renesas,h8300h-intc", "renesas,h8300-intc" as fallback.
- #interrupt-cells: has to be <2>: an interrupt index and flags, as defined in
interrupts.txt in this directory
- regs: Base address of interrupt controller registers.
Optional properties:
- any properties, listed in interrupts.txt, and any standard resource allocation
properties
Example:
h8intc: interrupt-controller@fee012 {
compatible = "renesas,h8300h-intc", "renesas,h8300-intc";
#interrupt-cells = <2>;
interrupt-controller;
reg = <0xfee012 7>;
};
* H8S Interrupt controller
Required properties:
- compatible: has to be "renesas,h8s-intc", "renesas,h8300-intc" as fallback.
- #interrupt-cells: has to be <2>: an interrupt index and flags, as defined in
interrupts.txt in this directory
- regs: Base address of interrupt controller registers.
Optional properties:
- any properties, listed in interrupts.txt, and any standard resource allocation
properties
Example:
h8intc: interrupt-controller@fffe00 {
compatible = "renesas,h8s-intc", "renesas,h8300-intc";
#interrupt-cells = <2>;
interrupt-controller;
reg = <0xfffe00 24>;
};
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/memory-controllers/renesas,h8300-bsc.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: H8/300 bus controller
maintainers:
- Krzysztof Kozlowski <krzk@kernel.org>
- Yoshinori Sato <ysato@users.sourceforge.jp>
properties:
compatible:
items:
- enum:
- renesas,h8300h-bsc
- renesas,h8s-bsc
- const: renesas,h8300-bsc
reg:
maxItems: 1
required:
- compatible
- reg
additionalProperties: false
examples:
- |
memory-controller@fee01e {
compatible = "renesas,h8300h-bsc", "renesas,h8300-bsc";
reg = <0xfee01e 8>;
};
* Renesas H8/300 16bit timer
The 16bit timer is a 16bit timer/counter with configurable clock inputs and
programmable compare match.
Required Properties:
- compatible: must contain "renesas,16bit-timer"
- reg: base address and length of the registers block for the timer module.
- interrupts: interrupt-specifier for the timer, IMIA
- clocks: a list of phandle, one for each entry in clock-names.
- clock-names: must contain "peripheral_clk" for the functional clock.
- renesas,channel: timer channel number.
Example:
timer16: timer@ffff68 {
compatible = "reneas,16bit-timer";
reg = <0xffff68 8>, <0xffff60 8>;
interrupts = <24>;
renesas,channel = <0>;
clocks = <&pclk>;
clock-names = "peripheral_clk";
};
* Renesas H8/300 8bit timer
The 8bit timer is a 8bit timer/counter with configurable clock inputs and
programmable compare match.
This implement only supported cascade mode.
Required Properties:
- compatible: must contain "renesas,8bit-timer"
- reg: base address and length of the registers block for the timer module.
- interrupts: interrupt-specifier for the timer, CMIA and TOVI
- clocks: a list of phandle, one for each entry in clock-names.
- clock-names: must contain "fck" for the functional clock.
Example:
timer8_0: timer@ffff80 {
compatible = "renesas,8bit-timer";
reg = <0xffff80 10>;
interrupts = <36>;
clocks = <&fclk>;
clock-names = "fck";
};
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | TODO |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | ok |
| ia64: | ok |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | ok |
| ia64: | ok |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | ok |
| hexagon: | ok |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | TODO |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | ok |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | ok |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | TODO |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | TODO |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | ok |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | ok |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -34,7 +34,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | .. |
| arm64: | ok |
| csky: | .. |
| h8300: | .. |
| hexagon: | .. |
| ia64: | TODO |
| m68k: | .. |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | ok |
| csky: | ok |
| h8300: | ok |
| hexagon: | ok |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | .. |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | ok |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | ok |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | TODO |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | ok |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | .. |
| h8300: | .. |
| hexagon: | .. |
| ia64: | TODO |
| m68k: | .. |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | N/A |
| csky: | TODO |
| h8300: | .. |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | .. |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | TODO |
| arm64: | TODO |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -11,7 +11,6 @@
| arm: | ok |
| arm64: | ok |
| csky: | TODO |
| h8300: | TODO |
| hexagon: | TODO |
| ia64: | TODO |
| m68k: | TODO |
......
......@@ -8607,17 +8607,6 @@ L: linux-efi@vger.kernel.org
S: Maintained
F: block/partitions/efi.*
H8/300 ARCHITECTURE
M: Yoshinori Sato <ysato@users.sourceforge.jp>
L: uclinux-h8-devel@lists.sourceforge.jp (moderated for non-subscribers)
S: Maintained
W: http://uclinux-h8.sourceforge.jp
T: git git://git.sourceforge.jp/gitroot/uclinux-h8/linux.git
F: arch/h8300/
F: drivers/clk/h8300/
F: drivers/clocksource/h8300_*.c
F: drivers/irqchip/irq-renesas-h8*.c
HABANALABS PCI DRIVER
M: Oded Gabbay <ogabbay@kernel.org>
S: Supported
......
......@@ -3,7 +3,10 @@ generic-y += asm-offsets.h
generic-y += extable.h
generic-y += gpio.h
generic-y += kvm_para.h
generic-y += spinlock.h
generic-y += spinlock_types.h
generic-y += qrwlock.h
generic-y += qrwlock_types.h
generic-y += parport.h
generic-y += user.h
generic-y += vmlinux.lds.h
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_CSKY_SPINLOCK_H
#define __ASM_CSKY_SPINLOCK_H
#include <linux/spinlock_types.h>
#include <asm/barrier.h>
/*
* Ticket-based spin-locking.
*/
static inline void arch_spin_lock(arch_spinlock_t *lock)
{
arch_spinlock_t lockval;
u32 ticket_next = 1 << TICKET_NEXT;
u32 *p = &lock->lock;
u32 tmp;
asm volatile (
"1: ldex.w %0, (%2) \n"
" mov %1, %0 \n"
" add %0, %3 \n"
" stex.w %0, (%2) \n"
" bez %0, 1b \n"
: "=&r" (tmp), "=&r" (lockval)
: "r"(p), "r"(ticket_next)
: "cc");
while (lockval.tickets.next != lockval.tickets.owner)
lockval.tickets.owner = READ_ONCE(lock->tickets.owner);
smp_mb();
}
static inline int arch_spin_trylock(arch_spinlock_t *lock)
{
u32 tmp, contended, res;
u32 ticket_next = 1 << TICKET_NEXT;
u32 *p = &lock->lock;
do {
asm volatile (
" ldex.w %0, (%3) \n"
" movi %2, 1 \n"
" rotli %1, %0, 16 \n"
" cmpne %1, %0 \n"
" bt 1f \n"
" movi %2, 0 \n"
" add %0, %0, %4 \n"
" stex.w %0, (%3) \n"
"1: \n"
: "=&r" (res), "=&r" (tmp), "=&r" (contended)
: "r"(p), "r"(ticket_next)
: "cc");
} while (!res);
if (!contended)
smp_mb();
return !contended;
}
static inline void arch_spin_unlock(arch_spinlock_t *lock)
{
smp_mb();
WRITE_ONCE(lock->tickets.owner, lock->tickets.owner + 1);
}
static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
{
return lock.tickets.owner == lock.tickets.next;
}
static inline int arch_spin_is_locked(arch_spinlock_t *lock)
{
return !arch_spin_value_unlocked(READ_ONCE(*lock));
}
static inline int arch_spin_is_contended(arch_spinlock_t *lock)
{
struct __raw_tickets tickets = READ_ONCE(lock->tickets);
return (tickets.next - tickets.owner) > 1;
}
#define arch_spin_is_contended arch_spin_is_contended
#include <asm/qrwlock.h>
#endif /* __ASM_CSKY_SPINLOCK_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_CSKY_SPINLOCK_TYPES_H
#define __ASM_CSKY_SPINLOCK_TYPES_H
#ifndef __LINUX_SPINLOCK_TYPES_RAW_H
# error "please don't include this file directly"
#endif
#define TICKET_NEXT 16
typedef struct {
union {
u32 lock;
struct __raw_tickets {
/* little endian */
u16 owner;
u16 next;
} tickets;
};
} arch_spinlock_t;
#define __ARCH_SPIN_LOCK_UNLOCKED { { 0 } }
#include <asm-generic/qrwlock_types.h>
#endif /* __ASM_CSKY_SPINLOCK_TYPES_H */
# SPDX-License-Identifier: GPL-2.0-only
obj-y += kernel/ mm/ boot/dts/
# for cleaning
subdir- += boot
# SPDX-License-Identifier: GPL-2.0
config H8300
def_bool y
select ARCH_32BIT_OFF_T
select ARCH_HAS_BINFMT_FLAT
select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
select BINFMT_FLAT_OLD_ALWAYS_RAM
select GENERIC_ATOMIC64
select HAVE_UID16
select VIRT_TO_BUS
select GENERIC_IRQ_SHOW
select FRAME_POINTER
select GENERIC_CPU_DEVICES
select MODULES_USE_ELF_RELA
select COMMON_CLK
select ARCH_WANT_FRAME_POINTERS
select OF
select OF_IRQ
select OF_EARLY_FLATTREE
select TIMER_OF
select H8300_TMR8
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
select HAVE_ARCH_KGDB
select HAVE_ARCH_HASH
select CPU_NO_EFFICIENT_FFS
select UACCESS_MEMCPY
config CPU_BIG_ENDIAN
def_bool y
config GENERIC_HWEIGHT
def_bool y
config NO_IOPORT_MAP
def_bool y
config GENERIC_CSUM
def_bool y
config HZ
int
default 100
config NR_CPUS
int
default 1
source "arch/h8300/Kconfig.cpu"
# SPDX-License-Identifier: GPL-2.0
config CPU_H8300H
bool
config CPU_H8S
bool
config H83069
bool
select CPU_H8300H
select H8300_TMR16
select RENESAS_H8300H_INTC
config H8S2678
bool
select CPU_H8S
select H8300_TPU
select RENESAS_H8S_INTC
config RAMKERNEL
bool
config ROMKERNEL
bool
menu "Processor type and features"
choice
prompt "H8/300 platform"
config H8300_AE3068
bool "AE-3068/69"
select H83069
select RAMKERNEL
help
AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support
More Information. (Japanese Only)
<http://akizukidenshi.com/catalog/default.aspx>
AE-3068/69 Evaluation Board Support
More Information.
<http://www.microtronique.com/ae3069lan.htm>
config H8300_H8MAX
bool "H8MAX"
select H83069
select RAMKERNEL
help
H8MAX Evaluation Board Support
More Information. (Japanese Only)
<http://strawberry-linux.com/h8/index.html>
config H8300_KANEBEBE
bool "KaneBebe"
select H83069
select RAMKERNEL
help
KaneBebe Evalition Board Support
More Information. (Japanese Only)
<http://www.nissin-tech.com/2009/10/uclinuxkane-bebe-h83069f.html>
config H8300H_SIM
bool "H8/300H GDB Simulator"
select H83069
select ROMKERNEL
help
GDB Simulator Support
More Information.
<http://sourceware.org/sid/>
config H8S_EDOSK2674
bool "EDOSK-2674"
select H8S2678
select RAMKERNEL
help
Renesas EDOSK-2674 Evaluation Board Support
More Information.
<http://www.azpower.com/H8-uClinux/index.html>
<http://www.renesas.eu/products/tools/introductory_evaluation_tools/evaluation_development_os_kits/edosk2674r/edosk2674r_software_tools_root.jsp>
config H8S_SIM
bool "H8S GDB Simulator"
select H8S2678
select ROMKERNEL
help
GDB Simulator Support
More Information.
<http://sourceware.org/sid/>
endchoice
config H8300_BUILTIN_DTB
string "Builtin DTB"
default ""
config OFFSET
hex "Load offset"
default 0
endmenu
# SPDX-License-Identifier: GPL-2.0-only
# dummy file, do not delete
#
# arch/h8300/Makefile
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
#
# (C) Copyright 2002-2015 Yoshinori Sato <ysato@users.sourceforge.jp>
#
KBUILD_DEFCONFIG := edosk2674_defconfig
cflags-$(CONFIG_CPU_H8300H) := -mh
aflags-$(CONFIG_CPU_H8300H) := -mh -Wa,--mach=h8300h
ldflags-$(CONFIG_CPU_H8300H) := -mh8300helf_linux
cflags-$(CONFIG_CPU_H8S) := -ms
aflags-$(CONFIG_CPU_H8S) := -ms -Wa,--mach=h8300s
ldflags-$(CONFIG_CPU_H8S) := -mh8300self_linux
KBUILD_CFLAGS += $(cflags-y)
KBUILD_CFLAGS += -mint32 -fno-builtin
KBUILD_CFLAGS += -D__linux__
KBUILD_CFLAGS += -DUTS_SYSNAME=\"uClinux\"
KBUILD_AFLAGS += $(aflags-y)
KBUILD_LDFLAGS += $(ldflags-y)
CHECKFLAGS += -msize-long
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE := $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-)
endif
libs-y += arch/$(ARCH)/lib/
boot := arch/h8300/boot
vmlinux.srec vmlinux.bin zImage uImage.bin: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
define archhelp
@echo 'vmlinux.bin - Create raw binary'
@echo 'vmlinux.srec - Create srec binary'
@echo 'zImage - Compressed kernel image'
endef
# SPDX-License-Identifier: GPL-2.0
# arch/h8300/boot/Makefile
targets := vmlinux.srec vmlinux.bin zImage
subdir- := compressed
OBJCOPYFLAGS_vmlinux.srec := -Osrec
OBJCOPYFLAGS_vmlinux.bin := -Obinary
OBJCOPYFLAGS_zImage := -O binary -R .note -R .comment -R .stab -R .stabstr -S
UIMAGE_LOADADDR = $(CONFIG_RAMBASE)
UIMAGE_ENTRYADDR = $(shell /bin/bash -c 'printf "0x%08x" \
$$[$(CONFIG_RAMBASE) + $(CONFIG_OFFSET)]')
$(obj)/vmlinux.srec $(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)
$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
$(call if_changed,objcopy)
$(obj)/compressed/vmlinux: FORCE
$(Q)$(MAKE) $(build)=$(obj)/compressed $@
$(obj)/uImage.bin: $(obj)/vmlinux.bin
$(call if_changed,uimage,none)
CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec arch/$(ARCH)/uImage.bin
# SPDX-License-Identifier: GPL-2.0
#
# linux/arch/sh/boot/compressed/Makefile
#
# create a compressed vmlinux image from the original vmlinux
#
targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
OBJECTS = $(obj)/head.o $(obj)/misc.o
#
# IMAGE_OFFSET is the load offset of the compression loader
# Assign dummy values if these 2 variables are not defined,
# in order to suppress error message.
#
CONFIG_MEMORY_START ?= 0x00400000
CONFIG_BOOT_LINK_OFFSET ?= 0x00280000
IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET))))
LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name 2>/dev/null)
LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup -T $(obj)/vmlinux.lds \
--defsym output=$(CONFIG_MEMORY_START)
$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE
$(call if_changed,ld)
$(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)
suffix-$(CONFIG_KERNEL_GZIP) := gzip
suffix-$(CONFIG_KERNEL_LZO) := lzo
compress-$(CONFIG_KERNEL_GZIP) := gzip
compress-$(CONFIG_KERNEL_LZO) := lzo_with_size
$(obj)/vmlinux.bin.$(suffix-y): $(obj)/vmlinux.bin FORCE
$(call if_changed,$(compress-y))
LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T
OBJCOPYFLAGS := -O binary
$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
$(call if_changed,ld)
CFLAGS_misc.o = -O0
/* SPDX-License-Identifier: GPL-2.0 */
/*
* linux/arch/h8300/boot/compressed/head.S
*
* Copyright (C) 2006 Yoshinori Sato
*/
#include <linux/linkage.h>
.section .text..startup,"ax"
.global startup
startup:
mov.l #startup, sp
mov.l er0, er4
mov.l #__sbss, er0
mov.l #__ebss, er1
sub.l er0, er1
shlr er1
shlr er1
sub.l er2, er2
1:
mov.l er2, @er0
adds #4, er0
dec.l #1, er1
bne 1b
jsr @decompress_kernel
mov.l er4, er0
jmp @output
.align 9
fake_headers_as_bzImage:
.word 0
.ascii "HdrS" ; header signature
.word 0x0202 ; header version number (>= 0x0105)
; or else old loadlin-1.5 will fail)
.word 0 ; default_switch
.word 0 ; SETUPSEG
.word 0x1000
.word 0 ; pointing to kernel version string
.byte 0 ; = 0, old one (LILO, Loadlin,
; 0xTV: T=0 for LILO
; V = version
.byte 1 ; Load flags bzImage=1
.word 0x8000 ; size to move, when setup is not
.long 0x100000 ; 0x100000 = default for big kernel
.long 0 ; address of loaded ramdisk image
.long 0 ; its size in bytes
.end
// SPDX-License-Identifier: GPL-2.0
/*
* arch/h8300/boot/compressed/misc.c
*
* This is a collection of several routines from gzip-1.0.3
* adapted for Linux.
*
* malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
*
* Adapted for h8300 by Yoshinori Sato 2006
*/
#include <linux/uaccess.h>
/*
* gzip declarations
*/
#define OF(args) args
#define STATIC static
#undef memset
#undef memcpy
#define memzero(s, n) memset((s), (0), (n))
extern int _end;
static unsigned long free_mem_ptr;
static unsigned long free_mem_end_ptr;
extern char input_data[];
extern int input_len;
extern char output[];
#define HEAP_SIZE 0x10000
#ifdef CONFIG_KERNEL_GZIP
#include "../../../../lib/decompress_inflate.c"
#endif
#ifdef CONFIG_KERNEL_LZO
#include "../../../../lib/decompress_unlzo.c"
#endif
void *memset(void *s, int c, size_t n)
{
int i;
char *ss = (char *)s;
for (i = 0; i < n; i++)
ss[i] = c;
return s;
}
void *memcpy(void *dest, const void *src, size_t n)
{
int i;
char *d = (char *)dest, *s = (char *)src;
for (i = 0; i < n; i++)
d[i] = s[i];
return dest;
}
static void error(char *x)
{
while (1)
; /* Halt */
}
void decompress_kernel(void)
{
free_mem_ptr = (unsigned long)&_end;
free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
__decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);
}
/* SPDX-License-Identifier: GPL-2.0 */
SECTIONS
{
.text :
{
__stext = . ;
__text = .;
*(.text..startup)
*(.text)
__etext = . ;
}
.rodata :
{
*(.rodata)
}
. = ALIGN(0x4) ;
.data :
{
. = ALIGN(0x4) ;
__sdata = . ;
___data_start = . ;
*(.data.*)
}
. = ALIGN(0x4) ;
.bss :
{
__sbss = . ;
*(.bss*)
. = ALIGN(0x4) ;
__ebss = . ;
}
_end = . ;
}
SECTIONS
{
.data : {
input_len = .;
LONG(input_data_end - input_data) input_data = .;
*(.data)
input_data_end = .;
}
}
# SPDX-License-Identifier: GPL-2.0
obj-y += $(addsuffix .dtb.o, $(CONFIG_H8300_BUILTIN_DTB))
dtb-$(CONFIG_H8300H_SIM) := h8300h_sim.dtb
dtb-$(CONFIG_H8S_SIM) := h8s_sim.dtb
dtb-$(CONFIG_H8S_EDOSK2674) := edosk2674.dtb
// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
/ {
compatible = "renesas,edosk2674";
#address-cells = <1>;
#size-cells = <1>;
interrupt-parent = <&h8intc>;
chosen {
bootargs = "console=ttySC2,38400";
stdout-path = &sci2;
};
aliases {
serial0 = &sci0;
serial1 = &sci1;
serial2 = &sci2;
};
xclk: oscillator {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <33333333>;
clock-output-names = "xtal";
};
pllclk: pllclk {
compatible = "renesas,h8s2678-pll-clock";
clocks = <&xclk>;
#clock-cells = <0>;
reg = <0xffff3b 1>, <0xffff45 1>;
};
core_clk: core_clk {
compatible = "renesas,h8300-div-clock";
clocks = <&pllclk>;
#clock-cells = <0>;
reg = <0xffff3b 1>;
renesas,width = <3>;
};
fclk: fclk {
compatible = "fixed-factor-clock";
clocks = <&core_clk>;
#clock-cells = <0>;
clock-div = <1>;
clock-mult = <1>;
};
memory@400000 {
device_type = "memory";
reg = <0x400000 0x800000>;
};
cpus {
#address-cells = <1>;
#size-cells = <0>;
cpu@0 {
compatible = "renesas,h8300";
clock-frequency = <33333333>;
};
};
h8intc: interrupt-controller@fffe00 {
compatible = "renesas,h8s-intc", "renesas,h8300-intc";
#interrupt-cells = <2>;
interrupt-controller;
reg = <0xfffe00 24>;
};
bsc: memory-controller@fffec0 {
compatible = "renesas,h8s-bsc", "renesas,h8300-bsc";
reg = <0xfffec0 24>;
};
tpu: timer@ffffe0 {
compatible = "renesas,tpu";
reg = <0xffffe0 16>, <0xfffff0 12>;
clocks = <&fclk>;
clock-names = "fck";
};
timer8: timer@ffffb0 {
compatible = "renesas,8bit-timer";
reg = <0xffffb0 10>;
interrupts = <72 0>;
clocks = <&fclk>;
clock-names = "fck";
};
sci0: serial@ffff78 {
compatible = "renesas,sci";
reg = <0xffff78 8>;
interrupts = <88 0>, <89 0>, <90 0>, <91 0>;
clocks = <&fclk>;
clock-names = "fck";
};
sci1: serial@ffff80 {
compatible = "renesas,sci";
reg = <0xffff80 8>;
interrupts = <92 0>, <93 0>, <94 0>, <95 0>;
clocks = <&fclk>;
clock-names = "fck";
};
sci2: serial@ffff88 {
compatible = "renesas,sci";
reg = <0xffff88 8>;
interrupts = <96 0>, <97 0>, <98 0>, <99 0>;
clocks = <&fclk>;
clock-names = "fck";
};
};
// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
/ {
compatible = "gnu,gdbsim";
#address-cells = <1>;
#size-cells = <1>;
interrupt-parent = <&h8intc>;
chosen {
bootargs = "earlyprintk=h8300-sim";
stdout-path = <&sci0>;
};
aliases {
serial0 = &sci0;
serial1 = &sci1;
};
xclk: oscillator {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <20000000>;
clock-output-names = "xtal";
};
core_clk: core_clk {
compatible = "renesas,h8300-div-clock";
clocks = <&xclk>;
#clock-cells = <0>;
reg = <0xfee01b 2>;
renesas,width = <2>;
};
fclk: fclk {
compatible = "fixed-factor-clock";
clocks = <&core_clk>;
#clock-cells = <0>;
clock-div = <1>;
clock-mult = <1>;
};
memory@400000 {
device_type = "memory";
reg = <0x400000 0x400000>;
};
cpus {
#address-cells = <1>;
#size-cells = <0>;
cpu@0 {
compatible = "renesas,h8300";
clock-frequency = <20000000>;
};
};
h8intc: interrupt-controller@fee012 {
compatible = "renesas,h8300h-intc", "renesas,h8300-intc";
#interrupt-cells = <2>;
interrupt-controller;
reg = <0xfee012 7>;
};
bsc: memory-controller@fee01e {
compatible = "renesas,h8300h-bsc", "renesas,h8300-bsc";
reg = <0xfee01e 8>;
};
timer8: timer@ffff80 {
compatible = "renesas,8bit-timer";
reg = <0xffff80 10>;
interrupts = <36 0>;
clocks = <&fclk>;
clock-names = "fck";
};
timer16: timer@ffff68 {
compatible = "renesas,16bit-timer";
reg = <0xffff68 8>, <0xffff60 8>;
interrupts = <26 0>;
renesas,channel = <0>;
clocks = <&fclk>;
clock-names = "fck";
};
sci0: serial@ffffb0 {
compatible = "renesas,sci";
reg = <0xffffb0 8>;
interrupts = <52 0>, <53 0>, <54 0>, <55 0>;
clocks = <&fclk>;
clock-names = "fck";
};
sci1: serial@ffffb8 {
compatible = "renesas,sci";
reg = <0xffffb8 8>;
interrupts = <56 0>, <57 0>, <58 0>, <59 0>;
clocks = <&fclk>;
clock-names = "fck";
};
};
// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
/ {
compatible = "gnu,gdbsim";
#address-cells = <1>;
#size-cells = <1>;
interrupt-parent = <&h8intc>;
chosen {
bootargs = "earlyprintk=h8300-sim";
stdout-path = <&sci0>;
};
aliases {
serial0 = &sci0;
serial1 = &sci1;
};
xclk: oscillator {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <33333333>;
clock-output-names = "xtal";
};
pllclk: pllclk {
compatible = "renesas,h8s2678-pll-clock";
clocks = <&xclk>;
#clock-cells = <0>;
reg = <0xfee03b 2>, <0xfee045 2>;
};
core_clk: core_clk {
compatible = "renesas,h8300-div-clock";
clocks = <&pllclk>;
#clock-cells = <0>;
reg = <0xfee03b 2>;
renesas,width = <3>;
};
fclk: fclk {
compatible = "fixed-factor-clock";
clocks = <&core_clk>;
#clock-cells = <0>;
clock-div = <1>;
clock-mult = <1>;
};
memory@400000 {
device_type = "memory";
reg = <0x400000 0x800000>;
};
cpus {
#address-cells = <1>;
#size-cells = <0>;
cpu@0 {
compatible = "renesas,h8300";
clock-frequency = <33333333>;
};
};
h8intc: interrupt-controller@fffe00 {
compatible = "renesas,h8s-intc", "renesas,h8300-intc";
#interrupt-cells = <2>;
interrupt-controller;
reg = <0xfffe00 24>;
};
bsc: memory-controller@fffec0 {
compatible = "renesas,h8s-bsc", "renesas,h8300-bsc";
reg = <0xfffec0 24>;
};
tpu: timer@ffffe0 {
compatible = "renesas,tpu";
reg = <0xffffe0 16>, <0xfffff0 12>;
clocks = <&fclk>;
clock-names = "fck";
};
timer8: timer@ffffb0 {
compatible = "renesas,8bit-timer";
reg = <0xffffb0 10>;
interrupts = <72 0>;
clocks = <&fclk>;
clock-names = "fck";
};
sci0: serial@ffff78 {
compatible = "renesas,sci";
reg = <0xffff78 8>;
interrupts = <88 0>, <89 0>, <90 0>, <91 0>;
clocks = <&fclk>;
clock-names = "fck";
};
sci1: serial@ffff80 {
compatible = "renesas,sci";
reg = <0xffff80 8>;
interrupts = <92 0>, <93 0>, <94 0>, <95 0>;
clocks = <&fclk>;
clock-names = "fck";
};
};
# CONFIG_LOCALVERSION_AUTO is not set
# CONFIG_USELIB is not set
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_UID16 is not set
# CONFIG_SYSFS_SYSCALL is not set
# CONFIG_KALLSYMS is not set
# CONFIG_BASE_FULL is not set
# CONFIG_FUTEX is not set
# CONFIG_EPOLL is not set
# CONFIG_SIGNALFD is not set
# CONFIG_TIMERFD is not set
# CONFIG_EVENTFD is not set
# CONFIG_AIO is not set
# CONFIG_ADVISE_SYSCALLS is not set
CONFIG_EMBEDDED=y
# CONFIG_VM_EVENT_COUNTERS is not set
# CONFIG_COMPAT_BRK is not set
CONFIG_SLOB=y
# CONFIG_BLOCK is not set
CONFIG_H8S_SIM=y
CONFIG_H8300_BUILTIN_DTB="h8s_sim"
# CONFIG_BINFMT_SCRIPT is not set
CONFIG_BINFMT_FLAT=y
# CONFIG_COREDUMP is not set
# CONFIG_UEVENT_HELPER is not set
# CONFIG_STANDALONE is not set
# CONFIG_PREVENT_FIRMWARE_BUILD is not set
# CONFIG_FW_LOADER is not set
# CONFIG_ALLOW_DEV_COREDUMP is not set
# CONFIG_INPUT is not set
# CONFIG_SERIO is not set
# CONFIG_VT is not set
# CONFIG_UNIX98_PTYS is not set
# CONFIG_LEGACY_PTYS is not set
# CONFIG_DEVKMEM is not set
CONFIG_SERIAL_SH_SCI=y
CONFIG_SERIAL_SH_SCI_CONSOLE=y
# CONFIG_HW_RANDOM is not set
# CONFIG_HWMON is not set
# CONFIG_USB_SUPPORT is not set
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
# CONFIG_PROC_FS is not set
# CONFIG_SYSFS is not set
# CONFIG_MISC_FILESYSTEMS is not set
CONFIG_DEBUG_INFO=y
# CONFIG_ENABLE_MUST_CHECK is not set
# CONFIG_LOCALVERSION_AUTO is not set
# CONFIG_USELIB is not set
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_UID16 is not set
# CONFIG_SYSFS_SYSCALL is not set
# CONFIG_KALLSYMS is not set
# CONFIG_BASE_FULL is not set
# CONFIG_FUTEX is not set
# CONFIG_EPOLL is not set
# CONFIG_SIGNALFD is not set
# CONFIG_TIMERFD is not set
# CONFIG_EVENTFD is not set
# CONFIG_AIO is not set
# CONFIG_ADVISE_SYSCALLS is not set
CONFIG_EMBEDDED=y
# CONFIG_VM_EVENT_COUNTERS is not set
# CONFIG_COMPAT_BRK is not set
CONFIG_SLOB=y
# CONFIG_BLOCK is not set
CONFIG_H8300H_SIM=y
CONFIG_H8300_BUILTIN_DTB="h8300h_sim"
# CONFIG_BINFMT_SCRIPT is not set
CONFIG_BINFMT_FLAT=y
# CONFIG_COREDUMP is not set
# CONFIG_UEVENT_HELPER is not set
# CONFIG_STANDALONE is not set
# CONFIG_PREVENT_FIRMWARE_BUILD is not set
# CONFIG_FW_LOADER is not set
# CONFIG_ALLOW_DEV_COREDUMP is not set
# CONFIG_INPUT is not set
# CONFIG_SERIO is not set
# CONFIG_VT is not set
# CONFIG_UNIX98_PTYS is not set
# CONFIG_LEGACY_PTYS is not set
# CONFIG_DEVKMEM is not set
CONFIG_SERIAL_SH_SCI=y
CONFIG_SERIAL_SH_SCI_EARLYCON=y
# CONFIG_HW_RANDOM is not set
# CONFIG_HWMON is not set
# CONFIG_USB_SUPPORT is not set
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
# CONFIG_PROC_FS is not set
# CONFIG_SYSFS is not set
# CONFIG_MISC_FILESYSTEMS is not set
CONFIG_DEBUG_INFO=y
# CONFIG_ENABLE_MUST_CHECK is not set
# CONFIG_LOCALVERSION_AUTO is not set
# CONFIG_USELIB is not set
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_UID16 is not set
# CONFIG_SYSFS_SYSCALL is not set
# CONFIG_KALLSYMS is not set
# CONFIG_BASE_FULL is not set
# CONFIG_FUTEX is not set
# CONFIG_EPOLL is not set
# CONFIG_SIGNALFD is not set
# CONFIG_TIMERFD is not set
# CONFIG_EVENTFD is not set
# CONFIG_AIO is not set
# CONFIG_ADVISE_SYSCALLS is not set
CONFIG_EMBEDDED=y
# CONFIG_VM_EVENT_COUNTERS is not set
# CONFIG_COMPAT_BRK is not set
CONFIG_SLOB=y
# CONFIG_BLOCK is not set
CONFIG_H8S_SIM=y
CONFIG_H8300_BUILTIN_DTB="h8s_sim"
# CONFIG_BINFMT_SCRIPT is not set
CONFIG_BINFMT_FLAT=y
# CONFIG_COREDUMP is not set
# CONFIG_UEVENT_HELPER is not set
# CONFIG_STANDALONE is not set
# CONFIG_PREVENT_FIRMWARE_BUILD is not set
# CONFIG_FW_LOADER is not set
# CONFIG_ALLOW_DEV_COREDUMP is not set
# CONFIG_INPUT is not set
# CONFIG_SERIO is not set
# CONFIG_VT is not set
# CONFIG_UNIX98_PTYS is not set
# CONFIG_LEGACY_PTYS is not set
# CONFIG_DEVKMEM is not set
CONFIG_SERIAL_SH_SCI=y
CONFIG_SERIAL_SH_SCI_CONSOLE=y
# CONFIG_HW_RANDOM is not set
# CONFIG_HWMON is not set
# CONFIG_USB_SUPPORT is not set
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
# CONFIG_PROC_FS is not set
# CONFIG_SYSFS is not set
# CONFIG_MISC_FILESYSTEMS is not set
CONFIG_DEBUG_INFO=y
# CONFIG_ENABLE_MUST_CHECK is not set
# SPDX-License-Identifier: GPL-2.0
generic-y += asm-offsets.h
generic-y += cmpxchg.h
generic-y += extable.h
generic-y += kvm_para.h
generic-y += mcs_spinlock.h
generic-y += parport.h
generic-y += spinlock.h
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_BITOPS_H
#define _H8300_BITOPS_H
/*
* Copyright 1992, Linus Torvalds.
* Copyright 2002, Yoshinori Sato
*/
#include <linux/compiler.h>
#include <asm-generic/bitops/fls.h>
#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/fls64.h>
#ifdef __KERNEL__
#ifndef _LINUX_BITOPS_H
#error only <linux/bitops.h> can be included directly
#endif
/*
* Function prototypes to keep gcc -Wall happy
*/
/*
* ffz = Find First Zero in word. Undefined if no zero exists,
* so code should check against ~0UL first..
*/
static inline unsigned long ffz(unsigned long word)
{
unsigned long result;
result = -1;
__asm__("1:\n\t"
"shlr.l %1\n\t"
"adds #1,%0\n\t"
"bcs 1b"
: "=r"(result),"=r"(word)
: "0"(result), "1"(word));
return result;
}
#define H8300_GEN_BITOP(FNAME, OP) \
static inline void FNAME(int nr, volatile unsigned long *addr) \
{ \
unsigned char *b_addr; \
unsigned char bit = nr & 7; \
\
b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3); \
if (__builtin_constant_p(nr)) { \
__asm__(OP " %1,%0" : "+WU"(*b_addr) : "i"(nr & 7)); \
} else { \
__asm__(OP " %s1,%0" : "+WU"(*b_addr) : "r"(bit)); \
} \
}
H8300_GEN_BITOP(set_bit, "bset")
H8300_GEN_BITOP(clear_bit, "bclr")
H8300_GEN_BITOP(change_bit, "bnot")
#define __set_bit(nr, addr) set_bit((nr), (addr))
#define __clear_bit(nr, addr) clear_bit((nr), (addr))
#define __change_bit(nr, addr) change_bit((nr), (addr))
#undef H8300_GEN_BITOP
static inline int test_bit(int nr, const volatile unsigned long *addr)
{
int ret = 0;
unsigned char *b_addr;
unsigned char bit = nr & 7;
b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3);
if (__builtin_constant_p(nr)) {
__asm__("bld %Z2,%1\n\t"
"rotxl %0\n\t"
: "=r"(ret)
: "WU"(*b_addr), "i"(nr & 7), "0"(ret) : "cc");
} else {
__asm__("btst %w2,%1\n\t"
"beq 1f\n\t"
"inc.l #1,%0\n"
"1:"
: "=r"(ret)
: "WU"(*b_addr), "r"(bit), "0"(ret) : "cc");
}
return ret;
}
#define __test_bit(nr, addr) test_bit(nr, addr)
#define H8300_GEN_TEST_BITOP(FNNAME, OP) \
static inline int FNNAME(int nr, void *addr) \
{ \
int retval = 0; \
char ccrsave; \
unsigned char *b_addr; \
unsigned char bit = nr & 7; \
\
b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3); \
if (__builtin_constant_p(nr)) { \
__asm__("stc ccr,%s2\n\t" \
"orc #0x80,ccr\n\t" \
"bld %4,%1\n\t" \
OP " %4,%1\n\t" \
"rotxl.l %0\n\t" \
"ldc %s2,ccr" \
: "=r"(retval), "+WU" (*b_addr), "=&r"(ccrsave) \
: "0"(retval), "i"(nr & 7) : "cc"); \
} else { \
__asm__("stc ccr,%t3\n\t" \
"orc #0x80,ccr\n\t" \
"btst %s3,%1\n\t" \
OP " %s3,%1\n\t" \
"beq 1f\n\t" \
"inc.l #1,%0\n\t" \
"1:\n" \
"ldc %t3,ccr" \
: "=r"(retval), "+WU" (*b_addr) \
: "0" (retval), "r"(bit) : "cc"); \
} \
return retval; \
} \
\
static inline int __ ## FNNAME(int nr, void *addr) \
{ \
int retval = 0; \
unsigned char *b_addr; \
unsigned char bit = nr & 7; \
\
b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3); \
if (__builtin_constant_p(nr)) { \
__asm__("bld %3,%1\n\t" \
OP " %3,%1\n\t" \
"rotxl.l %0\n\t" \
: "=r"(retval), "+WU"(*b_addr) \
: "0" (retval), "i"(nr & 7)); \
} else { \
__asm__("btst %s3,%1\n\t" \
OP " %s3,%1\n\t" \
"beq 1f\n\t" \
"inc.l #1,%0\n\t" \
"1:" \
: "=r"(retval), "+WU"(*b_addr) \
: "0" (retval), "r"(bit)); \
} \
return retval; \
}
H8300_GEN_TEST_BITOP(test_and_set_bit, "bset")
H8300_GEN_TEST_BITOP(test_and_clear_bit, "bclr")
H8300_GEN_TEST_BITOP(test_and_change_bit, "bnot")
#undef H8300_GEN_TEST_BITOP
#include <asm-generic/bitops/ffs.h>
static inline unsigned long __ffs(unsigned long word)
{
unsigned long result;
result = -1;
__asm__("1:\n\t"
"shlr.l %1\n\t"
"adds #1,%0\n\t"
"bcc 1b"
: "=r" (result),"=r"(word)
: "0"(result), "1"(word));
return result;
}
#include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/hweight.h>
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#endif /* __KERNEL__ */
#endif /* _H8300_BITOPS_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_BUG_H
#define _H8300_BUG_H
/* always true */
#define is_valid_bugaddr(addr) (1)
#include <asm-generic/bug.h>
struct pt_regs;
extern void die(const char *str, struct pt_regs *fp, unsigned long err);
#endif
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __H8300_BYTEORDER_H__
#define __H8300_BYTEORDER_H__
#include <linux/byteorder/big_endian.h>
#endif
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ARCH_H8300_CACHE_H
#define __ARCH_H8300_CACHE_H
/* bytes per L1 cache line */
#define L1_CACHE_SHIFT 2
#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
#define __cacheline_aligned
#define ____cacheline_aligned
#endif
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_H8300_ELF_H
#define __ASM_H8300_ELF_H
/*
* ELF register definitions..
*/
#include <asm/ptrace.h>
#include <asm/user.h>
typedef unsigned long elf_greg_t;
#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
typedef unsigned long elf_fpregset_t;
/*
* This is used to ensure we don't load something for the wrong architecture.
*/
#define elf_check_arch(x) ((x)->e_machine == EM_H8_300)
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_H8_300
#if defined(CONFIG_CPU_H8300H)
#define ELF_CORE_EFLAGS 0x810000
#endif
#if defined(CONFIG_CPU_H8S)
#define ELF_CORE_EFLAGS 0x820000
#endif
#define ELF_PLAT_INIT(_r) do { (_r)->er1 = 0; } while (0)
#define ELF_EXEC_PAGESIZE 4096
/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
use of this is to invoke "./ld.so someprog" to test out a new version of
the loader. We need to make sure that it is out of the way of the program
that it will "exec", and that there is sufficient room for the brk. */
#define ELF_ET_DYN_BASE 0xD0000000UL
/* This yields a mask that user programs can use to figure out what
instruction set this cpu supports. */
#define ELF_HWCAP (0)
/* This yields a string that ld.so will use to load implementation
specific libraries for optimization. This is more specific in
intent than poking at uname or /proc/cpuinfo. */
#define ELF_PLATFORM (NULL)
#define R_H8_NONE 0
#define R_H8_DIR32 1
#define R_H8_DIR32_28 2
#define R_H8_DIR32_24 3
#define R_H8_DIR32_16 4
#define R_H8_DIR32U 6
#define R_H8_DIR32U_28 7
#define R_H8_DIR32U_24 8
#define R_H8_DIR32U_20 9
#define R_H8_DIR32U_16 10
#define R_H8_DIR24 11
#define R_H8_DIR24_20 12
#define R_H8_DIR24_16 13
#define R_H8_DIR24U 14
#define R_H8_DIR24U_20 15
#define R_H8_DIR24U_16 16
#define R_H8_DIR16 17
#define R_H8_DIR16U 18
#define R_H8_DIR16S_32 19
#define R_H8_DIR16S_28 20
#define R_H8_DIR16S_24 21
#define R_H8_DIR16S_20 22
#define R_H8_DIR16S 23
#define R_H8_DIR8 24
#define R_H8_DIR8U 25
#define R_H8_DIR8Z_32 26
#define R_H8_DIR8Z_28 27
#define R_H8_DIR8Z_24 28
#define R_H8_DIR8Z_20 29
#define R_H8_DIR8Z_16 30
#define R_H8_PCREL16 31
#define R_H8_PCREL8 32
#define R_H8_BPOS 33
#define R_H8_PCREL32 34
#define R_H8_GOT32O 35
#define R_H8_GOT16O 36
#define R_H8_DIR16A8 59
#define R_H8_DIR16R8 60
#define R_H8_DIR24A8 61
#define R_H8_DIR24R8 62
#define R_H8_DIR32A16 63
#define R_H8_ABS32 65
#define R_H8_ABS32A16 127
#endif
/* SPDX-License-Identifier: GPL-2.0 */
/*
* arch/h8300/asm/include/flat.h -- uClinux flat-format executables
*/
#ifndef __H8300_FLAT_H__
#define __H8300_FLAT_H__
#include <asm/unaligned.h>
/*
* on the H8 a couple of the relocations have an instruction in the
* top byte. As there can only be 24bits of address space, we just
* always preserve that 8bits at the top, when it isn't an instruction
* is is 0 (davidm@snapgear.com)
*/
#define flat_get_relocate_addr(rel) (rel & ~0x00000001)
static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
u32 *addr)
{
u32 val = get_unaligned((__force u32 *)rp);
if (!(flags & FLAT_FLAG_GOTPIC))
val &= 0x00ffffff;
*addr = val;
return 0;
}
static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
{
u32 *p = (__force u32 *)rp;
put_unaligned((addr & 0x00ffffff) | (*(char *)p << 24), p);
return 0;
}
#endif /* __H8300_FLAT_H__ */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_HASH_H
#define _ASM_HASH_H
/*
* The later H8SX models have a 32x32-bit multiply, but the H8/300H
* and H8S have only 16x16->32. Since it's tolerably compact, this is
* basically an inlined version of the __mulsi3 code. Since the inputs
* are not expected to be small, it's also simplfied by skipping the
* early-out checks.
*
* (Since neither CPU has any multi-bit shift instructions, a
* shift-and-add version is a non-starter.)
*
* TODO: come up with an arch-specific version of the hashing in fs/namei.c,
* since that is heavily dependent on rotates. Which, as mentioned, suck
* horribly on H8.
*/
#if defined(CONFIG_CPU_H300H) || defined(CONFIG_CPU_H8S)
#define HAVE_ARCH__HASH_32 1
/*
* Multiply by k = 0x61C88647. Fitting this into three registers requires
* one extra instruction, but reducing register pressure will probably
* make that back and then some.
*
* GCC asm note: %e1 is the high half of operand %1, while %f1 is the
* low half. So if %1 is er4, then %e1 is e4 and %f1 is r4.
*
* This has been designed to modify x in place, since that's the most
* common usage, but preserve k, since hash_64() makes two calls in
* quick succession.
*/
static inline u32 __attribute_const__ __hash_32(u32 x)
{
u32 temp;
asm( "mov.w %e1,%f0"
"\n mulxu.w %f2,%0" /* klow * xhigh */
"\n mov.w %f0,%e1" /* The extra instruction */
"\n mov.w %f1,%f0"
"\n mulxu.w %e2,%0" /* khigh * xlow */
"\n add.w %e1,%f0"
"\n mulxu.w %f2,%1" /* klow * xlow */
"\n add.w %f0,%e1"
: "=&r" (temp), "=r" (x)
: "%r" (GOLDEN_RATIO_32), "1" (x));
return x;
}
#endif
#endif /* _ASM_HASH_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_IO_H
#define _H8300_IO_H
#ifdef __KERNEL__
#include <linux/types.h>
/* H8/300 internal I/O functions */
#define __raw_readb __raw_readb
static inline u8 __raw_readb(const volatile void __iomem *addr)
{
return *(volatile u8 *)addr;
}
#define __raw_readw __raw_readw
static inline u16 __raw_readw(const volatile void __iomem *addr)
{
return *(volatile u16 *)addr;
}
#define __raw_readl __raw_readl
static inline u32 __raw_readl(const volatile void __iomem *addr)
{
return *(volatile u32 *)addr;
}
#define __raw_writeb __raw_writeb
static inline void __raw_writeb(u8 b, const volatile void __iomem *addr)
{
*(volatile u8 *)addr = b;
}
#define __raw_writew __raw_writew
static inline void __raw_writew(u16 b, const volatile void __iomem *addr)
{
*(volatile u16 *)addr = b;
}
#define __raw_writel __raw_writel
static inline void __raw_writel(u32 b, const volatile void __iomem *addr)
{
*(volatile u32 *)addr = b;
}
static inline void ctrl_bclr(int b, void __iomem *addr)
{
if (__builtin_constant_p(b))
__asm__("bclr %1,%0" : "+WU"(*(u8 *)addr): "i"(b));
else
__asm__("bclr %w1,%0" : "+WU"(*(u8 *)addr): "r"(b));
}
static inline void ctrl_bset(int b, void __iomem *addr)
{
if (__builtin_constant_p(b))
__asm__("bset %1,%0" : "+WU"(*(u8 *)addr): "i"(b));
else
__asm__("bset %w1,%0" : "+WU"(*(u8 *)addr): "r"(b));
}
#include <asm-generic/io.h>
#endif /* __KERNEL__ */
#endif /* _H8300_IO_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_IRQ_H_
#define _H8300_IRQ_H_
#if defined(CONFIG_CPU_H8300H)
#define NR_IRQS 64
#define IRQ_CHIP h8300h_irq_chip
#define EXT_IRQ0 12
#define EXT_IRQS 6
#elif defined(CONFIG_CPU_H8S)
#define NR_IRQS 128
#define IRQ_CHIP h8s_irq_chip
#define EXT_IRQ0 16
#define EXT_IRQS 16
#endif
static inline int irq_canonicalize(int irq)
{
return irq;
}
void h8300_init_ipr(void);
extern struct irq_chip h8300h_irq_chip;
extern struct irq_chip h8s_irq_chip;
#endif /* _H8300_IRQ_H_ */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_IRQFLAGS_H
#define _H8300_IRQFLAGS_H
#ifdef CONFIG_CPU_H8300H
typedef unsigned char h8300flags;
static inline h8300flags arch_local_save_flags(void)
{
h8300flags flags;
__asm__ volatile ("stc ccr,%w0" : "=r" (flags));
return flags;
}
static inline void arch_local_irq_disable(void)
{
__asm__ volatile ("orc #0xc0,ccr");
}
static inline void arch_local_irq_enable(void)
{
__asm__ volatile ("andc #0x3f,ccr");
}
static inline h8300flags arch_local_irq_save(void)
{
h8300flags flags;
__asm__ volatile ("stc ccr,%w0\n\t"
"orc #0xc0,ccr" : "=r" (flags));
return flags;
}
static inline void arch_local_irq_restore(h8300flags flags)
{
__asm__ volatile ("ldc %w0,ccr" : : "r" (flags) : "cc");
}
static inline int arch_irqs_disabled_flags(unsigned long flags)
{
return (flags & 0xc0) == 0xc0;
}
#endif
#ifdef CONFIG_CPU_H8S
typedef unsigned short h8300flags;
static inline h8300flags arch_local_save_flags(void)
{
h8300flags flags;
__asm__ volatile ("stc ccr,%w0\n\tstc exr,%x0" : "=r" (flags));
return flags;
}
static inline void arch_local_irq_disable(void)
{
__asm__ volatile ("orc #0x80,ccr\n\t");
}
static inline void arch_local_irq_enable(void)
{
__asm__ volatile ("andc #0x7f,ccr\n\t"
"andc #0xf0,exr\n\t");
}
static inline h8300flags arch_local_irq_save(void)
{
h8300flags flags;
__asm__ volatile ("stc ccr,%w0\n\t"
"stc exr,%x0\n\t"
"orc #0x80,ccr\n\t"
: "=r" (flags));
return flags;
}
static inline void arch_local_irq_restore(h8300flags flags)
{
__asm__ volatile ("ldc %w0,ccr\n\t"
"ldc %x0,exr"
: : "r" (flags) : "cc");
}
static inline int arch_irqs_disabled_flags(h8300flags flags)
{
return (flags & 0x0080) == 0x0080;
}
#endif
static inline int arch_irqs_disabled(void)
{
return arch_irqs_disabled_flags(arch_local_save_flags());
}
#endif /* _H8300_IRQFLAGS_H */
/*
* Copyright (C) 2015 Yoshinori Sato <ysato@users.sourceforge.jp>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
#ifndef _ASM_H8300_KGDB_H
#define _ASM_H8300_KGDB_H
#define CACHE_FLUSH_IS_SAFE 1
#define BUFMAX 2048
enum regnames {
GDB_ER0, GDB_ER1, GDB_ER2, GDB_ER3,
GDB_ER4, GDB_ER5, GDB_ER6, GDB_SP,
GDB_CCR, GDB_PC,
GDB_CYCLLE,
#if defined(CONFIG_CPU_H8S)
GDB_EXR,
#endif
GDB_TICK, GDB_INST,
#if defined(CONFIG_CPU_H8S)
GDB_MACH, GDB_MACL,
#endif
/* do not change the last entry or anything below! */
GDB_NUMREGBYTES, /* number of registers */
};
#define GDB_SIZEOF_REG sizeof(u32)
#if defined(CONFIG_CPU_H8300H)
#define DBG_MAX_REG_NUM (13)
#elif defined(CONFIG_CPU_H8S)
#define DBG_MAX_REG_NUM (14)
#endif
#define NUMREGBYTES (DBG_MAX_REG_NUM * GDB_SIZEOF_REG)
#define BREAK_INSTR_SIZE 2
static inline void arch_kgdb_breakpoint(void)
{
__asm__ __volatile__("trapa #2");
}
#endif /* _ASM_H8300_KGDB_H */
#ifndef _ASM_H8300_MMU_CONTEXT_H
#define _ASM_H8300_MMU_CONTEXT_H
#include <asm-generic/nommu_context.h>
#endif /* _ASM_H8300_MMU_CONTEXT_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_PAGE_H
#define _H8300_PAGE_H
#include <asm-generic/page.h>
#include <linux/types.h>
#define MAP_NR(addr) (((uintptr_t)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
#ifndef __ASSEMBLY__
extern unsigned long rom_length;
extern unsigned long memory_start;
extern unsigned long memory_end;
extern unsigned long _ramend;
#endif
#endif
#define PAGE_OFFSET_RAW 0x00000000
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_PGTABLE_H
#define _H8300_PGTABLE_H
#include <asm-generic/pgtable-nopud.h>
extern void paging_init(void);
#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
#define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
#define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
#define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
#define __swp_type(x) (0)
#define __swp_offset(x) (0)
#define __swp_entry(typ, off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
#define kern_addr_valid(addr) (1)
#define pgprot_writecombine(prot) (prot)
#define pgprot_noncached pgprot_writecombine
static inline int pte_file(pte_t pte) { return 0; }
#define swapper_pg_dir ((pgd_t *) 0)
/*
* ZERO_PAGE is a global shared page that is always zero: used
* for zero-mapped memory areas etc..
*/
#define ZERO_PAGE(vaddr) (virt_to_page(0))
/*
* These would be in other places but having them here reduces the diffs.
*/
extern unsigned int kobjsize(const void *objp);
extern int is_in_rom(unsigned long);
/*
* All 32bit addresses are effectively valid for vmalloc...
* Sort of meaningless for non-VM targets.
*/
#define VMALLOC_START 0
#define VMALLOC_END 0xffffffff
#define arch_enter_lazy_cpu_mode() do {} while (0)
#endif /* _H8300_PGTABLE_H */
/* SPDX-License-Identifier: GPL-2.0 */
/*
* include/asm-h8300/processor.h
*
* Copyright (C) 2002 Yoshinori Sato
*
* Based on: linux/asm-m68nommu/processor.h
*
* Copyright (C) 1995 Hamish Macdonald
*/
#ifndef __ASM_H8300_PROCESSOR_H
#define __ASM_H8300_PROCESSOR_H
#include <linux/compiler.h>
#include <asm/ptrace.h>
#include <asm/current.h>
static inline unsigned long rdusp(void)
{
extern unsigned int _sw_usp;
return _sw_usp;
}
static inline void wrusp(unsigned long usp)
{
extern unsigned int _sw_usp;
_sw_usp = usp;
}
/*
* User space process size: 3.75GB. This is hardcoded into a few places,
* so don't change it unless you know what you are doing.
*/
#define TASK_SIZE (0xFFFFFFFFUL)
#ifdef __KERNEL__
#define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif
/*
* This decides where the kernel will search for a free chunk of vm
* space during mmap's. We won't be using it
*/
#define TASK_UNMAPPED_BASE 0
struct thread_struct {
unsigned long ksp; /* kernel stack pointer */
unsigned long usp; /* user stack pointer */
unsigned long ccr; /* saved status register */
unsigned long esp0; /* points to SR of stack frame */
struct {
unsigned short *addr;
unsigned short inst;
} breakinfo;
};
#define INIT_THREAD { \
.ksp = sizeof(init_stack) + (unsigned long)init_stack, \
.usp = 0, \
.ccr = PS_S, \
.esp0 = 0, \
.breakinfo = { \
.addr = (unsigned short *)-1, \
.inst = 0 \
} \
}
/*
* Do necessary setup to start up a newly executed thread.
*
* pass the data segment into user programs if it exists,
* it can't hurt anything as far as I can tell
*/
#if defined(CONFIG_CPU_H8300H)
#define start_thread(_regs, _pc, _usp) \
do { \
(_regs)->pc = (_pc); \
(_regs)->ccr = 0x00; /* clear all flags */ \
(_regs)->er5 = current->mm->start_data; /* GOT base */ \
(_regs)->sp = ((unsigned long)(_usp)) - sizeof(unsigned long) * 3; \
} while (0)
#endif
#if defined(CONFIG_CPU_H8S)
#define start_thread(_regs, _pc, _usp) \
do { \
(_regs)->pc = (_pc); \
(_regs)->ccr = 0x00; /* clear kernel flag */ \
(_regs)->exr = 0x78; /* enable all interrupts */ \
(_regs)->er5 = current->mm->start_data; /* GOT base */ \
/* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \
(_regs)->sp = ((unsigned long)(_usp)) - 14; \
} while (0)
#endif
/* Forward declaration, a strange C thing */
struct task_struct;
/* Free all resources held by a thread. */
static inline void release_thread(struct task_struct *dead_task)
{
}
unsigned long __get_wchan(struct task_struct *p);
#define KSTK_EIP(tsk) \
({ \
unsigned long eip = 0; \
if ((tsk)->thread.esp0 > PAGE_SIZE && \
MAP_NR((tsk)->thread.esp0) < max_mapnr) \
eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
eip; })
#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
#define cpu_relax() barrier()
#define HARD_RESET_NOW() ({ \
local_irq_disable(); \
asm("jmp @@0"); \
})
#endif
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_PTRACE_H
#define _H8300_PTRACE_H
#include <uapi/asm/ptrace.h>
struct task_struct;
#ifndef __ASSEMBLY__
#ifndef PS_S
#define PS_S (0x10)
#endif
#if defined(CONFIG_CPU_H8300H)
#define H8300_REGS_NO 11
#endif
#if defined(CONFIG_CPU_H8S)
#define H8300_REGS_NO 12
#endif
#define arch_has_single_step() (1)
#define user_mode(regs) (!((regs)->ccr & PS_S))
#define instruction_pointer(regs) ((regs)->pc)
#define profile_pc(regs) instruction_pointer(regs)
#define user_stack_pointer(regs) ((regs)->sp)
#define current_pt_regs() ((struct pt_regs *) \
(THREAD_SIZE + (unsigned long)current_thread_info()) - 1)
#define signal_pt_regs() ((struct pt_regs *)current->thread.esp0)
#define current_user_stack_pointer() rdusp()
#define task_pt_regs(task) \
((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1)
extern long h8300_get_reg(struct task_struct *task, int regno);
extern int h8300_put_reg(struct task_struct *task, int regno,
unsigned long data);
#endif /* __ASSEMBLY__ */
#endif /* _H8300_PTRACE_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_SIGNAL_H
#define _H8300_SIGNAL_H
#include <uapi/asm/signal.h>
/* Most things should be clean enough to redefine this at will, if care
is taken to make libc match. */
#define _NSIG 64
#define _NSIG_BPW 32
#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
typedef unsigned long old_sigset_t; /* at least 32 bits */
typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;
#define __ARCH_HAS_SA_RESTORER
#include <asm/sigcontext.h>
#endif /* _H8300_SIGNAL_H */
/* nothing required here yet */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_STRING_H_
#define _H8300_STRING_H_
#ifdef __KERNEL__ /* only set these up for kernel code */
#include <asm/setup.h>
#include <asm/page.h>
#define __HAVE_ARCH_MEMSET
extern void *memset(void *s, int c, size_t count);
#define __HAVE_ARCH_MEMCPY
extern void *memcpy(void *d, const void *s, size_t count);
#endif /* KERNEL */
#endif
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_SWITCH_TO_H
#define _H8300_SWITCH_TO_H
/*
* switch_to(n) should switch tasks to task ptr, first checking that
* ptr isn't the current task, in which case it does nothing. This
* also clears the TS-flag if the task we switched to has used the
* math co-processor latest.
*/
/*
* switch_to() saves the extra registers, that are not saved
* automatically by SAVE_SWITCH_STACK in resume(), ie. d0-d5 and
* a0-a1. Some of these are used by schedule() and its predecessors
* and so we might get see unexpected behaviors when a task returns
* with unexpected register values.
*
* syscall stores these registers itself and none of them are used
* by syscall after the function in the syscall has been called.
*
* Beware that resume now expects *next to be in d1 and the offset of
* tss to be in a1. This saves a few instructions as we no longer have
* to push them onto the stack and read them back right after.
*
* 02/17/96 - Jes Sorensen (jds@kom.auc.dk)
*
* Changed 96/09/19 by Andreas Schwab
* pass prev in a0, next in a1, offset of tss in d1, and whether
* the mm structures are shared in d2 (to avoid atc flushing).
*
* H8/300 Porting 2002/09/04 Yoshinori Sato
*/
asmlinkage void resume(void);
#define switch_to(prev, next, last) \
do { \
void *_last; \
__asm__ __volatile__( \
"mov.l %1, er0\n\t" \
"mov.l %2, er1\n\t" \
"mov.l %3, er2\n\t" \
"jsr @_resume\n\t" \
"mov.l er2,%0\n\t" \
: "=r" (_last) \
: "r" (&(prev->thread)), \
"r" (&(next->thread)), \
"g" (prev) \
: "cc", "er0", "er1", "er2", "er3"); \
(last) = _last; \
} while (0)
#endif /* _H8300_SWITCH_TO_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_H8300_SYSCALLS_32_H
#define __ASM_H8300_SYSCALLS_32_H
#ifdef __KERNEL__
#include <linux/compiler.h>
#include <linux/linkage.h>
#include <linux/types.h>
#include <linux/ptrace.h>
#include <uapi/linux/audit.h>
static inline int
syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
{
return regs->orig_er0;
}
static inline void
syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
unsigned long *args)
{
*args++ = regs->er1;
*args++ = regs->er2;
*args++ = regs->er3;
*args++ = regs->er4;
*args++ = regs->er5;
*args = regs->er6;
}
static inline int
syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_H8300;
}
/* Misc syscall related bits */
asmlinkage long do_syscall_trace_enter(struct pt_regs *regs);
asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
#endif /* __KERNEL__ */
#endif /* __ASM_H8300_SYSCALLS_32_H */
/* SPDX-License-Identifier: GPL-2.0 */
/* thread_info.h: h8300 low-level thread information
* adapted from the i386 and PPC versions by Yoshinori Sato <ysato@users.sourceforge.jp>
*
* Copyright (C) 2002 David Howells (dhowells@redhat.com)
* - Incorporating suggestions made by Linus Torvalds and Dave Miller
*/
#ifndef _ASM_THREAD_INFO_H
#define _ASM_THREAD_INFO_H
#include <asm/page.h>
#ifdef __KERNEL__
/*
* Size of kernel stack for each process. This must be a power of 2...
*/
#define THREAD_SIZE_ORDER 1
#define THREAD_SIZE 8192 /* 2 pages */
#ifndef __ASSEMBLY__
/*
* low level task data.
* If you change this, change the TI_* offsets below to match.
*/
struct thread_info {
struct task_struct *task; /* main task structure */
unsigned long flags; /* low level flags */
int cpu; /* cpu we're on */
int preempt_count; /* 0 => preemptable, <0 => BUG */
};
/*
* macros/functions for gaining access to the thread information structure
*/
#define INIT_THREAD_INFO(tsk) \
{ \
.task = &tsk, \
.flags = 0, \
.cpu = 0, \
.preempt_count = INIT_PREEMPT_COUNT, \
}
/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
__asm__("mov.l sp, %0\n\t"
"and.w %1, %T0"
: "=&r"(ti)
: "i" (~(THREAD_SIZE-1) & 0xffff));
return ti;
}
#endif /* __ASSEMBLY__ */
/*
* thread information flag bit numbers
*/
#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
#define TIF_SIGPENDING 1 /* signal pending */
#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
#define TIF_SINGLESTEP 3 /* singlestepping active */
#define TIF_MEMDIE 4 /* is terminating due to OOM killer */
#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
#define TIF_NOTIFY_RESUME 6 /* callback before returning to user */
#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
#define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */
#define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling TIF_NEED_RESCHED */
#define TIF_NOTIFY_SIGNAL 10 /* signal notifications exist */
/* as above, but as bit values */
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
#define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
/* work to do in syscall trace */
#define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
_TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
/* work to do on any return to u-space */
#define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \
_TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \
_TIF_SINGLESTEP | _TIF_NOTIFY_RESUME | \
_TIF_SYSCALL_TRACEPOINT | _TIF_NOTIFY_SIGNAL)
/* work to do on interrupt/exception return */
#define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
_TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
#endif /* __KERNEL__ */
#endif /* _ASM_THREAD_INFO_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __H8300_TLB_H__
#define __H8300_TLB_H__
#include <asm-generic/tlb.h>
#endif
/*
* linux/include/asm-h8300/traps.h
*
* Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/
#ifndef _H8300_TRAPS_H
#define _H8300_TRAPS_H
extern void _system_call(void);
extern void _interrupt_entry(void);
extern void _trace_break(void);
extern void _nmi(void);
extern void _interrupt_entry(void);
extern unsigned long *_interrupt_redirect_table;
#define JMP_OP 0x5a000000
#define JSR_OP 0x5e000000
#define VECTOR(address) ((JMP_OP)|((unsigned long)address))
#define REDIRECT(address) ((JSR_OP)|((unsigned long)address))
#define CPU_VECTOR ((unsigned long *)0x000000)
#define ADDR_MASK (0xffffff)
#define TRACE_VEC 5
#define TRAP0_VEC 8
#define TRAP1_VEC 9
#define TRAP2_VEC 10
#define TRAP3_VEC 11
extern char _start[], _etext[];
#define check_kernel_text(addr) \
((addr >= (unsigned long)(_start)) && \
(addr < (unsigned long)(_etext)) && !(addr & 1))
#endif /* _H8300_TRAPS_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _H8300_USER_H
#define _H8300_USER_H
#include <asm/page.h>
/* Core file format: The core file is written in such a way that gdb
can understand it and provide useful information to the user (under
linux we use the 'trad-core' bfd). There are quite a number of
obstacles to being able to view the contents of the floating point
registers, and until these are solved you will not be able to view the
contents of them. Actually, you can read in the core file and look at
the contents of the user struct to find out what the floating point
registers contain.
The actual file contents are as follows:
UPAGE: 1 page consisting of a user struct that tells gdb what is present
in the file. Directly after this is a copy of the task_struct, which
is currently not used by gdb, but it may come in useful at some point.
All of the registers are stored as part of the upage. The upage should
always be only one page.
DATA: The data area is stored. We use current->end_text to
current->brk to pick up all of the user variables, plus any memory
that may have been malloced. No attempt is made to determine if a page
is demand-zero or if a page is totally unused, we just cover the entire
range. All of the addresses are rounded in such a way that an integral
number of pages is written.
STACK: We need the stack information in order to get a meaningful
backtrace. We need to write the data from (esp) to
current->start_stack, so we round each of these off in order to be able
to write an integer number of pages.
The minimum core file size is 3 pages, or 12288 bytes.
*/
/* This is the old layout of "struct pt_regs" as of Linux 1.x, and
is still the layout used by user (the new pt_regs doesn't have
all registers). */
struct user_regs_struct {
long er1, er2, er3, er4, er5, er6;
long er0;
long usp;
long orig_er0;
long ccr;
long pc;
};
/* When the kernel dumps core, it starts by dumping the user struct -
this will be used by gdb to figure out where the data and stack segments
are within the file, and what virtual addresses to use. */
struct user {
/* We start with the registers, to mimic the way that "memory" is returned
from the ptrace(3,...) function. */
struct user_regs_struct regs; /* Where the registers are actually stored */
/* ptrace does not yet supply these. Someday.... */
/* The rest of this junk is to help gdb figure out what goes where */
unsigned long int u_tsize; /* Text segment size (pages). */
unsigned long int u_dsize; /* Data segment size (pages). */
unsigned long int u_ssize; /* Stack segment size (pages). */
unsigned long start_code; /* Starting virtual address of text. */
unsigned long start_stack; /* Starting virtual address of stack area.
This is actually the bottom of the stack,
the top of the stack is always found in the
esp register. */
long int signal; /* Signal that caused the core dump. */
int reserved; /* No longer used */
unsigned long u_ar0; /* Used by gdb to help find the values for */
/* the registers. */
unsigned long magic; /* To uniquely identify a core file */
char u_comm[32]; /* User command that was responsible */
};
#endif
#ifndef _ASM_H8300_VMALLOC_H
#define _ASM_H8300_VMALLOC_H
#endif /* _ASM_H8300_VMALLOC_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment