diff -ruP -Xcludes linux-2.4.6.uclinux-orig/CREDITS linux-2.4.6/CREDITS --- linux-2.4.6.uclinux-orig/CREDITS Fri Jun 29 06:58:05 2001 +++ linux-2.4.6/CREDITS Thu Sep 20 11:55:40 2001 @@ -155,6 +155,14 @@ S: Calgary, Alberta S: Canada +N: Miles Bader +E: miles@gnu.org +D: v850 port (uClinux) +S: NEC Corporation +S: 1753 Shimonumabe, Nakahara-ku +S: Kawasaki 211-8666 +S: Japan + N: Ralf Baechle E: ralf@gnu.org P: 1024/AF7B30C1 CF 97 C2 CC 6D AE A7 FE C8 BA 9C FC 88 DE 32 C3 diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/Makefile linux-2.4.6/arch/v850/Makefile --- linux-2.4.6.uclinux-orig/arch/v850/Makefile Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/Makefile Thu Sep 20 11:24:58 2001 @@ -0,0 +1,67 @@ +# +# arch/v850/Makefile +# +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. Remember to do have actions +# for "archclean" and "archdep" for cleaning up and making dependencies for +# this architecture +# +# 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. +# + +UTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\" + +# r16 is a fixed pointer to the current task +CFLAGS += -pipe -ffixed-r16 -mv850e -mno-prolog-function -fno-builtin -DNO_MM -DNO_FPU -D__ELF__ $(UTS_SYSNAME) -D__linux__ + + +# linker scripts +ifdef CONFIG_SIM +LINKFLAGS = -T $(TOPDIR)/arch/v850/sim.ld +endif +ifdef CONFIG_RTE_MA1_CB +ifdef CONFIG_ROM_KERNEL +LINKFLAGS = -T $(TOPDIR)/arch/v850/rte_ma1_cb-rom.ld +else +LINKFLAGS = -T $(TOPDIR)/arch/v850/rte_ma1_cb.ld +endif +endif + +HEAD := arch/$(ARCH)/kernel/head.o + +SUBDIRS += arch/$(ARCH)/kernel arch/$(ARCH)/lib +CORE_FILES := arch/v850/kernel/kernel.o $(CORE_FILES) +LIBS += arch/v850/lib/lib.a + +# Link in root filesystem +ifdef CONFIG_RTE_MA1_CB +CORE_FILES += blkmem0.o + +# Note that we use the build-system's objcopy, as the v850 tools are fairly +# old, and don't have the --rename-section option. +blkmem0.o: root.ext2 + objcopy -I binary -O elf32-little -B i386 --rename-section .data=.blkmem0,alloc,load,readonly,data,contents $< $@ +endif + +# +# If you want the kernel build to build modules outside of the tree +# then define this and pass it to the main linux makefile +# +ifdef EXTRA_MODULE_DIRS +SUBDIRS += $(EXTRA_MODULE_DIRS) +endif + +bootstrap: + @$(MAKEBOOT) bootstrap + +archmrproper: + +archdep: + +archclean: + rm -f $(LINUX) + rm -f arch/v850/kernel/v850_defs.h arch/v850/kernel/v850_defs.d + +include $(TOPDIR)/Rules.make diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/README linux-2.4.6/arch/v850/README --- linux-2.4.6.uclinux-orig/arch/v850/README Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/README Wed Oct 10 18:07:04 2001 @@ -0,0 +1,13 @@ +This port to the NEC v850e processor supports the following platforms: + + + The gdb v850e simulator (CONFIG_SIM); see the subdirectory `sim' for some + more support files for this. + + + The Midas labs RTE-V850E/MA1-CB evaluation board (CONFIG_RTE_MA1_CB), + with untested support for the RTE-V850E/NB85E-CB board + (CONFIG_RTE_NB85E_CB). This support has only been tested when running + with the Multi-debugger monitor ROM (for the Green Hills Multi debugger). + +Porting to anything with a V850E/MA1 or MA2 processor should be simple. +See the file and the files it includes for an example of +how to add platform/chip-specific support. diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/config.in linux-2.4.6/arch/v850/config.in --- linux-2.4.6.uclinux-orig/arch/v850/config.in Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/config.in Tue Oct 2 14:10:31 2001 @@ -0,0 +1,297 @@ +############################################################################# +# +# For a description of the syntax of this configuration file, +# see Documentation/kbuild/config-language.txt. +# +# based mainly on the arch/i386/config.in and bit of the 2.0, m68knommu +# config.in +# +############################################################################# + +mainmenu_name 'uClinux/v850 (w/o MMU) Kernel Configuration' + +define_bool CONFIG_UCLINUX y +define_bool CONFIG_UID16 y +define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y +define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n + +############################################################################# + +mainmenu_option next_comment +comment 'Code maturity level options' +bool 'Prompt for development and/or incomplete code/drivers' CONFIG_EXPERIMENTAL +endmenu + +############################################################################# + +mainmenu_option next_comment +comment 'Loadable module support' +bool 'Enable loadable module support' CONFIG_MODULES +if [ "$CONFIG_MODULES" = "y" ]; then + bool ' Set version information on all module symbols' CONFIG_MODVERSIONS + bool ' Kernel module loader' CONFIG_KMOD +fi +endmenu + +############################################################################# + +mainmenu_option next_comment +comment 'Processor type and features' + +# initialize dependent values +#define_bool CONFIG_V850E_MA1 n +#define_bool CONFIG_V850E_TEG n +#define_bool CONFIG_V850E_NB85E n +#define_bool CONFIG_NB85E_UART n +#define_bool CONFIG_RTE_CB n +#define_bool CONFIG_ROM_KERNEL n + +choice 'Platform' \ + "RTE-V850E/MA1-CB CONFIG_RTE_MA1_CB \ + RTE-V850E/NB85E-CB CONFIG_RTE_NB85E_CB \ + GDB CONFIG_SIM" \ + gdb + +if [ "$CONFIG_RTE_MA1_CB" = y ]; then + define_bool CONFIG_V850E_MA1 y + define_bool CONFIG_V850E_TEG n + define_bool CONFIG_RTE_CB y +fi + +if [ "$CONFIG_RTE_NB85E_CB" = y ]; then + define_bool CONFIG_V850E_TEG y + define_bool CONFIG_V850E_MA1 n + define_bool CONFIG_RTE_CB y +fi + +if [ "$CONFIG_SIM" = y ]; then + define_bool CONFIG_V850E_MA1 n + define_bool CONFIG_V850E_TEG n + define_bool CONFIG_V850E_NB85E n + define_bool CONFIG_RTE_CB n +else + # All CPUs current supported except for the simular use the the nb85e core + define_bool CONFIG_V850E_NB85E y +fi + +# All CPUs currently supported use the v850e architecture +define_bool CONFIG_V850E y + +if [ "$CONFIG_RTE_CB" = y ]; then + bool 'Kernel in ROM' CONFIG_ROM_KERNEL + if [ "$CONFIG_ROM_KERNEL" = n ]; then + bool 'Enable Multi debugger support' CONFIG_RTE_CB_MULTI + else + define_bool CONFIG_RTE_CB_MULTI n + fi +else + define_bool CONFIG_ROM_KERNEL n + define_bool CONFIG_RTE_CB_MULTI n +fi + +if [ "$CONFIG_V850E_MA1" = y ]; then + bool 'Enable on-chip UART support' CONFIG_NB85E_UART +elif [ "$CONFIG_V850E_TEG" = y ]; then + bool 'Enable on-chip UART support' CONFIG_NB85E_UART +else + define_bool CONFIG_NB85E_UART n +fi + +endmenu + +############################################################################# + +mainmenu_option next_comment +comment 'General setup' + +bool 'Networking support' CONFIG_NET + +source drivers/pci/Config.in + +if [ "$CONFIG_VISWS" != "y" ]; then + bool 'MCA support' CONFIG_MCA +fi + +bool 'Support for hot-pluggable devices' CONFIG_HOTPLUG + +if [ "$CONFIG_HOTPLUG" = "y" ] ; then + source drivers/pcmcia/Config.in +else + define_bool CONFIG_PCMCIA n +fi + +bool 'System V IPC' CONFIG_SYSVIPC +bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT +bool 'Sysctl support' CONFIG_SYSCTL +if [ "$CONFIG_PROC_FS" = "y" ]; then + choice 'Kernel core (/proc/kcore) format' \ + "ELF CONFIG_KCORE_ELF \ + A.OUT CONFIG_KCORE_AOUT" ELF +fi +tristate 'Kernel support for flat binaries' CONFIG_BINFMT_FLAT +if [ "$CONFIG_BINFMT_FLAT" != "n" ]; then + bool ' Enable ZFLAT support' CONFIG_BINFMT_ZFLAT +fi +tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT +tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF +tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC + +bool 'Power Management support' CONFIG_PM + +dep_bool ' ACPI support' CONFIG_ACPI $CONFIG_PM +if [ "$CONFIG_ACPI" != "n" ]; then + if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + bool ' ACPI interpreter (EXPERIMENTAL)' CONFIG_ACPI_INTERPRETER + bool ' Enter S1 for sleep (EXPERIMENTAL)' CONFIG_ACPI_S1_SLEEP + fi +fi + +endmenu + +############################################################################# + +source drivers/mtd/Config.in + +source drivers/parport/Config.in + +source drivers/pnp/Config.in + +source drivers/block/Config.in + +if [ "$CONFIG_NET" = "y" ]; then + source net/Config.in +fi + +source drivers/telephony/Config.in + +############################################################################# + +mainmenu_option next_comment +comment 'ATA/IDE/MFM/RLL support' + +tristate 'ATA/IDE/MFM/RLL support' CONFIG_IDE + +if [ "$CONFIG_IDE" != "n" ]; then + source drivers/ide/Config.in +else + define_bool CONFIG_BLK_DEV_IDE_MODES n + define_bool CONFIG_BLK_DEV_HD n +fi +endmenu + +############################################################################# + +mainmenu_option next_comment +comment 'SCSI support' + +tristate 'SCSI support' CONFIG_SCSI + +if [ "$CONFIG_SCSI" != "n" ]; then + source drivers/scsi/Config.in +fi +endmenu + +############################################################################# + +source drivers/ieee1394/Config.in + +source drivers/i2o/Config.in + +if [ "$CONFIG_NET" = "y" ]; then + mainmenu_option next_comment + comment 'Network device support' + + bool 'Network device support' CONFIG_NETDEVICES + if [ "$CONFIG_NETDEVICES" = "y" ]; then + source drivers/net/Config.in + if [ "$CONFIG_ATM" = "y" ]; then + source drivers/atm/Config.in + fi + fi + endmenu +fi + +source net/ax25/Config.in + +source net/irda/Config.in + +############################################################################# + +mainmenu_option next_comment +comment 'ISDN subsystem' +if [ "$CONFIG_NET" != "n" ]; then + tristate 'ISDN support' CONFIG_ISDN + if [ "$CONFIG_ISDN" != "n" ]; then + source drivers/isdn/Config.in + fi +fi +endmenu + +############################################################################# + +mainmenu_option next_comment +comment 'Old CD-ROM drivers (not SCSI, not IDE)' + +bool 'Support non-SCSI/IDE/ATAPI CDROM drives' CONFIG_CD_NO_IDESCSI +if [ "$CONFIG_CD_NO_IDESCSI" != "n" ]; then + source drivers/cdrom/Config.in +fi +endmenu + +############################################################################# + +source drivers/char/Config.in + + +#source drivers/misc/Config.in + +source fs/Config.in + +if [ "$CONFIG_VT" = "y" ]; then + mainmenu_option next_comment + comment 'Console drivers' + bool 'VGA text console' CONFIG_VGA_CONSOLE + bool 'Video mode selection support' CONFIG_VIDEO_SELECT + if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + tristate 'MDA text console (dual-headed) (EXPERIMENTAL)' CONFIG_MDA_CONSOLE + source drivers/video/Config.in + fi + endmenu +fi + +############################################################################# + +mainmenu_option next_comment +comment 'Sound' + +tristate 'Sound card support' CONFIG_SOUND +if [ "$CONFIG_SOUND" != "n" ]; then + source drivers/sound/Config.in +fi +endmenu + +############################################################################# + +source drivers/usb/Config.in + +############################################################################# + +mainmenu_option next_comment +comment 'Kernel hacking' + +bool 'Full Symbolic/Source Debugging support' CONFIG_FULLDEBUG +#bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC +bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ + +bool 'Kernel profiling support' CONFIG_PROFILE +if [ "$CONFIG_PROFILE" = "y" ]; then + int ' Profile shift count' CONFIG_PROFILE_SHIFT 2 + bool 'Use fast second timer for profiling' CONFIG_HIGHPROFILE +fi + +bool 'Suppress Kernel BUG Messages' CONFIG_NO_KERNEL_MSG + +endmenu + + +############################################################################# diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/Makefile linux-2.4.6/arch/v850/kernel/Makefile --- linux-2.4.6.uclinux-orig/arch/v850/kernel/Makefile Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/Makefile Thu Oct 4 16:35:29 2001 @@ -0,0 +1,42 @@ +# +# arch/v850/kernel/Makefile +# +# Copyright (C) 2001 NEC Corporation +# Copyright (C) 2001 Miles Bader +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# + +all: head.o kernel.o + +USE_STANDARD_AS_RULE := true + +O_TARGET := kernel.o +obj-y := intv.o entry.o process.o syscalls.o time.o semaphore.o setup.o \ + signal.o irq.o mach.o ptrace.o v850_ksyms.o bug.o + +# chip-specific code +obj-$(CONFIG_V850E_MA1) += ma.o nb85e_utils.o nb85e_timer_d.o +obj-$(CONFIG_V850E_NB85E) += nb85e.o +# platform-specific code +obj-$(CONFIG_SIM) += sim.o simcons.o +obj-$(CONFIG_RTE_CB) += rte_cb.o +obj-$(CONFIG_RTE_MA1_CB) += rte_ma1_cb.o +obj-$(CONFIG_RTE_NB85E_CB) += rte_nb85e_cb.o +obj-$(CONFIG_RTE_CB_MULTI) += rte_cb_multi.o + +head.o: head.S v850_defs.h +entry.o: entry.S v850_defs.h + +v850_defs.h: v850_defs.c v850_defs.head + rm -f v850_defs.d + SUNPRO_DEPENDENCIES="v850_defs.d v850_defs.h" \ + $(CC) $(filter-out -MD,$(CFLAGS)) -S v850_defs.c + cp v850_defs.head v850_defs.h + grep '^#define' v850_defs.s >> v850_defs.h + rm v850_defs.s +-include v850_defs.d + +include $(TOPDIR)/Rules.make diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/bug.c linux-2.4.6/arch/v850/kernel/bug.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/bug.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/bug.c Mon Oct 1 17:43:00 2001 @@ -0,0 +1,58 @@ +/* + * arch/v850/kernel/bug.c -- Bug reporting functions + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include + +#include +#include +#include + +void __bug (const char *file, int line, void *data) +{ + if (data) + printk (KERN_CRIT "kernel BUG at %s:%d (data = %p)!\n", + file, line, data); + else + printk (KERN_CRIT "kernel BUG at %s:%d!\n", file, line); + + machine_halt (); +} + +int bad_trap (int trap_num, struct pt_regs *regs) +{ + printk (KERN_CRIT + "unimplemented trap %d called at 0x%08lx, pid %d!\n", + trap_num, regs->pc, current->pid); + return -ENOSYS; +} + +int debug_trap (struct pt_regs *regs) +{ + printk (KERN_CRIT "debug trap at 0x%08lx!\n", regs->pc); + return -ENOSYS; +} + +void unexpected_reset (unsigned long ret_addr, unsigned long kmode, + struct task_struct *task, unsigned long sp) +{ + printk (KERN_CRIT + "unexpected reset in %s mode, pid %d" + " (ret_addr = 0x%lx, sp = 0x%lx)\n", + kmode ? "kernel" : "user", + task ? task->pid : -1, + ret_addr, sp); + + machine_halt (); +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/entry.S linux-2.4.6/arch/v850/kernel/entry.S --- linux-2.4.6.uclinux-orig/arch/v850/kernel/entry.S Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/entry.S Wed Oct 10 14:28:35 2001 @@ -0,0 +1,1049 @@ +/* + * arch/v850/kernel/entry.S -- Low-level system-call handling, trap handlers, + * and context-switching + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include + +#include +#include +#include +#include +#include + +#include "v850_defs.h" + + +/* If non-zero, printk message for each syscall entry/exit. */ +#define TRACE_TRAPS 0 + + +/* Make a slightly more convenient alias for C_SYMBOL_NAME. */ +#define CSYM C_SYMBOL_NAME + + +/* The offset of the struct pt_regs in a `state save frame' on the stack. */ +#define PTO STATE_SAVE_PT_OFFSET + + +/* Save argument registers to the struct pt_regs pointed to by EP. */ +#define SAVE_ARG_REGS \ + sst.w r6, PTO+PT_GPR(6)[ep]; \ + sst.w r7, PTO+PT_GPR(7)[ep]; \ + sst.w r8, PTO+PT_GPR(8)[ep]; \ + sst.w r9, PTO+PT_GPR(9)[ep]; +/* Restore argument registers from the struct pt_regs pointed to by EP. */ +#define RESTORE_ARG_REGS \ + sld.w PTO+PT_GPR(6)[ep], r6; \ + sld.w PTO+PT_GPR(7)[ep], r7; \ + sld.w PTO+PT_GPR(8)[ep], r8; \ + sld.w PTO+PT_GPR(9)[ep], r9; + +/* Save value return registers to the struct pt_regs pointed to by EP. */ +#define SAVE_RVAL_REGS \ + sst.w r10, PTO+PT_GPR(10)[ep]; \ + sst.w r11, PTO+PT_GPR(11)[ep]; +/* Restore value return registers from the struct pt_regs pointed to by EP. */ +#define RESTORE_RVAL_REGS \ + sld.w PTO+PT_GPR(10)[ep], r10; \ + sld.w PTO+PT_GPR(11)[ep], r11; + + +#define SAVE_CALL_CLOBBERED_REGS_BEFORE_ARGS \ + sst.w r1, PTO+PT_GPR(1)[ep]; \ + sst.w r5, PTO+PT_GPR(5)[ep]; +#define SAVE_CALL_CLOBBERED_REGS_AFTER_RVAL \ + sst.w r12, PTO+PT_GPR(12)[ep]; \ + sst.w r13, PTO+PT_GPR(13)[ep]; \ + sst.w r14, PTO+PT_GPR(14)[ep]; \ + sst.w r15, PTO+PT_GPR(15)[ep]; \ + sst.w r16, PTO+PT_GPR(16)[ep]; \ + sst.w r17, PTO+PT_GPR(17)[ep]; \ + sst.w r18, PTO+PT_GPR(18)[ep]; \ + sst.w r19, PTO+PT_GPR(19)[ep]; +#define RESTORE_CALL_CLOBBERED_REGS_BEFORE_ARGS \ + sld.w PTO+PT_GPR(1)[ep], r1; \ + sld.w PTO+PT_GPR(5)[ep], r5; +#define RESTORE_CALL_CLOBBERED_REGS_AFTER_RVAL \ + sld.w PTO+PT_GPR(12)[ep], r12; \ + sld.w PTO+PT_GPR(13)[ep], r13; \ + sld.w PTO+PT_GPR(14)[ep], r14; \ + sld.w PTO+PT_GPR(15)[ep], r15; \ + sld.w PTO+PT_GPR(16)[ep], r16; \ + sld.w PTO+PT_GPR(17)[ep], r17; \ + sld.w PTO+PT_GPR(18)[ep], r18; \ + sld.w PTO+PT_GPR(19)[ep], r19; + +/* Save `call clobbered' registers to the struct pt_regs pointed to by EP. */ +#define SAVE_CALL_CLOBBERED_REGS \ + SAVE_CALL_CLOBBERED_REGS_BEFORE_ARGS; \ + SAVE_ARG_REGS; \ + SAVE_RVAL_REGS; \ + SAVE_CALL_CLOBBERED_REGS_AFTER_RVAL; +/* Restore `call clobbered' registers from the struct pt_regs pointed to + by EP. */ +#define RESTORE_CALL_CLOBBERED_REGS \ + RESTORE_CALL_CLOBBERED_REGS_BEFORE_ARGS; \ + RESTORE_ARG_REGS; \ + RESTORE_RVAL_REGS; \ + RESTORE_CALL_CLOBBERED_REGS_AFTER_RVAL; + +/* Save `call clobbered' registers except for the return-value registers + to the struct pt_regs pointed to by EP. */ +#define SAVE_CALL_CLOBBERED_REGS_NO_RVAL \ + SAVE_CALL_CLOBBERED_REGS_BEFORE_ARGS; \ + SAVE_ARG_REGS; \ + SAVE_CALL_CLOBBERED_REGS_AFTER_RVAL; +/* Restore `call clobbered' registers except for the return-value registers + from the struct pt_regs pointed to by EP. */ +#define RESTORE_CALL_CLOBBERED_REGS_NO_RVAL \ + RESTORE_CALL_CLOBBERED_REGS_BEFORE_ARGS; \ + RESTORE_ARG_REGS; \ + RESTORE_CALL_CLOBBERED_REGS_AFTER_RVAL; + +/* Zero `call clobbered' registers except for the return-value registers. */ +#define ZERO_CALL_CLOBBERED_REGS_NO_RVAL \ + mov r0, r1; mov r0, r5; \ + mov r0, r12; mov r0, r13; mov r0, r14; mov r0, r15; \ + mov r0, r16; mov r0, r17; mov r0, r18; mov r0, r19; + +/* Save `call saved' registers to the struct pt_regs pointed to by EP. */ +#define SAVE_CALL_SAVED_REGS \ + sst.w r2, PTO+PT_GPR(2)[ep]; \ + sst.w r20, PTO+PT_GPR(20)[ep]; \ + sst.w r21, PTO+PT_GPR(21)[ep]; \ + sst.w r22, PTO+PT_GPR(22)[ep]; \ + sst.w r23, PTO+PT_GPR(23)[ep]; \ + sst.w r24, PTO+PT_GPR(24)[ep]; \ + sst.w r25, PTO+PT_GPR(25)[ep]; \ + sst.w r26, PTO+PT_GPR(26)[ep]; \ + sst.w r27, PTO+PT_GPR(27)[ep]; \ + sst.w r28, PTO+PT_GPR(28)[ep]; \ + sst.w r29, PTO+PT_GPR(29)[ep]; +/* Restore `call saved' registers from the struct pt_regs pointed to by EP. */ +#define RESTORE_CALL_SAVED_REGS \ + sld.w PTO+PT_GPR(2)[ep], r2; \ + sld.w PTO+PT_GPR(20)[ep], r20; \ + sld.w PTO+PT_GPR(21)[ep], r21; \ + sld.w PTO+PT_GPR(22)[ep], r22; \ + sld.w PTO+PT_GPR(23)[ep], r23; \ + sld.w PTO+PT_GPR(24)[ep], r24; \ + sld.w PTO+PT_GPR(25)[ep], r25; \ + sld.w PTO+PT_GPR(26)[ep], r26; \ + sld.w PTO+PT_GPR(27)[ep], r27; \ + sld.w PTO+PT_GPR(28)[ep], r28; \ + sld.w PTO+PT_GPR(29)[ep], r29; + + +/* Save system registers to the struct pt_regs pointed to by REG. + r19 is clobbered. */ +#define SAVE_SYS_REGS \ + stsr SR_EIPC, r19; /* user's PC, before interrupt */ \ + sst.w r19, PTO+PT_PC[ep]; \ + stsr SR_EIPSW, r19; /* & PSW (XXX save this?) */ \ + sst.w r19, PTO+PT_PSW[ep]; \ + stsr SR_CTPC, r19; /* (XXX maybe not used in kernel?) */ \ + sst.w r19, PTO+PT_CTPC[ep]; \ + stsr SR_CTPSW, r19; /* " */ \ + sst.w r19, PTO+PT_CTPSW[ep]; \ + stsr SR_CTBP, r19; /* " */ \ + sst.w r19, PTO+PT_CTBP[ep]; +/* Restore system registers from the struct pt_regs pointed to by EP. + LP is clobbered (it is used as a scratch register because the POP_STATE + macro restores it, and this macro is usually used inside POP_STATE). */ +#define RESTORE_SYS_REGS \ + sld.w PTO+PT_PC[ep], lp; \ + ldsr lp, SR_EIPC; /* user's PC, before interrupt */ \ + sld.w PTO+PT_PSW[ep], lp; \ + ldsr lp, SR_EIPSW; /* & PSW (XXX save this?) */ \ + sld.w PTO+PT_CTPC[ep], lp; \ + ldsr lp, SR_CTPC; /* (XXX maybe not used in kernel?) */ \ + sld.w PTO+PT_CTPSW[ep], lp; \ + ldsr lp, SR_CTPSW; /* " */ \ + sld.w PTO+PT_CTBP[ep], lp; \ + ldsr lp, SR_CTBP; /* " */ + + +/* Save system registers to the struct pt_regs pointed to by REG. This is a + NMI-specific version, because NMIs save the PC/PSW in a different place + than other interrupt requests. r19 is clobbered. */ +#define SAVE_SYS_REGS_FOR_NMI \ + stsr SR_FEPC, r19; /* user's PC, before NMI */ \ + sst.w r19, PTO+PT_PC[ep]; \ + stsr SR_FEPSW, r19; /* & PSW (XXX save this?) */ \ + sst.w r19, PTO+PT_PSW[ep]; \ + stsr SR_CTPC, r19; /* (XXX maybe not used in kernel?) */ \ + sst.w r19, PTO+PT_CTPC[ep]; \ + stsr SR_CTPSW, r19; /* " */ \ + sst.w r19, PTO+PT_CTPSW[ep]; \ + stsr SR_CTBP, r19; /* " */ \ + sst.w r19, PTO+PT_CTBP[ep]; +/* Restore system registers from the struct pt_regs pointed to by EP. This is + a NMI-specific version, because NMIs save the PC/PSW in a different place + than other interrupt requests. LP is clobbered (it is used as a scratch + register because the POP_STATE macro restores it, and this macro is usually + used inside POP_STATE). */ +#define RESTORE_SYS_REGS_FOR_NMI \ + ldsr lp, SR_FEPC; /* user's PC, before NMI */ \ + sld.w PTO+PT_PC[ep], lp; \ + ldsr lp, SR_FEPSW; /* & PSW (XXX save this?) */ \ + sld.w PTO+PT_PSW[ep], lp; \ + ldsr lp, SR_CTPC; /* (XXX maybe not used in kernel?) */ \ + sld.w PTO+PT_CTPC[ep], lp; \ + ldsr lp, SR_CTPSW; /* " */ \ + sld.w PTO+PT_CTPSW[ep], lp; \ + ldsr lp, SR_CTBP; /* " */ \ + sld.w PTO+PT_CTBP[ep], lp; + + +/* Push register state, except for the stack pointer, on the stack in the form + of a struct pt_regs, in preparation for a system call. This macro makes + sure that `special' registers, system registers; TYPE identifies the set of + extra registers to be saved as well. EP is clobbered. */ +#define PUSH_STATE(type) \ + addi -STATE_SAVE_SIZE, sp, sp; /* Make room on the stack. */ \ + st.w ep, PTO+PT_GPR(GPR_EP)[sp]; \ + mov sp, ep; \ + sst.w gp, PTO+PT_GPR(GPR_GP)[ep]; \ + sst.w lp, PTO+PT_GPR(GPR_LP)[ep]; \ + type ## _STATE_SAVER; +/* Pop a register state, except for the stack pointer, from the struct pt_regs + on the stack. */ +#define POP_STATE(type) \ + mov sp, ep; \ + type ## _STATE_RESTORER; \ + sld.w PTO+PT_GPR(GPR_GP)[ep], gp; \ + sld.w PTO+PT_GPR(GPR_LP)[ep], lp; \ + sld.w PTO+PT_GPR(GPR_EP)[ep], ep; \ + addi STATE_SAVE_SIZE, sp, sp; /* Clean up our stack space. */ + + +/* Switch to the kernel stack if necessary, and push register state on the + stack in the form of a struct pt_regs. Also load the current task pointer + if switching from user mode. This macro makes sure that `special' + registers, system registers, and the stack pointer are saved; TYPE + identifies the set of extra registers to be saved as well. SYSCALL_NUM is + the register in which the system-call number this state is for is stored + (r0 if this isn't a system call). Interrupts should already be disabled + when calling this. */ +#define SAVE_STATE(type, syscall_num) \ + tst1 0, KM; /* See if already in kernel mode. */ \ + bz 1f; \ + /* Kernel-mode state save. */ \ + st.w sp, (PT_GPR(GPR_SP)-PT_SIZE)[sp]; /* Save original SP. */ \ + PUSH_STATE(type); \ + mov 1, r19; /* Was in kernel-mode. */ \ + sst.w r19, PTO+PT_KERNEL_MODE[ep]; /* [ep is set by PUSH_STATE] */ \ + br 2f; \ +1: /* User-mode state save. */ \ + st.w sp, USP_SCRATCH; /* Save user stack pointer. */ \ + ld.w KSP, sp; /* Switch to kernel stack. */ \ + PUSH_STATE(type); \ + sst.w r0, PTO+PT_KERNEL_MODE[ep]; /* Was in user-mode. */ \ + ld.w USP_SCRATCH, r19; \ + sst.w r19, PTO+PT_GPR(GPR_SP)[ep]; /* Store user SP. */ \ + mov 1, r19; \ + st.b r19, KM; /* Now we're in kernel-mode. */ \ + GET_CURRENT_TASK(CURRENT_TASK); /* Fetch the current task pointer. */ \ +2: /* Save away the syscall number. */ \ + sst.w syscall_num, PTO+PT_SYSCALL[ep] + + +/* Save register state not normally saved by PUSH_STATE for TYPE. */ +#define SAVE_EXTRA_STATE(type) \ + mov sp, ep; \ + type ## _EXTRA_STATE_SAVER; +/* Restore register state not normally restored by POP_STATE for TYPE. */ +#define RESTORE_EXTRA_STATE(type) \ + mov sp, ep; \ + type ## _EXTRA_STATE_RESTORER; + +/* Save any call-clobbered registers not normally saved by PUSH_STATE + for TYPE. */ +#define SAVE_EXTRA_STATE_FOR_FUNCALL(type) \ + mov sp, ep; \ + type ## _FUNCALL_EXTRA_STATE_SAVER; +/* Restore any call-clobbered registers not normally restored by POP_STATE for + TYPE. */ +#define RESTORE_EXTRA_STATE_FOR_FUNCALL(type) \ + mov sp, ep; \ + type ## _FUNCALL_EXTRA_STATE_RESTORER; + + +/* These are extra_state_saver/restorer values for a user trap. Note that we + save the argument registers so that restarted syscalls will function + properly (otherwise it wouldn't be necessary), and we must _not_ restore + the return-value registers (so that traps can return a value!), but there + are various options for what happens to other call-clobbered registers, + selected by preprocessor conditionals. */ + +#if TRAPS_PRESERVE_CALL_CLOBBERED_REGS + +/* Traps save/restore all call-clobbered registers (except for rval regs). */ +#define TRAP_STATE_SAVER \ + SAVE_CALL_CLOBBERED_REGS_NO_RVAL; \ + SAVE_SYS_REGS +#define TRAP_STATE_RESTORER \ + RESTORE_CALL_CLOBBERED_REGS_NO_RVAL; \ + RESTORE_SYS_REGS + +#else /* !TRAPS_PRESERVE_CALL_CLOBBERED_REGS */ + +/* Traps don't save call-clobbered registers (but do still save arg regs). */ +#define TRAP_STATE_SAVER \ + SAVE_ARG_REGS; \ + SAVE_SYS_REGS + +#if TRAPS_ZERO_CALL_CLOBBERED_REGS + +/* Traps zero call-clobbered registers (except for arg/rval regs) before + returning from a system call, to avoid any internal values from leaking out + of the kernel. */ +#define TRAP_STATE_RESTORER \ + ZERO_CALL_CLOBBERED_REGS_NO_ARGS_NO_RVAL; \ + RESTORE_ARG_REGS; \ + RESTORE_SYS_REGS + +#else /* !TRAPS_ZERO_CALL_CLOBBERED_REGS */ + +/* When traps return, they just leave call-clobbered registers (except for arg + regs) with whatever value they have from the kernel. */ +#define TRAP_STATE_RESTORER \ + RESTORE_ARG_REGS; \ + RESTORE_SYS_REGS + +#endif /* TRAPS_ZERO_CALL_CLOBBERED_REGS */ +#endif /* TRAPS_PRESERVE_CALL_CLOBBERED_REGS */ + +/* Save registers not normally saved by traps. */ +#define TRAP_EXTRA_STATE_SAVER \ + SAVE_RVAL_REGS; \ + SAVE_CALL_SAVED_REGS +#define TRAP_EXTRA_STATE_RESTORER \ + RESTORE_RVAL_REGS; \ + RESTORE_CALL_SAVED_REGS +#define TRAP_FUNCALL_EXTRA_STATE_SAVER \ + SAVE_RVAL_REGS +#define TRAP_FUNCALL_EXTRA_STATE_RESTORER \ + RESTORE_RVAL_REGS + + +/* Register saving/restoring for maskable interrupts. */ +#define INTERRUPT_STATE_SAVER \ + SAVE_CALL_CLOBBERED_REGS; \ + SAVE_SYS_REGS +#define INTERRUPT_STATE_RESTORER \ + RESTORE_CALL_CLOBBERED_REGS; \ + RESTORE_SYS_REGS +#define INTERRUPT_EXTRA_STATE_SAVER \ + SAVE_CALL_SAVED_REGS +#define INTERRUPT_EXTRA_STATE_RESTORER \ + RESTORE_CALL_SAVED_REGS +#define INTERRUPT_FUNCALL_EXTRA_STATE_SAVER /* nothing */ +#define INTERRUPT_FUNCALL_EXTRA_STATE_RESTORER /* nothing */ + +/* Register saving/restoring for non-maskable interrupts. */ +#define NMI_STATE_SAVER \ + SAVE_CALL_CLOBBERED_REGS; \ + SAVE_SYS_REGS_FOR_NMI +#define NMI_STATE_RESTORER \ + RESTORE_CALL_CLOBBERED_REGS; \ + RESTORE_SYS_REGS_FOR_NMI +#define NMI_EXTRA_STATE_SAVER \ + SAVE_CALL_SAVED_REGS +#define NMI_EXTRA_STATE_RESTORER \ + RESTORE_CALL_SAVED_REGS +#define NMI_FUNCALL_EXTRA_STATE_SAVER /* nothing */ +#define NMI_FUNCALL_EXTRA_STATE_RESTORER /* nothing */ + +/* Register saving/restoring for a context switch. We don't need to save too + many registers, because context-switching looks like a function call (via + the function `switch_thread'), so callers will save any call-clobbered + registers themselves. The stack pointer and return value are handled by + switch_thread itself. */ +#define SWITCH_STATE_SAVER \ + SAVE_CALL_SAVED_REGS +#define SWITCH_STATE_RESTORER \ + RESTORE_CALL_SAVED_REGS + + +/* Restore register state from the struct pt_regs on the stack, switch back + to the user stack if necessary, and return from the trap/interrupt. + EXTRA_STATE_RESTORER is a sequence of assembly language statements to + restore anything not restored by this macro. Only registers not saved by + the C compiler are restored (that is, R3(sp), R4(gp), R31(lp), and + anything restored by EXTRA_STATE_RESTORER). */ +#define RETURN(type) \ + ld.b PTO+PT_KERNEL_MODE[sp], r19; \ + di; /* Disable interrupts */ \ + cmp r19, r0; /* See if returning to kernel mode, */\ + bne 2f; /* ... if so, skip resched &c. */ \ + \ + /* We're returning to user mode, so check for various conditions that \ + trigger rescheduling. */ \ + ld.w TASK_NEED_RESCHED[CURRENT_TASK], r18; \ + cmp r18, r0; \ + bnz 3f; /* Call the scheduler. */ \ + \ + /* XXX Is PT_DTRACE handling needed here? */ \ + /* XXX m68knommu also checks TASK_STATE & TASK_COUNTER here. */ \ + \ + /* Maybe handle a signal */ \ + ld.w TASK_SIGPENDING[CURRENT_TASK], r18; /* Pending signals */ \ + cmp r18, r0; \ + bnz 4f; /* Signals to handle, handle them */ \ + \ +/* Finally, return to user state. */ \ +1: st.b r0, KM; /* Now officially in user state. */ \ + POP_STATE(type); \ + st.w sp, KSP; /* Save the kernel stack pointer. */ \ + ld.w PT_GPR(GPR_SP)-PT_SIZE[sp], sp; \ + /* Restore user stack pointer. */ \ + reti; \ + \ +/* Return to kernel state. */ \ +2: POP_STATE(type); \ + reti; \ + \ +/* Call the scheduler before returning from a syscall/trap. */ \ +3: SAVE_EXTRA_STATE_FOR_FUNCALL(type); /* Prepare for funcall. */ \ + jarl CSYM(schedule), lp; /* Call scheduler */ \ + RESTORE_EXTRA_STATE_FOR_FUNCALL(type); \ + br 1b; \ + \ +/* Handle a signal return; Pending signals should be in r18. */ \ +4: /* Not all registers are saved by the normal trap/interrupt entry \ + points (for instance, call-saved registers (because the normal \ + C-compiler calling sequence in the kernel makes sure they're \ + preserved), and call-clobbered registers in the case of \ + traps), but signal handlers may want to examine or change the \ + complete register state. Here we save anything not saved by \ + the normal entry sequence, so that it may be safely restored \ + (in a possibly modified form) after do_signal returns. */ \ + SAVE_EXTRA_STATE(type) /* Save state not saved by entry. */ \ + movea PTO, sp, r6; /* Arg 1: struct pt_regs *regs */ \ + mov r0, r7; /* Arg 2: sigset_t *oldset */ \ + jarl CSYM(do_signal), lp; /* Handle any signals */ \ + RESTORE_EXTRA_STATE(type); /* Restore extra regs. */ \ + br 1b; + + +/* Jump to the appropriate function for the system call number in r12 + (r12 is not preserved), or return an error if r12 is not valid. The + LP register should point to the location where the called function + should return. [note that MAKE_SYS_CALL uses label 1] */ +#define MAKE_SYS_CALL \ + /* See if the system call number is valid. */ \ + addi -NR_syscalls, r12, r0; \ + bnh 1f; \ + /* Figure out which function to use for this system call. */ \ + shl 2, r12; \ + mov hilo(syscall_table), r19; \ + add r19, r12; \ + ld.w 0[r12], r12; \ + /* Make the system call. */ \ + jmp [r12]; \ + /* The syscall number is invalid, return an error. */ \ +1: addi -ENOSYS, r0, r10; \ + jmp [lp]; + + + .text + +/* + * User trap. + * + * Trap 0 system calls are also handled here. + * + * Syscall protocol: + * Syscall number in r12, args in r6-r9 + * Return value in r10 + */ +G_ENTRY(trap): + SAVE_STATE(TRAP, r12) // Save registers. + stsr SR_ECR, r19 // Find out which trap it was. + ei // Enable interrupts. + mov hilo(ret_from_trap), lp // where the trap should return + + // The following two shifts (1) clear out extraneous NMI data in the + // upper 16-bits, (2) convert the 0x40 - 0x5f range of trap ECR + // numbers into the (0-31) << 2 range we want, (3) set the flags. + shl 27, r19 // chop off all high bits + shr 25, r19 // scale back down and then << 2 + bnz 2f // See if not trap 0. + +#if TRACE_TRAPS + addi -40, sp, sp + st.w r12, 16[sp] + st.w r6, 20[sp] + st.w r7, 24[sp] + st.w r8, 28[sp] + st.w r9, 32[sp] + st.w lp, 36[sp] + .data +trap_entry_msg: .asciz "[trap 0, %d (pid %d, km %d)]\n" + .text + mov hilo(trap_entry_msg), r6 + mov r12, r7 + ld.w TASK_PID[CURRENT_TASK], r8 + ld.w PTO+PT_KERNEL_MODE[ep], r9 + jarl CSYM(printk), lp + ld.w 16[sp], r12 + ld.w 20[sp], r6 + ld.w 24[sp], r7 + ld.w 28[sp], r8 + ld.w 32[sp], r9 + ld.w 36[sp], lp + addi 40, sp, sp +#endif /* TRACE_TRAPS */ + + // Trap 0 is a `short' system call, skip general trap table. + MAKE_SYS_CALL // Jump to the syscall function. + +2: // For other traps, use a table lookup. + mov hilo(trap_table), r18 + add r19, r18 + ld.w 0[r18], r18 + jmp [r18] // Jump to the trap handler. +END(trap) + +/* This is just like ret_from_trap, but first restores extra registers + saved by some wrappers. */ +L_ENTRY(restore_extra_regs_and_ret_from_trap): + RESTORE_EXTRA_STATE(TRAP) + // fall through +END(restore_extra_regs_and_ret_from_trap) + +/* Entry point used to return from a syscall/trap. */ +L_ENTRY(ret_from_trap): +#if TRACE_TRAPS + addi -32, sp, sp + st.w r10, 16[sp] + .data +trap0_exit_msg: .asciz "[ret_from_trap: %d (pid %d, km %d)]\n" + .text + mov hilo(trap0_exit_msg), r6 + mov r10, r7 + ld.w TASK_PID[CURRENT_TASK], r8 + ld.w 32+PTO+PT_KERNEL_MODE[sp], r9 + jarl CSYM(printk), lp + ld.w 16[sp], r10 + addi 32, sp, sp +#endif /* TRACE_TRAPS */ + RETURN(TRAP) +END(ret_from_trap) + +/* This the initial entry point for a new child thread, with an appropriate + stack in place that makes it look the the child is in the middle of an + syscall. This function is actually `returned to' from switch_thread + (copy_thread makes ret_from_fork the return address in each new thread's + saved context). */ +C_ENTRY(ret_from_fork): + mov r10, r6 // switch_thread returns the prev task. + jarl CSYM(schedule_tail), lp // ...which is schedule_tail's arg + mov r0, r10 // Child's fork call should return 0. + br ret_from_trap // Do normal trap return. +C_END(ret_from_fork) + + +/* + * Trap 1: `long' system calls + * `Long' syscall protocol: + * Syscall number in r12, args in r6-r9, r13-r14 + * Return value in r10 + */ +L_ENTRY(syscall_long): + // Push extra arguments on the stack. Note that by default, the trap + // handler reserves enough stack space for 6 arguments, so we don't + // have to make any additional room. + st.w r13, 16[sp] // arg 5 + st.w r14, 20[sp] // arg 6 + +#if !TRAPS_PRESERVE_CALL_CLOBBERED_REGS + // Make sure r13 and r14 are preserved, in case we have to restart a + // system call because of a signal (ep has already been set by caller). + sst.w r13, PTO+PT_GPR(13)[ep] + sst.w r14, PTO+PT_GPR(13)[ep] + mov hilo(ret_from_long_syscall), lp +#endif /* !TRAPS_PRESERVE_CALL_CLOBBERED_REGS */ + +#if TRACE_TRAPS + addi -40, sp, sp + st.w r12, 16[sp] + st.w r6, 20[sp] + st.w r7, 24[sp] + st.w r8, 28[sp] + st.w r9, 32[sp] + st.w lp, 36[sp] + .data +trap1_entry_msg: .asciz "[trap 1, %d (pid %d, km %d)]\n" + .text + mov hilo(trap1_entry_msg), r6 + mov r12, r7 + ld.w TASK_PID[CURRENT_TASK], r8 + ld.w PTO+PT_KERNEL_MODE[ep], r9 + jarl CSYM(printk), lp + ld.w 16[sp], r12 + ld.w 20[sp], r6 + ld.w 24[sp], r7 + ld.w 28[sp], r8 + ld.w 32[sp], r9 + ld.w 36[sp], lp + addi 40, sp, sp +#endif /* TRACE_TRAPS */ + + MAKE_SYS_CALL // Jump to the syscall function. +END(syscall_long) + +#if !TRAPS_PRESERVE_CALL_CLOBBERED_REGS +/* Entry point used to return from a long syscall. Only needed to restore + r13/r14 if the general trap mechanism doesnt' do so. */ +L_ENTRY(ret_from_long_syscall): + ld.w PTO+PT_GPR(13)[sp], r13 // Restore the extra registers + ld.w PTO+PT_GPR(13)[ep], r14 + br ret_from_trap // The rest is the same as other traps +END(ret_from_long_syscall) +#endif /* !TRAPS_PRESERVE_CALL_CLOBBERED_REGS */ + + +/* These syscalls need access to the struct pt_regs on the stack, so we + implement them in assembly (they're basically all wrappers anyway). */ + +L_ENTRY(sys_fork_wrapper): +#ifdef NO_MM + // fork almost works, enough to trick you into looking elsewhere :-( + addi -EINVAL, r0, r10 + jmp [lp] +#else + // Save state not saved by entry. This is actually slight overkill; + // it's actually only necessary to save any state restored by + // switch_thread that's not saved by the trap entry. + SAVE_EXTRA_STATE(TRAP) // Save state not saved by entry. + addi SIGCHLD, r0, r6 // Arg 0: flags + ld.w PTO+PT_GPR(GPR_SP)[sp], r7 // Arg 1: child SP (use parent's) + movea PTO, sp, r8 // Arg 2: parent context + mov r0, r9 // Arg 3: (unused) + jr CSYM(do_fork) // Do real work (tail-call). +#endif +END(sys_fork_wrapper) + +L_ENTRY(sys_vfork_wrapper): + // Save state not saved by entry. This is actually slight overkill; + // it's actually only necessary to save any state restored by + // switch_thread that's not saved by the trap entry. + SAVE_EXTRA_STATE(TRAP) // Save state not saved by entry. + addi CLONE_VFORK | CLONE_VM | SIGCHLD, r0, r6 // Arg 0: flags + ld.w PTO+PT_GPR(GPR_SP)[sp], r7 // Arg 1: child SP (use parent's) + movea PTO, sp, r8 // Arg 2: parent context + mov r0, r9 // Arg 3: (unused) + jr CSYM(do_fork) // Do real work (tail-call). +END(sys_vfork_wrapper) + +L_ENTRY(sys_clone_wrapper): + // Save state not saved by entry. This is actually slight overkill; + // it's actually only necessary to save any state restored by + // switch_thread that's not saved by the trap entry. + SAVE_EXTRA_STATE(TRAP) // Save state not saved by entry. + ld.w PTO+PT_GPR(GPR_SP)[sp], r19 // parent's stack pointer + cmp r7, r0 // See if child SP arg (arg 1) is 0. + cmov z, r19, r7, r7 // ... and use the parent's if so. + movea PTO, sp, r8 // Arg 2: parent context + mov r0, r9 // Arg 3: (unused) + jr CSYM(do_fork) // Do real work (tail-call). +END(sys_clone_wrapper) + +L_ENTRY(sys_execve_wrapper): + movea PTO, sp, r9 // add user context as 4th arg + jr CSYM(sys_execve) // Do real work (tail-call). +END(sys_execve_wrapper) + +L_ENTRY(sys_sigsuspend_wrapper): + SAVE_EXTRA_STATE(TRAP) // Save state not saved by entry. + movea PTO, sp, r7 // add user context as 2nd arg + jarl CSYM(sys_sigsuspend), lp// Do real work. + br restore_extra_regs_and_ret_from_trap +END(sys_sigsuspend_wrapper) +L_ENTRY(sys_rt_sigsuspend_wrapper): + SAVE_EXTRA_STATE(TRAP) // Save state not saved by entry. + movea PTO, sp, r8 // add user context as 3rd arg + jarl CSYM(sys_rt_sigsuspend), lp // Do real work. + br restore_extra_regs_and_ret_from_trap +END(sys_rt_sigsuspend_wrapper) + +L_ENTRY(sys_sigreturn_wrapper): + SAVE_EXTRA_STATE(TRAP) // Save state not saved by entry. + movea PTO, sp, r6 // add user context as 1st arg + jarl CSYM(sys_sigreturn), lp // Do real work. + br restore_extra_regs_and_ret_from_trap +END(sys_sigreturn_wrapper) +L_ENTRY(sys_rt_sigreturn_wrapper): + SAVE_EXTRA_STATE(TRAP) // Save state not saved by entry. + movea PTO, sp, r6 // add user context as 1st arg + jarl CSYM(sys_rt_sigreturn), lp // Do real work. + br restore_extra_regs_and_ret_from_trap +END(sys_rt_sigreturn_wrapper) + + +/* + * Hardware maskable interrupts. + */ +G_ENTRY(irq): + SAVE_STATE(INTERRUPT, r0) // Save registers. + + stsr SR_ECR, r6 // Find out which interrupt it was. + movea PTO, sp, r7 // User regs are arg2 + + // All v850 implementations I know about encode their interrupts as + // multiples of 0x10, starting at 0x80 (after NMIs and software + // interrupts). Convert this number into a simple IRQ index for the + // rest of the kernel. We also clear the upper 16 bits, which hold + // NMI info, and don't appear to be cleared when a NMI returns. + shl 16, r6 // clear upper 16 bits + shr 20, r6 // shift back, and remove lower nibble + add -8, r6 // remove bias for irqs + // Call the high-level interrupt handling code. + jarl CSYM(handle_irq), lp + // fall through + +/* Entry point used to return from an interrupt (also used by exception + handlers, below). */ +ret_from_interrupt: + RETURN(INTERRUPT) +END(irq) + + +/* + * Hardware non-maskable interrupts. + */ +G_ENTRY(nmi): + SAVE_STATE(NMI, r0) // Save registers. + + stsr SR_ECR, r6 // Find out which nmi it was. + shr 16, r6 // NMI number is in upper 16 bits + movea PTO, sp, r7 // User regs are arg2 + + // Non-maskable interrupts always lie right after maskable interrupts. + // Call the generic IRQ handler, with two arguments, the IRQ number, + // and a pointer to the user registers, to handle the specifics. + addi FIRST_NMI, r6, r6 + jarl CSYM(handle_irq), lp + // Control may or may not actually return here -- NMI1 and NMI2 are + // `unrecoverable,' so the handler may just reset the machine. + RETURN(NMI) +END(nmi) + + +/* + * Illegal instruction trap. + */ +G_ENTRY(illegal_instruction): + SAVE_STATE(INTERRUPT, r0) // Save registers. + ei + addi SIGILL, r0, r6 // Arg 0: signal number + mov CURRENT_TASK, r7 // Arg 1: task + mov hilo(ret_from_interrupt), lp // where the handler should return + jr CSYM(force_sig) +END(illegal_instruction) + + +/* + * `Debug' trap + */ +G_ENTRY(dbtrap): + SAVE_STATE(INTERRUPT, r0) // Save registers. + ei + movea PTO, sp, r6 // Arg 0: user regs + mov hilo(ret_from_interrupt), lp // where the handler should return + jr CSYM(debug_trap) +END(dbtrap) + + +/* + * Trap with no handler + */ +L_ENTRY(bad_trap_wrapper): + mov r19, r6 // Arg 0: trap number + movea PTO, sp, r7 // Arg 1: user regs + jr CSYM(bad_trap) // tail call handler +END(bad_trap_wrapper) + + +/* + * This is where we switch between two threads. The arguments are: + * r6 -- pointer to the struct thread for the `current' process + * r7 -- pointer to the struct thread for the `new' process. + * when this function returns, it will return to the new thread. + */ +C_ENTRY(switch_thread): + // Return the previous task (r10 is not clobbered by restore below) + mov CURRENT_TASK, r10 + // First, push the current processor state on the stack + PUSH_STATE(SWITCH) + // Now save the location of the kernel stack pointer for this thread; + // since we've pushed all other state on the stack, this is enough to + // restore it all later. + st.w sp, THREAD_KSP[r6] + // Now restore the stack pointer from the new process + ld.w THREAD_KSP[r7], sp + // ... and restore all state from that + POP_STATE(SWITCH) + // Update the current task pointer + GET_CURRENT_TASK(CURRENT_TASK) + // Now return into the new thread + jmp [lp] +C_END(switch_thread) + + + .data + +__ALIGN +trap_table: + .long bad_trap_wrapper // trap 0, doesn't use trap table. + .long syscall_long // trap 1, `long' syscall. + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + .long bad_trap_wrapper + + + .section .rodata +__ALIGN +syscall_table: + .long CSYM(sys_ni_syscall) // 0 - old "setup()" system call + .long CSYM(sys_exit) + .long sys_fork_wrapper + .long CSYM(sys_read) + .long CSYM(sys_write) + .long CSYM(sys_open) // 5 + .long CSYM(sys_close) + .long CSYM(sys_waitpid) + .long CSYM(sys_creat) + .long CSYM(sys_link) + .long CSYM(sys_unlink) // 10 + .long sys_execve_wrapper + .long CSYM(sys_chdir) + .long CSYM(sys_time) + .long CSYM(sys_mknod) + .long CSYM(sys_chmod) // 15 + .long CSYM(sys_chown16) + .long CSYM(sys_ni_syscall) // was: break + .long CSYM(sys_stat) + .long CSYM(sys_lseek) + .long CSYM(sys_getpid) // 20 + .long CSYM(sys_mount) + .long CSYM(sys_oldumount) + .long CSYM(sys_setuid16) + .long CSYM(sys_getuid16) + .long CSYM(sys_stime) // 25 + .long CSYM(sys_ptrace) + .long CSYM(sys_alarm) + .long CSYM(sys_fstat) + .long CSYM(sys_pause) + .long CSYM(sys_utime) // 30 + .long CSYM(sys_ni_syscall) // was: stty + .long CSYM(sys_ni_syscall) // was: gtty + .long CSYM(sys_access) + .long CSYM(sys_nice) + .long CSYM(sys_ni_syscall) // 35, was: ftime + .long CSYM(sys_sync) + .long CSYM(sys_kill) + .long CSYM(sys_rename) + .long CSYM(sys_mkdir) + .long CSYM(sys_rmdir) // 40 + .long CSYM(sys_dup) + .long CSYM(sys_pipe) + .long CSYM(sys_times) + .long CSYM(sys_ni_syscall) // was: prof + .long CSYM(sys_brk) // 45 + .long CSYM(sys_setgid16) + .long CSYM(sys_getgid16) + .long CSYM(sys_signal) + .long CSYM(sys_geteuid16) + .long CSYM(sys_getegid16) // 50 + .long CSYM(sys_acct) + .long CSYM(sys_umount) // recycled never used phys() + .long CSYM(sys_ni_syscall) // was: lock + .long CSYM(sys_ioctl) + .long CSYM(sys_fcntl) // 55 + .long CSYM(sys_ni_syscall) // was: mpx + .long CSYM(sys_setpgid) + .long CSYM(sys_ni_syscall) // was: ulimit + .long CSYM(sys_ni_syscall) + .long CSYM(sys_umask) // 60 + .long CSYM(sys_chroot) + .long CSYM(sys_ustat) + .long CSYM(sys_dup2) + .long CSYM(sys_getppid) + .long CSYM(sys_getpgrp) // 65 + .long CSYM(sys_setsid) + .long CSYM(sys_sigaction) + .long CSYM(sys_sgetmask) + .long CSYM(sys_ssetmask) + .long CSYM(sys_setreuid16) // 70 + .long CSYM(sys_setregid16) + .long sys_sigsuspend_wrapper + .long CSYM(sys_sigpending) + .long CSYM(sys_sethostname) + .long CSYM(sys_setrlimit) // 75 + .long CSYM(sys_old_getrlimit) + .long CSYM(sys_getrusage) + .long CSYM(sys_gettimeofday) + .long CSYM(sys_settimeofday) + .long CSYM(sys_getgroups16) // 80 + .long CSYM(sys_setgroups16) + .long CSYM(sys_ni_syscall) // was: old_select + .long CSYM(sys_symlink) + .long CSYM(sys_lstat) + .long CSYM(sys_readlink) // 85 + .long CSYM(sys_uselib) + .long CSYM(sys_swapon) + .long CSYM(sys_reboot) + .long CSYM(old_readdir) + .long CSYM(sys_mmap) // 90 + .long CSYM(sys_munmap) + .long CSYM(sys_truncate) + .long CSYM(sys_ftruncate) + .long CSYM(sys_fchmod) + .long CSYM(sys_fchown16) // 95 + .long CSYM(sys_getpriority) + .long CSYM(sys_setpriority) + .long CSYM(sys_ni_syscall) // was: profil + .long CSYM(sys_statfs) + .long CSYM(sys_fstatfs) // 100 + .long CSYM(sys_ni_syscall) // i386: ioperm + .long CSYM(sys_socketcall) + .long CSYM(sys_syslog) + .long CSYM(sys_setitimer) + .long CSYM(sys_getitimer) // 105 + .long CSYM(sys_newstat) + .long CSYM(sys_newlstat) + .long CSYM(sys_newfstat) + .long CSYM(sys_ni_syscall) + .long CSYM(sys_ni_syscall) // 110, i386: iopl + .long CSYM(sys_vhangup) + .long CSYM(sys_ni_syscall) // was: idle + .long CSYM(sys_ni_syscall) // i386: vm86old + .long CSYM(sys_wait4) + .long CSYM(sys_swapoff) // 115 + .long CSYM(sys_sysinfo) + .long CSYM(sys_ipc) + .long CSYM(sys_fsync) + .long sys_sigreturn_wrapper + .long sys_clone_wrapper // 120 + .long CSYM(sys_setdomainname) + .long CSYM(sys_newuname) + .long CSYM(sys_ni_syscall) // i386: modify_ldt, m68k: cacheflush + .long CSYM(sys_adjtimex) + .long CSYM(sys_mprotect) // 125 + .long CSYM(sys_sigprocmask) + .long CSYM(sys_create_module) + .long CSYM(sys_init_module) + .long CSYM(sys_delete_module) + .long CSYM(sys_get_kernel_syms) // 130 + .long CSYM(sys_quotactl) + .long CSYM(sys_getpgid) + .long CSYM(sys_fchdir) + .long CSYM(sys_bdflush) + .long CSYM(sys_sysfs) // 135 + .long CSYM(sys_personality) + .long CSYM(sys_ni_syscall) // for afs_syscall + .long CSYM(sys_setfsuid16) + .long CSYM(sys_setfsgid16) + .long CSYM(sys_llseek) // 140 + .long CSYM(sys_getdents) + .long CSYM(sys_select) + .long CSYM(sys_flock) + .long CSYM(sys_msync) + .long CSYM(sys_readv) // 145 + .long CSYM(sys_writev) + .long CSYM(sys_getsid) + .long CSYM(sys_fdatasync) + .long CSYM(sys_sysctl) + .long CSYM(sys_mlock) // 150 + .long CSYM(sys_munlock) + .long CSYM(sys_mlockall) + .long CSYM(sys_munlockall) + .long CSYM(sys_sched_setparam) + .long CSYM(sys_sched_getparam) // 155 + .long CSYM(sys_sched_setscheduler) + .long CSYM(sys_sched_getscheduler) + .long CSYM(sys_sched_yield) + .long CSYM(sys_sched_get_priority_max) + .long CSYM(sys_sched_get_priority_min) // 160 + .long CSYM(sys_sched_rr_get_interval) + .long CSYM(sys_nanosleep) + .long CSYM(sys_mremap) + .long CSYM(sys_setresuid16) + .long CSYM(sys_getresuid16) // 165 + .long CSYM(sys_ni_syscall) // for vm86 + .long CSYM(sys_query_module) + .long CSYM(sys_poll) + .long CSYM(sys_nfsservctl) + .long CSYM(sys_setresgid16) // 170 + .long CSYM(sys_getresgid16) + .long CSYM(sys_prctl) + .long sys_rt_sigreturn_wrapper + .long CSYM(sys_rt_sigaction) + .long CSYM(sys_rt_sigprocmask) // 175 + .long CSYM(sys_rt_sigpending) + .long CSYM(sys_rt_sigtimedwait) + .long CSYM(sys_rt_sigqueueinfo) + .long sys_rt_sigsuspend_wrapper + .long CSYM(sys_pread) // 180 + .long CSYM(sys_pwrite) + .long CSYM(sys_lchown16); + .long CSYM(sys_getcwd) + .long CSYM(sys_capget) + .long CSYM(sys_capset) // 185 + .long CSYM(sys_sigaltstack) + .long CSYM(sys_sendfile) + .long CSYM(sys_ni_syscall) // streams1 + .long CSYM(sys_ni_syscall) // streams2 + .long sys_vfork_wrapper // 190 + .long CSYM(sys_getrlimit) + .long CSYM(sys_mmap2) + .long CSYM(sys_truncate64) + .long CSYM(sys_ftruncate64) + .long CSYM(sys_stat64) // 195 + .long CSYM(sys_lstat64) + .long CSYM(sys_fstat64) + .long CSYM(sys_chown) + .long CSYM(sys_getuid) + .long CSYM(sys_getgid) // 200 + .long CSYM(sys_geteuid) + .long CSYM(sys_getegid) + .long CSYM(sys_setreuid) + .long CSYM(sys_setregid) + .long CSYM(sys_getgroups) // 205 + .long CSYM(sys_setgroups) + .long CSYM(sys_fchown) + .long CSYM(sys_setresuid) + .long CSYM(sys_getresuid) + .long CSYM(sys_setresgid) // 210 + .long CSYM(sys_getresgid) + .long CSYM(sys_lchown) + .long CSYM(sys_setuid) + .long CSYM(sys_setgid) + .long CSYM(sys_setfsuid) // 215 + .long CSYM(sys_setfsgid) + + .space (NR_syscalls-216)*4 diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/head.S linux-2.4.6/arch/v850/kernel/head.S --- linux-2.4.6.uclinux-orig/arch/v850/kernel/head.S Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/head.S Tue Oct 2 15:50:52 2001 @@ -0,0 +1,91 @@ +/* + * arch/v850/kernel/head.S -- Lowest-level startup code + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include + + + .text + + // Define `mach_early_init' as a weak symbol + .global C_SYMBOL_NAME(mach_early_init) + .weak C_SYMBOL_NAME(mach_early_init) + +C_ENTRY(start): + // Make sure interrupts are turned off, just in case + di + + // See if we got here via an unexpected reset + ld.w RESET_GUARD, r19 // Check current value of reset guard + mov RESET_GUARD_ACTIVE, r20 + cmp r19, r20 + bne 1f // Guard was not active + + // If we get here, the reset guard was active. Load up some + // interesting values as arguments, and jump to the handler. + st.w r0, RESET_GUARD // Allow further resets to succeed + mov lp, r6 // Arg 0: return address + ld.b KM, r7 // Arg 1: kernel mode + mov sp, r9 // Arg 3: stack pointer + ld.w KSP, r19 // maybe switch to kernel stack + cmp r7, r0 // see if already in kernel mode + cmov z, r19, sp, sp // and switch to kernel stack if not + GET_CURRENT_TASK(r8) // Arg 2: task pointer + jr C_SYMBOL_NAME(unexpected_reset) + +1: st.w r20, RESET_GUARD // Turn on reset guard + + // Load the current task pointer (in r20) and stack. + mov hilo(C_SYMBOL_NAME(init_task_union)), CURRENT_TASK + movea KERNEL_STACK_SIZE, CURRENT_TASK, sp + + // See if there's a platform-specific early-initialization routine + // defined; it's a weak symbol, so it will have an address of zero if + // there's not. + mov hilo(C_SYMBOL_NAME(mach_early_init)), r6 + cmp r6, r0 + bz 3f + + // There is one, so call it. If this function is written in C, it + // should be very careful -- the stack pointer is valid, but very + // little else is (e.g., bss is not zeroed yet). + jarl 2f, lp // first figure out return address +2: add 3f - ., lp + jmp [r6] // do call + + // Kernel stack pointer save location +3: st.w sp, KSP + + // Assert that we're in `kernel mode' + mov 1, r19 + st.w r19, KM + + // Zero bss area, since we can't rely upon any loader to do so + mov hilo(C_SYMBOL_NAME(_sbss)), ep + mov hilo(C_SYMBOL_NAME(_ebss)), r10 +4: sst.w r0, 0[ep] + add 4, ep + cmp ep, r10 + bne 4b + + // Start Linux kernel. + jarl C_SYMBOL_NAME(start_kernel), lp + // fall through +END(start) + +C_ENTRY(exit): + halt + br C_SYMBOL_NAME(exit) /* Should never get here */ +END(exit) diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/intv.S linux-2.4.6/arch/v850/kernel/intv.S --- linux-2.4.6.uclinux-orig/arch/v850/kernel/intv.S Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/intv.S Fri Sep 28 13:49:11 2001 @@ -0,0 +1,56 @@ +/* + * arch/v850/kernel/intv.S -- Interrupt vectors + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include + + + /* Interrupt vectors. */ + .section .intv.common, "ax" + + /* This is used to align the section, in case the linker script needs + to use wierd tricks. */ + .balign 0x10 + + /* Start out with reset vector. */ + .org 0x0 + jr C_SYMBOL_NAME(start) + + /* Now come interrupt vectors. */ + .org 0x10 + jr nmi // NMI0 + .org 0x20 + jr nmi // NMI1 + .org 0x30 + jr nmi // NMI2 + + .org 0x40 + jr trap // TRAP0n + .org 0x50 + jr trap // TRAP1n + + .org 0x60 + jr illegal_instruction // illegal insn trap + + .org 0x70 + jr dbtrap // DBTRAP insn + + + /* Hardware interrupt vectors. */ + .section .intv.mach, "ax" + .org 0x0 + + .rept NUM_MACH_IRQS + .balign 0x10 + jr irq + .endr diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/irq.c linux-2.4.6/arch/v850/kernel/irq.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/irq.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/irq.c Fri Oct 5 14:28:32 2001 @@ -0,0 +1,714 @@ +/* + * arch/v850/kernel/irq.c -- High-level interrupt handling + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * Copyright (C) 1994-2000 Ralf Baechle + * Copyright (C) 1992 Linus Torvalds + * + * 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. + * + * This file was was derived from the mips version, arch/mips/kernel/irq.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* + * Controller mappings for all interrupt sources: + */ +irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = + { [0 ... NR_IRQS-1] = { 0, &no_irq_type, NULL, 0, SPIN_LOCK_UNLOCKED}}; + +/* + * Special irq handlers. + */ + +void no_action(int cpl, void *dev_id, struct pt_regs *regs) { } + +/* + * Generic no controller code + */ + +static void enable_none(unsigned int irq) { } +static unsigned int startup_none(unsigned int irq) { return 0; } +static void disable_none(unsigned int irq) { } +static void ack_none(unsigned int irq) +{ + /* + * 'what should we do if we get a hw irq event on an illegal vector'. + * each architecture has to answer this themselves, it doesnt deserve + * a generic callback i think. + */ + printk("received IRQ %d with unknown interrupt type\n", irq); +} + +/* startup is the same as "enable", shutdown is same as "disable" */ +#define shutdown_none disable_none +#define end_none enable_none + +struct hw_interrupt_type no_irq_type = { + "none", + startup_none, + shutdown_none, + enable_none, + disable_none, + ack_none, + end_none +}; + +volatile unsigned long irq_err_count, spurious_count; + +/* + * Generic, controller-independent functions: + */ + +int get_irq_list(char *buf) +{ + struct irqaction * action; + char *p = buf; + int i; + + p += sprintf(p, " "); + for (i=0; i < 1 /*smp_num_cpus*/; i++) + p += sprintf(p, "CPU%d ", i); + *p++ = '\n'; + + for (i = 0 ; i < NR_IRQS ; i++) { + action = irq_desc[i].action; + if (!action) + continue; + p += sprintf(p, "%3d: ",i); + p += sprintf(p, "%10u ", kstat_irqs(i)); + p += sprintf(p, " %14s", irq_desc[i].handler->typename); + p += sprintf(p, " %s", action->name); + + for (action=action->next; action; action = action->next) + p += sprintf(p, ", %s", action->name); + *p++ = '\n'; + } + p += sprintf(p, "ERR: %10lu\n", irq_err_count); + return p - buf; +} + +/* + * This should really return information about whether + * we should do bottom half handling etc. Right now we + * end up _always_ checking the bottom half, which is a + * waste of time and is not what some drivers would + * prefer. + */ +int handle_IRQ_event(unsigned int irq, struct pt_regs * regs, struct irqaction * action) +{ + int status; + int cpu = smp_processor_id(); + + irq_enter(cpu, irq); + + status = 1; /* Force the "do bottom halves" bit */ + + if (!(action->flags & SA_INTERRUPT)) + __sti(); + + do { + status |= action->flags; + action->handler(irq, action->dev_id, regs); + action = action->next; + } while (action); + if (status & SA_SAMPLE_RANDOM) + add_interrupt_randomness(irq); + __cli(); + + irq_exit(cpu, irq); + + return status; +} + +/* + * Generic enable/disable code: this just calls + * down into the PIC-specific version for the actual + * hardware disable after having gotten the irq + * controller lock. + */ + +/** + * disable_irq_nosync - disable an irq without waiting + * @irq: Interrupt to disable + * + * Disable the selected interrupt line. Disables of an interrupt + * stack. Unlike disable_irq(), this function does not ensure existing + * instances of the IRQ handler have completed before returning. + * + * This function may be called from IRQ context. + */ + +void inline disable_irq_nosync(unsigned int irq) +{ + irq_desc_t *desc = irq_desc + irq; + unsigned long flags; + + spin_lock_irqsave(&desc->lock, flags); + if (!desc->depth++) { + desc->status |= IRQ_DISABLED; + desc->handler->disable(irq); + } + spin_unlock_irqrestore(&desc->lock, flags); +} + +/** + * disable_irq - disable an irq and wait for completion + * @irq: Interrupt to disable + * + * Disable the selected interrupt line. Disables of an interrupt + * stack. That is for two disables you need two enables. This + * function waits for any pending IRQ handlers for this interrupt + * to complete before returning. If you use this function while + * holding a resource the IRQ handler may need you will deadlock. + * + * This function may be called - with care - from IRQ context. + */ + +void disable_irq(unsigned int irq) +{ + disable_irq_nosync(irq); + + if (!local_irq_count(smp_processor_id())) { + do { + barrier(); + } while (irq_desc[irq].status & IRQ_INPROGRESS); + } +} + +/** + * enable_irq - enable interrupt handling on an irq + * @irq: Interrupt to enable + * + * Re-enables the processing of interrupts on this IRQ line + * providing no disable_irq calls are now in effect. + * + * This function may be called from IRQ context. + */ + +void enable_irq(unsigned int irq) +{ + irq_desc_t *desc = irq_desc + irq; + unsigned long flags; + + spin_lock_irqsave(&desc->lock, flags); + switch (desc->depth) { + case 1: { + unsigned int status = desc->status & ~IRQ_DISABLED; + desc->status = status; + if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { + desc->status = status | IRQ_REPLAY; + hw_resend_irq(desc->handler,irq); + } + desc->handler->enable(irq); + /* fall-through */ + } + default: + desc->depth--; + break; + case 0: + printk("enable_irq(%u) unbalanced from %p\n", irq, + __builtin_return_address(0)); + } + spin_unlock_irqrestore(&desc->lock, flags); +} + +/* + * do_IRQ handles all normal device IRQ's (the special + * SMP cross-CPU interrupts have their own specific + * handlers). + */ +asmlinkage unsigned int handle_irq (int irq, struct pt_regs *regs) +{ + /* + * We ack quickly, we don't want the irq controller + * thinking we're snobs just because some other CPU has + * disabled global interrupts (we have already done the + * INT_ACK cycles, it's too late to try to pretend to the + * controller that we aren't taking the interrupt). + * + * 0 return value means that this irq is already being + * handled by some other CPU. (or is disabled) + */ + int cpu = smp_processor_id(); + irq_desc_t *desc = irq_desc + irq; + struct irqaction * action; + unsigned int status; + + kstat.irqs[cpu][irq]++; + spin_lock(&desc->lock); + desc->handler->ack(irq); + /* + REPLAY is when Linux resends an IRQ that was dropped earlier + WAITING is used by probe to mark irqs that are being tested + */ + status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING); + status |= IRQ_PENDING; /* we _want_ to handle it */ + + /* + * If the IRQ is disabled for whatever reason, we cannot + * use the action we have. + */ + action = NULL; + if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) { + action = desc->action; + status &= ~IRQ_PENDING; /* we commit to handling */ + status |= IRQ_INPROGRESS; /* we are handling it */ + } + desc->status = status; + + /* + * If there is no IRQ handler or it was disabled, exit early. + Since we set PENDING, if another processor is handling + a different instance of this same irq, the other processor + will take care of it. + */ + if (!action) + goto out; + + /* + * Edge triggered interrupts need to remember + * pending events. + * This applies to any hw interrupts that allow a second + * instance of the same irq to arrive while we are in handle_irq + * or in the handler. But the code here only handles the _second_ + * instance of the irq, not the third or fourth. So it is mostly + * useful for irq hardware that does not mask cleanly in an + * SMP environment. + */ + for (;;) { + spin_unlock(&desc->lock); + handle_IRQ_event(irq, regs, action); + spin_lock(&desc->lock); + + if (!(desc->status & IRQ_PENDING)) + break; + desc->status &= ~IRQ_PENDING; + } + desc->status &= ~IRQ_INPROGRESS; +out: + /* + * The ->end() handler has to deal with interrupts which got + * disabled while the handler was running. + */ + desc->handler->end(irq); + spin_unlock(&desc->lock); + + if (softirq_pending(cpu)) + do_softirq(); + + return 1; +} + +/** + * request_irq - allocate an interrupt line + * @irq: Interrupt line to allocate + * @handler: Function to be called when the IRQ occurs + * @irqflags: Interrupt type flags + * @devname: An ascii name for the claiming device + * @dev_id: A cookie passed back to the handler function + * + * This call allocates interrupt resources and enables the + * interrupt line and IRQ handling. From the point this + * call is made your handler function may be invoked. Since + * your handler function must clear any interrupt the board + * raises, you must take care both to initialise your hardware + * and to set up the interrupt handler in the right order. + * + * Dev_id must be globally unique. Normally the address of the + * device data structure is used as the cookie. Since the handler + * receives this value it makes sense to use it. + * + * If your interrupt is shared you must pass a non NULL dev_id + * as this is required when freeing the interrupt. + * + * Flags: + * + * SA_SHIRQ Interrupt is shared + * + * SA_INTERRUPT Disable local interrupts while processing + * + * SA_SAMPLE_RANDOM The interrupt can be used for entropy + * + */ + +int request_irq(unsigned int irq, + void (*handler)(int, void *, struct pt_regs *), + unsigned long irqflags, + const char * devname, + void *dev_id) +{ + int retval; + struct irqaction * action; + +#if 1 + /* + * Sanity-check: shared interrupts should REALLY pass in + * a real dev-ID, otherwise we'll have trouble later trying + * to figure out which interrupt is which (messes up the + * interrupt freeing logic etc). + */ + if (irqflags & SA_SHIRQ) { + if (!dev_id) + printk("Bad boy: %s (at 0x%x) called us without a dev_id!\n", devname, (&irq)[-1]); + } +#endif + + if (irq >= NR_IRQS) + return -EINVAL; + if (!handler) + return -EINVAL; + + action = (struct irqaction *) + kmalloc(sizeof(struct irqaction), GFP_KERNEL); + if (!action) + return -ENOMEM; + + action->handler = handler; + action->flags = irqflags; + action->mask = 0; + action->name = devname; + action->next = NULL; + action->dev_id = dev_id; + + retval = setup_irq(irq, action); + if (retval) + kfree(action); + return retval; +} + +/** + * free_irq - free an interrupt + * @irq: Interrupt line to free + * @dev_id: Device identity to free + * + * Remove an interrupt handler. The handler is removed and if the + * interrupt line is no longer in use by any driver it is disabled. + * On a shared IRQ the caller must ensure the interrupt is disabled + * on the card it drives before calling this function. The function + * does not return until any executing interrupts for this IRQ + * have completed. + * + * This function may be called from interrupt context. + * + * Bugs: Attempting to free an irq in a handler for the same irq hangs + * the machine. + */ + +void free_irq(unsigned int irq, void *dev_id) +{ + irq_desc_t *desc; + struct irqaction **p; + unsigned long flags; + + if (irq >= NR_IRQS) + return; + + desc = irq_desc + irq; + spin_lock_irqsave(&desc->lock,flags); + p = &desc->action; + for (;;) { + struct irqaction * action = *p; + if (action) { + struct irqaction **pp = p; + p = &action->next; + if (action->dev_id != dev_id) + continue; + + /* Found it - now remove it from the list of entries */ + *pp = action->next; + if (!desc->action) { + desc->status |= IRQ_DISABLED; + desc->handler->shutdown(irq); + } + spin_unlock_irqrestore(&desc->lock,flags); + +#ifdef CONFIG_SMP + /* Wait to make sure it's not being used on another CPU */ + while (desc->status & IRQ_INPROGRESS) + barrier(); +#endif + kfree(action); + return; + } + printk("Trying to free free IRQ%d\n",irq); + spin_unlock_irqrestore(&desc->lock,flags); + return; + } +} + +/* + * IRQ autodetection code.. + * + * This depends on the fact that any interrupt that + * comes in on to an unassigned handler will get stuck + * with "IRQ_WAITING" cleared and the interrupt + * disabled. + */ + +static DECLARE_MUTEX(probe_sem); + +/** + * probe_irq_on - begin an interrupt autodetect + * + * Commence probing for an interrupt. The interrupts are scanned + * and a mask of potential interrupt lines is returned. + * + */ + +unsigned long probe_irq_on(void) +{ + unsigned int i; + irq_desc_t *desc; + unsigned long val; + unsigned long delay; + + down(&probe_sem); + /* + * something may have generated an irq long ago and we want to + * flush such a longstanding irq before considering it as spurious. + */ + for (i = NR_IRQS-1; i > 0; i--) { + desc = irq_desc + i; + + spin_lock_irq(&desc->lock); + if (!irq_desc[i].action) + irq_desc[i].handler->startup(i); + spin_unlock_irq(&desc->lock); + } + + /* Wait for longstanding interrupts to trigger. */ + for (delay = jiffies + HZ/50; time_after(delay, jiffies); ) + /* about 20ms delay */ synchronize_irq(); + + /* + * enable any unassigned irqs + * (we must startup again here because if a longstanding irq + * happened in the previous stage, it may have masked itself) + */ + for (i = NR_IRQS-1; i > 0; i--) { + desc = irq_desc + i; + + spin_lock_irq(&desc->lock); + if (!desc->action) { + desc->status |= IRQ_AUTODETECT | IRQ_WAITING; + if (desc->handler->startup(i)) + desc->status |= IRQ_PENDING; + } + spin_unlock_irq(&desc->lock); + } + + /* + * Wait for spurious interrupts to trigger + */ + for (delay = jiffies + HZ/10; time_after(delay, jiffies); ) + /* about 100ms delay */ synchronize_irq(); + + /* + * Now filter out any obviously spurious interrupts + */ + val = 0; + for (i = 0; i < NR_IRQS; i++) { + irq_desc_t *desc = irq_desc + i; + unsigned int status; + + spin_lock_irq(&desc->lock); + status = desc->status; + + if (status & IRQ_AUTODETECT) { + /* It triggered already - consider it spurious. */ + if (!(status & IRQ_WAITING)) { + desc->status = status & ~IRQ_AUTODETECT; + desc->handler->shutdown(i); + } else + if (i < 32) + val |= 1 << i; + } + spin_unlock_irq(&desc->lock); + } + + return val; +} + +/* + * Return a mask of triggered interrupts (this + * can handle only legacy ISA interrupts). + */ + +/** + * probe_irq_mask - scan a bitmap of interrupt lines + * @val: mask of interrupts to consider + * + * Scan the ISA bus interrupt lines and return a bitmap of + * active interrupts. The interrupt probe logic state is then + * returned to its previous value. + * + * Note: we need to scan all the irq's even though we will + * only return ISA irq numbers - just so that we reset them + * all to a known state. + */ +unsigned int probe_irq_mask(unsigned long val) +{ + int i; + unsigned int mask; + + mask = 0; + for (i = 0; i < NR_IRQS; i++) { + irq_desc_t *desc = irq_desc + i; + unsigned int status; + + spin_lock_irq(&desc->lock); + status = desc->status; + + if (status & IRQ_AUTODETECT) { + if (i < 16 && !(status & IRQ_WAITING)) + mask |= 1 << i; + + desc->status = status & ~IRQ_AUTODETECT; + desc->handler->shutdown(i); + } + spin_unlock_irq(&desc->lock); + } + up(&probe_sem); + + return mask & val; +} + +/* + * Return the one interrupt that triggered (this can + * handle any interrupt source). + */ + +/** + * probe_irq_off - end an interrupt autodetect + * @val: mask of potential interrupts (unused) + * + * Scans the unused interrupt lines and returns the line which + * appears to have triggered the interrupt. If no interrupt was + * found then zero is returned. If more than one interrupt is + * found then minus the first candidate is returned to indicate + * their is doubt. + * + * The interrupt probe logic state is returned to its previous + * value. + * + * BUGS: When used in a module (which arguably shouldnt happen) + * nothing prevents two IRQ probe callers from overlapping. The + * results of this are non-optimal. + */ + +int probe_irq_off(unsigned long val) +{ + int i, irq_found, nr_irqs; + + nr_irqs = 0; + irq_found = 0; + for (i = 0; i < NR_IRQS; i++) { + irq_desc_t *desc = irq_desc + i; + unsigned int status; + + spin_lock_irq(&desc->lock); + status = desc->status; + + if (status & IRQ_AUTODETECT) { + if (!(status & IRQ_WAITING)) { + if (!nr_irqs) + irq_found = i; + nr_irqs++; + } + desc->status = status & ~IRQ_AUTODETECT; + desc->handler->shutdown(i); + } + spin_unlock_irq(&desc->lock); + } + up(&probe_sem); + + if (nr_irqs > 1) + irq_found = -irq_found; + return irq_found; +} + +/* this was setup_x86_irq but it seems pretty generic */ +int setup_irq(unsigned int irq, struct irqaction * new) +{ + int shared = 0; + unsigned long flags; + struct irqaction *old, **p; + irq_desc_t *desc = irq_desc + irq; + + /* + * Some drivers like serial.c use request_irq() heavily, + * so we have to be careful not to interfere with a + * running system. + */ + if (new->flags & SA_SAMPLE_RANDOM) { + /* + * This function might sleep, we want to call it first, + * outside of the atomic block. + * Yes, this might clear the entropy pool if the wrong + * driver is attempted to be loaded, without actually + * installing a new handler, but is this really a problem, + * only the sysadmin is able to do this. + */ + rand_initialize_irq(irq); + } + + /* + * The following block of code has to be executed atomically + */ + spin_lock_irqsave(&desc->lock,flags); + p = &desc->action; + if ((old = *p) != NULL) { + /* Can't share interrupts unless both agree to */ + if (!(old->flags & new->flags & SA_SHIRQ)) { + spin_unlock_irqrestore(&desc->lock,flags); + return -EBUSY; + } + + /* add new interrupt at end of irq queue */ + do { + p = &old->next; + old = *p; + } while (old); + shared = 1; + } + + *p = new; + + if (!shared) { + desc->depth = 0; + desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING); + desc->handler->startup(irq); + } + spin_unlock_irqrestore(&desc->lock,flags); + + /* register_irq_proc(irq); */ + return 0; +} + +/* Initialize irq handling for IRQs BASE to BASE+NUM-1. */ +void __init +init_irq_handlers (int base_irq, int num, struct hw_interrupt_type *irq_type) +{ + while (num-- > 0) { + irq_desc[base_irq].status = IRQ_DISABLED; + irq_desc[base_irq].action = NULL; + irq_desc[base_irq].depth = 1; + irq_desc[base_irq].handler = irq_type; + base_irq++; + } +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/ma.c linux-2.4.6/arch/v850/kernel/ma.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/ma.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/ma.c Thu Oct 4 10:20:35 2001 @@ -0,0 +1,69 @@ +/* + * arch/v850/kernel/ma.c -- V850E/MA series of cpu chips + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "mach.h" + +void __init mach_sched_init (struct irqaction *timer_action) +{ + /* Start hardware timer. */ + nb85e_timer_d_configure (0, HZ); + /* Install timer interrupt handler. */ + setup_irq (IRQ_INTCMD(0), timer_action); +} + +struct nb85e_intc_irq_init irq_inits[] = { + { "IRQ", 0, NUM_MACH_IRQS, 7 }, + { "CMD", IRQ_INTCMD(0), IRQ_INTCMD_NUM, 5 }, + { "DMA", IRQ_INTDMA(0), IRQ_INTDMA_NUM, 2 }, + { "CSI", IRQ_INTCSI(0), IRQ_INTCSI_NUM, 4 }, + { "SER", IRQ_INTSER(0), IRQ_INTSER_NUM, 3 }, + { "SR", IRQ_INTSR(0), IRQ_INTSR_NUM, 4 }, + { "ST", IRQ_INTST(0), IRQ_INTST_NUM, 5 }, + { 0 } +}; +#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1) + +struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS]; + +void __init mach_init_irqs (void) +{ + nb85e_intc_init_irq_types (irq_inits, hw_itypes); +} + +/* Called before configuring an on-chip UART. */ +void ma_uart_pre_configure (unsigned chan, unsigned cflags, unsigned baud) +{ + /* We only know about the first two UART channels (though + specific chips may have more). */ + if (chan < 2) { + unsigned bits = 0x3 << (chan * 3); + /* Specify that the relevent pins on the chip should do + serial I/O, not direct I/O. */ + MA_PORT4_PMC |= bits; + /* Specify that we're using the UART, not the CSI device. */ + MA_PORT4_PFC |= bits; + } +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/mach.c linux-2.4.6/arch/v850/kernel/mach.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/mach.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/mach.c Wed Sep 12 13:49:51 2001 @@ -0,0 +1,17 @@ +/* + * arch/v850/kernel/mach.c -- Defaults for some things defined by "mach.h" + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include "mach.h" + +/* Called with each timer tick, if non-zero. */ +void (*mach_tick)(void) = 0; diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/mach.h linux-2.4.6/arch/v850/kernel/mach.h --- linux-2.4.6.uclinux-orig/arch/v850/kernel/mach.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/mach.h Wed Oct 10 13:53:40 2001 @@ -0,0 +1,57 @@ +/* + * arch/v850/kernel/mach.h -- Machine-dependent functions used by v850 port + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_MACH_H__ +#define __V850_MACH_H__ + +#include +#include +#include +#include + +#include +#include +#include + +void mach_setup (char **cmdline); +void mach_gettimeofday (struct timeval *tv); +int mach_get_cpu_info (char *buffer); +int mach_get_hardware_list (char *buffer); +void mach_sched_init (struct irqaction *timer_action); +void mach_get_physical_ram (unsigned long *ram_start, unsigned long *ram_len); +void mach_init_irqs (void); + +/* If defined, is called very early in the kernel initialization. The + stack pointer is valid, but very little has been initialized (e.g., + bss is not zeroed yet) when this is called, so care must taken. */ +void mach_early_init (void); + +/* If defined, called after the bootmem allocator has been initialized, + to allow the platform-dependent code to reserve any areas of RAM that + the kernel shouldn't touch. */ +void mach_reserve_bootmem (void) __attribute__ ((__weak__)); + +/* Called with each timer tick, if non-zero. */ +void (*mach_tick) (void); + +/* The following establishes aliases for various mach_ functions to the + name by which the rest of the kernal calls them. These statements + should only have an effect in the file that defines the actual functions. */ +#define MACH_ALIAS(to, from) \ + asm (".global " macrology_stringify (C_SYMBOL_NAME (to)) ";" \ + macrology_stringify (C_SYMBOL_NAME (to)) \ + " = " macrology_stringify (C_SYMBOL_NAME (from))) +MACH_ALIAS (get_cpuinfo, mach_get_cpu_info); +MACH_ALIAS (get_hardware_list, mach_get_hardware_list); + +#endif /* __V850_MACH_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/nb85e.c linux-2.4.6/arch/v850/kernel/nb85e.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/nb85e.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/nb85e.c Fri Oct 5 14:06:06 2001 @@ -0,0 +1,87 @@ +/* + * arch/v850/kernel/nb85e.c -- Machine-specific code for NB85E cpu core + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "mach.h" + +unsigned long cpu_clock_freq = CPU_CLOCK_FREQ; + +#ifdef CONFIG_PROC_FS +int mach_get_cpu_info (char *buf) +{ + extern unsigned long loops_per_jiffy; + return sprintf (buf, + "CPU-Family: v850\n" + "CPU-Arch: v850e\n" + "CPU-Model: %s\n" + "BogoMips: %lu.%02lu\n", + CHIP, + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); +} +#endif /* CONFIG_PROC_FS */ + + +/* Initialize hardware interrupt sources. */ + +static void irq_nop (unsigned irq) { } + +static unsigned nb85e_intc_irq_startup (unsigned irq) +{ + nb85e_intc_clear_pending_irq (irq); + nb85e_intc_enable_irq (irq); + return 0; +} + +/* Initialize HW_IRQ_TYPES for INTC-controlled irqs described in array + INITS (which is terminated by an entry with the name field == 0). */ +void __init nb85e_intc_init_irq_types (struct nb85e_intc_irq_init *inits, + struct hw_interrupt_type *hw_irq_types) +{ + struct nb85e_intc_irq_init *init; + for (init = inits; init->name; init++) { + int i; + struct hw_interrupt_type *hwit = hw_irq_types++; + + hwit->typename = init->name; + + hwit->startup = nb85e_intc_irq_startup; + hwit->shutdown = nb85e_intc_disable_irq; + hwit->enable = nb85e_intc_enable_irq; + hwit->disable = nb85e_intc_disable_irq; + hwit->ack = irq_nop; + hwit->end = irq_nop; + + /* Initialize kernel IRQ infrastructure for this interrupt. */ + init_irq_handlers (init->base, init->num, hwit); + + /* Set the interrupt priorities. */ + for (i = 0; i < init->num; i++) + /* This write also (1) disables the interrupt, and + (2) clears any pending interrupts. */ + NB85E_INTC_IC (init->base + i) + = (NB85E_INTC_IC_PR (init->priority) + | NB85E_INTC_IC_MK); + } +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/nb85e_timer_d.c linux-2.4.6/arch/v850/kernel/nb85e_timer_d.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/nb85e_timer_d.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/nb85e_timer_d.c Tue Sep 25 16:16:38 2001 @@ -0,0 +1,52 @@ +/* + * include/asm-v850/nb85e_timer_d.c -- `Timer D' component often used + * with the NB85E cpu core + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include + +#include +#include + +/* Start interval timer TIMER (0-3). The timer will issue the + corresponding INTCMD interrupt RATE times per second. + This function does not enable the interrupt. */ +void nb85e_timer_d_configure (unsigned timer, unsigned rate) +{ + unsigned divlog2, count; + + /* Calculate params for timer. */ + if (! calc_counter_params ( + cpu_clock_freq, rate, + NB85E_TIMER_D_TMCD_CS_MIN, NB85E_TIMER_D_TMCD_CS_MAX, 16, + &divlog2, &count)) + printk ("Cannot find interval timer %d setting suitable" + " for rate of %dHz.\n" + "Using rate of %ldHz instead.\n", + timer, rate, (cpu_clock_freq >> divlog2) >> 16); + + /* Do the actual hardware timer initialization: */ + + /* Enable timer. */ + NB85E_TIMER_D_TMCD(timer) = NB85E_TIMER_D_TMCD_CAE; + /* Set clock divider. */ + NB85E_TIMER_D_TMCD(timer) + = NB85E_TIMER_D_TMCD_CAE + | NB85E_TIMER_D_TMCD_CS(divlog2); + /* Set timer compare register. */ + NB85E_TIMER_D_CMD(timer) = count; + /* Start counting. */ + NB85E_TIMER_D_TMCD(timer) + = NB85E_TIMER_D_TMCD_CAE + | NB85E_TIMER_D_TMCD_CS(divlog2) + | NB85E_TIMER_D_TMCD_CE; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/nb85e_utils.c linux-2.4.6/arch/v850/kernel/nb85e_utils.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/nb85e_utils.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/nb85e_utils.c Fri Sep 21 16:21:29 2001 @@ -0,0 +1,65 @@ +/* + * include/asm-v850/nb85e_utils.h -- Utility functions associated with + * the NB85E cpu core + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +/* Note: these functions are often associated with the N85E cpu core, + but not always, which is why they're not in `nb85e.c'. */ + +#include + +/* Calculate counter clock-divider and count values to attain the + desired frequency RATE from the base frequency BASE_FREQ. The + counter is expected to have a clock-divider, which can divide the + system cpu clock by a power of two value from MIN_DIVLOG2 to + MAX_DIV_LOG2, and a word-size of COUNTER_SIZE bits (the counter + counts up and resets whenever it's equal to the compare register, + generating an interrupt or whatever when it does so). The returned + values are: *DIVLOG2 -- log2 of the desired clock divider and *COUNT + -- the counter compare value to use. Returns true if it was possible + to find a reasonable value, otherwise false (and the other return + values will be set to be as good as possible). */ +int calc_counter_params (unsigned long base_freq, + unsigned long rate, + unsigned min_divlog2, unsigned max_divlog2, + unsigned counter_size, + unsigned *divlog2, unsigned *count) +{ + unsigned _divlog2; + int ok = 0; + + /* Find the lowest clock divider setting that can represent RATE. */ + for (_divlog2 = min_divlog2; _divlog2 <= max_divlog2; _divlog2++) { + /* Minimum interrupt rate possible using this divider. */ + int min_int_rate + = (base_freq >> _divlog2) >> counter_size; + + if (min_int_rate <= rate) { + /* This setting is the highest resolution + setting that's slow enough enough to attain + RATE interrupts per second, so use it. */ + ok = 1; + break; + } + } + + if (_divlog2 > max_divlog2) + /* Can't find correct setting. */ + _divlog2 = max_divlog2; + + if (divlog2) + *divlog2 = _divlog2; + if (count) + *count = ((base_freq >> _divlog2) + rate/2) / rate; + + return ok; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/process.c linux-2.4.6/arch/v850/kernel/process.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/process.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/process.c Tue Sep 11 14:12:33 2001 @@ -0,0 +1,281 @@ +/* + * arch/v850/kernel/process.c -- Arch-dependent process handling + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +static struct fs_struct init_fs = INIT_FS; +static struct files_struct init_files = INIT_FILES; +static struct signal_struct init_signals = INIT_SIGNALS; +struct mm_struct init_mm = INIT_MM (init_mm); + +union task_union init_task_union +__attribute__ ((section (".data.init_task"), aligned (KERNEL_STACK_SIZE))) + = { task: INIT_TASK (init_task_union.task) }; + +asmlinkage void ret_from_fork (void); + + +/* The idle loop. */ +static void default_idle (void) +{ + while (1) { + while (! current->need_resched) + __asm__ ("halt" ::: "cc"); + schedule (); + } +} + +void (*idle)(void) = default_idle; + +/* + * The idle thread. There's no useful work to be + * done, so just try to conserve power and have a + * low exit latency (ie sit in a loop waiting for + * somebody to say that they'd like to reschedule) + */ +void cpu_idle (void) +{ + /* endless idle loop with no priority at all */ + init_idle (); + current->nice = 20; + current->counter = -100; + (*idle) (); +} + +struct spec_reg_name { + const char *name; + int gpr; +}; + +struct spec_reg_name spec_reg_names[] = { + { "sp", GPR_SP }, + { "gp", GPR_GP }, + { "tp", GPR_TP }, + { "ep", GPR_EP }, + { "lp", GPR_LP }, + { 0, 0 } +}; + +void show_regs (struct pt_regs *regs) +{ + int gpr_base, gpr_offs; + + printk (" pc 0x%08lx psw 0x%08lx\n", regs->pc, regs->psw); + printk (" ctpc 0x%08lx ctpsw 0x%08lx ctbp 0x%08lx\n", + regs->ctpc, regs->ctpsw, regs->ctbp); + + for (gpr_base = 0; gpr_base < NUM_GPRS; gpr_base += 4) { + for (gpr_offs = 0; gpr_offs < 4; gpr_offs++) { + int gpr = gpr_base + gpr_offs; + long val = regs->gpr[gpr]; + struct spec_reg_name *srn; + + for (srn = spec_reg_names; srn->name; srn++) + if (srn->gpr == gpr) + break; + + if (srn->name) + printk ("%7s 0x%08lx", srn->name, val); + else + printk (" r%02d 0x%08lx", gpr, val); + } + + printk ("\n"); + } +} + +/* + * This is the mechanism for creating a new kernel thread. + * + * NOTE! Only a kernel-only process (ie the swapper or direct descendants who + * haven't done an "execve()") should use this: it will work within a system + * call from a "real" process, but the process memory space will not be free'd + * until both the parent and the child have exited. + */ +int kernel_thread (int (*fn)(void *), void *arg, unsigned long flags) +{ + mm_segment_t fs; + register unsigned long __ret __asm__ ("r10"); + register unsigned long clone_flags __asm__ ("r6") + = (long)flags | CLONE_VM; + + fs = get_fs (); + set_fs (KERNEL_DS); + + /* Note -- this is basically an inline copy of the clone() + function. */ + __asm__ __volatile__ ( + "addi %1, r0, r12;" + "trap 0;" /* clone syscall */ + "cmp r10, r0;" /* if not 0, we're the parent */ + "bne 1f;" /* ... so do nothing else. */ + "mov %4, r6;" /* arg for FN */ + "jarl .+4, r31;" /* figure out current pc */ + "add 4, r31;" /* and return addr for fun call */ + "jmp %2;" /* In the child, call FN */ + "addi %3, r0, r12;"/* and ... */ + "trap 0;" /* exit. */ + "1:" /* parent thread jumps here */ + : "=r" (__ret) + : "i" (__NR_clone), "r" (fn), "i" (__NR_exit), "r" (arg), + "r" (clone_flags) + : "r1", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", + "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r31", + "memory"); + + set_fs (fs); + + return __ret; +} + +void flush_thread (void) +{ + set_fs (USER_DS); +} + +int copy_thread (int nr, unsigned long clone_flags, + unsigned long stack_start, unsigned long stack_size, + struct task_struct *p, struct pt_regs *regs) +{ + /* Start pushing stuff from the top of the childs kernel stack. */ + unsigned long ksp = (unsigned long)p + KERNEL_STACK_SIZE; + /* We push two `state save' stack fames (see entry.S) on the new + kernel stack: + 1) The innermost one is what switch_thread would have + pushed, and is used when we context switch to the child + thread for the first time. It's set up to return to + ret_from_fork in entry.S. + 2) The outermost one (nearest the top) is what a syscall + trap would have pushed, and is set up to return to the + same location as the parent thread, but with a return + value of 0. */ + struct pt_regs *child_switch_regs, *child_trap_regs; + + /* Trap frame. */ + ksp -= STATE_SAVE_SIZE; + child_trap_regs = (struct pt_regs *)(ksp + STATE_SAVE_PT_OFFSET); + /* Switch frame. */ + ksp -= STATE_SAVE_SIZE; + child_switch_regs = (struct pt_regs *)(ksp + STATE_SAVE_PT_OFFSET); + + /* First copy parent's register state to child. */ + *child_switch_regs = *regs; + *child_trap_regs = *regs; + + /* switch_thread returns to the restored value of the lp + register (r31), so we make that the place where we want to + jump when the child thread begins running. */ + child_switch_regs->gpr[GPR_LP] = (v850_reg_t)ret_from_fork; + + /* Thread state for the child (everything else is on the stack). */ + p->thread.ksp = ksp; + + return 0; +} + +/* + * fill in the user structure for a core dump.. + */ +void dump_thread (struct pt_regs *regs, struct user *dump) +{ +#if 0 /* Later. XXX */ + dump->magic = CMAGIC; + dump->start_code = 0; + dump->start_stack = regs->gpr[GPR_SP]; + dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; + dump->u_dsize = ((unsigned long) (current->mm->brk + + (PAGE_SIZE-1))) >> PAGE_SHIFT; + dump->u_dsize -= dump->u_tsize; + dump->u_ssize = 0; + + if (dump->start_stack < TASK_SIZE) + dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; + + dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump); + dump->regs = *regs; + dump->u_fpvalid = 0; +#endif +} + +/* + * sys_execve() executes a new program. + */ +asmlinkage int sys_execve (char *name, char **argv, char **envp, + struct pt_regs *regs) +{ + char *filename = getname (name); + int error = PTR_ERR (filename); + + if (! IS_ERR (filename)) { + error = do_execve (filename, argv, envp, regs); + putname (filename); + } + + return error; +} + +/* + * These bracket the sleeping functions.. + */ +extern void scheduling_functions_start_here (void); +extern void scheduling_functions_end_here (void); +#define first_sched ((unsigned long) scheduling_functions_start_here) +#define last_sched ((unsigned long) scheduling_functions_end_here) + +unsigned long get_wchan (struct task_struct *p) +{ +#if 0 /* Barf. Figure out the stack-layout later. XXX */ + unsigned long fp, pc; + int count = 0; + + if (!p || p == current || p->state == TASK_RUNNING) + return 0; + + pc = thread_saved_pc (&p->thread); + + /* This quite disgusting function walks up the stack, following + saved return address, until it something that's out of bounds + (as defined by `first_sched' and `last_sched'). It then + returns the last PC that was in-bounds. */ + do { + if (fp < stack_page + sizeof (struct task_struct) || + fp >= 8184+stack_page) + return 0; + pc = ((unsigned long *)fp)[1]; + /* FIXME: This depends on the order of these functions. */ + if (pc < first_sched || pc >= last_sched) + return pc; + fp = *(unsigned long *) fp; + } while (count++ < 16); +#endif + + return 0; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/ptrace.c linux-2.4.6/arch/v850/kernel/ptrace.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/ptrace.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/ptrace.c Tue Sep 11 14:23:22 2001 @@ -0,0 +1,20 @@ +/* + * arch/v850/kernel/ptrace.c -- `ptrace' system call + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include + +/* Not implemented yet. XXX */ +int sys_ptrace (long request, long pid, long addr, long data) +{ + return -ENOSYS; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/rte_cb.c linux-2.4.6/arch/v850/kernel/rte_cb.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/rte_cb.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/rte_cb.c Fri Oct 5 14:39:05 2001 @@ -0,0 +1,148 @@ +/* + * include/asm-v850/rte_cb.c -- Midas Labs RTE-CB series of evaluation boards + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include + +#include +#include + +#include "mach.h" + +static void led_tick (void); + +#ifdef CONFIG_RTE_CB_MULTI +extern void multi_init (void); +#endif + + +#ifdef CONFIG_ROM_KERNEL +/* Initialization for kernel in ROM. */ +static inline rom_kernel_init (void) +{ + /* If the kernel is in ROM, we have to copy any initialized data + from ROM into RAM. */ + extern unsigned long _data_load_start, _sdata, _edata; + register unsigned long *src = &_data_load_start; + register unsigned long *dst = &_sdata, *end = &_edata; + + while (dst != end) + *dst++ = *src++; +} +#endif /* CONFIG_ROM_KERNEL */ + +void __init mach_early_init (void) +{ + nb85e_intc_disable_irqs (); + +#if defined (CONFIG_ROM_KERNEL) + rom_kernel_init (); +#elif defined (CONFIG_RTE_CB_MULTI) + multi_init (); +#endif +} + +void __init mach_setup (char **cmdline) +{ + printk ("CPU: %s\n" + "Platform: %s%s\n", + CHIP_LONG, + PLATFORM_LONG, +#ifdef CONFIG_ROM_KERNEL + "" +#elif defined (CONFIG_RTE_CB_MULTI) + " (with Multi ROM monitor)" +#else + " (with ROM monitor)" +#endif + ); + +#ifdef CONFIG_NB85E_UART + nb85e_uart_cons_init (); +#endif + + mach_tick = led_tick; + + ROOT_DEV = MKDEV (BLKMEM_MAJOR, 0); +} + +void machine_restart (char *__unused) +{ + disable_reset_guard (); + __asm__ __volatile__ ("jmp r0"); /* Jump to the reset vector. */ +} + +void machine_halt (void) +{ + disable_reset_guard (); + for (;;) + __asm__ __volatile__ ("halt"); +} + +void machine_power_off (void) +{ + machine_halt (); +} + +#ifdef CONFIG_PROC_FS +int mach_get_hardware_list (char *buf) +{ + int len = mach_get_cpu_info (buf); + len += sprintf (buf + len, + "Platform:\t%s\nMemory:\t%uK\n", + PLATFORM, + (SRAM_SIZE + SDRAM_SIZE) / 1024); + return len; +} +#endif /* CONFIG_PROC_FS */ + + +/* Animated LED display for timer tick. */ + +#define TICK_UPD_FREQ 6 +static int tick_frames[][10] = { + { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, -1 }, + { 0x9c, 0xa3, -1 }, + { 0xa3, 0xff, -1 }, + { 0x9c, 0xff, -1 }, + { -1 } +}; + +static void led_tick () +{ + static unsigned counter = 0; + + if (++counter == (HZ / TICK_UPD_FREQ)) { + static unsigned frame_nums[LED_NUM_DIGITS] = { 0 }; + int digit; + + for (digit = 0; + digit < LED_NUM_DIGITS && tick_frames[digit][0] >= 0; + digit++) + { + int frame = tick_frames[digit][frame_nums[digit]]; + if (frame < 0) { + LED (digit) = tick_frames[digit][0]; + frame_nums[digit] = 1; + } else { + LED (digit) = frame; + frame_nums[digit]++; + break; + } + } + + counter = 0; + } +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/rte_cb_multi.c linux-2.4.6/arch/v850/kernel/rte_cb_multi.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/rte_cb_multi.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/rte_cb_multi.c Thu Oct 4 16:34:42 2001 @@ -0,0 +1,84 @@ +/* + * include/asm-v850/rte_multi.c -- Support for Multi debugger monitor ROM + * on Midas Labs RTE-CB series of evaluation boards + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include + +#include + +/* A table of which interrupt vectors to install, since blindly + installing all of them makes the debugger stop working. This is a + list of offsets in the interrupt vector area; each entry means to + copy that particular 16-byte vector. An entry less than zero ends + the table. */ +static long multi_intv_install_table[] = { + 0x40, 0x50, /* trap vectors */ + /* Note -- illegal insn trap is used by the debugger. */ + 0x240, 0x250, 0x260, /* timer D interrupts */ + 0x2D0, 0x2E0, 0x2F0, /* UART channel 0 */ + 0x310, 0x320, 0x330, /* UART channel 1 */ + 0x350, 0x360, 0x370, /* UART channel 2 */ + -1 +}; + +/* Early initialization for kernel using Multi debugger ROM monitor. */ +void __init multi_init (void) +{ + /* We're using the Multi debugger monitor, so we have to install + the interrupt vectors. The monitor doesn't allow them to be + initially downloaded into their final destination because + it's in the monitor's scratch-RAM area. Unfortunately, Multi + also doesn't deal correctly with ELF sections where the LMA + and VMA differ -- it just ignores the LMA -- so we can't use + that feature to work around the problem. What we do instead + is just put the interrupt vectors into a normal section, and + do the necessary copying and relocation here. Since the + interrupt vector basically only contains `jr' instructions + and no-ops, it's not that hard. */ + extern unsigned long _intv_load_start, _intv_start, _intv_end; + register unsigned long *src = &_intv_load_start; + register unsigned long *dst = (unsigned long *)INTV_BASE; + register unsigned long jr_fixup = (char *)&_intv_start - (char *)dst; + register long *ii; + + /* Copy interupt vectors as instructed by multi_intv_install_table. */ + for (ii = multi_intv_install_table; *ii >= 0; ii++) { + /* Copy 16-byte interrupt vector at offset *ii. */ + int boffs; + for (boffs = 0; boffs < 0x10; boffs += sizeof *src) { + /* Copy a single word, fixing up the jump offs + if it's a `jr' instruction. */ + int woffs = (*ii + boffs) / sizeof *src; + unsigned long word = src[woffs]; + + if ((word & 0xFC0) == 0x780) { + /* A `jr' insn, fix up its offset (and yes, the + wierd half-word swapping is intentional). */ + unsigned short hi = word & 0xFFFF; + unsigned short lo = word >> 16; + unsigned long udisp22 + = lo + ((hi & 0x3F) << 16); + long disp22 = (long)(udisp22 << 10) >> 10; + + disp22 += jr_fixup; + + hi = ((disp22 >> 16) & 0x3F) | 0x780; + lo = disp22 & 0xFFFF; + + word = hi + (lo << 16); + } + + dst[woffs] = word; + } + } +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/rte_ma1_cb.c linux-2.4.6/arch/v850/kernel/rte_ma1_cb.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/rte_ma1_cb.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/rte_ma1_cb.c Fri Oct 5 17:09:56 2001 @@ -0,0 +1,78 @@ +/* + * arch/v850/kernel/rte_ma1_cb.c -- Midas labs RTE-V850E/MA1-CB board + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "mach.h" + +void __init mach_get_physical_ram (unsigned long *ram_start, + unsigned long *ram_len) +{ + /* SRAM and SDRAM are almost contiguous (see + mach_reserve_bootmem to see exactly how), so just use both as + one big area. */ + *ram_start = SRAM_ADDR; + *ram_len = SRAM_SIZE + SDRAM_SIZE - SRAM_ADDR; +} + +void __init mach_reserve_bootmem () +{ + unsigned long dup; + extern char _blkmem_0_start, _blkmem_0_end; + +#ifdef CONFIG_RTE_CB_MULTI + /* Prevent the kernel from touching the monitor's scratch RAM. */ + reserve_bootmem (MON_SCRATCH_ADDR, MON_SCRATCH_SIZE); +#endif + + /* The space between SRAM and SDRAM is filled with duplicate + images of SRAM. Prevent the kernel from using them. */ + for (dup = SRAM_ADDR + SRAM_SIZE; dup < SDRAM_ADDR; dup += SRAM_SIZE) + reserve_bootmem (dup, SRAM_SIZE); + + /* Reserve the space used by the root filesystem image. */ + reserve_bootmem ((unsigned long)&_blkmem_0_start, + &_blkmem_0_end - &_blkmem_0_start); +} + +void mach_gettimeofday (struct timeval *tv) +{ + tv->tv_sec = 0; + tv->tv_usec = 0; +} + +/* Called before configuring an on-chip UART. */ +void rte_ma1_cb_uart_pre_configure (unsigned chan, + unsigned cflags, unsigned baud) +{ + /* The RTE-MA1-CB connects some general-purpose I/O pins on the + CPU to the RTS/CTS lines of UART 0's serial connection. + I/O pins P42 and P43 are RTS and CTS respectively. */ + if (chan == 0) { + /* Put P42 & P43 in I/O port mode. */ + MA_PORT4_PMC &= ~0xC; + /* Make P42 and output, and P43 an input. */ + MA_PORT4_PM = (MA_PORT4_PM & ~0xC) | 0x8; + } + + /* Do pre-configuration for the actual UART. */ + ma_uart_pre_configure (chan, cflags, baud); +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/rte_nb85e_cb.c linux-2.4.6/arch/v850/kernel/rte_nb85e_cb.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/rte_nb85e_cb.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/rte_nb85e_cb.c Thu Oct 4 15:55:02 2001 @@ -0,0 +1,63 @@ +/* + * arch/v850/kernel/rte_nb85e_cb.c -- Midas labs RTE-V850E/NB85E-CB board + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "mach.h" + +void mach_get_physical_ram (unsigned long *ram_start, unsigned long *ram_len) +{ + /* Find memory used for root fs image. */ + unsigned long blkmem_0_start = (unsigned long)&_blkmem_0_start; + unsigned long blkmem_0_end = (unsigned long)&_blkmem_0_end; + + /* We just use SDRAM here; the kernel itself is in SRAM. */ + *ram_start = SDRAM_ADDR; + *ram_len = SDRAM_SIZE; + + /* See if the root fs image is in SDRAM (otherwise it doesn't + affect us). */ + if (blkmem_0_end > blkmem_0_start + && blkmem_0_start < SDRAM_ADDR + SDRAM_SIZE + && blkmem_0_end >= SDRAM_ADDR) + { + if (blkmem_0_start == SDRAM_ADDR) { + /* We only know how to deal with one case, where the + blkmem is exactly at the start of SDRAM. */ + unsigned len = blkmem_0_end - blkmem_0_start; + len = (len + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); + + *ram_start += len; + *ram_len -= len; + } else + printk ("Blkmem0 in strange place: 0lx%x - 0x%lx!\n", + blkmem_0_start, blkmem_0_end); + } +} + +void mach_gettimeofday (struct timeval *tv) +{ + tv->tv_sec = 0; + tv->tv_usec = 0; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/semaphore.c linux-2.4.6/arch/v850/kernel/semaphore.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/semaphore.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/semaphore.c Tue Sep 11 14:27:49 2001 @@ -0,0 +1,164 @@ +/* + * arch/v850/kernel/semaphore.c -- Semaphore support + * + * Copyright (C) 1998-2000 IBM Corporation + * Copyright (C) 1999 Linus Torvalds + * + * 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. + * + * This file is a copy of the s390 version, arch/s390/kernel/semaphore.c + * Author(s): Martin Schwidefsky + * which was derived from the i386 version, linux/arch/i386/kernel/semaphore.c + */ + +#include + +#include + +/* + * Semaphores are implemented using a two-way counter: + * The "count" variable is decremented for each process + * that tries to acquire the semaphore, while the "sleeping" + * variable is a count of such acquires. + * + * Notably, the inline "up()" and "down()" functions can + * efficiently test if they need to do any extra work (up + * needs to do something only if count was negative before + * the increment operation. + * + * "sleeping" and the contention routine ordering is + * protected by the semaphore spinlock. + * + * Note that these functions are only called when there is + * contention on the lock, and as such all this is the + * "non-critical" part of the whole semaphore business. The + * critical part is the inline stuff in + * where we want to avoid any extra jumps and calls. + */ + +/* + * Logic: + * - only on a boundary condition do we need to care. When we go + * from a negative count to a non-negative, we wake people up. + * - when we go from a non-negative count to a negative do we + * (a) synchronize with the "sleeper" count and (b) make sure + * that we're on the wakeup list before we synchronize so that + * we cannot lose wakeup events. + */ + +void __up(struct semaphore *sem) +{ + wake_up(&sem->wait); +} + +static spinlock_t semaphore_lock = SPIN_LOCK_UNLOCKED; + +void __down(struct semaphore * sem) +{ + struct task_struct *tsk = current; + DECLARE_WAITQUEUE(wait, tsk); + tsk->state = TASK_UNINTERRUPTIBLE; + add_wait_queue_exclusive(&sem->wait, &wait); + + spin_lock_irq(&semaphore_lock); + sem->sleepers++; + for (;;) { + int sleepers = sem->sleepers; + + /* + * Add "everybody else" into it. They aren't + * playing, because we own the spinlock. + */ + if (!atomic_add_negative(sleepers - 1, &sem->count)) { + sem->sleepers = 0; + break; + } + sem->sleepers = 1; /* us - see -1 above */ + spin_unlock_irq(&semaphore_lock); + + schedule(); + tsk->state = TASK_UNINTERRUPTIBLE; + spin_lock_irq(&semaphore_lock); + } + spin_unlock_irq(&semaphore_lock); + remove_wait_queue(&sem->wait, &wait); + tsk->state = TASK_RUNNING; + wake_up(&sem->wait); +} + +int __down_interruptible(struct semaphore * sem) +{ + int retval = 0; + struct task_struct *tsk = current; + DECLARE_WAITQUEUE(wait, tsk); + tsk->state = TASK_INTERRUPTIBLE; + add_wait_queue_exclusive(&sem->wait, &wait); + + spin_lock_irq(&semaphore_lock); + sem->sleepers ++; + for (;;) { + int sleepers = sem->sleepers; + + /* + * With signals pending, this turns into + * the trylock failure case - we won't be + * sleeping, and we* can't get the lock as + * it has contention. Just correct the count + * and exit. + */ + if (signal_pending(current)) { + retval = -EINTR; + sem->sleepers = 0; + atomic_add(sleepers, &sem->count); + break; + } + + /* + * Add "everybody else" into it. They aren't + * playing, because we own the spinlock. The + * "-1" is because we're still hoping to get + * the lock. + */ + if (!atomic_add_negative(sleepers - 1, &sem->count)) { + sem->sleepers = 0; + break; + } + sem->sleepers = 1; /* us - see -1 above */ + spin_unlock_irq(&semaphore_lock); + + schedule(); + tsk->state = TASK_INTERRUPTIBLE; + spin_lock_irq(&semaphore_lock); + } + spin_unlock_irq(&semaphore_lock); + tsk->state = TASK_RUNNING; + remove_wait_queue(&sem->wait, &wait); + wake_up(&sem->wait); + return retval; +} + +/* + * Trylock failed - make sure we correct for + * having decremented the count. + */ +int __down_trylock(struct semaphore * sem) +{ + unsigned long flags; + int sleepers; + + spin_lock_irqsave(&semaphore_lock, flags); + sleepers = sem->sleepers + 1; + sem->sleepers = 0; + + /* + * Add "everybody else" and us into it. They aren't + * playing, because we own the spinlock. + */ + if (!atomic_add_negative(sleepers, &sem->count)) + wake_up(&sem->wait); + + spin_unlock_irqrestore(&semaphore_lock, flags); + return 1; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/setup.c linux-2.4.6/arch/v850/kernel/setup.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/setup.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/setup.c Thu Oct 4 16:02:32 2001 @@ -0,0 +1,229 @@ +/* + * arch/v850/kernel/setup.c -- Arch-dependent initialization functions + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include +#include + +#include + +#include "mach.h" + +extern int _intv_start, _intv_end; +extern int _start, _stext, _etext, _sdata, _edata, _sbss, _ebss, _end; + +char command_line[512]; +char saved_command_line[512]; + +/* Memory not used by the kernel. */ +static unsigned long total_ram_pages; + +/* System RAM. */ +static unsigned long ram_start = 0, ram_len = 0; + +#define ADDR_TO_PAGE_UP(x) ((((unsigned long)x) + PAGE_SIZE-1) >> PAGE_SHIFT) +#define ADDR_TO_PAGE(x) (((unsigned long)x) >> PAGE_SHIFT) +#define PAGE_TO_ADDR(x) (((unsigned long)x) << PAGE_SHIFT) + +static void init_mem_alloc (unsigned long ram_start, unsigned long ram_len); + +void __init setup_arch (char **cmdline) +{ + /* Keep a copy of command line */ + *cmdline = command_line; + memcpy (saved_command_line, command_line, sizeof saved_command_line); + saved_command_line[sizeof saved_command_line - 1] = '\0'; + + init_mm.start_code = (unsigned long) &_stext; + init_mm.end_code = (unsigned long) &_etext; + init_mm.end_data = (unsigned long) &_edata; + init_mm.brk = (unsigned long) &_end; + + /* Find out what mem this machine has. */ + mach_get_physical_ram (&ram_start, &ram_len); + /* ... and tell the kernel about it. */ + init_mem_alloc (ram_start, ram_len); + + /* do machine-specific setups. */ + mach_setup (cmdline); +} + +void __init trap_init (void) +{ +} + +static void irq_nop (unsigned irq) { } +static unsigned irq_zero (unsigned irq) { return 0; } + +static void nmi_end (unsigned irq) +{ + if (irq > FIRST_NMI) { + printk (KERN_CRIT "NMI %d is unrecoverable; restarting...", + irq - FIRST_NMI); + machine_restart (0); + } +} + +static struct hw_interrupt_type nmi_irq_type = { + "NMI", + irq_zero, /* startup */ + irq_nop, /* shutdown */ + irq_nop, /* enable */ + irq_nop, /* disable */ + irq_nop, /* ack */ + nmi_end, /* end */ +}; + +void __init init_IRQ (void) +{ + init_irq_handlers (0, NUM_MACH_IRQS, 0); + init_irq_handlers (FIRST_NMI, NUM_NMIS, &nmi_irq_type); + mach_init_irqs (); +} + +void __init mem_init (void) +{ + max_mapnr = MAP_NR (ram_start + ram_len); + + num_physpages = ADDR_TO_PAGE (ram_len); + + total_ram_pages = free_all_bootmem (); + + printk ("Memory: %luK/%luK available" + " (%luK kernel code, %luK data)\n", + PAGE_TO_ADDR (nr_free_pages()) / 1024, + ram_len / 1024, + ((unsigned long)&_etext - (unsigned long)&_stext) / 1024, + ((unsigned long)&_ebss - (unsigned long)&_sdata) / 1024); +} + +void free_initmem (void) +{ + extern char __init_begin, __init_end; + unsigned long start = PAGE_ALIGN ((unsigned long)(&__init_begin)); + unsigned long end = PAGE_ALIGN ((unsigned long)(&__init_end)); + unsigned long addr; + + printk("Freeing unused kernel memory: %ldK freed\n", + (end - start) / 1024); + + for (addr = start; addr < end; addr += PAGE_SIZE) { + mem_map_t *page = virt_to_page (addr); + ClearPageReserved (page); + set_page_count (page, 1); + free_page (page); + total_ram_pages++; + } +} + +void si_meminfo (struct sysinfo *info) +{ + info->totalram = total_ram_pages; + info->sharedram = 0; + info->freeram = nr_free_pages (); + info->bufferram = atomic_read (&buffermem_pages); + info->totalhigh = 0; + info->freehigh = 0; + info->mem_unit = PAGE_SIZE; +} + + +/* Initialize the `bootmem allocator'. RAM_START and RAM_LEN identify + what RAM may be used. */ +static void __init +init_bootmem_alloc (unsigned long ram_start, unsigned long ram_len) +{ + /* Address range of the `kernel proper'. */ + unsigned long kernel_start = (unsigned long)&_start; + unsigned long kernel_end = (unsigned long)&_end; + /* End of the managed RAM space. */ + unsigned long ram_end = ram_start + ram_len; + /* Address range of the interrupt vector table. */ + unsigned long intv_start = (unsigned long)&_intv_start; + unsigned long intv_end = (unsigned long)&_intv_end; + /* How long we think the bootmem allocation bitmap will be. */ + unsigned guess_bootmap_len = ram_end / PAGE_SIZE / 8; + /* True if the kernel is in the managed RAM area. */ + int kernel_in_ram = (kernel_end > ram_start && kernel_start < ram_end); + /* True if the interrupt vectors are in the managed RAM area. */ + int intv_in_ram = (intv_end > ram_start && intv_start < ram_end); + /* True if the interrupt vectors are inside the kernel proper. */ + int intv_in_kernel + = (intv_end > kernel_start && intv_start < kernel_end); + /* Address and length of the bootmem allocator's allocation bitmap. */ + unsigned long bootmap, bootmap_len; + + /* Decide where to locate the bootmap. */ + if (kernel_in_ram) + /* Put it right after the kernel. */ + bootmap = kernel_end; + else if (ram_start < intv_end + && ram_start + guess_bootmap_len > intv_start) + /* Put it at the beginning of RAM, but make sure to skip + the interrupt vectors. */ + bootmap = intv_end; + else + /* Just put it at the start of RAM, since RAM doesn't + start at 0. */ + bootmap = ram_start; + + /* Round bootmap location up to next page. */ + bootmap = PAGE_TO_ADDR (ADDR_TO_PAGE_UP (bootmap)); + + /* Initialize bootmem allocator. */ + bootmap_len = init_bootmem_node (NODE_DATA (0), + ADDR_TO_PAGE (bootmap), + ADDR_TO_PAGE (PAGE_OFFSET), + ADDR_TO_PAGE (ram_end)); + + /* Now make the RAM actually allocatable (it starts out `reserved'). */ + free_bootmem (ram_start, ram_len); + + if (kernel_in_ram) + /* Reserve the kernel address space, so it doesn't get + allocated. */ + reserve_bootmem (kernel_start, kernel_end - kernel_start); + + if (intv_in_ram && !intv_in_kernel) + /* Reserve the interrupt vector space. */ + reserve_bootmem (intv_start, intv_end - intv_start); + + /* Reserve the bootmap space. */ + reserve_bootmem (bootmap, bootmap_len); + + /* Let the platform-dependent code reserve some too. */ + if (mach_reserve_bootmem) + mach_reserve_bootmem (); +} + +/* Tell the kernel about what RAM it may use for memory allocation. */ +static void __init +init_mem_alloc (unsigned long ram_start, unsigned long ram_len) +{ + unsigned i; + unsigned long zones_size[MAX_NR_ZONES]; + + init_bootmem_alloc (ram_start, ram_len); + + for (i = 0; i < MAX_NR_ZONES; i++) + zones_size[i] = 0; + + /* We stuff all the memory into one area, which includes the + initial gap from PAGE_OFFSET to ram_start. */ + zones_size[ZONE_DMA] + = ADDR_TO_PAGE (ram_len + (ram_start - PAGE_OFFSET)); + + free_area_init_node (0, 0, 0, zones_size, PAGE_OFFSET, 0); +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/signal.c linux-2.4.6/arch/v850/kernel/signal.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/signal.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/signal.c Thu Oct 4 15:18:21 2001 @@ -0,0 +1,642 @@ +/* + * arch/v850/kernel/signal.c -- Signal handling + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * Copyright (C) 1999,2000 Niibe Yutaka & Kaz Kojima + * Copyright (C) 1991,1992 Linus Torvalds + * + * 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. + * + * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson + * + * This file was was derived from the sh version, arch/sh/kernel/signal.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEBUG_SIG 0 + +#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) + +asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset); + +int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from) +{ + if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t))) + return -EFAULT; + if (from->si_code < 0) + return __copy_to_user(to, from, sizeof(siginfo_t)); + else { + int err; + + /* If you change siginfo_t structure, please be sure + this code is fixed accordingly. + It should never copy any pad contained in the structure + to avoid security leaks, but must copy the generic + 3 ints plus the relevant union member. */ + err = __put_user(from->si_signo, &to->si_signo); + err |= __put_user(from->si_errno, &to->si_errno); + err |= __put_user((short)from->si_code, &to->si_code); + /* First 32bits of unions are always present. */ + err |= __put_user(from->si_pid, &to->si_pid); + switch (from->si_code >> 16) { + case __SI_FAULT >> 16: + break; + case __SI_CHLD >> 16: + err |= __put_user(from->si_utime, &to->si_utime); + err |= __put_user(from->si_stime, &to->si_stime); + err |= __put_user(from->si_status, &to->si_status); + default: + err |= __put_user(from->si_uid, &to->si_uid); + break; + /* case __SI_RT: This is not generated by the kernel as of now. */ + } + return err; + } +} + +/* + * Atomically swap in the new signal mask, and wait for a signal. + */ +asmlinkage int +sys_sigsuspend(old_sigset_t mask, struct pt_regs *regs) +{ + sigset_t saveset; + + mask &= _BLOCKABLE; + spin_lock_irq(¤t->sigmask_lock); + saveset = current->blocked; + siginitset(¤t->blocked, mask); + recalc_sigpending(current); + spin_unlock_irq(¤t->sigmask_lock); + + regs->gpr[GPR_RVAL] = -EINTR; + while (1) { + current->state = TASK_INTERRUPTIBLE; + schedule(); + if (do_signal(regs, &saveset)) + return -EINTR; + } +} + +asmlinkage int +sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, + struct pt_regs *regs) +{ + sigset_t saveset, newset; + + /* XXX: Don't preclude handling different sized sigset_t's. */ + if (sigsetsize != sizeof(sigset_t)) + return -EINVAL; + + if (copy_from_user(&newset, unewset, sizeof(newset))) + return -EFAULT; + sigdelsetmask(&newset, ~_BLOCKABLE); + spin_lock_irq(¤t->sigmask_lock); + saveset = current->blocked; + current->blocked = newset; + recalc_sigpending(current); + spin_unlock_irq(¤t->sigmask_lock); + + regs->gpr[GPR_RVAL] = -EINTR; + while (1) { + current->state = TASK_INTERRUPTIBLE; + schedule(); + if (do_signal(regs, &saveset)) + return -EINTR; + } +} + +asmlinkage int +sys_sigaction(int sig, const struct old_sigaction *act, + struct old_sigaction *oact) +{ + struct k_sigaction new_ka, old_ka; + int ret; + + if (act) { + old_sigset_t mask; + if (verify_area(VERIFY_READ, act, sizeof(*act)) || + __get_user(new_ka.sa.sa_handler, &act->sa_handler) || + __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) + return -EFAULT; + __get_user(new_ka.sa.sa_flags, &act->sa_flags); + __get_user(mask, &act->sa_mask); + siginitset(&new_ka.sa.sa_mask, mask); + } + + ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); + + if (!ret && oact) { + if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) || + __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || + __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) + return -EFAULT; + __put_user(old_ka.sa.sa_flags, &oact->sa_flags); + __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); + } + + return ret; +} + +asmlinkage int +sys_sigaltstack(const stack_t *uss, stack_t *uoss, + struct pt_regs *regs) +{ + return do_sigaltstack(uss, uoss, regs->gpr[GPR_SP]); +} + + +/* + * Do a signal return; undo the signal stack. + */ + +struct sigframe +{ + struct sigcontext sc; + unsigned long extramask[_NSIG_WORDS-1]; + unsigned long tramp[2]; /* signal trampoline */ +}; + +struct rt_sigframe +{ + struct siginfo *pinfo; + void *puc; + struct siginfo info; + struct ucontext uc; + unsigned long tramp[2]; /* signal trampoline */ +}; + +static int +restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc, int *rval_p) +{ + unsigned int err = 0; + +#define COPY(x) err |= __get_user(regs->x, &sc->regs.x) + COPY(gpr[0]); COPY(gpr[1]); COPY(gpr[2]); COPY(gpr[3]); + COPY(gpr[4]); COPY(gpr[5]); COPY(gpr[6]); COPY(gpr[7]); + COPY(gpr[8]); COPY(gpr[9]); COPY(gpr[10]); COPY(gpr[11]); + COPY(gpr[12]); COPY(gpr[13]); COPY(gpr[14]); COPY(gpr[15]); + COPY(gpr[16]); COPY(gpr[17]); COPY(gpr[18]); COPY(gpr[19]); + COPY(gpr[20]); COPY(gpr[21]); COPY(gpr[22]); COPY(gpr[23]); + COPY(gpr[24]); COPY(gpr[25]); COPY(gpr[26]); COPY(gpr[27]); + COPY(gpr[28]); COPY(gpr[29]); COPY(gpr[30]); COPY(gpr[31]); + COPY(pc); COPY(psw); + COPY(ctpc); COPY(ctpsw); COPY(ctbp); +#undef COPY + + return err; +} + +asmlinkage int sys_sigreturn(struct pt_regs *regs) +{ + struct sigframe *frame = (struct sigframe *)regs->gpr[GPR_SP]; + sigset_t set; + int rval; + + if (verify_area(VERIFY_READ, frame, sizeof(*frame))) + goto badframe; + + if (__get_user(set.sig[0], &frame->sc.oldmask) + || (_NSIG_WORDS > 1 + && __copy_from_user(&set.sig[1], &frame->extramask, + sizeof(frame->extramask)))) + goto badframe; + + sigdelsetmask(&set, ~_BLOCKABLE); + + spin_lock_irq(¤t->sigmask_lock); + current->blocked = set; + recalc_sigpending(current); + spin_unlock_irq(¤t->sigmask_lock); + + if (restore_sigcontext(regs, &frame->sc, &rval)) + goto badframe; + return rval; + +badframe: + force_sig(SIGSEGV, current); + return 0; +} + +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs) +{ + struct rt_sigframe *frame = (struct rt_sigframe *)regs->gpr[GPR_SP]; + sigset_t set; + stack_t st; + int rval; + + if (verify_area(VERIFY_READ, frame, sizeof(*frame))) + goto badframe; + + if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) + goto badframe; + + sigdelsetmask(&set, ~_BLOCKABLE); + spin_lock_irq(¤t->sigmask_lock); + current->blocked = set; + recalc_sigpending(current); + spin_unlock_irq(¤t->sigmask_lock); + + if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &rval)) + goto badframe; + + if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st))) + goto badframe; + /* It is more difficult to avoid calling this function than to + call it and ignore errors. */ + do_sigaltstack(&st, NULL, regs->gpr[GPR_SP]); + + return rval; + +badframe: + force_sig(SIGSEGV, current); + return 0; +} + +/* + * Set up a signal frame. + */ + +static int +setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs, + unsigned long mask) +{ + int err = 0; + +#define COPY(x) err |= __put_user(regs->x, &sc->regs.x) + COPY(gpr[0]); COPY(gpr[1]); COPY(gpr[2]); COPY(gpr[3]); + COPY(gpr[4]); COPY(gpr[5]); COPY(gpr[6]); COPY(gpr[7]); + COPY(gpr[8]); COPY(gpr[9]); COPY(gpr[10]); COPY(gpr[11]); + COPY(gpr[12]); COPY(gpr[13]); COPY(gpr[14]); COPY(gpr[15]); + COPY(gpr[16]); COPY(gpr[17]); COPY(gpr[18]); COPY(gpr[19]); + COPY(gpr[20]); COPY(gpr[21]); COPY(gpr[22]); COPY(gpr[23]); + COPY(gpr[24]); COPY(gpr[25]); COPY(gpr[26]); COPY(gpr[27]); + COPY(gpr[28]); COPY(gpr[29]); COPY(gpr[30]); COPY(gpr[31]); + COPY(pc); COPY(psw); + COPY(ctpc); COPY(ctpsw); COPY(ctbp); +#undef COPY + + err |= __put_user(mask, &sc->oldmask); + + return err; +} + +/* + * Determine which stack to use.. + */ +static inline void * +get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) +{ + /* Default to using normal stack */ + unsigned long sp = regs->gpr[GPR_SP]; + + if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp)) + sp = current->sas_ss_sp + current->sas_ss_size; + + return (void *)((sp - frame_size) & -8UL); +} + +static void setup_frame(int sig, struct k_sigaction *ka, + sigset_t *set, struct pt_regs *regs) +{ + struct sigframe *frame; + int err = 0; + int signal; + + frame = get_sigframe(ka, regs, sizeof(*frame)); + + if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) + goto give_sigsegv; + + signal = current->exec_domain + && current->exec_domain->signal_invmap + && sig < 32 + ? current->exec_domain->signal_invmap[sig] + : sig; + + err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); + + if (_NSIG_WORDS > 1) { + err |= __copy_to_user(frame->extramask, &set->sig[1], + sizeof(frame->extramask)); + } + + /* Set up to return from userspace. If provided, use a stub + already in userspace. */ + if (ka->sa.sa_flags & SA_RESTORER) { + regs->gpr[GPR_LP] = (unsigned long) ka->sa.sa_restorer; + } else { + /* Note, these encodings are _little endian_! */ + + /* addi __NR_sigreturn, r0, r12 */ + err |= __put_user(0x6600 | (__NR_sigreturn << 16), + frame->tramp + 0); + /* trap 0 */ + err |= __put_user(0x010007e0, + frame->tramp + 1); + + regs->gpr[GPR_LP] = (unsigned long)frame->tramp; + + flush_cache_sigtramp (regs->gpr[GPR_LP]); + } + + if (err) + goto give_sigsegv; + + /* Set up registers for signal handler */ + regs->gpr[GPR_SP] = (unsigned long) frame; + regs->gpr[GPR_ARG0] = signal; /* Arg for signal handler */ + regs->pc = (unsigned long) ka->sa.sa_handler; + + set_fs(USER_DS); + +#if DEBUG_SIG + printk("SIG deliver (%s:%d): sp=%p pc=%08lx ra=%08lx\n", + current->comm, current->pid, frame, regs->pc, ); +#endif + + return; + +give_sigsegv: + if (sig == SIGSEGV) + ka->sa.sa_handler = SIG_DFL; + force_sig(SIGSEGV, current); +} + +static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, + sigset_t *set, struct pt_regs *regs) +{ + struct rt_sigframe *frame; + int err = 0; + int signal; + + frame = get_sigframe(ka, regs, sizeof(*frame)); + + if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) + goto give_sigsegv; + + signal = current->exec_domain + && current->exec_domain->signal_invmap + && sig < 32 + ? current->exec_domain->signal_invmap[sig] + : sig; + + err |= __put_user(&frame->info, &frame->pinfo); + err |= __put_user(&frame->uc, &frame->puc); + err |= copy_siginfo_to_user(&frame->info, info); + + /* Create the ucontext. */ + err |= __put_user(0, &frame->uc.uc_flags); + err |= __put_user(0, &frame->uc.uc_link); + err |= __put_user((void *)current->sas_ss_sp, + &frame->uc.uc_stack.ss_sp); + err |= __put_user(sas_ss_flags(regs->gpr[GPR_SP]), + &frame->uc.uc_stack.ss_flags); + err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); + err |= setup_sigcontext(&frame->uc.uc_mcontext, + regs, set->sig[0]); + err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); + + /* Set up to return from userspace. If provided, use a stub + already in userspace. */ + if (ka->sa.sa_flags & SA_RESTORER) { + regs->gpr[GPR_LP] = (unsigned long) ka->sa.sa_restorer; + } else { + /* Note, these encodings are _little endian_! */ + + /* addi __NR_sigreturn, r0, r12 */ + err |= __put_user(0x6600 | (__NR_sigreturn << 16), + frame->tramp + 0); + /* trap 0 */ + err |= __put_user(0x010007e0, + frame->tramp + 1); + + regs->gpr[GPR_LP] = (unsigned long)frame->tramp; + + flush_cache_sigtramp (regs->gpr[GPR_LP]); + } + + if (err) + goto give_sigsegv; + + /* Set up registers for signal handler */ + regs->gpr[GPR_SP] = (unsigned long) frame; + regs->gpr[GPR_ARG0] = signal; /* Arg for signal handler */ + regs->pc = (unsigned long) ka->sa.sa_handler; + + set_fs(USER_DS); + +#if DEBUG_SIG + printk("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n", + current->comm, current->pid, frame, regs->pc, regs->pr); +#endif + + return; + +give_sigsegv: + if (sig == SIGSEGV) + ka->sa.sa_handler = SIG_DFL; + force_sig(SIGSEGV, current); +} + +/* + * OK, we're invoking a handler + */ + +static void +handle_signal(unsigned long sig, struct k_sigaction *ka, + siginfo_t *info, sigset_t *oldset, struct pt_regs * regs) +{ + /* Are we from a system call? */ + if (PT_REGS_SYSCALL (regs)) { + /* If so, check system call restarting.. */ + switch (regs->gpr[GPR_RVAL]) { + case -ERESTARTNOHAND: + regs->gpr[GPR_RVAL] = -EINTR; + break; + + case -ERESTARTSYS: + if (!(ka->sa.sa_flags & SA_RESTART)) { + regs->gpr[GPR_RVAL] = -EINTR; + break; + } + /* fallthrough */ + case -ERESTARTNOINTR: + regs->gpr[12] = PT_REGS_SYSCALL (regs); + regs->pc -= 4; /* Size of `trap 0' insn. */ + } + + PT_REGS_SET_SYSCALL (regs, 0); + } + + /* Set up the stack frame */ + if (ka->sa.sa_flags & SA_SIGINFO) + setup_rt_frame(sig, ka, info, oldset, regs); + else + setup_frame(sig, ka, oldset, regs); + + if (ka->sa.sa_flags & SA_ONESHOT) + ka->sa.sa_handler = SIG_DFL; + + if (!(ka->sa.sa_flags & SA_NODEFER)) { + spin_lock_irq(¤t->sigmask_lock); + sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); + sigaddset(¤t->blocked,sig); + recalc_sigpending(current); + spin_unlock_irq(¤t->sigmask_lock); + } +} + +/* + * Note that 'init' is a special process: it doesn't get signals it doesn't + * want to handle. Thus you cannot kill init even with a SIGKILL even by + * mistake. + * + * Note that we go through the signals twice: once to check the signals that + * the kernel can handle, and then we build all the user-level signal handling + * stack-frames in one go after that. + */ +int do_signal(struct pt_regs *regs, sigset_t *oldset) +{ + siginfo_t info; + struct k_sigaction *ka; + + /* + * We want the common case to go fast, which + * is why we may in certain cases get here from + * kernel mode. Just return without doing anything + * if so. + */ + if (!user_mode(regs)) + return 1; + + if (!oldset) + oldset = ¤t->blocked; + + for (;;) { + unsigned long signr; + + spin_lock_irq(¤t->sigmask_lock); + signr = dequeue_signal(¤t->blocked, &info); + spin_unlock_irq(¤t->sigmask_lock); + + if (!signr) + break; + + if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) { + /* Let the debugger run. */ + current->exit_code = signr; + current->state = TASK_STOPPED; + notify_parent(current, SIGCHLD); + schedule(); + + /* We're back. Did the debugger cancel the sig? */ + if (!(signr = current->exit_code)) + continue; + current->exit_code = 0; + + /* The debugger continued. Ignore SIGSTOP. */ + if (signr == SIGSTOP) + continue; + + /* Update the siginfo structure. Is this good? */ + if (signr != info.si_signo) { + info.si_signo = signr; + info.si_errno = 0; + info.si_code = SI_USER; + info.si_pid = current->p_pptr->pid; + info.si_uid = current->p_pptr->uid; + } + + /* If the (new) signal is now blocked, requeue it. */ + if (sigismember(¤t->blocked, signr)) { + send_sig_info(signr, &info, current); + continue; + } + } + + ka = ¤t->sig->action[signr-1]; + if (ka->sa.sa_handler == SIG_IGN) { + if (signr != SIGCHLD) + continue; + /* Check for SIGCHLD: it's special. */ + while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0) + /* nothing */; + continue; + } + + if (ka->sa.sa_handler == SIG_DFL) { + int exit_code = signr; + + /* Init gets no signals it doesn't want. */ + if (current->pid == 1) + continue; + + switch (signr) { + case SIGCONT: case SIGCHLD: case SIGWINCH: + continue; + + case SIGTSTP: case SIGTTIN: case SIGTTOU: + if (is_orphaned_pgrp(current->pgrp)) + continue; + /* FALLTHRU */ + + case SIGSTOP: + current->state = TASK_STOPPED; + current->exit_code = signr; + if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP)) + notify_parent(current, SIGCHLD); + schedule(); + continue; + + case SIGQUIT: case SIGILL: case SIGTRAP: + case SIGABRT: case SIGFPE: case SIGSEGV: + case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ: + if (do_coredump(signr, regs)) + exit_code |= 0x80; + /* FALLTHRU */ + + default: + sigaddset(¤t->pending.signal, signr); + recalc_sigpending(current); + current->flags |= PF_SIGNALED; + do_exit(exit_code); + /* NOTREACHED */ + } + } + + /* Whee! Actually deliver the signal. */ + handle_signal(signr, ka, &info, oldset, regs); + return 1; + } + + /* Did we come from a system call? */ + if (PT_REGS_SYSCALL (regs)) { + /* Restart the system call - no handlers present */ + if (regs->gpr[GPR_RVAL] == -ERESTARTNOHAND || + regs->gpr[GPR_RVAL] == -ERESTARTSYS || + regs->gpr[GPR_RVAL] == -ERESTARTNOINTR) { + regs->gpr[12] = PT_REGS_SYSCALL (regs); + regs->pc -= 4; /* Size of `trap 0' insn. */ + } + } + return 0; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/sim.c linux-2.4.6/arch/v850/kernel/sim.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/sim.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/sim.c Mon Oct 1 16:44:03 2001 @@ -0,0 +1,220 @@ +/* + * arch/v850/kernel/sim.c -- Machine-specific stuff for GDB v850e simulator + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "mach.h" + +/* The (arbitrary) size of RAM for our simulated machine. */ +#define MEM_SIZE ((long)(8*1024*1024)) +/* The name of a file containing the root filesystem. */ +#define ROOT_FS "root.ext2" + +extern void simcons_setup (void); +extern void simcons_poll_ttys (void); + +/* These are where `blkmem' device 0 is allocated. We put the root + filesystem there. */ +unsigned long blkmem_0_addr, blkmem_0_len; +/* Make the root filesystem R/W. */ +int blkmem_0_rw = 1; + +static int read_file (const char *name, + unsigned long *addr, unsigned long *len, + const char **err); + +void __init mach_setup (char **cmdline) +{ + const char *err; + + printk ("CPU: NEC v850e (GDB simulator)\n"); + + simcons_setup (); + + printk (KERN_INFO "Reading root filesystem: %s", ROOT_FS); + if (read_file (ROOT_FS, &blkmem_0_addr, &blkmem_0_len, &err)) { + printk (" (size %luK)\n", blkmem_0_len / 1024); + ROOT_DEV = MKDEV (BLKMEM_MAJOR, 0); + } else { + static char bogus_blkmem_array[1]; + + printk ("...%s failed!\n", err); + + /* blkmem is going to attempt to read the device even if + we don't specify it as the root, so make sure it + points to something innocuous. */ + blkmem_0_addr = (unsigned long)bogus_blkmem_array; + blkmem_0_len = 0; + } +} + +void mach_get_physical_ram (unsigned long *ram_start, unsigned long *ram_len) +{ + *ram_start = 0; + *ram_len = MEM_SIZE; +} + +void __init mach_sched_init (struct irqaction *timer_action) +{ + /* ...do magic timer initialization?... */ + mach_tick = simcons_poll_ttys; + setup_irq (0, timer_action); +} + + +static void irq_nop (unsigned irq) { } +static unsigned irq_zero (unsigned irq) { return 0; } + +static struct hw_interrupt_type sim_irq_type = { + "IRQ", + irq_zero, /* startup */ + irq_nop, /* shutdown */ + irq_nop, /* enable */ + irq_nop, /* disable */ + irq_nop, /* ack */ + irq_nop, /* end */ +}; + +void __init mach_init_irqs (void) +{ + init_irq_handlers (0, NUM_MACH_IRQS, &sim_irq_type); +} + + +void mach_gettimeofday (struct timeval *tv) +{ + long timeval[2], timezone[2]; + int rval = V850_SIM_SYSCALL (gettimeofday, timeval, timezone); + if (rval == 0) { + tv->tv_sec = timeval[0]; + tv->tv_usec = timeval[1]; + } +} + +#ifdef CONFIG_PROC_FS +int mach_get_cpu_info (char *buf) +{ + extern unsigned long loops_per_jiffy; + return sprintf (buf, + "CPU-Family: v850\n" + "CPU-Arch: v850e\n" + "CPU-Model: GDB/v850e simulator\n" + "BogoMips: %lu.%02lu\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); +} + +int mach_get_hardware_list (char *buf) +{ + int len = mach_get_cpu_info (buf); + len += sprintf (buf + len, "Memory:\t\t%luK\n", MEM_SIZE / 1024); + return len; +} +#endif /* CONFIG_PROC_FS */ + +void machine_restart (char *__unused) +{ + /* Turn off reset guard. */ + *(volatile unsigned long *)RESET_GUARD_ADDR = 0; + + V850_SIM_SYSCALL (write, 1, "RESTART\n", 8); + + /* Jump to the reset vector. */ + __asm__ __volatile__ ("jmp r0"); +} + +void machine_halt (void) +{ + /* Turn off reset guard. */ + *(volatile unsigned long *)RESET_GUARD_ADDR = 0; + + V850_SIM_SYSCALL (write, 1, "HALT\n", 5); +#if 0 + for (;;) + __asm__ __volatile__ ("halt"); +#else + V850_SIM_SYSCALL (exit, 0); +#endif +} + +void machine_power_off (void) +{ + V850_SIM_SYSCALL (write, 1, "POWER OFF\n", 10); + machine_halt (); +} + +/* Load data from a file called NAME into ram. The address and length + of the data image are returned in ADDR and LEN. */ +static int __init +read_file (const char *name, + unsigned long *addr, unsigned long *len, + const char **err) +{ + int rval, fd; + unsigned long cur, left; + /* Note this is not a normal stat buffer, it's an ad-hoc + structure defined by the simulator. */ + unsigned long stat_buf[10]; + + /* Stat the file to find out the length. */ + rval = V850_SIM_SYSCALL (stat, name, stat_buf); + if (rval < 0) { + if (err) *err = "stat"; + return 0; + } + *len = stat_buf[4]; + + /* Open the file; `0' is O_RDONLY. */ + fd = V850_SIM_SYSCALL (open, name, 0); + if (fd < 0) { + if (err) *err = "open"; + return 0; + } + + *addr = (unsigned long)alloc_bootmem(*len); + if (! *addr) { + V850_SIM_SYSCALL (close, fd); + if (err) *err = "alloc_bootmem"; + return 0; + } + + cur = *addr; + left = *len; + while (left > 0) { + int chunk = V850_SIM_SYSCALL (read, fd, cur, left); + if (chunk <= 0) + break; + cur += chunk; + left -= chunk; + } + V850_SIM_SYSCALL (close, fd); + if (left > 0) { + /* Some read failed. */ + free_bootmem (*addr, *len); + if (err) *err = "read"; + return 0; + } + + return 1; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/simcons.c linux-2.4.6/arch/v850/kernel/simcons.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/simcons.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/simcons.c Fri Sep 28 15:49:35 2001 @@ -0,0 +1,163 @@ +/* + * arch/v850/kernel/simcons.c -- Console I/O for GDB v850e simulator + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + + +/* Low-level console. */ + +static void simcons_write (struct console *co, const char *s, unsigned count) +{ + V850_SIM_SYSCALL (write, 1, s, count); +} + +static int simcons_wait_key (struct console *co) +{ + char buf[1]; + int len = V850_SIM_SYSCALL (read, 0, &buf, 1); + if (len == 1) + return buf[0]; + else + return -1; +} + +static kdev_t simcons_device (struct console *c) +{ + return MKDEV (TTY_MAJOR, 64 + c->index); +} + +static struct console simcons = +{ + name: "simcons", + write: simcons_write, + wait_key: simcons_wait_key, + device: simcons_device, + flags: CON_PRINTBUFFER, + index: -1, +}; + +/* Higher level TTY interface. */ + +static struct tty_struct *tty_table[1] = { 0 }; +static struct termios *tty_termios[1] = { 0 }; +static struct termios *tty_termios_locked[1] = { 0 }; +static struct tty_driver tty_driver = { 0 }; +static int tty_refcount = 0; + +int simcons_tty_open (struct tty_struct *tty, struct file *filp) +{ + return 0; +} + +int simcons_tty_write (struct tty_struct *tty, int from_user, + const unsigned char *buf, int count) +{ + return V850_SIM_SYSCALL (write, 1, buf, count); +} + +int simcons_tty_write_room (struct tty_struct *tty) +{ + /* Completely arbitrary. */ + return 0x100000; +} + +int simcons_tty_chars_in_buffer (struct tty_struct *tty) +{ + /* We have no buffer. */ + return 0; +} + +int __init simcons_tty_init (void) +{ + tty_driver.name = "simcons"; + tty_driver.major = TTY_MAJOR; + tty_driver.minor_start = 64; + tty_driver.num = 1; + tty_driver.type = TTY_DRIVER_TYPE_SYSCONS; + + tty_driver.refcount = &tty_refcount; + + tty_driver.table = tty_table; + tty_driver.termios = tty_termios; + tty_driver.termios_locked = tty_termios_locked; + + tty_driver.init_termios = tty_std_termios; + + tty_driver.open = simcons_tty_open; + tty_driver.write = simcons_tty_write; + tty_driver.write_room = simcons_tty_write_room; + tty_driver.chars_in_buffer = simcons_tty_chars_in_buffer; + + tty_register_driver (&tty_driver); +} +__initcall (simcons_tty_init); + +/* Poll for input on the console, and if there's any, deliver it to the + tty driver. */ +void simcons_poll_tty (struct tty_struct *tty) +{ + int flip = 0, send_break = 0; + struct pollfd pfd; + pfd.fd = 0; + pfd.events = POLLIN; + + if (V850_SIM_SYSCALL (poll, &pfd, 1, 0) > 0) { + if (pfd.revents & POLLIN) { + int left = TTY_FLIPBUF_SIZE - tty->flip.count; + + if (left > 0) { + unsigned char *buf = tty->flip.char_buf_ptr; + int rd = V850_SIM_SYSCALL (read, 0, buf, left); + + if (rd > 0) { + tty->flip.count += rd; + tty->flip.char_buf_ptr += rd; + memset (tty->flip.flag_buf_ptr, 0, rd); + tty->flip.flag_buf_ptr += rd; + flip = 1; + } else + send_break = 1; + } + } else if (pfd.revents & POLLERR) + send_break = 1; + } + + if (send_break) { + tty_insert_flip_char (tty, 0, TTY_BREAK); + flip = 1; + } + + if (flip) + tty_schedule_flip (tty); +} + +void simcons_poll_ttys (void) +{ + if (tty_table[0]) + simcons_poll_tty (tty_table[0]); +} + +void simcons_setup (void) +{ + V850_SIM_SYSCALL (make_raw, 0); + register_console (&simcons); + printk ("Console: GDB/v850e simulator stdio\n"); +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/syscalls.c linux-2.4.6/arch/v850/kernel/syscalls.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/syscalls.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/syscalls.c Tue Sep 11 14:18:42 2001 @@ -0,0 +1,246 @@ +/* + * arch/v850/kernel/syscalls.c -- Various system-call definitions not + * defined in machine-independent code + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * This file was derived the ppc version, arch/ppc/kernel/syscalls.c + * ... which was derived from "arch/i386/kernel/sys_i386.c" by Gary Thomas; + * modified by Cort Dougan (cort@cs.nmt.edu) + * and Paul Mackerras (paulus@cs.anu.edu.au). + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* + * sys_ipc() is the de-multiplexer for the SysV IPC calls.. + * + * This is really horribly ugly. + */ +int +sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth) +{ + int version, ret; + + version = call >> 16; /* hack for backward compatibility */ + call &= 0xffff; + + ret = -EINVAL; + switch (call) { + case SEMOP: + ret = sys_semop (first, (struct sembuf *)ptr, second); + break; + case SEMGET: + ret = sys_semget (first, second, third); + break; + case SEMCTL: + { + union semun fourth; + + if (!ptr) + break; + if ((ret = verify_area (VERIFY_READ, ptr, sizeof(long))) + || (ret = get_user(fourth.__pad, (void **)ptr))) + break; + ret = sys_semctl (first, second, third, fourth); + break; + } + case MSGSND: + ret = sys_msgsnd (first, (struct msgbuf *) ptr, second, third); + break; + case MSGRCV: + switch (version) { + case 0: { + struct ipc_kludge tmp; + + if (!ptr) + break; + if ((ret = verify_area (VERIFY_READ, ptr, sizeof(tmp))) + || (ret = copy_from_user(&tmp, + (struct ipc_kludge *) ptr, + sizeof (tmp)))) + break; + ret = sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, + third); + break; + } + default: + ret = sys_msgrcv (first, (struct msgbuf *) ptr, + second, fifth, third); + break; + } + break; + case MSGGET: + ret = sys_msgget ((key_t) first, second); + break; + case MSGCTL: + ret = sys_msgctl (first, second, (struct msqid_ds *) ptr); + break; + case SHMAT: + switch (version) { + default: { + ulong raddr; + + if ((ret = verify_area(VERIFY_WRITE, (ulong*) third, + sizeof(ulong)))) + break; + ret = sys_shmat (first, (char *) ptr, second, &raddr); + if (ret) + break; + ret = put_user (raddr, (ulong *) third); + break; + } + case 1: /* iBCS2 emulator entry point */ + if (!segment_eq(get_fs(), get_ds())) + break; + ret = sys_shmat (first, (char *) ptr, second, + (ulong *) third); + break; + } + break; + case SHMDT: + ret = sys_shmdt ((char *)ptr); + break; + case SHMGET: + ret = sys_shmget (first, second, third); + break; + case SHMCTL: + ret = sys_shmctl (first, second, (struct shmid_ds *) ptr); + break; + } + + return ret; +} + +/* + * sys_pipe() is the normal C calling standard for creating + * a pipe. It's not the way unix traditionally does this, though. + */ +int sys_pipe (int *fildes) +{ + int fd[2]; + int error; + + error = do_pipe (fd); + if (!error) { + if (copy_to_user (fildes, fd, 2*sizeof (int))) + error = -EFAULT; + } + return error; +} + +static inline unsigned long +do_mmap2 (unsigned long addr, size_t len, + unsigned long prot, unsigned long flags, + unsigned long fd, unsigned long pgoff) +{ + struct file * file = NULL; + int ret = -EBADF; + + flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); + if (! (flags & MAP_ANONYMOUS)) { + if (!(file = fget (fd))) + goto out; + } + + down_write (¤t->mm->mmap_sem); + ret = do_mmap_pgoff (file, addr, len, prot, flags, pgoff); + up_write (¤t->mm->mmap_sem); + if (file) + fput (file); +out: + return ret; +} + +unsigned long sys_mmap2 (unsigned long addr, size_t len, + unsigned long prot, unsigned long flags, + unsigned long fd, unsigned long pgoff) +{ + return do_mmap2 (addr, len, prot, flags, fd, pgoff); +} + +unsigned long sys_mmap (unsigned long addr, size_t len, + unsigned long prot, unsigned long flags, + unsigned long fd, off_t offset) +{ + int err = -EINVAL; + + if (offset & ~PAGE_MASK) + goto out; + + err = do_mmap2 (addr, len, prot, flags, fd, offset >> PAGE_SHIFT); +out: + return err; +} + +int sys_pause (void) +{ + current->state = TASK_INTERRUPTIBLE; + schedule (); + return -ERESTARTNOHAND; +} + +int sys_uname (struct old_utsname * name) +{ + int err = -EFAULT; + + down_read (&uts_sem); + if (name && !copy_to_user (name, &system_utsname, sizeof (*name))) + err = 0; + up_read (&uts_sem); + return err; +} + +int sys_olduname (struct oldold_utsname * name) +{ + int error; + + if (!name) + return -EFAULT; + if (!access_ok (VERIFY_WRITE, name, sizeof (struct oldold_utsname))) + return -EFAULT; + + down_read (&uts_sem); + error = __copy_to_user (&name->sysname, &system_utsname.sysname, + __OLD_UTS_LEN); + error -= __put_user (0, name->sysname + __OLD_UTS_LEN); + error -= __copy_to_user (&name->nodename, &system_utsname.nodename, + __OLD_UTS_LEN); + error -= __put_user (0, name->nodename + __OLD_UTS_LEN); + error -= __copy_to_user (&name->release, &system_utsname.release, + __OLD_UTS_LEN); + error -= __put_user (0, name->release + __OLD_UTS_LEN); + error -= __copy_to_user (&name->version, &system_utsname.version, + __OLD_UTS_LEN); + error -= __put_user (0, name->version + __OLD_UTS_LEN); + error -= __copy_to_user (&name->machine, &system_utsname.machine, + __OLD_UTS_LEN); + error = __put_user (0, name->machine + __OLD_UTS_LEN); + up_read (&uts_sem); + + error = error ? -EFAULT : 0; + return error; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/time.c linux-2.4.6/arch/v850/kernel/time.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/time.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/time.c Fri Oct 5 14:28:42 2001 @@ -0,0 +1,184 @@ +/* + * linux/arch/v850/kernel/time.c -- Arch-dependent timer functions + * + * Copyright (C) 1991, 1992, 1995, 2001 Linus Torvalds + * + * This file contains the v850-specific time handling details. + * Most of the stuff is located in the machine specific files. + * + * 1997-09-10 Updated NTP code according to technical memorandum Jan '96 + * "A Kernel Model for Precision Timekeeping" by Dave Mills + */ + +#include /* CONFIG_HEARTBEAT */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "mach.h" + +static inline void do_profile (unsigned long pc) +{ + if (prof_buffer && current->pid) { + extern int _stext; + pc -= (unsigned long) &_stext; + pc >>= prof_shift; + if (pc < prof_len) + ++prof_buffer[pc]; + else + /* + * Don't ignore out-of-bounds PC values silently, + * put them into the last histogram slot, so if + * present, they will show up as a sharp peak. + */ + ++prof_buffer[prof_len-1]; + } +} + +/* + * timer_interrupt() needs to keep up the real-time clock, + * as well as call the "do_timer()" routine every clocktick + */ +static void timer_interrupt (int irq, void *dummy, struct pt_regs *regs) +{ +#if 0 + /* last time the cmos clock got updated */ + static long last_rtc_update=0; +#endif + + /* may need to kick the hardware timer */ + if (mach_tick) + mach_tick (); + + do_timer (regs); + + if (! user_mode (regs)) + do_profile (regs->pc); + +#if 0 + /* + * If we have an externally synchronized Linux clock, then update + * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be + * called as close as possible to 500 ms before the new second starts. + */ + if ((time_status & STA_UNSYNC) == 0 && + xtime.tv_sec > last_rtc_update + 660 && + xtime.tv_usec >= 500000 - ((unsigned) tick) / 2 && + xtime.tv_usec <= 500000 + ((unsigned) tick) / 2) { + if (set_rtc_mmss (xtime.tv_sec) == 0) + last_rtc_update = xtime.tv_sec; + else + last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */ + } +#ifdef CONFIG_HEARTBEAT + /* use power LED as a heartbeat instead -- much more useful + for debugging -- based on the version for PReP by Cort */ + /* acts like an actual heart beat -- ie thump-thump-pause... */ + if (mach_heartbeat) { + static unsigned cnt = 0, period = 0, dist = 0; + + if (cnt == 0 || cnt == dist) + mach_heartbeat ( 1 ); + else if (cnt == 7 || cnt == dist+7) + mach_heartbeat ( 0 ); + + if (++cnt > period) { + cnt = 0; + /* The hyperbolic function below modifies the heartbeat period + * length in dependency of the current (5min) load. It goes + * through the points f(0)=126, f(1)=86, f(5)=51, + * f(inf)->30. */ + period = ((672<= 1000000) { + usec -= 1000000; + sec++; + } + + tv->tv_sec = sec; + tv->tv_usec = usec; +} + +void do_settimeofday (struct timeval *tv) +{ + write_lock_irq (&xtime_lock); + /* This is revolting. We need to set the xtime.tv_usec + * correctly. However, the value in this location is + * is value at the last tick. + * Discover what correction gettimeofday + * would have done, and then undo it! + */ +#if 0 + tv->tv_usec -= mach_gettimeoffset (); +#endif + + while (tv->tv_usec < 0) { + tv->tv_usec += 1000000; + tv->tv_sec--; + } + + xtime = *tv; + time_adjust = 0; /* stop active adjtime () */ + time_status |= STA_UNSYNC; + time_maxerror = NTP_PHASE_LIMIT; + time_esterror = NTP_PHASE_LIMIT; + write_unlock_irq (&xtime_lock); +} + +static int timer_dev_id; +static struct irqaction timer_irqaction = { + timer_interrupt, + SA_INTERRUPT, + 0, + "timer", + &timer_dev_id, + NULL +}; + +void time_init (void) +{ + mach_gettimeofday (&xtime); + mach_sched_init (&timer_irqaction); +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/v850_defs.c linux-2.4.6/arch/v850/kernel/v850_defs.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/v850_defs.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/v850_defs.c Wed Oct 10 11:56:43 2001 @@ -0,0 +1,61 @@ +/* + * This program is used to generate definitions needed by + * assembly language modules. + * + * We use the technique used in the OSF Mach kernel code: + * generate asm statements containing #defines, + * compile this file to assembler, and then extract the + * #defines from the assembly-language output. + */ + +#include +#include +#include +#include +#include +#include + +#define DEFINE(sym, val) \ + asm volatile ("\n#define " #sym " %0" : : "i" (val)) + +int main (void) +{ + /* offsets into the task struct */ + DEFINE (TASK_STATE, offsetof (struct task_struct, state)); + DEFINE (TASK_FLAGS, offsetof (struct task_struct, flags)); + DEFINE (TASK_PTRACE, offsetof (struct task_struct, ptrace)); + DEFINE (TASK_BLOCKED, offsetof (struct task_struct, blocked)); + DEFINE (TASK_COUNTER, offsetof (struct task_struct, counter)); + DEFINE (TASK_SIGPENDING, offsetof (struct task_struct, sigpending)); + DEFINE (TASK_NEED_RESCHED, offsetof (struct task_struct, need_resched)); + DEFINE (TASK_THREAD, offsetof (struct task_struct, thread)); + DEFINE (TASK_MM, offsetof (struct task_struct, mm)); + DEFINE (TASK_ACTIVE_MM, offsetof (struct task_struct, active_mm)); + DEFINE (TASK_PID, offsetof (struct task_struct, pid)); + + /* offsets into the kernel_stat struct */ + DEFINE (STAT_IRQ, offsetof (struct kernel_stat, irqs)); + + + /* signal defines */ + DEFINE (SIGSEGV, SIGSEGV); + DEFINE (SEGV_MAPERR, SEGV_MAPERR); + DEFINE (SIGTRAP, SIGTRAP); + DEFINE (SIGCHLD, SIGCHLD); + DEFINE (SIGILL, SIGILL); + DEFINE (TRAP_TRACE, TRAP_TRACE); + + /* ptrace flag bits */ + DEFINE (PT_PTRACED, PT_PTRACED); + DEFINE (PT_TRACESYS, PT_TRACESYS); + DEFINE (PT_DTRACE, PT_DTRACE); + + /* error values */ + DEFINE (ENOSYS, ENOSYS); + + /* clone flag bits */ + DEFINE (CLONE_VFORK, CLONE_VFORK); + DEFINE (CLONE_VM, CLONE_VM); + + return 0; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/v850_defs.head linux-2.4.6/arch/v850/kernel/v850_defs.head --- linux-2.4.6.uclinux-orig/arch/v850/kernel/v850_defs.head Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/v850_defs.head Wed Jul 25 17:27:30 2001 @@ -0,0 +1,5 @@ +/* + * WARNING! This file is automatically generated - DO NOT EDIT! + */ + +#define TS_MAGICKEY 0x5a5a5a5a diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/kernel/v850_ksyms.c linux-2.4.6/arch/v850/kernel/v850_ksyms.c --- linux-2.4.6.uclinux-orig/arch/v850/kernel/v850_ksyms.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/kernel/v850_ksyms.c Tue Sep 11 14:24:16 2001 @@ -0,0 +1,108 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//asmlinkage long long __ashrdi3 (long long, int); +//asmlinkage long long __lshrdi3 (long long, int); + +extern void dump_thread(struct pt_regs *, struct user *); +extern int dump_fpu(elf_fpregset_t *); + +/* platform dependent support */ + +EXPORT_SYMBOL(__ioremap); +EXPORT_SYMBOL(iounmap); +EXPORT_SYMBOL(dump_fpu); +EXPORT_SYMBOL(dump_thread); +EXPORT_SYMBOL(strnlen); +EXPORT_SYMBOL(strrchr); +EXPORT_SYMBOL(strstr); +EXPORT_SYMBOL(mach_enable_irq); +EXPORT_SYMBOL(mach_disable_irq); +EXPORT_SYMBOL(kernel_thread); + +/* Networking helper routines. */ +EXPORT_SYMBOL(csum_partial_copy); + +/* The following are special because they're not called + explicitly (the C compiler generates them). Fortunately, + their interface isn't gonna change any time soon now, so + it's OK to leave it out of version control. */ +//EXPORT_SYMBOL_NOVERS(__ashrdi3); +//EXPORT_SYMBOL_NOVERS(__lshrdi3); +EXPORT_SYMBOL_NOVERS(memcpy); +EXPORT_SYMBOL_NOVERS(memset); +EXPORT_SYMBOL_NOVERS(memcmp); +EXPORT_SYMBOL_NOVERS(memscan); + +EXPORT_SYMBOL_NOVERS(__down_failed); +EXPORT_SYMBOL_NOVERS(__down_failed_interruptible); +EXPORT_SYMBOL_NOVERS(__down_failed_trylock); +EXPORT_SYMBOL_NOVERS(__up_wakeup); + +EXPORT_SYMBOL(get_wchan); + +/* + * libgcc functions - functions that are used internally by the + * compiler... (prototypes are not correct though, but that + * doesn't really matter since they're not versioned). + */ +extern void __gcc_bcmp(void); +extern void __ashldi3(void); +extern void __ashrdi3(void); +extern void __cmpdi2(void); +extern void __divdi3(void); +extern void __divsi3(void); +extern void __lshrdi3(void); +extern void __moddi3(void); +extern void __modsi3(void); +extern void __muldi3(void); +extern void __mulsi3(void); +extern void __negdi2(void); +extern void __ucmpdi2(void); +extern void __udivdi3(void); +extern void __udivmoddi4(void); +extern void __udivsi3(void); +extern void __umoddi3(void); +extern void __umodsi3(void); + + /* gcc lib functions */ +EXPORT_SYMBOL_NOVERS(__gcc_bcmp); +EXPORT_SYMBOL_NOVERS(__ashldi3); +EXPORT_SYMBOL_NOVERS(__ashrdi3); +EXPORT_SYMBOL_NOVERS(__cmpdi2); +EXPORT_SYMBOL_NOVERS(__divdi3); +EXPORT_SYMBOL_NOVERS(__divsi3); +EXPORT_SYMBOL_NOVERS(__lshrdi3); +EXPORT_SYMBOL_NOVERS(__moddi3); +EXPORT_SYMBOL_NOVERS(__modsi3); +EXPORT_SYMBOL_NOVERS(__muldi3); +EXPORT_SYMBOL_NOVERS(__mulsi3); +EXPORT_SYMBOL_NOVERS(__negdi2); +EXPORT_SYMBOL_NOVERS(__ucmpdi2); +EXPORT_SYMBOL_NOVERS(__udivdi3); +EXPORT_SYMBOL_NOVERS(__udivmoddi4); +EXPORT_SYMBOL_NOVERS(__udivsi3); +EXPORT_SYMBOL_NOVERS(__umoddi3); +EXPORT_SYMBOL_NOVERS(__umodsi3); + +EXPORT_SYMBOL_NOVERS(strlen); + +EXPORT_SYMBOL_NOVERS(_current_task); diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/lib/Makefile linux-2.4.6/arch/v850/lib/Makefile --- linux-2.4.6.uclinux-orig/arch/v850/lib/Makefile Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/lib/Makefile Tue Sep 11 14:38:08 2001 @@ -0,0 +1,11 @@ +# +# arch/v850/lib/Makefile +# + +.S.o: + $(CC) $(AFLAGS) -D__ASSEMBLY__ -traditional -c $< -o $@ + +L_TARGET = lib.a +obj-y = ashrdi3.o ashldi3.o muldi3.o negdi2.o checksum.o memcpy.o memset.o + +include $(TOPDIR)/Rules.make diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/lib/ashldi3.c linux-2.4.6/arch/v850/lib/ashldi3.c --- linux-2.4.6.uclinux-orig/arch/v850/lib/ashldi3.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/lib/ashldi3.c Tue Aug 21 15:01:46 2001 @@ -0,0 +1,62 @@ +/* ashldi3.c extracted from gcc-2.95.2/libgcc2.c which is: */ +/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define BITS_PER_UNIT 8 + +typedef int SItype __attribute__ ((mode (SI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef int word_type __attribute__ ((mode (__word__))); + +struct DIstruct {SItype high, low;}; + +typedef union +{ + struct DIstruct s; + DItype ll; +} DIunion; + +DItype +__ashldi3 (DItype u, word_type b) +{ + DIunion w; + word_type bm; + DIunion uu; + + if (b == 0) + return u; + + uu.ll = u; + + bm = (sizeof (SItype) * BITS_PER_UNIT) - b; + if (bm <= 0) + { + w.s.low = 0; + w.s.high = (USItype)uu.s.low << -bm; + } + else + { + USItype carries = (USItype)uu.s.low >> bm; + w.s.low = (USItype)uu.s.low << b; + w.s.high = ((USItype)uu.s.high << b) | carries; + } + + return w.ll; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/lib/ashrdi3.c linux-2.4.6/arch/v850/lib/ashrdi3.c --- linux-2.4.6.uclinux-orig/arch/v850/lib/ashrdi3.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/lib/ashrdi3.c Wed Jul 25 17:27:31 2001 @@ -0,0 +1,63 @@ +/* ashrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */ +/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define BITS_PER_UNIT 8 + +typedef int SItype __attribute__ ((mode (SI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef int word_type __attribute__ ((mode (__word__))); + +struct DIstruct {SItype high, low;}; + +typedef union +{ + struct DIstruct s; + DItype ll; +} DIunion; + +DItype +__ashrdi3 (DItype u, word_type b) +{ + DIunion w; + word_type bm; + DIunion uu; + + if (b == 0) + return u; + + uu.ll = u; + + bm = (sizeof (SItype) * BITS_PER_UNIT) - b; + if (bm <= 0) + { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1); + w.s.low = uu.s.high >> -bm; + } + else + { + USItype carries = (USItype)uu.s.high << bm; + w.s.high = uu.s.high >> b; + w.s.low = ((USItype)uu.s.low >> b) | carries; + } + + return w.ll; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/lib/checksum.c linux-2.4.6/arch/v850/lib/checksum.c --- linux-2.4.6.uclinux-orig/arch/v850/lib/checksum.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/lib/checksum.c Wed Jul 25 17:27:31 2001 @@ -0,0 +1,157 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * IP/TCP/UDP checksumming routines + * + * Authors: Jorge Cwik, + * Arnt Gulbrandsen, + * Tom May, + * Andreas Schwab, + * Lots of code moved from tcp.c and ip.c; see those files + * for more names. + * + * 03/02/96 Jes Sorensen, Andreas Schwab, Roman Hodek: + * Fixed some nasty bugs, causing some horrible crashes. + * A: At some points, the sum (%0) was used as + * length-counter instead of the length counter + * (%1). Thanks to Roman Hodek for pointing this out. + * B: GCC seems to mess up if one uses too many + * data-registers to hold input values and one tries to + * specify d0 and d1 as scratch registers. Letting gcc choose these + * registers itself solves the problem. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +/* Revised by Kenneth Albanowski for m68knommu. Basic problem: unaligned access kills, so most + of the assembly has to go. */ + +#include +#include + +static inline unsigned short from32to16(unsigned long x) +{ + /* add up 16-bit and 16-bit for 16+c bit */ + x = (x & 0xffff) + (x >> 16); + /* add up carry.. */ + x = (x & 0xffff) + (x >> 16); + return x; +} + +static unsigned long do_csum(const unsigned char * buff, int len) +{ + int odd, count; + unsigned long result = 0; + + if (len <= 0) + goto out; + odd = 1 & (unsigned long) buff; + if (odd) { + result = *buff; + len--; + buff++; + } + count = len >> 1; /* nr of 16-bit words.. */ + if (count) { + if (2 & (unsigned long) buff) { + result += *(unsigned short *) buff; + count--; + len -= 2; + buff += 2; + } + count >>= 1; /* nr of 32-bit words.. */ + if (count) { + unsigned long carry = 0; + do { + unsigned long w = *(unsigned long *) buff; + count--; + buff += 4; + result += carry; + result += w; + carry = (w > result); + } while (count); + result += carry; + result = (result & 0xffff) + (result >> 16); + } + if (len & 2) { + result += *(unsigned short *) buff; + buff += 2; + } + } + if (len & 1) + result += (*buff << 8); + result = from32to16(result); + if (odd) + result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); +out: + return result; +} + +/* + * This is a version of ip_compute_csum() optimized for IP headers, + * which always checksum on 4 octet boundaries. + */ +unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) +{ + return ~do_csum(iph,ihl*4); +} + +/* + * computes the checksum of a memory block at buff, length len, + * and adds in "sum" (32-bit) + * + * returns a 32-bit number suitable for feeding into itself + * or csum_tcpudp_magic + * + * this function must be called with even lengths, except + * for the last fragment, which may be odd + * + * it's best to have buff aligned on a 32-bit boundary + */ +unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) +{ + unsigned int result = do_csum(buff, len); + + /* add in old sum, and carry.. */ + result += sum; + /* 16+c bits -> 16 bits */ + result = (result & 0xffff) + (result >> 16); + return result; +} + +/* + * this routine is used for miscellaneous IP-like checksums, mainly + * in icmp.c + */ +unsigned short ip_compute_csum(const unsigned char * buff, int len) +{ + return ~do_csum(buff,len); +} + +/* + * copy from fs while checksumming, otherwise like csum_partial + */ + +unsigned int +csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *csum_err) +{ + if (csum_err) *csum_err = 0; + memcpy(dst, src, len); + return csum_partial(dst, len, sum); +} + +/* + * copy from ds while checksumming, otherwise like csum_partial + */ + +unsigned int +csum_partial_copy(const char *src, char *dst, int len, int sum) +{ + memcpy(dst, src, len); + return csum_partial(dst, len, sum); +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/lib/memcpy.c linux-2.4.6/arch/v850/lib/memcpy.c --- linux-2.4.6.uclinux-orig/arch/v850/lib/memcpy.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/lib/memcpy.c Fri Jul 27 13:38:03 2001 @@ -0,0 +1,12 @@ + +#include +#include + +void * memcpy(void * to, const void * from, size_t n) +{ + const char *c_from = from; + char *c_to = to; + while (n-- > 0) + *c_to++ = *c_from++; + return((void *) to); +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/lib/memset.c linux-2.4.6/arch/v850/lib/memset.c --- linux-2.4.6.uclinux-orig/arch/v850/lib/memset.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/lib/memset.c Wed Jul 25 17:27:31 2001 @@ -0,0 +1,47 @@ +#include + +void * memset(void * s, int c, size_t count) +{ + void *xs = s; + size_t temp; + + if (!count) + return xs; + c &= 0xff; + c |= c << 8; + c |= c << 16; + if ((long) s & 1) + { + char *cs = s; + *cs++ = c; + s = cs; + count--; + } + if (count > 2 && (long) s & 2) + { + short *ss = s; + *ss++ = c; + s = ss; + count -= 2; + } + temp = count >> 2; + if (temp) + { + long *ls = s; + for (; temp; temp--) + *ls++ = c; + s = ls; + } + if (count & 2) + { + short *ss = s; + *ss++ = c; + s = ss; + } + if (count & 1) + { + char *cs = s; + *cs = c; + } + return xs; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/lib/muldi3.c linux-2.4.6/arch/v850/lib/muldi3.c --- linux-2.4.6.uclinux-orig/arch/v850/lib/muldi3.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/lib/muldi3.c Tue Aug 21 15:07:35 2001 @@ -0,0 +1,61 @@ +/* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and + gcc-2.7.2.3/longlong.h which is: */ +/* Copyright (C) 1989, 1992, 1993, 1994, 1995, 2001 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define umul_ppmm(w1, w0, u, v) \ + __asm__ ("mulu %3, %0, %1" \ + : "=r" ((USItype)(w0)), \ + "=r" ((USItype)(w1)) \ + : "%0" ((USItype)(u)), \ + "r" ((USItype)(v))) + +#define __umulsidi3(u, v) \ + ({DIunion __w; \ + umul_ppmm (__w.s.high, __w.s.low, u, v); \ + __w.ll; }) + +typedef int SItype __attribute__ ((mode (SI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef int word_type __attribute__ ((mode (__word__))); + +struct DIstruct {SItype high, low;}; + +typedef union +{ + struct DIstruct s; + DItype ll; +} DIunion; + +DItype +__muldi3 (DItype u, DItype v) +{ + DIunion w; + DIunion uu, vv; + + uu.ll = u, + vv.ll = v; + + w.ll = __umulsidi3 (uu.s.low, vv.s.low); + w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high + + (USItype) uu.s.high * (USItype) vv.s.low); + + return w.ll; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/lib/negdi2.c linux-2.4.6/arch/v850/lib/negdi2.c --- linux-2.4.6.uclinux-orig/arch/v850/lib/negdi2.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/lib/negdi2.c Tue Sep 11 14:37:02 2001 @@ -0,0 +1,25 @@ +/* + * arch/v850/lib/negdi2.c -- 64-bit negation + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +typedef int DItype __attribute__ ((mode (DI))); + +DItype __negdi2 (DItype x) +{ + __asm__ __volatile__ + ("not r6, r10;" + "add 1, r10;" + "setf c, r6;" + "not r7, r11;" + "add r6, r11" + ::: "r6", "r7", "r10", "r11"); +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/rte_ma1_cb-rom.ld linux-2.4.6/arch/v850/rte_ma1_cb-rom.ld --- linux-2.4.6.uclinux-orig/arch/v850/rte_ma1_cb-rom.ld Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/rte_ma1_cb-rom.ld Thu Sep 20 13:43:46 2001 @@ -0,0 +1,85 @@ +/* Note, all symbols are prefixed with an extra `_' for compatibility with + the existing linux sources. */ + +SECTIONS { + . = 0 ; /* ROM starts at 0. */ + __start = . ; + + /* Interrupt vector space. */ + .intv { + __intv_start = . ; + *(.intv) /* Interrupt vectors. */ + *(.intv.common) /* Vectors common to all v850e proc. */ + . = 0x80 ; /* Relative to section start */ + *(.intv.mach) /* Machine-specific int. vectors. */ + __intv_end = . ; + } + + .text : { + __stext = . ; + *(.text) + *(.text.exit) + *(.text.lock) + *(.exitcall.exit) + __real_etext = .; /* There may be data after here. */ + *(.rodata) + . = ALIGN(0x4) ; + *(.kstrtab) + . = ALIGN(16); /* Exception table */ + ___start___ex_table = .; + *(__ex_table) + ___stop___ex_table = .; + + ___start___ksymtab = .; /* Kernel symbol table */ + *(__ksymtab) + ___stop___ksymtab = .; + . = ALIGN(4) ; + __etext = . ; + } + + .data BLOCK(0x4) : { + __sdata = . ; + ___data_start = . ; + *(.data) + *(.data.exit) + . = ALIGN(16); + *(.data.cacheline_aligned) + . = ALIGN(0x2000) ; + *(.data.init_task) + . = ALIGN(0x2000) ; + __edata = . ; + } + + .bss BLOCK(0x4) : { + __sbss = . ; + *(.bss) + *(COMMON) + . = ALIGN(4) ; + __ebss = . ; + } + + .init BLOCK(4096) : { + ___init_begin = .; + *(.text.init) + *(.data.init) + . = ALIGN(16); + ___setup_start = .; + *(.setup.init) + ___setup_end = .; + ___initcall_start = .; + *(.initcall.init) + . = ALIGN(4) ; + ___initcall_end = .; + ___init_end = .; + } + + /* `blkmem' device contents for the root filesystem. */ + .blkmem { + __blkmem_0_start = _binary_root_ext2_start ; + *(.blkmem0) + *(=.blkmem0) /* bug in objcopy results in mis-named sections.*/ + __blkmem_0_end = _binary_root_ext2_end ; + } + + __end = . ; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/rte_ma1_cb.ld linux-2.4.6/arch/v850/rte_ma1_cb.ld --- linux-2.4.6.uclinux-orig/arch/v850/rte_ma1_cb.ld Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/rte_ma1_cb.ld Tue Oct 2 15:16:46 2001 @@ -0,0 +1,131 @@ +/* Note, all symbols are prefixed with an extra `_' for compatibility with + the existing linux sources. */ +MEMORY { + /* 1MB of SRAM; we can't use the last 32KB, because it's used by + the monitor scratch-RAM. This memory is mirrored 4 times. */ + SRAM : ORIGIN = 0x00400000, LENGTH = 0x000F8000 + /* Monitor scratch RAM; only the interrupt vectors should go here. */ + MRAM : ORIGIN = 0x004F8000, LENGTH = 0x00008000 + /* 32MB of SDRAM */ + SDRAM : ORIGIN = 0x00800000, LENGTH = 0x00200000 +} + +SECTIONS { + . = 0x00400000 ; + __start = . ; + + .text : { + __stext = . ; + *(.text) + *(.text.exit) + *(.text.lock) + *(.exitcall.exit) + __real_etext = .; /* There may be data after here. */ + *(.rodata) + + . = ALIGN (0x4) ; + *(.kstrtab) + + . = ALIGN (4) ; + *(.call_table_data) + *(.call_table_text) + + . = ALIGN (16); /* Exception table */ + ___start___ex_table = .; + *(__ex_table) + ___stop___ex_table = .; + + ___start___ksymtab = .; /* Kernel symbol table */ + *(__ksymtab) + ___stop___ksymtab = .; + . = ALIGN (4) ; + __etext = . ; + } > SRAM + + .data ALIGN (0x4) : { + __sdata = . ; + ___data_start = . ; + *(.data) + *(.data.exit) + . = ALIGN (16); + *(.data.cacheline_aligned) + . = ALIGN (0x2000) ; + *(.data.init_task) + . = ALIGN (0x2000) ; + __edata = . ; + } > SRAM + + .bss ALIGN (0x4) : { + __sbss = . ; + *(.bss) + *(COMMON) + . = ALIGN (4) ; + __ebss = . ; + } > SRAM + + .init ALIGN (4096) : { + ___init_begin = .; + *(.text.init) + *(.data.init) + . = ALIGN (16); + ___setup_start = .; + *(.setup.init) + ___setup_end = .; + ___initcall_start = .; + *(.initcall.init) + . = ALIGN (4) ; + ___initcall_end = .; + } > SRAM + + /* This provides address at which the interrupt vectors are + initially loaded by the loader. */ + __intv_load_start = ALIGN (0x10) ; + + /* Interrupt vector space. Because we're using the monitor + ROM, Instead of the native interrupt vector, we must use the + `alternate interrupt vector' area. Note that this is in + `SRAM' space, which is not currently used by the kernel (the + kernel uses `SDRAM' space). */ + + /* We can't load the interrupt vectors directly into their + target location, because the monitor ROM for the GHS Multi + debugger barfs if we try. Unfortunately, Multi also doesn't + deal correctly with ELF sections where the LMA and VMA differ + (it just ignores the LMA), so we can't use that feature to + work around the problem! What we do instead is just put the + interrupt vectors into a normal section, and have the + `mach_early_init' function for Midas boards do the necessary + copying and relocation at runtime (this section basically + only contains `jr' instructions, so it's not that hard). + + This the section structure I initially tried to use (which more + accurately expresses the intent): + + .intv 0x007F8000 : AT (ADDR (.init) + SIZEOF (.init)) { + ... + } > MRAM + */ + + .intv ALIGN (0x10) : { + __intv_start = . ; + *(.intv) /* Interrupt vectors. */ + *(.intv.common) /* Vectors common to all v850e proc. */ + . = 0x80 ; + *(.intv.mach) /* Machine-specific int. vectors. */ + __intv_end = . ; + } > SRAM + + /* This is here so that when we free init memory, the initial + load-area of the interrupt vectors is freed too. */ + ___init_end = __intv_end; + + __end = ___init_end ; + + /* `blkmem' device contents for the root filesystem. */ + .blkmem : { + __blkmem_0_start = _binary_root_ext2_start ; + *(.blkmem0) + *(=.blkmem0) /* bug in objcopy results in mis-named sections.*/ + __blkmem_0_end = _binary_root_ext2_end ; + } > SDRAM +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/README linux-2.4.6/arch/v850/sim/README --- linux-2.4.6.uclinux-orig/arch/v850/sim/README Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/README Wed Oct 10 18:08:00 2001 @@ -0,0 +1,13 @@ +This directory contains some useful files for debugging using the gdb +v850 simulator. + + + gdb-scripts/ An example .gdbrc and useful gdb scripts. + + patches/ Patches for the simulator and gdb + + updroot A shell script that copies a directory tree called + `root' into an ext2 filesystem image called + `root.ext2', which is the name the simulator-specific + startup code in the uclinux v850 port looks for to + initialize the root filesystem. diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/README linux-2.4.6/arch/v850/sim/gdb-scripts/README --- linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/README Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/gdb-scripts/README Wed Oct 10 18:08:05 2001 @@ -0,0 +1,17 @@ +This directory contains some shell and gdb scripts useful for debugging. + + + example.gdbinit An example `.gdbinit' file that sets things up + to run linux in the gdb v850 simulator. It + assumes that all the patch files in ../patches + have been applied. + + +The following are gdb scripts that when loaded into gdb (using the `source' +command) will install breakpoints which print out information at interesting +times: + + trace-loadproc.gdb Print a message for each process exec. + trace-switch.gdb Print a message for each context switch. + trace-irq.gdb Print messages for interrupts/interrupt returns. + trace-traps.gdb Print messages for traps (syscalls) & trap returns. diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/example.gdbinit linux-2.4.6/arch/v850/sim/gdb-scripts/example.gdbinit --- linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/example.gdbinit Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/gdb-scripts/example.gdbinit Wed Oct 10 17:49:15 2001 @@ -0,0 +1,23 @@ +set height 0 +set pagination off + +disp/i $pc + +target sim +sim architecture v850e + +sim memory delete all +sim memory region 0,0x800000 +sim memory region 0xFFFF0000,0x10000 + +# These addresses are somewhat conservative, but might need to be +# changed if the kernel text-segment shrinks appreciably. +sim read-protect-low-memory 0x4a000 +sim write-protect-low-memory 0x4a000 + +# 24Hz @1/10 speed = 2.4Hz +sim watch-clock-intov1 +420 + +sim stdio off + +load linux diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/trace-irq.gdb linux-2.4.6/arch/v850/sim/gdb-scripts/trace-irq.gdb --- linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/trace-irq.gdb Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/gdb-scripts/trace-irq.gdb Wed Sep 5 18:09:43 2001 @@ -0,0 +1,13 @@ +break *irq +command + silent + printf "[irq %d]\n", ($ecr - 0x80) / 16 + cont +end + +break *ret_from_interrupt +command + silent + printf "[ret_from_interrupt]\n" + cont +end diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/trace-loadproc.gdb linux-2.4.6/arch/v850/sim/gdb-scripts/trace-loadproc.gdb --- linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/trace-loadproc.gdb Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/gdb-scripts/trace-loadproc.gdb Thu Sep 13 17:37:30 2001 @@ -0,0 +1,6 @@ +break binfmt_flat.c:691 +command + silent + printf "[loaded process `%s' at 0x%x (text 0x%x-0x%x, data 0x%x-0x%x, bss 0x%x-0x%x)]\n", bprm->filename, textpos, current->mm->start_code, current->mm->end_code, current->mm->start_data, current->mm->end_data, current->mm->end_data, current->mm->brk + cont +end diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/trace-switch.gdb linux-2.4.6/arch/v850/sim/gdb-scripts/trace-switch.gdb --- linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/trace-switch.gdb Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/gdb-scripts/trace-switch.gdb Thu Sep 6 10:27:16 2001 @@ -0,0 +1,18 @@ +break *switch_thread +command + silent + printf "[switch 0x%x -> 0x%x]:\n", $r6, $r7 + #call show_regs ($r7 + 24) + #printf "New: " + #p/x *(struct pt_regs *)($r7 + 24) + cont +end + +#break *(switch_thread + 38) +#command +# silent +# printf "Old: " +# p/x *(struct pt_regs *)($sp + 24) +# cont +#end +# \ No newline at end of file diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/trace-traps.gdb linux-2.4.6/arch/v850/sim/gdb-scripts/trace-traps.gdb --- linux-2.4.6.uclinux-orig/arch/v850/sim/gdb-scripts/trace-traps.gdb Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/gdb-scripts/trace-traps.gdb Wed Sep 5 18:00:07 2001 @@ -0,0 +1,13 @@ +break *trap +command + silent + printf "[trap %d, %d]\n", ($ecr - 0x40), $r12 + cont +end + +break *ret_from_trap +command + silent + printf "[ret_from_trap %d, 0x%x]\n", ((struct pt_regs *)($sp + 24))->gpr[0], $r10 + cont +end diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/README linux-2.4.6/arch/v850/sim/patches/README --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/README Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/README Wed Oct 10 18:08:12 2001 @@ -0,0 +1,62 @@ +This directory contains patches to gdb and the gdb v850 simulator. +Some are necessary to run uclinux, others are useful for debugging. + + + Bug fixes: + + sim-bitop-bug.patch Fixes a bug in the simulator implementation of + bit operators. + + sim-trap-addr.patch Fixes a bug where the simulator uses the wrong + address for vectoring to a software trap. + + + New features (necessary): + + sim-interrupt-priority.patch + Adds interrupt priorities to the simulator's + implementation of `hardware' interrupts. + + sim-halt.patch Makes the `halt' instruction work like a real + hardware halt instruction. The implementation + is non-optimal -- it simply busy-waits. + + + New features (optional): + + gdb-sim-inftty.patch A patches to make gdb manage tty modes in the + simulator the same way it does with a real + process inferior. This allows the simulator + to switch to raw mode without interfering with + debugging. + + sim-makeraw.patch Adds a simulator `syscall' named `make_raw', which + allows a program running on the simulator to + switch the real terminal into raw mode. + + sim-raw-stdio.patch Adds the simulator command `stdio on|off', + which allows switching on or off special + treatment of stdio I/O. + + sim-poll.patch Adds `poll' as a simulator `syscall', allowing + polling of real file descriptors by the + simulated program. + + +Debugging aids: + +These patches must be applied in order, since later patches depend on +features added by earlier ones. + + sim-record-branches.patch Adds the simulator command `recent-branches' + which will dump information about the last + 32 branches taken by the simulated program. + + sim-lomem-protect.patch Adds the simulator commands + `read-protect-low-memory BOUNDARY', + `write-protect-low-memory BOUNDARY', and + `protected-low-memory-info'. + + sim-himem-trace.patch Adds the simulator command + `trace-io-writes on|off' (which traces + writes to `I/O space' (above 0xFFFFF000). diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/gdb-sim-inftty.patch linux-2.4.6/arch/v850/sim/patches/gdb-sim-inftty.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/gdb-sim-inftty.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/gdb-sim-inftty.patch Wed Sep 5 11:54:04 2001 @@ -0,0 +1,175 @@ +2001-09-05 Miles Bader + + * remote-sim.c (gdbsim_create_inferior): Call target_terminal_init. + (stdin_serial, our_ttystate, inferior_ttystate, terminal_is_ours): + New variables. + (gdbsim_terminal_init, gdbsim_terminal_inferior) + (gdbsim_terminal_ours_for_output, gdbsim_terminal_ours) + (gdbsim_terminal_ours_1): New functions. + (init_gdbsim_ops): Add terminal control ops. + +diff -up gdb/remote-sim.c.\~1\~ gdb/remote-sim.c +--- gdb/remote-sim.c.~1~ Wed Jan 17 20:52:03 2001 ++++ gdb/remote-sim.c Wed Sep 5 11:48:50 2001 +@@ -469,6 +469,8 @@ gdbsim_create_inferior (exec_file, args, + (exec_file ? exec_file: "(NULL)"), + args); + ++ target_terminal_init (); ++ + gdbsim_kill (); + remove_breakpoints (); + init_wait_for_inferior (); +@@ -922,6 +924,135 @@ simulator_command (args, from_tty) + something funny. */ + registers_changed (); + } ++ ++/* Record terminal status separately for debugger and inferior. */ ++static serial_t stdin_serial; ++ ++/* Our own tty state, which we restore every time we need to deal with the ++ terminal. We only set it once, when GDB first starts. The settings of ++ flags which readline saves and restores and unimportant. */ ++static serial_ttystate our_ttystate; ++ ++/* TTY state for the inferior. We save it whenever the inferior stops, and ++ restore it when it resumes. */ ++static serial_ttystate inferior_ttystate; ++ ++/* Nonzero if our terminal settings are in effect. Zero if the ++ inferior's settings are in effect. Ignored if stdin isn't a terminal. */ ++extern int terminal_is_ours; ++ ++ ++/* Initialize the terminal settings we record for the inferior, ++ before we actually run the inferior. */ ++void ++gdbsim_terminal_init () ++{ ++ if (! stdin_serial) ++ { ++ stdin_serial = SERIAL_FDOPEN (0); ++ if (stdin_serial) ++ our_ttystate = SERIAL_GET_TTY_STATE (stdin_serial); ++ } ++ ++ if (stdin_serial) ++ { ++ if (inferior_ttystate) ++ free (inferior_ttystate); ++ inferior_ttystate = SERIAL_GET_TTY_STATE (stdin_serial); ++ } ++ ++ terminal_is_ours = 1; ++} ++ ++/* Put the inferior's terminal settings into effect. ++ This is preparation for starting or resuming the inferior. */ ++void ++gdbsim_terminal_inferior () ++{ ++ if (stdin_serial && terminal_is_ours) ++ /* Because we were careful to not change in or out of raw mode in ++ terminal_ours, we will not change in our out of raw mode with ++ this call, so we don't flush any input. */ ++ if (SERIAL_SET_TTY_STATE (stdin_serial, inferior_ttystate) == -1) ++ fprintf_unfiltered ++ (gdb_stderr, ++ "[setting tty state failed in terminal_inferior: %s]\n", ++ strerror (errno)); ++ terminal_is_ours = 0; ++} ++ ++static void gdbsim_terminal_ours_1 PARAMS ((int)); ++ ++/* Put some of our terminal settings into effect, ++ enough to get proper results from our output, ++ but do not change into or out of RAW mode ++ so that no input is discarded. ++ ++ After doing this, either terminal_ours or terminal_inferior ++ should be called to get back to a normal state of affairs. */ ++void ++gdbsim_terminal_ours_for_output () ++{ ++ gdbsim_terminal_ours_1 (1); ++} ++ ++/* Put our terminal settings into effect. ++ First record the inferior's terminal settings ++ so they can be restored properly later. */ ++void ++gdbsim_terminal_ours () ++{ ++ gdbsim_terminal_ours_1 (0); ++} ++ ++/* output_only is not used, and should not be used unless we introduce ++ separate terminal_is_ours and terminal_is_ours_for_output ++ flags. */ ++static void ++gdbsim_terminal_ours_1 (output_only) ++ int output_only; ++{ ++ if (stdin_serial && !terminal_is_ours) ++ { ++ terminal_is_ours = 1; ++ ++ /* Here we used to set ICANON in our ttystate, but I believe this ++ was an artifact from before when we used readline. Readline sets ++ the tty state when it needs to. ++ FIXME-maybe: However, query() expects non-raw mode and doesn't ++ use readline. Maybe query should use readline (on the other hand, ++ this only matters for HAVE_SGTTY, not termio or termios, I think). */ ++ ++ /* Set tty state to our_ttystate. We don't change in our out of raw ++ mode, to avoid flushing input. We need to do the same thing ++ regardless of output_only, because we don't have separate ++ terminal_is_ours and terminal_is_ours_for_output flags. It's OK, ++ though, since readline will deal with raw mode when/if it needs to. ++ */ ++ ++ SERIAL_NOFLUSH_SET_TTY_STATE (stdin_serial, our_ttystate, ++ inferior_ttystate); ++ } ++} ++ ++/* ARGSUSED */ ++void ++gdbsim_terminal_info (args, from_tty) ++ char *args; ++ int from_tty; ++{ ++ if (stdin_serial) ++ { ++ printf_filtered ("Inferior's terminal status (currently saved by GDB):\n"); ++ SERIAL_PRINT_TTY_STATE (stdin_serial, inferior_ttystate); ++ } ++ else ++ { ++ printf_filtered ("This GDB does not control a terminal.\n"); ++ return; ++ } ++} ++ + + /* Define the target subroutine names */ + +@@ -950,11 +1081,11 @@ init_gdbsim_ops(void) + gdbsim_ops.to_files_info = gdbsim_files_info; + gdbsim_ops.to_insert_breakpoint = gdbsim_insert_breakpoint; + gdbsim_ops.to_remove_breakpoint = gdbsim_remove_breakpoint; +- gdbsim_ops.to_terminal_init = NULL; +- gdbsim_ops.to_terminal_inferior = NULL; +- gdbsim_ops.to_terminal_ours_for_output = NULL; +- gdbsim_ops.to_terminal_ours = NULL; +- gdbsim_ops.to_terminal_info = NULL; ++ gdbsim_ops.to_terminal_init = gdbsim_terminal_init; ++ gdbsim_ops.to_terminal_inferior = gdbsim_terminal_inferior; ++ gdbsim_ops.to_terminal_ours_for_output = gdbsim_terminal_ours_for_output; ++ gdbsim_ops.to_terminal_ours = gdbsim_terminal_ours; ++ gdbsim_ops.to_terminal_info = gdbsim_terminal_info; + gdbsim_ops.to_kill = gdbsim_kill; + gdbsim_ops.to_load = gdbsim_load; + gdbsim_ops.to_lookup_symbol = NULL; diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-bitop-bug.patch linux-2.4.6/arch/v850/sim/patches/sim-bitop-bug.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-bitop-bug.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-bitop-bug.patch Fri Aug 24 15:41:44 2001 @@ -0,0 +1,21 @@ +diff -up /proj/soft2/uclinux/src/v850ice-000414-nmit-RELEASE-20010327/sim/v850/simops.c.\~1\~ /proj/soft2/uclinux/src/v850ice-000414-nmit-RELEASE-20010327/sim/v850/simops.c +--- /proj/soft2/uclinux/src/v850ice-000414-nmit-RELEASE-20010327/sim/v850/simops.c.~1~ Mon Mar 26 13:20:00 2001 ++++ /proj/soft2/uclinux/src/v850ice-000414-nmit-RELEASE-20010327/sim/v850/simops.c Fri Aug 24 15:38:19 2001 +@@ -1892,7 +1892,7 @@ OP_E607E0 (void) + temp = load_mem (State.regs[ OP[0] ], 1); + + PSW &= ~PSW_Z; +- if ((temp & (1 << State.regs[ OP[1] & 0x7 ])) == 0) ++ if ((temp & (1 << (State.regs[ OP[1] ] & 0x7))) == 0) + PSW |= PSW_Z; + + trace_output (OP_BIT); +@@ -1919,7 +1919,7 @@ OP_22207E0 (void) + \ + trace_input (name, OP_BIT_CHANGE, 0); \ + \ +- bit = 1 << State.regs[ OP[1] & 0x7 ]; \ ++ bit = 1 << (State.regs[ OP[1] ] & 0x7); \ + temp = load_mem (State.regs[ OP[0] ], 1); \ + \ + PSW &= ~PSW_Z; \ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-halt.patch linux-2.4.6/arch/v850/sim/patches/sim-halt.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-halt.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-halt.patch Mon Aug 27 16:21:16 2001 @@ -0,0 +1,22 @@ +2001-08-27 Miles Bader + + * simops.c (OP_12007E0): Don't halt the simulator, just let the + halt insn loop (the loop will be exited by any interrupt). + +diff -up sim/v850/simops.c.\~2\~ sim/v850/simops.c +--- sim/v850/simops.c.~2~ Fri Aug 24 15:38:19 2001 ++++ sim/v850/simops.c Mon Aug 27 15:34:48 2001 +@@ -1575,10 +1575,10 @@ int + OP_12007E0 () + { + trace_input ("halt", OP_NONE, 0); +- /* FIXME this should put processor into a mode where NMI still handled */ + trace_output (OP_NONE); +- sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC, +- sim_stopped, SIM_SIGTRAP); ++ /* We use a PC adjustment of 0, so the halt insn keeps looping, but ++ interrupts handle it specially, and will cause the halt insn to ++ complete. */ + return 0; + } + diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-himem-trace.patch linux-2.4.6/arch/v850/sim/patches/sim-himem-trace.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-himem-trace.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-himem-trace.patch Tue Sep 18 18:44:07 2001 @@ -0,0 +1,113 @@ +diff -up sim/v850/sim-main.h.\~5\~ sim/v850/sim-main.h +--- sim/v850/sim-main.h.~5~ Fri Sep 7 13:56:29 2001 ++++ sim/v850/sim-main.h Tue Sep 18 16:06:02 2001 +@@ -208,6 +208,14 @@ extern address_word sim_lomem_write_prot + address_word addr, unsigned len, + sim_cia cia, int is_write); + ++/* Boundary above which writes are traced. */ ++extern address_word sim_himem_trace_boundary; ++/* Called to trace loads/stores to memory above sim_himem_trace_boundary. */ ++extern void sim_trace_himem_fw (SIM_DESC sd, sim_cpu *cpu, ++ address_word addr, unsigned len, ++ unsigned long val, ++ sim_cia cia, int is_write); ++ + #define load_mem(ADDR,LEN) \ + ({ \ + address_word _addr = (ADDR); \ +@@ -229,6 +237,8 @@ extern void sim_lomem_falt (SIM_DESC sd, + sim_cpu *cpu = STATE_CPU (sd, 0); \ + if (_addr < sim_lomem_write_protect_boundary) \ + sim_lomem_fault (sd, cpu, _addr, LEN, PC, 1); \ ++ else if (_addr > sim_himem_trace_boundary) \ ++ sim_trace_himem_rw (sd, cpu, _addr, LEN, (unsigned long)_data, PC, 1); \ + else \ + sim_core_write_unaligned_##LEN (cpu, PC, write_map, _addr, _data); \ + }) +diff -up sim/v850/interp.c.\~5\~ sim/v850/interp.c +--- sim/v850/interp.c.~5~ Fri Sep 7 14:33:22 2001 ++++ sim/v850/interp.c Tue Sep 18 16:09:22 2001 +@@ -32,6 +32,13 @@ static const char * get_insn_name (sim_c + SIM_DESC simulator; + + ++#define stringify(sym) stringify_1(sym) ++#define stringify_1(sym) #sym ++ ++ ++#define IO_MEM_BOUNDARY 0xFFFFF000 ++ ++ + + /* Options. */ + +@@ -39,7 +46,8 @@ enum { + OPTION_V850_RECENT_BRANCHES = OPTION_START, + OPTION_V850_READ_PROTECT_LOMEM, + OPTION_V850_WRITE_PROTECT_LOMEM, +- OPTION_V850_PROTECTED_LOMEM_INFO ++ OPTION_V850_PROTECTED_LOMEM_INFO, ++ OPTION_V850_TRACE_IO_WRITES + }; + + static DECLARE_OPTION_HANDLER (v850_option_handler); +@@ -61,6 +69,11 @@ static const OPTION v850_options[] = + OPTION_V850_PROTECTED_LOMEM_INFO }, + '\0', NULL, "Show which low-memory addresses are protected from reading/writing", + v850_option_handler }, ++ { {"trace-io-writes", required_argument, NULL, ++ OPTION_V850_TRACE_IO_WRITES }, ++ '\0', "on|off", ++ "Trace writes to I/O memory (above " stringify(IO_MEM_BOUNDARY) ")", ++ v850_option_handler }, + { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL } + }; + +@@ -113,6 +126,20 @@ v850_option_handler (SIM_DESC sd, sim_cp + } + return SIM_RC_OK; + ++ case OPTION_V850_TRACE_IO_WRITES: ++ { ++ if (strcmp (arg, "on") == 0 || strcmp (arg, "yes") == 0) ++ sim_himem_trace_boundary = IO_MEM_BOUNDARY; ++ else if (strcmp (arg, "off") == 0 || strcmp (arg, "no") == 0) ++ sim_himem_trace_boundary = 0xFFFFFFF; ++ else ++ { ++ sim_io_eprintf (sd, "Invalid argument `%s'\n", arg); ++ return SIM_RC_FAIL; ++ } ++ } ++ return SIM_RC_OK; ++ + default: + sim_io_eprintf (sd, "Unknown v850 option %d\n", opt); + return SIM_RC_FAIL; +@@ -527,4 +554,25 @@ address_word sim_lomem_read_protect_boun + "core: %d byte %s protected low memory address 0x%lx at 0x%lx\n", + len, is_write ? "write to" : "read from", addr, cia); + sim_engine_halt (sd, cpu, NULL, cia, sim_stopped, SIM_SIGSEGV); ++} ++ ++/* Boundary above which writes are traced. */ ++address_word sim_himem_trace_boundary; ++ ++/* Called to trace loads/stores to memory above sim_himem_trace_boundary. */ ++void ++sim_trace_himem_rw (SIM_DESC sd, sim_cpu *cpu, ++ address_word addr, unsigned len, unsigned long val, ++ sim_cia cia, int is_write) ++{ ++ const char *v = is_write ? "write" : "read"; ++ const char *p = is_write ? "to" : "from"; ++ if (len == 1 && isascii (val) && isprint ((char)val)) ++ sim_io_printf (sd, ++ "core: %d byte %s at 0x%lx %s high memory address 0x%lx: 0x%02lx ('%c')\n", ++ len, v, cia, p, addr, val, (char)val); ++ else ++ sim_io_printf (sd, ++ "core: %d byte %s at 0x%lx %s high memory address 0x%lx: 0x%0*lx (%ld)\n", ++ len, v, cia, p, addr, len * 2, val, val); + } diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-interrupt-priority.patch linux-2.4.6/arch/v850/sim/patches/sim-interrupt-priority.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-interrupt-priority.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-interrupt-priority.patch Mon Aug 27 16:21:35 2001 @@ -0,0 +1,206 @@ +2001-08-24 Miles Bader + + * sim-main.h (struct _sim_cpu): New fields `current_interrupts' + and `pending_interrupts'. + * interp.c (do_interrupt): Don't deliver a maskable interrupt + unless it's `higher priority' than any interrupt currently being + serviced. Update current interrupt active/pending state. + Automatically adjust the resume address if the PC is currently + pointing at a `halt' instruction, to resume at the next insn. + * v850.igen ("reti"): Remove the highest-priority interrupt's bit + from the current-interrupts mask. + +diff -up sim/v850/sim-main.h.\~1\~ sim/v850/sim-main.h +--- sim/v850/sim-main.h.~1~ Mon Jan 22 13:50:38 2001 ++++ sim/v850/sim-main.h Mon Aug 27 15:14:29 2001 +@@ -50,6 +50,12 @@ struct _sim_cpu + sim_event *pending_nmi; + /* ... base type ... */ + sim_cpu_base base; ++ /* One bit for each interrupt currently being serviced. */ ++ unsigned current_interrupts; ++ /* One bit for each interrupt that's been blocked because of a higher ++ priority interrupt. This is used to avoid multiple pending ++ interrupts stacking up. */ ++ unsigned pending_interrupts; + }; + + #define CIA_GET(CPU) ((CPU)->reg.pc + 0) +diff -up sim/v850/interp.c.\~1\~ sim/v850/interp.c +--- sim/v850/interp.c.~1~ Thu Oct 5 19:59:56 2000 ++++ sim/v850/interp.c Mon Aug 27 16:15:01 2001 +@@ -66,8 +66,9 @@ do_interrupt (sd, data) + void *data; + { + char **interrupt_name = (char**)data; +- enum interrupt_type inttype; +- inttype = (interrupt_name - STATE_WATCHPOINTS (sd)->interrupt_names); ++ enum interrupt_type inttype ++ = (interrupt_name - STATE_WATCHPOINTS (sd)->interrupt_names); ++ unsigned pc_adjust; + + /* For a hardware reset, drop everything and jump to the start + address */ +@@ -79,6 +80,14 @@ do_interrupt (sd, data) + sim_engine_restart (sd, NULL, NULL, NULL_CIA); + } + ++ /* How to adjust the PC upon return from this interrupt. This is zero ++ for everything but a `halt' instruction. */ ++ if (load_mem (PC, 2) == 0x07e0 && load_mem (PC + 2, 2) == 0x0120) ++ /* PC is pointing to a `halt' insn. */ ++ pc_adjust = 4; ++ else ++ pc_adjust = 0; ++ + /* Deliver an NMI when allowed */ + if (inttype == int_nmi) + { +@@ -100,7 +109,7 @@ do_interrupt (sd, data) + /* NMI can be delivered. Do not deschedule pending_nmi as + that, if still in the event queue, is a second NMI that + needs to be delivered later. */ +- FEPC = PC; ++ FEPC = PC + pc_adjust; + FEPSW = PSW; + /* Set the FECC part of the ECR. */ + ECR &= 0x0000ffff; +@@ -116,16 +125,74 @@ do_interrupt (sd, data) + /* deliver maskable interrupt when allowed */ + if (inttype > int_nmi && inttype < num_int_types) + { +- if ((PSW & PSW_NP) || (PSW & PSW_ID)) ++ unsigned int_code, int_pc, int_num, int_mask; ++ ++ switch (inttype) ++ { ++ case int_intov1: ++ int_pc = 0x80; ++ int_code = 0x80; ++ int_num = 0; ++ break; ++ case int_intp10: ++ int_pc = 0x90; ++ int_code = 0x90; ++ int_num = 1; ++ break; ++ case int_intp11: ++ int_pc = 0xa0; ++ int_code = 0xa0; ++ int_num = 2; ++ break; ++ case int_intp12: ++ int_pc = 0xb0; ++ int_code = 0xb0; ++ int_num = 3; ++ break; ++ case int_intp13: ++ int_pc = 0xc0; ++ int_code = 0xc0; ++ int_num = 4; ++ break; ++ case int_intcm4: ++ int_pc = 0xd0; ++ int_code = 0xd0; ++ int_num = 5; ++ break; ++ default: ++ /* Should never be possible. */ ++ sim_engine_abort (sd, NULL, NULL_CIA, ++ "do_interrupt - internal error - bad switch"); ++ break; ++ } ++ ++ int_mask = 1 << int_num; ++ ++ /* A maskable interrupt can't be delivered if: ++ (1) A NMI is currently being serviced, or ++ (2) The interrupt-disable bit is set, or ++ (3) It's `lower-priority' than the interrupt currently being ++ serviced. Here, `lower-priority' really means `has a ++ higher interrupt number'. */ ++ if ((PSW & PSW_NP) || (PSW & PSW_ID) ++ || (STATE_CPU (sd, 0)->current_interrupts & (int_mask - 1))) + { +- /* Can't deliver this interrupt, reschedule it for later */ +- sim_events_schedule (sd, 1, do_interrupt, data); ++ /* Can't deliver this interrupt, reschedule it for later. If ++ the interrupt is already pending, though, don't bother, ++ since there's already an event queued for it (and we only ++ want to deliver one interrupt when it becomes possible to ++ do so). */ ++ if (! (STATE_CPU (sd, 0)->pending_interrupts & int_mask)) ++ { ++ sim_events_schedule (sd, 1, do_interrupt, data); ++ STATE_CPU (sd, 0)->pending_interrupts |= int_mask; ++ } + return; + } + else + { + /* save context */ +- EIPC = PC; ++ EIPC = PC + pc_adjust; + EIPSW = PSW; + /* Disable further interrupts. */ + PSW |= PSW_ID; +@@ -133,38 +200,13 @@ do_interrupt (sd, data) + PSW &= ~PSW_EP; + /* Clear the EICC part of the ECR, will set below. */ + ECR &= 0xffff0000; +- switch (inttype) +- { +- case int_intov1: +- PC = 0x80; +- ECR |= 0x80; +- break; +- case int_intp10: +- PC = 0x90; +- ECR |= 0x90; +- break; +- case int_intp11: +- PC = 0xa0; +- ECR |= 0xa0; +- break; +- case int_intp12: +- PC = 0xb0; +- ECR |= 0xb0; +- break; +- case int_intp13: +- PC = 0xc0; +- ECR |= 0xc0; +- break; +- case int_intcm4: +- PC = 0xd0; +- ECR |= 0xd0; +- break; +- default: +- /* Should never be possible. */ +- sim_engine_abort (sd, NULL, NULL_CIA, +- "do_interrupt - internal error - bad switch"); +- break; +- } ++ ++ /* Set the new program counter and ECR. */ ++ PC = int_pc; ++ ECR |= int_code; ++ ++ STATE_CPU (sd, 0)->current_interrupts |= int_mask; ++ STATE_CPU (sd, 0)->pending_interrupts &= ~int_mask; + } + sim_engine_restart (sd, NULL, NULL, NULL_CIA); + } +diff -up sim/v850/v850.igen.\~1\~ sim/v850/v850.igen +--- sim/v850/v850.igen.~1~ Mon Mar 26 13:20:00 2001 ++++ sim/v850/v850.igen Mon Aug 27 15:55:47 2001 +@@ -742,6 +742,10 @@ rrrrr,110100,RRRRR + iiiiiiiiiiiiiiii:VI + { + nia = (EIPC & ~1); + PSW = EIPSW; ++ // We must be returning from the highest priority interrupt, so ++ // clear its bit. ++ STATE_CPU (SD, CPU)->current_interrupts ++ &= (STATE_CPU (SD, CPU)->current_interrupts - 1); + } + TRACE_BRANCH1 (PSW); + } diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-lomem-protect.patch linux-2.4.6/arch/v850/sim/patches/sim-lomem-protect.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-lomem-protect.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-lomem-protect.patch Tue Sep 18 15:46:06 2001 @@ -0,0 +1,197 @@ +2001-09-07 Miles Bader + + * v850.igen ("switch r"): Use IMEM16 instead of load_mem. + * interp.c (do_interrupt): Use IMEM16 instead of load_mem to look + for a `halt' instruction. + * sim-main.h (IMEM16): Use `STATE_CPU(sd,0)' instead of `CPU', + as IMEM16_IMMED does. + + * sim-main.h (sim_lomem_read_protect_boundary) + (sim_lomem_write_protect_boundary): New declarations. + (sim_lomem_fault): New declaration. + (load_mem, store_mem): Test reads/writes against the appropriate + boundary and signal an error if below it. + + * interp.c (v850_options): Add entries for read/write-protect-lomem. + (v850_option_handler): Parse them. + (OPTION_V850_READ_PROTECT_LOMEM, OPTION_V850_WRITE_PROTECT_LOMEM): + New enums. + +diff -up sim/v850/sim-main.h.\~3\~ sim/v850/sim-main.h +--- sim/v850/sim-main.h.~3~ Mon Aug 27 15:14:29 2001 ++++ sim/v850/sim-main.h Fri Sep 7 13:56:29 2001 +@@ -195,21 +195,44 @@ nia = PC + + /* Function declarations. */ + ++ + #define IMEM16(EA) \ +-sim_core_read_aligned_2 (CPU, PC, exec_map, (EA)) ++sim_core_read_aligned_2 (STATE_CPU (sd, 0), PC, exec_map, (EA)) + + #define IMEM16_IMMED(EA,N) \ + sim_core_read_aligned_2 (STATE_CPU (sd, 0), \ + PC, exec_map, (EA) + (N) * 2) + +-#define load_mem(ADDR,LEN) \ +-sim_core_read_unaligned_##LEN (STATE_CPU (simulator, 0), \ +- PC, read_map, (ADDR)) +- +-#define store_mem(ADDR,LEN,DATA) \ +-sim_core_write_unaligned_##LEN (STATE_CPU (simulator, 0), \ +- PC, write_map, (ADDR), (DATA)) +- ++/* Boundary below which memory is write-protected. */ ++extern address_word sim_lomem_write_protect_boundary; ++/* Boundary below which memory is read-protected. */ ++extern address_word sim_lomem_read_protect_boundary; ++/* Called if there's an invalid read/write. */ ++extern void sim_lomem_fault (SIM_DESC sd, sim_cpu *cpu, ++ address_word addr, unsigned len, ++ sim_cia cia, int is_write); ++ ++#define load_mem(ADDR,LEN) \ ++ ({ \ ++ address_word _addr = (ADDR); \ ++ SIM_DESC sd = simulator; \ ++ sim_cpu *cpu = STATE_CPU (sd, 0); \ ++ if (_addr < sim_lomem_read_protect_boundary) \ ++ sim_lomem_fault (sd, cpu, _addr, LEN, PC, 0); \ ++ sim_core_read_unaligned_##LEN (cpu, PC, read_map, _addr); \ ++ }) ++ ++#define store_mem(ADDR,LEN,DATA) \ ++ ({ \ ++ address_word _addr = (ADDR); \ ++ unsigned_##LEN _data = (DATA); \ ++ SIM_DESC sd = simulator; \ ++ sim_cpu *cpu = STATE_CPU (sd, 0); \ ++ if (_addr < sim_lomem_write_protect_boundary) \ ++ sim_lomem_fault (sd, cpu, _addr, LEN, PC, 1); \ ++ else \ ++ sim_core_write_unaligned_##LEN (cpu, PC, write_map, _addr, _data); \ ++ }) + + /* compare cccc field against PSW */ + int condition_met (unsigned code); +diff -up sim/v850/interp.c.\~4\~ sim/v850/interp.c +--- sim/v850/interp.c.~4~ Wed Sep 5 16:24:37 2001 ++++ sim/v850/interp.c Fri Sep 7 14:33:22 2001 +@@ -37,6 +37,9 @@ SIM_DESC simulator; + + enum { + OPTION_V850_RECENT_BRANCHES = OPTION_START, ++ OPTION_V850_READ_PROTECT_LOMEM, ++ OPTION_V850_WRITE_PROTECT_LOMEM, ++ OPTION_V850_PROTECTED_LOMEM_INFO + }; + + static DECLARE_OPTION_HANDLER (v850_option_handler); +@@ -46,6 +49,18 @@ static const OPTION v850_options[] = + { {"recent-branches", no_argument, NULL, OPTION_V850_RECENT_BRANCHES }, + '\0', NULL, "Show a list of recent branches", + v850_option_handler }, ++ { {"read-protect-low-memory", required_argument, NULL, ++ OPTION_V850_READ_PROTECT_LOMEM }, ++ '\0', "BOUNDARY", "Signal a fault for any reads below address BOUNDARY", ++ v850_option_handler }, ++ { {"write-protect-low-memory", required_argument, NULL, ++ OPTION_V850_WRITE_PROTECT_LOMEM }, ++ '\0', "BOUNDARY", "Signal a fault for any writes below address BOUNDARY", ++ v850_option_handler }, ++ { {"protected-low-memory-info", no_argument, NULL, ++ OPTION_V850_PROTECTED_LOMEM_INFO }, ++ '\0', NULL, "Show which low-memory addresses are protected from reading/writing", ++ v850_option_handler }, + { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL } + }; + +@@ -60,6 +75,44 @@ v850_option_handler (SIM_DESC sd, sim_cp + case OPTION_V850_RECENT_BRANCHES: + show_recent_branches (sd); + return SIM_RC_OK; ++ ++ case OPTION_V850_READ_PROTECT_LOMEM: ++ case OPTION_V850_WRITE_PROTECT_LOMEM: ++ { ++ char *tail; ++ int is_write = (opt == OPTION_V850_WRITE_PROTECT_LOMEM); ++ address_word addr = strtol (arg, &tail, 0); ++ if (addr == 0 && tail == arg) ++ { ++ sim_io_eprintf (sd, "Invalid %s-protect boundary `%s'\n", ++ is_write ? "write" : "read", arg); ++ return SIM_RC_FAIL; ++ } ++ if (is_write) ++ sim_lomem_write_protect_boundary = addr; ++ else ++ sim_lomem_read_protect_boundary = addr; ++ } ++ return SIM_RC_OK; ++ ++ case OPTION_V850_PROTECTED_LOMEM_INFO: ++ { ++ if (sim_lomem_read_protect_boundary == 0) ++ sim_io_printf (sd, "No addresses protected against reading\n"); ++ else ++ sim_io_printf (sd, ++ "Addresses below 0x%lx protected against reading\n", ++ sim_lomem_read_protect_boundary); ++ ++ if (sim_lomem_write_protect_boundary == 0) ++ sim_io_printf (sd, "No addresses protected against writing\n"); ++ else ++ sim_io_printf (sd, ++ "Addresses below 0x%lx protected against writing\n", ++ sim_lomem_write_protect_boundary); ++ } ++ return SIM_RC_OK; ++ + default: + sim_io_eprintf (sd, "Unknown v850 option %d\n", opt); + return SIM_RC_FAIL; +@@ -116,7 +169,7 @@ do_interrupt (sd, data) + + /* How to adjust the PC upon return from this interrupt. This is zero + for everything but a `halt' instruction. */ +- if (load_mem (PC, 2) == 0x07e0 && load_mem (PC + 2, 2) == 0x0120) ++ if (IMEM16 (PC) == 0x07e0 && IMEM16 (PC + 2) == 0x0120) + /* PC is pointing to a `halt' insn. */ + pc_adjust = 4; + else +@@ -464,4 +517,22 @@ show_recent_branches (SIM_DESC sd) + wrapped = 1; + } + } ++} ++ ++ ++/* Boundary below which memory is write-protected. */ ++address_word sim_lomem_write_protect_boundary = 0; ++/* Boundary below which memory is read-protected. */ ++address_word sim_lomem_read_protect_boundary = 0; ++ ++/* Called if there's an invalid read/write. */ ++void ++sim_lomem_fault (SIM_DESC sd, sim_cpu *cpu, ++ address_word addr, unsigned len, ++ sim_cia cia, int is_write) ++{ ++ sim_io_eprintf (sd, ++ "core: %d byte %s protected low memory address 0x%lx at 0x%lx\n", ++ len, is_write ? "write to" : "read from", addr, cia); ++ sim_engine_halt (sd, cpu, NULL, cia, sim_stopped, SIM_SIGSEGV); + } +diff -up sim/v850/v850.igen.\~3\~ sim/v850/v850.igen +--- sim/v850/v850.igen.~3~ Mon Aug 27 15:55:47 2001 ++++ sim/v850/v850.igen Fri Sep 7 14:31:32 2001 +@@ -1049,7 +1049,7 @@ rrrrr,001100,RRRRR:I:::subr + SAVE_1; + trace_input ("switch", OP_REG, 0); + adr = (cia + 2) + (State.regs[ reg1 ] << 1); +- nia = (cia + 2) + (EXTEND16 (load_mem (adr, 2)) << 1); ++ nia = (cia + 2) + (EXTEND16 (IMEM16 (adr)) << 1); + trace_output (OP_REG); + } + diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-makeraw.patch linux-2.4.6/arch/v850/sim/patches/sim-makeraw.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-makeraw.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-makeraw.patch Wed Sep 5 11:54:58 2001 @@ -0,0 +1,41 @@ +diff -up sim/v850/simops.c.\~4\~ sim/v850/simops.c +--- sim/v850/simops.c.~4~ Mon Sep 3 15:50:09 2001 ++++ sim/v850/simops.c Wed Sep 5 11:08:43 2001 +@@ -37,6 +37,11 @@ + #include + #endif + ++#ifdef HAVE_TERMIOS_H ++#include ++#define TARGET_SYS_make_raw 1024 ++#endif ++ + /* This is an array of the bit positions of registers r20 .. r31 in + that order in a prepare/dispose instruction. */ + int type1_regs[12] = { 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 0, 21 }; +@@ -1898,6 +1903,25 @@ OP_10007E0 () + } + break; + #endif ++#endif ++ ++#ifdef TARGET_SYS_make_raw ++ case TARGET_SYS_make_raw: ++ { ++ struct termios termios; ++ int fd = PARM1; ++ int rval = tcgetattr (fd, &termios); ++ ++ if (rval >= 0) ++ { ++ cfmakeraw (&termios); ++ termios.c_oflag |= OPOST; ++ rval = tcsetattr (fd, TCSANOW, &termios); ++ } ++ ++ RETVAL = rval; ++ } ++ break; + #endif + + default: diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-poll.patch linux-2.4.6/arch/v850/sim/patches/sim-poll.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-poll.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-poll.patch Mon Sep 3 16:08:05 2001 @@ -0,0 +1,105 @@ +sim/v850/ChangeLog: +2001-09-03 Miles Bader + + * simops.c (OP_10007E0): Add handling of `poll' system call. + * configure.in (AC_CHECK_FUNCS): Add `poll'. + (AC_CHECK_HEADERS): Add `poll.h'. + +libgloss/ChangeLog: +2001-09-03 Miles Bader + + * v850/sys/syscall.h (SYS_poll): New syscall. + +diff -up sim/v850/simops.c.\~3\~ sim/v850/simops.c +--- sim/v850/simops.c.~3~ Mon Aug 27 17:34:08 2001 ++++ sim/v850/simops.c Mon Sep 3 15:50:09 2001 +@@ -22,6 +22,10 @@ + #endif + #endif + ++#ifdef HAVE_POLL_H ++#include ++#endif ++ + #include "targ-vals.h" + + #include "libiberty.h" +@@ -1773,6 +1777,44 @@ OP_10007E0 () + store_mem (buf + 20, 4, host_stat.st_atime); + store_mem (buf + 28, 4, host_stat.st_mtime); + store_mem (buf + 36, 4, host_stat.st_ctime); ++ } ++ break; ++#endif ++#endif ++ ++#ifdef HAVE_POLL ++#ifdef TARGET_SYS_poll ++ case TARGET_SYS_poll: ++ { ++ reg_t sfds; ++ int fd, nevents; ++ int nfds = PARM2; ++ int fds_len = nfds * sizeof (struct pollfd); ++ struct pollfd *fds = zalloc (fds_len); ++ ++ /* Copy the fd structures from sim memory to real memory. */ ++ for (fd = 0, sfds = PARM1; fd < nfds; fd++, sfds += 8) ++ { ++ fds[fd].fd = load_mem (sfds, 4); ++ fds[fd].events = load_mem (sfds + 4, 2); ++ fds[fd].revents = load_mem (sfds + 6, 2); ++ } ++ ++ nevents = poll (fds, nfds, PARM3); ++ RETVAL = nevents; ++ ++ for (fd = 0, sfds = PARM1; ++ fd < nfds && nevents > 0; ++ fd++, sfds += 8) ++ { ++ if (fds[fd].revents) ++ { ++ store_mem (sfds + 6, 2, fds[fd].revents); ++ nevents--; ++ } ++ } ++ ++ zfree (fds); + } + break; + #endif +diff -up sim/v850/configure.in.\~1\~ sim/v850/configure.in +--- sim/v850/configure.in.~1~ Mon Mar 26 13:20:00 2001 ++++ sim/v850/configure.in Mon Sep 3 13:54:13 2001 +@@ -12,7 +12,7 @@ SIM_AC_OPTION_WARNINGS + SIM_AC_OPTION_RESERVED_BITS + SIM_AC_OPTION_BITSIZE(32,31) + +-AC_CHECK_FUNCS(time chmod utime fork execve execv chown) +-AC_CHECK_HEADERS(unistd.h stdlib.h string.h strings.h utime.h time.h) ++AC_CHECK_FUNCS(time chmod utime fork execve execv chown poll) ++AC_CHECK_HEADERS(unistd.h stdlib.h string.h strings.h utime.h time.h poll.h) + + SIM_AC_OUTPUT +diff -up libgloss/v850/sys/syscall.h.\~1\~ libgloss/v850/sys/syscall.h +--- libgloss/v850/sys/syscall.h.~1~ Thu Oct 5 19:59:59 2000 ++++ libgloss/v850/sys/syscall.h Mon Sep 3 16:05:02 2001 +@@ -25,14 +25,14 @@ + #define SYS_fstat 22 + #define SYS_time 23 + +- + #define SYS_ARG 24 +-#define SYS_stat 38 + ++#define SYS_stat 38 ++#define SYS_poll 29 + + #define SYS_pipe 42 + #define SYS_execve 59 +-#define SYS_times 43 ++#define SYS_times 43 + #define SYS_gettimeofday 116 + + #define SYS_utime 201 /* not really a system call */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-raw-stdio.patch linux-2.4.6/arch/v850/sim/patches/sim-raw-stdio.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-raw-stdio.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-raw-stdio.patch Tue Sep 4 15:35:34 2001 @@ -0,0 +1,71 @@ +diff -up sim/common/sim-options.c.\~1\~ sim/common/sim-options.c +--- sim/common/sim-options.c.~1~ Thu Oct 5 19:59:52 2000 ++++ sim/common/sim-options.c Tue Sep 4 13:50:12 2001 +@@ -1,5 +1,5 @@ + /* Simulator option handling. +- Copyright (C) 1996, 1997 Free Software Foundation, Inc. ++ Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc. + Contributed by Cygnus Support. + + This file is part of GDB, the GNU debugger. +@@ -111,6 +111,7 @@ typedef enum { + #ifdef SIM_H8300 /* FIXME: Should be movable to h8300 dir. */ + OPTION_H8300, + #endif ++ OPTION_STDIO, + } STANDARD_OPTIONS; + + static const OPTION standard_options[] = +@@ -182,6 +183,10 @@ static const OPTION standard_options[] = + '\0', "BFDNAME", "Specify the object-code format for the object files", + standard_option_handler }, + ++ { {"stdio", required_argument, NULL, OPTION_STDIO}, ++ '\0', "on|off", "Turn special treatment of stdio on or off", ++ standard_option_handler}, ++ + { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL } + }; + +@@ -399,6 +404,18 @@ standard_option_handler (SIM_DESC sd, si + if (STATE_OPEN_KIND (sd) == SIM_OPEN_STANDALONE) + exit (0); + /* FIXME: 'twould be nice to do something similar if gdb. */ ++ break; ++ ++ case OPTION_STDIO: ++ if (strcmp (arg, "on") == 0) ++ current_stdio = DO_USE_STDIO; ++ else if (strcmp (arg, "off") == 0) ++ current_stdio = DONT_USE_STDIO; ++ else ++ { ++ sim_io_eprintf (sd, "Argument `%s' for `--stdio' invalid, `on' or `off' expected\n", arg); ++ return SIM_RC_FAIL; ++ } + break; + } + +diff -up sim/common/callback.c.\~1\~ sim/common/callback.c +--- sim/common/callback.c.~1~ Thu Oct 5 19:59:52 2000 ++++ sim/common/callback.c Tue Sep 4 14:46:50 2001 +@@ -289,18 +289,7 @@ os_write (p, fd, buf, len) + if (result) + return result; + real_fd = fdmap (p, fd); +- switch (real_fd) +- { +- default: +- result = wrap (p, write (real_fd, buf, len)); +- break; +- case 1: +- result = p->write_stdout (p, buf, len); +- break; +- case 2: +- result = p->write_stderr (p, buf, len); +- break; +- } ++ result = wrap (p, write (real_fd, buf, len)); + return result; + } + diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-record-branches.patch linux-2.4.6/arch/v850/sim/patches/sim-record-branches.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-record-branches.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-record-branches.patch Wed Sep 5 16:38:17 2001 @@ -0,0 +1,158 @@ +2001-09-05 Miles Bader + + * sim-main.h (NUM_RECENT_BRANCHES, RECENT_BRANCH): New macros. + (struct recent_branch): New type. + (recent_branches, next_recent_branch): New declarations. + (TRACE_BRANCH0, TRACE_BRANCH1, TRACE_BRANCH2, TRACE_BRANCH3): Use + `RECENT_BRANCH'. + * interp.c (show_recent_branches, v850_option_handler): New functions. + (OPTION_V850_RECENT_BRANCHES): New enum. + (v850_options): New variable. + +diff -up sim/v850/sim-main.h.\~3\~ sim/v850/sim-main.h +--- sim/v850/sim-main.h.~3~ Mon Aug 27 15:14:29 2001 ++++ sim/v850/sim-main.h Wed Sep 5 16:14:07 2001 +@@ -264,8 +264,30 @@ extern unsigned32 trace_pc; + extern const char *trace_name; + extern int trace_module; + ++#define NUM_RECENT_BRANCHES 32 ++struct recent_branch { ++ unsigned long from, to, arg1, arg2, arg3; ++ const char *insn_name; ++}; ++extern struct recent_branch recent_branches[NUM_RECENT_BRANCHES]; ++extern int next_recent_branch; ++#define RECORD_BRANCH(_from, _to, _insn_name, _arg1, _arg2, _arg3) \ ++do { \ ++ struct recent_branch *rb; \ ++ if (next_recent_branch == NUM_RECENT_BRANCHES) \ ++ next_recent_branch = 0; \ ++ rb = &recent_branches[next_recent_branch++]; \ ++ rb->from = _from; \ ++ rb->to = _to; \ ++ rb->insn_name = _insn_name; \ ++ rb->arg1 = _arg1; \ ++ rb->arg2 = _arg2; \ ++ rb->arg3 = _arg3; \ ++} while (0) ++ + #define TRACE_BRANCH0() \ + do { \ ++ RECORD_BRANCH (cia, nia, itable[MY_INDEX].name, 0, 0, 0); \ + if (TRACE_BRANCH_P (CPU)) { \ + trace_module = TRACE_BRANCH_IDX; \ + trace_pc = cia; \ +@@ -277,6 +299,7 @@ do { \ + + #define TRACE_BRANCH1(IN1) \ + do { \ ++ RECORD_BRANCH (cia, nia, itable[MY_INDEX].name, IN1, 0, 0); \ + if (TRACE_BRANCH_P (CPU)) { \ + trace_module = TRACE_BRANCH_IDX; \ + trace_pc = cia; \ +@@ -289,6 +312,7 @@ do { \ + + #define TRACE_BRANCH2(IN1, IN2) \ + do { \ ++ RECORD_BRANCH (cia, nia, itable[MY_INDEX].name, IN1, IN2, 0); \ + if (TRACE_BRANCH_P (CPU)) { \ + trace_module = TRACE_BRANCH_IDX; \ + trace_pc = cia; \ +@@ -302,6 +326,7 @@ do { \ + + #define TRACE_BRANCH3(IN1, IN2, IN3) \ + do { \ ++ RECORD_BRANCH (cia, nia, itable[MY_INDEX].name, IN1, IN2, IN3); \ + if (TRACE_BRANCH_P (CPU)) { \ + trace_module = TRACE_BRANCH_IDX; \ + trace_pc = cia; \ +diff -up sim/v850/interp.c.\~3\~ sim/v850/interp.c +--- sim/v850/interp.c.~3~ Mon Aug 27 16:15:01 2001 ++++ sim/v850/interp.c Wed Sep 5 16:24:37 2001 +@@ -32,7 +32,41 @@ static const char * get_insn_name (sim_c + SIM_DESC simulator; + + ++ ++/* Options. */ + ++enum { ++ OPTION_V850_RECENT_BRANCHES = OPTION_START, ++}; ++ ++static DECLARE_OPTION_HANDLER (v850_option_handler); ++ ++static const OPTION v850_options[] = ++{ ++ { {"recent-branches", no_argument, NULL, OPTION_V850_RECENT_BRANCHES }, ++ '\0', NULL, "Show a list of recent branches", ++ v850_option_handler }, ++ { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL } ++}; ++ ++static void show_recent_branches (SIM_DESC sd); ++ ++static SIM_RC ++v850_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt, ++ char *arg, int is_command) ++{ ++ switch (opt) ++ { ++ case OPTION_V850_RECENT_BRANCHES: ++ show_recent_branches (sd); ++ return SIM_RC_OK; ++ default: ++ sim_io_eprintf (sd, "Unknown v850 option %d\n", opt); ++ return SIM_RC_FAIL; ++ } ++} ++ ++ + /* v850 interrupt model */ + + enum interrupt_type +@@ -269,6 +303,8 @@ sim_open (kind, cb, abfd, argv) + /* similarly if in the internal RAM region */ + sim_do_command (sd, "memory region 0xffe000,0x1000,1024"); + ++ sim_add_option_table (sd, NULL, v850_options); ++ + /* getopt will print the error message so we just have to exit if this fails. + FIXME: Hmmm... in the case of gdb we need getopt to call + print_filtered. */ +@@ -398,5 +434,34 @@ sim_do_command (sd, cmd) + sim_io_eprintf (sd, "`interrupt' command replaced by `sim watch'\n"); + else + sim_io_eprintf (sd, "Unknown command `%s'\n", cmd); ++ } ++} ++ ++ ++ ++struct recent_branch recent_branches[NUM_RECENT_BRANCHES] = { 0 }; ++int next_recent_branch = 0; ++ ++static void ++show_recent_branches (SIM_DESC sd) ++{ ++ int wrapped = 0, index = 0, i; ++ ++ for (i = next_recent_branch; i != next_recent_branch || !wrapped;) ++ { ++ if (recent_branches[i].insn_name) ++ { ++ struct recent_branch *rb = &recent_branches[i]; ++ sim_io_printf (sd, "%2d: 0x%08x -> 0x%08x %s %d, %d, %d\n", ++ index++, ++ rb->from, rb->to, ++ rb->insn_name, rb->arg1, rb->arg2, rb->arg3); ++ } ++ ++ if (++i == NUM_RECENT_BRANCHES) ++ { ++ i = 0; ++ wrapped = 1; ++ } + } + } diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-trap-addr.patch linux-2.4.6/arch/v850/sim/patches/sim-trap-addr.patch --- linux-2.4.6.uclinux-orig/arch/v850/sim/patches/sim-trap-addr.patch Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/patches/sim-trap-addr.patch Mon Aug 27 17:36:15 2001 @@ -0,0 +1,16 @@ +2001-08-27 Miles Bader + + * simops.c (OP_10007E0): Don't subtract 4 from the new trap PC. + +diff -up sim/v850/simops.c.\~2\~ sim/v850/simops.c +--- sim/v850/simops.c.~2~ Fri Aug 24 15:38:19 2001 ++++ sim/v850/simops.c Mon Aug 27 17:34:08 2001 +@@ -1875,7 +1875,7 @@ OP_10007E0 () + ECR |= 0x40 + OP[0]; + /* Flag that we are now doing exception processing. */ + PSW |= PSW_EP | PSW_ID; +- PC = ((OP[0] < 0x10) ? 0x40 : 0x50) - 4; ++ PC = (OP[0] < 0x10) ? 0x40 : 0x50; + + return 0; + } diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim/updroot linux-2.4.6/arch/v850/sim/updroot --- linux-2.4.6.uclinux-orig/arch/v850/sim/updroot Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim/updroot Mon Sep 17 14:40:24 2001 @@ -0,0 +1,27 @@ +#!/bin/sh + +SIZE=1024 +SRC=root +DST=root.ext2 + +TMP=/tmp/root.ext2 +MNT=/tmp/root.mnt + +dd if=/dev/zero of=$TMP bs=1024 count=$SIZE 2>&1 | grep -v 'records \(in\|out\)' 1>&2 +mke2fs -m0 -q -F $TMP 2>&1 | grep -v '^mke2fs ' 1>&2 + +mkdir -p $MNT +sudo mount -t ext2 $TMP $MNT -o loop + +mkdir -p $MNT/dev + +rm -rf $MNT/lost+found + +# Not need with devfs +#sudo mknod $MNT/dev/console c 5 1 + +(cd $SRC; tar cf - .) | (cd $MNT; tar xvf -) + +sudo umount $MNT + +mv $TMP . diff -ruP -Xcludes linux-2.4.6.uclinux-orig/arch/v850/sim.ld linux-2.4.6/arch/v850/sim.ld --- linux-2.4.6.uclinux-orig/arch/v850/sim.ld Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/arch/v850/sim.ld Wed Sep 19 13:45:16 2001 @@ -0,0 +1,76 @@ +/* Note, all symbols are prefixed with an extra `_' for compatibility with + the existing linux sources. */ + +SECTIONS { + . = 0; + __start = . ; + + .intv : { + __intv_start = . ; + *(.intv) /* Interrupt vectors. */ + *(.intv.common) /* Vectors common to all v850e proc. */ + . = 0x80 ; + *(.intv.mach) /* Machine-specific int. vectors. */ + __intv_end = . ; + } + + .text : { + __stext = . ; + *(.text) + *(.text.exit) + *(.text.lock) + *(.exitcall.exit) + __real_etext = .; /* There may be data after here. */ + *(.rodata) + . = ALIGN(0x4) ; + *(.kstrtab) + . = ALIGN(16); /* Exception table */ + ___start___ex_table = .; + *(__ex_table) + ___stop___ex_table = .; + + ___start___ksymtab = .; /* Kernel symbol table */ + *(__ksymtab) + ___stop___ksymtab = .; + . = ALIGN(4) ; + __etext = . ; + } + + .data BLOCK(0x4) : { + __sdata = . ; + ___data_start = . ; + *(.data) + *(.data.exit) + . = ALIGN(16); + *(.data.cacheline_aligned) + . = ALIGN(0x2000) ; + *(.data.init_task) + . = ALIGN(0x2000) ; + __edata = . ; + } + + .bss BLOCK(0x4) : { + __sbss = . ; + *(.bss) + *(COMMON) + . = ALIGN(4) ; + __ebss = . ; + } + + .init BLOCK(4096) : { + ___init_begin = .; + *(.text.init) + *(.data.init) + . = ALIGN(16); + ___setup_start = .; + *(.setup.init) + ___setup_end = .; + ___initcall_start = .; + *(.initcall.init) + . = ALIGN(4) ; + ___initcall_end = .; + ___init_end = .; + } + + __end = . ; +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/drivers/block/blkmem.c linux-2.4.6/drivers/block/blkmem.c --- linux-2.4.6.uclinux-orig/drivers/block/blkmem.c Mon Aug 27 17:12:18 2001 +++ linux-2.4.6/drivers/block/blkmem.c Tue Aug 28 13:48:52 2001 @@ -1,6 +1,6 @@ /* blkmem.c: Block access to memory spaces * - * Copyright (C) 2000 Lineo, Inc. (www.lineo.com) + * Copyright (C) 2000, 2001 Lineo, Inc. (www.lineo.com) * Copyright (C) 1997, 1998 D. Jeff Dionne , * Kenneth Albanowski , * @@ -67,6 +67,13 @@ /* * Please, configure the ROMFS for your system here */ + +/* v850e; this config stuff is ugly, ugly, ugly! */ +#ifdef CONFIG_V850E +#include +#endif + + /* (es) */ /* note: this is configured somewhere in arch/m68knommu/kernel/setup.c */ /* does it need to be here? */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/drivers/char/ChangeLog linux-2.4.6/drivers/char/ChangeLog --- linux-2.4.6.uclinux-orig/drivers/char/ChangeLog Wed Sep 2 02:32:13 1998 +++ linux-2.4.6/drivers/char/ChangeLog Fri Sep 28 13:45:00 2001 @@ -1,3 +1,8 @@ +2001-09-18 Miles Bader + + * nb85e_uart.c: New file. + * Makefile (obj-$(CONFIG_NB85E_UART)): Handle nb85e_uart.c. + 1998-08-26 Theodore Ts'o * serial.c (rs_open): Correctly decrement the module in-use count diff -ruP -Xcludes linux-2.4.6.uclinux-orig/drivers/char/Makefile linux-2.4.6/drivers/char/Makefile --- linux-2.4.6.uclinux-orig/drivers/char/Makefile Mon Aug 27 17:12:19 2001 +++ linux-2.4.6/drivers/char/Makefile Fri Sep 21 10:45:43 2001 @@ -170,6 +170,7 @@ obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o obj-$(CONFIG_MVME162_SCC) += generic_serial.o vme_scc.o obj-$(CONFIG_BVME6000_SCC) += generic_serial.o vme_scc.o +obj-$(CONFIG_NB85E_UART) += nb85e_uart.o generic_serial.o subdir-$(CONFIG_RIO) += rio subdir-$(CONFIG_INPUT) += joystick diff -ruP -Xcludes linux-2.4.6.uclinux-orig/drivers/char/nb85e_uart.c linux-2.4.6/drivers/char/nb85e_uart.c --- linux-2.4.6.uclinux-orig/drivers/char/nb85e_uart.c Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/drivers/char/nb85e_uart.c Wed Oct 10 16:09:55 2001 @@ -0,0 +1,598 @@ +/* + * drivers/char/nb85e_uart.c -- Serial I/O using V850E/NB85E on-chip UART + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* Magic number used in generic_serial header. */ +#define NB85E_UART_MAGIC 0xFABCAB22 + +/* Initial UART state. */ +#define NB85E_UART_INIT_BAUD 38400 +#define NB85E_UART_INIT_CFLAGS (B38400 | CS8 | CREAD) + +#define RS_EVENT_WRITE_WAKEUP 1 /* from generic_serial.h */ + +/* For use by modules eventually... */ +#define MOD_INC_USE_COUNT +#define MOD_DEC_USE_COUNT + + +/* Low-level UART functions. */ + +/* These masks define which control bits affect TX/RX modes, respectively. */ +#define RX_BITS \ + (NB85E_UART_ASIM_PS_MASK | NB85E_UART_ASIM_CL_8 | NB85E_UART_ASIM_ISRM) +#define TX_BITS \ + (NB85E_UART_ASIM_PS_MASK | NB85E_UART_ASIM_CL_8 | NB85E_UART_ASIM_SL_2) + +/* The UART require various delays after writing control registers. */ +static inline void nb85e_uart_delay (unsigned cycles) +{ + /* The loop takes 2 insns, so loop CYCLES / 2 times. */ + register unsigned count = cycles >> 1; + while (--count != 0) + /* nothing */; +} + +/* Configure and turn on uart channel CHAN, using the termios `control + modes' bits in CFLAGS, and a baud-rate of BAUD. */ +void nb85e_uart_configure (unsigned chan, unsigned cflags, unsigned baud) +{ + int cksr_min, flags; + unsigned new_config = 0; /* What we'll write to the control reg. */ + unsigned new_clk_divlog2; /* New baud-rate generate clock divider. */ + unsigned new_brgen_count; /* New counter max for baud-rate generator.*/ + /* These are the current values corresponding to the above. */ + unsigned old_config, old_clk_divlog2, old_brgen_count; + + /* Calculate new baud-rate generator config values. */ + cksr_min = 0; + while ((cpu_clock_freq >> cksr_min) > NB85E_UART_CKSR_MAX_FREQ) + cksr_min++; + /* Calculate the lot2 clock divider and baud-rate counter values + (note that the UART divides the resulting clock by 2, so + multiply BAUD by 2 here to compensate). */ + calc_counter_params (cpu_clock_freq, baud * 2, + cksr_min, NB85E_UART_CKSR_MAX, 8/*bits*/, + &new_clk_divlog2, &new_brgen_count); + + /* Figure out new configuration of control register. */ + if (cflags & CSTOPB) + /* Number of stop bits, 1 or 2. */ + new_config |= NB85E_UART_ASIM_SL_2; + if ((cflags & CSIZE) == CS8) + /* Number of data bits, 7 or 8. */ + new_config |= NB85E_UART_ASIM_CL_8; + if (! (cflags & PARENB)) + /* No parity check/generation. */ + new_config |= NB85E_UART_ASIM_PS_NONE; + else if (cflags & PARODD) + /* Odd parity check/generation. */ + new_config |= NB85E_UART_ASIM_PS_ODD; + else + /* Even parity check/generation. */ + new_config |= NB85E_UART_ASIM_PS_EVEN; + if (cflags & CREAD) + /* Reading enabled. */ + new_config |= NB85E_UART_ASIM_RXE; + + new_config |= NB85E_UART_ASIM_TXE; /* Writing is always enabled. */ + new_config |= NB85E_UART_ASIM_CAE; + new_config |= NB85E_UART_ASIM_ISRM; /* Errors generate a read-irq. */ + + /* Disable interrupts while we're twiddling the hardware. */ + save_flags_cli (flags); + +#ifdef NB85E_UART_PRE_CONFIGURE + NB85E_UART_PRE_CONFIGURE (chan, cflags, baud); +#endif + + old_config = NB85E_UART_ASIM (chan); + old_clk_divlog2 = NB85E_UART_CKSR (chan); + old_brgen_count = NB85E_UART_BRGC (chan); + + if (new_clk_divlog2 != old_clk_divlog2 + || new_brgen_count != old_brgen_count) + { + /* The baud rate has changed. First, disable the UART. */ + NB85E_UART_ASIM (chan) = 0; + old_config = 0; + /* Reprogram the baud-rate generator. */ + NB85E_UART_CKSR (chan) = new_clk_divlog2; + NB85E_UART_BRGC (chan) = new_brgen_count; + } + + if (! (old_config & NB85E_UART_ASIM_CAE)) { + /* If we are enabling the uart for the first time, start + by turning on the enable bit, which must be done + before turning on any other bits. */ + NB85E_UART_ASIM (chan) = NB85E_UART_ASIM_CAE; + /* Enabling the uart also resets it. */ + old_config = NB85E_UART_ASIM_CAE; + } + + if (new_config != old_config) { + /* Which of the TXE/RXE bits we'll temporarily turn off + before changing other control bits. */ + unsigned temp_disable = 0; + /* Which of the TXE/RXE bits will be enabled. */ + unsigned enable = 0; + unsigned changed_bits = new_config ^ old_config; + + /* Which of RX/TX will be enabled in the new configuration. */ + if (new_config & RX_BITS) + enable |= (new_config & NB85E_UART_ASIM_RXE); + if (new_config & TX_BITS) + enable |= (new_config & NB85E_UART_ASIM_TXE); + + /* Figure out which of RX/TX needs to be disabled; note + that this will only happen if they're not already + disabled. */ + if (changed_bits & RX_BITS) + temp_disable |= (old_config & NB85E_UART_ASIM_RXE); + if (changed_bits & TX_BITS) + temp_disable |= (old_config & NB85E_UART_ASIM_TXE); + + /* We have to turn off RX and/or TX mode before changing + any associated control bits. */ + if (temp_disable) + NB85E_UART_ASIM (chan) = old_config & ~temp_disable; + + /* Write the new control bits, while RX/TX are disabled. */ + if (changed_bits & ~enable) + NB85E_UART_ASIM (chan) = new_config & ~enable; + + /* The UART may not be reset properly unless we + wait at least 2 `basic-clocks' until turning + on the TXE/RXE bits again. A `basic clock' + is the clock used by the baud-rate generator, i.e., + the cpu clock divided by the 2^new_clk_divlog2. */ + nb85e_uart_delay (1 << (new_clk_divlog2 + 1)); + + /* Write the final version, with enable bits turned on. */ + NB85E_UART_ASIM (chan) = new_config; + } + + restore_flags (flags); +} + + +/* Low-level console. */ + +static void nb85e_uart_cons_write (struct console *co, + const char *s, unsigned count) +{ + if (count > 0) { + unsigned chan = co->index; + unsigned irq = IRQ_INTST (chan); + int irq_was_enabled, irq_was_pending, flags; + + /* We don't want to get `transmission completed' (INTST) + interrupts, since we're busy-waiting, so we disable + them while sending (we don't disable interrupts + entirely because sending over a serial line is really + slow). We save the status of INTST and restore it + when we're done so that using printk doesn't + interfere with normal serial transmission (other than + interleaving the output, of course!). This should + work correctly even if this function is interrupted + and the interrupt printks something. */ + + /* Disable interrupts while fiddling with INTST. */ + save_flags_cli (flags); + /* Get current INTST status. */ + irq_was_enabled = nb85e_intc_irq_enabled (irq); + irq_was_pending = nb85e_intc_irq_pending (irq); + /* Disable INTST if necessary. */ + if (irq_was_enabled) + nb85e_intc_disable_irq (irq); + /* Turn interrupts back on. */ + restore_flags (flags); + + /* Send characters. */ + while (count > 0) { + int ch = *s++; + + if (ch == '\n') { + /* We don't have the benefit of a tty + driver, so translate NL into CR LF. */ + nb85e_uart_wait_for_xmit_ok (chan); + nb85e_uart_putc (chan, '\r'); + } + + nb85e_uart_wait_for_xmit_ok (chan); + nb85e_uart_putc (chan, ch); + + count--; + } + + /* Restore saved INTST status. */ + if (irq_was_enabled) { + /* Wait for the last character we sent to be + completely transmitted (as we'll get an INTST + interrupt at that point). */ + nb85e_uart_wait_for_xmit_done (chan); + /* Clear pending interrupts received due + to our transmission, unless there was already + one pending, in which case we want the + handler to be called. */ + if (! irq_was_pending) + nb85e_intc_clear_pending_irq (irq); + /* ... and then turn back on handling. */ + nb85e_intc_enable_irq (irq); + } + } +} + +static int nb85e_uart_cons_wait_key (struct console *co) +{ + /* Bizarrely enough, there appears to be no way to poll the uart + to see if a character has been received! */ + return 0; +} + +static kdev_t nb85e_uart_cons_device (struct console *c) +{ + return MKDEV (TTY_MAJOR, NB85E_UART_MINOR_BASE + c->index); +} + +static struct console nb85e_uart_cons = +{ + name: "ttyS", + write: nb85e_uart_cons_write, + wait_key: nb85e_uart_cons_wait_key, + device: nb85e_uart_cons_device, + flags: CON_PRINTBUFFER, + index: -1, +}; + +void nb85e_uart_cons_init (void) +{ + nb85e_uart_configure (0, NB85E_UART_INIT_CFLAGS, NB85E_UART_INIT_BAUD); + register_console (&nb85e_uart_cons); + printk ("Console: V850E/NB85E on-chip UART channel 0\n"); +} + + +/* Interface for generic serial driver layer. */ + +struct nb85e_uart_tty_port { + struct gs_port gs; + unsigned chan; + struct tq_struct tqueue; +}; + +/* Transmit a character, if any are pending. */ +void nb85e_uart_tty_tx (struct nb85e_uart_tty_port *port) +{ + unsigned chan = port->chan; + int flags; + + /* If there are characters to transmit, try to transmit one of them. */ + if (port->gs.xmit_cnt > 0 && nb85e_uart_xmit_ok (port->chan)) { + nb85e_uart_putc (chan, port->gs.xmit_buf[port->gs.xmit_tail]); + port->gs.xmit_tail + = (port->gs.xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1); + port->gs.xmit_cnt--; + + if (port->gs.xmit_cnt <= port->gs.wakeup_chars) { + port->gs.event |= 1 << RS_EVENT_WRITE_WAKEUP; + queue_task (&port->tqueue, &tq_immediate); + mark_bh (IMMEDIATE_BH); + } + } + + save_flags_cli (flags); + if (port->gs.xmit_cnt == 0) + port->gs.flags &= ~GS_TX_INTEN; + restore_flags (flags); +} + +static void nb85e_uart_tty_disable_tx_interrupts (void *driver_data) +{ + struct nb85e_uart_tty_port *port = driver_data; + nb85e_intc_disable_irq (IRQ_INTST (port->chan)); +} + +static void nb85e_uart_tty_enable_tx_interrupts (void *driver_data) +{ + struct nb85e_uart_tty_port *port = driver_data; + nb85e_intc_disable_irq (IRQ_INTST (port->chan)); + nb85e_uart_tty_tx (port); + nb85e_intc_enable_irq (IRQ_INTST (port->chan)); +} + +static void nb85e_uart_tty_disable_rx_interrupts (void *driver_data) +{ + struct nb85e_uart_tty_port *port = driver_data; + nb85e_intc_disable_irq (IRQ_INTSR (port->chan)); +} + +static void nb85e_uart_tty_enable_rx_interrupts (void *driver_data) +{ + struct nb85e_uart_tty_port *port = driver_data; + nb85e_intc_enable_irq (IRQ_INTSR (port->chan)); +} + +static int nb85e_uart_tty_get_CD (void *driver_data) +{ + return 1; /* Can't really detect it, sorry... */ +} + +static void nb85e_uart_tty_shutdown_port (void *driver_data) +{ + struct nb85e_uart_tty_port *port = driver_data; + + port->gs.flags &= ~ GS_ACTIVE; + + /* Disable port interrupts. */ + free_irq (IRQ_INTST (port->chan), port); + free_irq (IRQ_INTSR (port->chan), port); + + /* Turn off xmit/recv enable bits. */ + NB85E_UART_ASIM (port->chan) &= ~(NB85E_UART_ASIM_TXE | NB85E_UART_ASIM_RXE); + /* Then reset the channel. */ + NB85E_UART_ASIM (port->chan) = 0; +} + +static int nb85e_uart_tty_set_real_termios (void *driver_data) +{ + struct nb85e_uart_tty_port *port = driver_data; + unsigned cflag = port->gs.tty->termios->c_cflag; + nb85e_uart_configure (port->chan, cflag, port->gs.baud); +} + +static int nb85e_uart_tty_chars_in_buffer (void *driver_data) +{ + /* There's only a one-character `buffer', and the only time we + actually know there's a character in it is when we receive a + character-received interrupt -- in which case we immediately + remove it anyway. */ + return 0; +} + +static void nb85e_uart_tty_close (void *driver_data) +{ + MOD_DEC_USE_COUNT; +} + +static void nb85e_uart_tty_hungup (void *driver_data) +{ + MOD_DEC_USE_COUNT; +} + +static void nb85e_uart_tty_getserial (void *driver_data, struct serial_struct *s) +{ + struct nb85e_uart_tty_port *port = driver_data; + s->line = port->chan; + s->xmit_fifo_size = 1; + s->irq = IRQ_INTSR (port->chan); /* actually have TX irq too, but... */ +} + +static struct real_driver nb85e_uart_tty_gs_driver = { + disable_tx_interrupts: nb85e_uart_tty_disable_tx_interrupts, + enable_tx_interrupts: nb85e_uart_tty_enable_tx_interrupts, + disable_rx_interrupts: nb85e_uart_tty_disable_rx_interrupts, + enable_rx_interrupts: nb85e_uart_tty_enable_rx_interrupts, + get_CD: nb85e_uart_tty_get_CD, + shutdown_port: nb85e_uart_tty_shutdown_port, + set_real_termios: nb85e_uart_tty_set_real_termios, + chars_in_buffer: nb85e_uart_tty_chars_in_buffer, + close: nb85e_uart_tty_close, + hungup: nb85e_uart_tty_hungup, + getserial: nb85e_uart_tty_getserial, +}; + +static struct nb85e_uart_tty_port nb85e_uart_tty_ports[NB85E_UART_NUM_CHANNELS]; + +static void init_nb85e_uart_tty_ports (void) +{ + int chan; + for (chan = 0; chan < NB85E_UART_NUM_CHANNELS; chan++) { + struct nb85e_uart_tty_port *port = &nb85e_uart_tty_ports[chan]; + + port->chan = chan; + + port->gs.magic = NB85E_UART_MAGIC; + port->gs.rd = &nb85e_uart_tty_gs_driver; + + init_waitqueue_head (&port->gs.open_wait); + init_waitqueue_head (&port->gs.close_wait); + + port->gs.normal_termios = tty_std_termios; + port->gs.normal_termios.c_cflag = NB85E_UART_INIT_CFLAGS; + + port->gs.close_delay = HZ / 2; /* .5s */ + port->gs.closing_wait = 30 * HZ; /* 30s */ + } +} + + +/* TTY interrupt handlers. */ + +void nb85e_uart_tty_tx_irq (int irq, void *data, struct pt_regs *regs) +{ + struct nb85e_uart_tty_port *port = data; + if (port->gs.flags & GS_ACTIVE) + nb85e_uart_tty_tx (port); + else + nb85e_uart_tty_disable_tx_interrupts (data); +} + +void nb85e_uart_tty_rx_irq (int irq, void *data, struct pt_regs *regs) +{ + struct nb85e_uart_tty_port *port = data; + + if (port->gs.flags & GS_ACTIVE) { + unsigned ch_stat; + unsigned err = NB85E_UART_ASIS (port->chan); + unsigned ch = NB85E_UART_RXB (port->chan); + + if (err & NB85E_UART_ASIS_OVE) + ch_stat = TTY_OVERRUN; + else if (err & NB85E_UART_ASIS_FE) + ch_stat = TTY_FRAME; + else if (err & NB85E_UART_ASIS_PE) + ch_stat = TTY_PARITY; + else + ch_stat = TTY_NORMAL; + + tty_insert_flip_char (port->gs.tty, ch, ch_stat); + tty_schedule_flip (port->gs.tty); + } else + nb85e_uart_tty_disable_rx_interrupts (port); +} + + +/* Higher level TTY interface. */ + +static struct tty_struct *nb85e_uart_ttys[NB85E_UART_NUM_CHANNELS] = { 0 }; +static struct termios *nb85e_uart_tty_termios[NB85E_UART_NUM_CHANNELS] = { 0 }; +static struct termios *nb85e_uart_tty_termios_locked[NB85E_UART_NUM_CHANNELS] = { 0 }; +static struct tty_driver nb85e_uart_tty_driver = { 0 }; +static int nb85e_uart_tty_refcount = 0; + +int nb85e_uart_tty_open (struct tty_struct *tty, struct file *filp) +{ + int err; + struct nb85e_uart_tty_port *port; + unsigned chan = MINOR (tty->device) - NB85E_UART_MINOR_BASE; + + if (chan >= NB85E_UART_NUM_CHANNELS) + return -ENODEV; + + port = &nb85e_uart_tty_ports[chan]; + + tty->driver_data = port; + port->gs.tty = tty; + port->gs.count++; + + port->tqueue.routine = gs_do_softint; + port->tqueue.data = &port->gs; + + /* + * Start up serial port + */ + err = gs_init_port (&port->gs); + if (err) + goto failed_1; + + port->gs.flags |= GS_ACTIVE; + + if (port->gs.count == 1) { + MOD_INC_USE_COUNT; + + /* Alloc RX irq. */ + err = request_irq (IRQ_INTSR (chan), nb85e_uart_tty_rx_irq, + SA_INTERRUPT, "nb85e_uart", port); + if (err) + goto failed_2; + + /* Alloc TX irq. */ + err = request_irq (IRQ_INTST (chan), nb85e_uart_tty_tx_irq, + SA_INTERRUPT, "nb85e_uart", port); + if (err) { + free_irq (IRQ_INTSR (chan), port); + goto failed_2; + } + } + + err = gs_block_til_ready (port, filp); + if (err) + goto failed_3; + + *tty->termios = port->gs.normal_termios; + + nb85e_uart_tty_enable_rx_interrupts (port); + + port->gs.session = current->session; + port->gs.pgrp = current->pgrp; + + return 0; + +failed_3: + free_irq (IRQ_INTST (chan), port); + free_irq (IRQ_INTSR (chan), port); +failed_2: + MOD_DEC_USE_COUNT; +failed_1: + port->gs.count--; + + return err; +} + +int __init nb85e_uart_tty_init (void) +{ + struct tty_driver *d = &nb85e_uart_tty_driver; + + d->driver_name = "nb85e_uart"; +#ifdef CONFIG_DEVFS_FS + d->name = "ttu/%d"; +#else + d->name = "ttyU"; +#endif + + d->major = TTY_MAJOR; + d->minor_start = NB85E_UART_MINOR_BASE; + d->num = 1; + d->type = TTY_DRIVER_TYPE_SERIAL; + d->subtype = SERIAL_TYPE_NORMAL; + + d->refcount = &nb85e_uart_tty_refcount; + + d->table = nb85e_uart_ttys; + d->termios = nb85e_uart_tty_termios; + d->termios_locked = nb85e_uart_tty_termios_locked; + + d->init_termios = tty_std_termios; + d->init_termios.c_cflag = NB85E_UART_INIT_CFLAGS; + + d->open = nb85e_uart_tty_open; + d->put_char = gs_put_char; + d->write = gs_write; + d->write_room = gs_write_room; + d->start = gs_start; + d->stop = gs_stop; + d->close = gs_close; + d->write = gs_write; + d->put_char = gs_put_char; + d->flush_chars = gs_flush_chars; + d->write_room = gs_write_room; + d->chars_in_buffer = gs_chars_in_buffer; + d->set_termios = gs_set_termios; + d->throttle = 0; /* NB85E_UART uarts have no hardware flow control */ + d->unthrottle = 0; /* " */ + d->stop = gs_stop; + d->start = gs_start; + d->hangup = gs_hangup; + d->flush_buffer = gs_flush_buffer; + + init_nb85e_uart_tty_ports (); + + tty_register_driver (&nb85e_uart_tty_driver); +} +__initcall (nb85e_uart_tty_init); diff -ruP -Xcludes linux-2.4.6.uclinux-orig/fs/ChangeLog linux-2.4.6/fs/ChangeLog --- linux-2.4.6.uclinux-orig/fs/ChangeLog Sun May 16 15:43:05 1999 +++ linux-2.4.6/fs/ChangeLog Thu Aug 30 11:44:39 2001 @@ -1,3 +1,12 @@ +2001-08-30 Miles Bader + + * binfmt_flat.c (load_flat_binary): Don't use the executable's + entry point as the start of the text segment (it may not be). + Skip header correctly when calculating start_code/end_code. + Don't assume data follows text when calculating end_code. + Relocate non-longword-aligned pointers correctly. + Include . + Mon Oct 24 23:27:42 1994 Theodore Y. Ts'o (tytso@rt-11) * fcntl.c (sys_fcntl): Liberalize security checks which Alan Cox diff -ruP -Xcludes linux-2.4.6.uclinux-orig/fs/binfmt_flat.c linux-2.4.6/fs/binfmt_flat.c --- linux-2.4.6.uclinux-orig/fs/binfmt_flat.c Mon Aug 27 17:12:20 2001 +++ linux-2.4.6/fs/binfmt_flat.c Fri Sep 7 16:47:40 2001 @@ -1,7 +1,7 @@ /* * linux/fs/binfmt_flat.c * - * Copyright (C) 2000 Lineo, by David McCullough + * Copyright (C) 2000, 2001 Lineo, by David McCullough * based heavily on: * * linux/fs/binfmt_aout.c: @@ -37,6 +37,7 @@ #include #include #include +#include #ifdef DEBUG #define DBG_FLT(a...) printk(##a) @@ -535,11 +536,14 @@ */ if (flags & FLAT_FLAG_GZIP) { result = decompress_exec(bprm, - ntohl(hdr->entry), - ((char *) textpos) + ntohl(hdr->entry), - text_len + data_len + (relocs * sizeof(unsigned long)) - - ntohl(hdr->entry), - 0); + sizeof (struct flat_hdr), + (((char *) textpos) + + sizeof (struct flat_hdr)), + (text_len + data_len + + (relocs + * sizeof(unsigned long)) + - sizeof (struct flat_hdr)), + 0); if (result >= (unsigned long) -4096) { printk("Unable to decompress data+bss, errno %d\n", (int)-result); @@ -560,7 +564,7 @@ } } - datapos = textpos + text_len; + datapos = textpos + ntohl (hdr->data_start); reloc = (unsigned long *) (textpos + ntohl(hdr->reloc_start)); memp = textpos; memkasked = text_len + data_len + extra; @@ -569,8 +573,8 @@ DBG_FLT("Mapping is %x, Entry point is %x, data_start is %x\n", textpos, ntohl(hdr->entry), ntohl(hdr->data_start)); - current->mm->start_code = textpos + ntohl(hdr->entry); - current->mm->end_code = textpos + ntohl(hdr->data_start); + current->mm->start_code = textpos + sizeof (struct flat_hdr); + current->mm->end_code = textpos + sizeof (struct flat_hdr) + text_len; current->mm->start_data = datapos; current->mm->end_data = datapos + data_len; #ifdef NO_MM @@ -624,9 +628,34 @@ if (rev > OLD_FLAT_VERSION) { for (i=0; i < relocs; i++) { + unsigned long addr; + + /* Get the address of the pointer to be + relocated (of course, the address has to be + relocated first). */ rp = (unsigned long *) calc_reloc(ntohl(reloc[i]), text_len); - if (*rp != 0) - *rp = calc_reloc(ntohl(*rp), text_len); /* And relocate it */ + + /* Get the pointer's value. */ + if (((unsigned long)rp & 0x3) == 0) + /* RP is longword aligned. */ + addr = *rp; + else + /* RP is not longword aligned; deal with it. */ + addr = get_unaligned (rp); + + if (addr != 0) { + /* Do the relocation. */ + addr = calc_reloc (ntohl (addr), text_len); + + /* Write back the relocated pointer. */ + if (((unsigned long)rp & 0x3) == 0) + /* RP is longword aligned. */ + *rp = addr; + else + /* RP is not longword aligned; + deal with it. */ + put_unaligned (addr, rp); + } } } else { for (i=0; i < relocs; i++) @@ -657,9 +686,11 @@ current->mm->start_stack = (unsigned long) create_flat_tables(p, bprm); - DBG_FLT("start_thread(regs=0x%x, start_code=0x%x, start_stack=0x%x)\n", - regs, current->mm->start_code, current->mm->start_stack); - start_thread(regs, current->mm->start_code, current->mm->start_stack); + DBG_FLT("start_thread(regs=0x%x, entry=0x%x, start_stack=0x%x)\n", + regs, textpos + ntohl(hdr->entry), current->mm->start_stack); + start_thread(regs, + textpos + ntohl(hdr->entry), + current->mm->start_stack); if (current->ptrace & PT_PTRACED) send_sig(SIGTRAP, current, 0); diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/a.out.h linux-2.4.6/include/asm-v850/a.out.h --- linux-2.4.6.uclinux-orig/include/asm-v850/a.out.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/a.out.h Wed Aug 29 10:57:41 2001 @@ -0,0 +1,26 @@ +#ifndef __V850_A_OUT_H__ +#define __V850_A_OUT_H__ + +struct exec +{ + unsigned long a_info; /* Use macros N_MAGIC, etc for access */ + unsigned a_text; /* length of text, in bytes */ + unsigned a_data; /* length of data, in bytes */ + unsigned a_bss; /* length of uninitialized data area for file, in bytes */ + unsigned a_syms; /* length of symbol table data in file, in bytes */ + unsigned a_entry; /* start address */ + unsigned a_trsize; /* length of relocation info for text, in bytes */ + unsigned a_drsize; /* length of relocation info for data, in bytes */ +}; + +#define N_TRSIZE(a) ((a).a_trsize) +#define N_DRSIZE(a) ((a).a_drsize) +#define N_SYMSIZE(a) ((a).a_syms) + +#ifdef __KERNEL__ + +#define STACK_TOP TASK_SIZE + +#endif + +#endif /* __V850_A_OUT_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/asm.h linux-2.4.6/include/asm-v850/asm.h --- linux-2.4.6.uclinux-orig/include/asm-v850/asm.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/asm.h Tue Sep 11 15:26:41 2001 @@ -0,0 +1,30 @@ +/* + * include/asm-v850/asm.h -- Macros for writing assembly code + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#undef __ALIGN +#undef __ALIGN_STR +#define __ALIGN .align 4 +#define __ALIGN_STR ".align 4" + +#define G_ENTRY(name) \ + __ALIGN; \ + .globl name; \ + .type name,@function; \ + name +#define END(name) \ + .size name,.-name + +#define L_ENTRY(name) \ + __ALIGN; \ + .type name,@function; \ + name diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/atomic.h linux-2.4.6/include/asm-v850/atomic.h --- linux-2.4.6.uclinux-orig/include/asm-v850/atomic.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/atomic.h Wed Oct 10 10:55:06 2001 @@ -0,0 +1,83 @@ +/* + * include/asm-v850/atomic.h -- Atomic operations + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_ATOMIC_H__ +#define __V850_ATOMIC_H__ + +#include + +#include + +#ifdef CONFIG_SMP +#error SMP not supported +#endif + +typedef struct { int counter; } atomic_t; + +#define ATOMIC_INIT(i) { (i) } + +#ifdef __KERNEL__ + +#define atomic_read(v) ((v)->counter) +#define atomic_set(v,i) (((v)->counter) = (i)) + +extern __inline__ int atomic_add_return (int i, volatile atomic_t *v) +{ + unsigned long flags; + int res; + + __save_flags_cli (flags); + res = v->counter + i; + v->counter = res; + __restore_flags (flags); + + return res; +} + +static __inline__ int atomic_sub_return (int i, volatile atomic_t *v) +{ + unsigned long flags; + int res; + + __save_flags_cli (flags); + res = v->counter - i; + v->counter = res; + __restore_flags (flags); + + return res; +} + +static __inline__ void atomic_clear_mask (unsigned long mask, unsigned long *addr) +{ + unsigned long flags; + + __save_flags_cli (flags); + *addr &= ~mask; + __restore_flags (flags); +} + +#endif + +#define atomic_add(i, v) atomic_add_return ((i), (v)) +#define atomic_sub(i, v) atomic_sub_return ((i), (v)) + +#define atomic_dec_return(v) atomic_sub_return (1, (v)) +#define atomic_inc_return(v) atomic_add_return (1, (v)) +#define atomic_inc(v) atomic_inc_return (v) +#define atomic_dec(v) atomic_dec_return (v) + +#define atomic_sub_and_test(i,v) (atomic_sub_return ((i), (v)) == 0) +#define atomic_dec_and_test(v) (atomic_sub_return (1, (v)) == 0) +#define atomic_add_negative(i,v) (atomic_add_return ((i), (v)) < 0) + +#endif /* __V850_ATOMIC_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/bitops.h linux-2.4.6/include/asm-v850/bitops.h --- linux-2.4.6.uclinux-orig/include/asm-v850/bitops.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/bitops.h Wed Oct 10 10:55:06 2001 @@ -0,0 +1,253 @@ +/* + * include/asm-v850/bitops.h -- Bit operations + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * Copyright (C) 1992 Linus Torvalds. + * + * 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 __V850_BITOPS_H__ +#define __V850_BITOPS_H__ + + +#include +#include /* swab32 */ +#include /* save_flags */ + +#ifdef __KERNEL__ + +/* + * The __ functions are not atomic + */ + +extern void set_bit (int nr, volatile void *addr); +extern void __set_bit (int nr, volatile void *addr); +extern void clear_bit (int nr, volatile void *addr); +extern void change_bit (int nr, volatile void *addr); +extern void __change_bit (int nr, volatile void *addr); +extern int test_and_set_bit (int nr, volatile void *addr); +extern int __test_and_set_bit (int nr, volatile void *addr); +extern int test_and_clear_bit (int nr, volatile void *addr); +extern int __test_and_clear_bit (int nr, volatile void *addr); +extern int test_and_change_bit (int nr, volatile void *addr); +extern int __test_and_change_bit (int nr, volatile void *addr); +extern int __constant_test_bit (int nr, const volatile void *addr); +extern int __test_bit (int nr, volatile void *addr); +extern int find_first_zero_bit (void *addr, unsigned size); +extern int find_next_zero_bit (void *addr, int size, int offset); + +/* + * ffz = Find First Zero in word. Undefined if no zero exists, + * so code should check against ~0UL first.. + */ +extern __inline__ unsigned long ffz (unsigned long word) +{ + unsigned long result = 0; + + while (word & 1) { + result++; + word >>= 1; + } + return result; +} + + +/* + * Note -- the following definitions generate warnings of the following + * form: `asm operand 0 probably doesn't match constraints', which are + * certainly bogus, because they are all register constrainst, so any + * operand should just be forced into a register. However I don't know + * how to disable the warning. + */ + +extern __inline__ void set_bit (int nr, volatile void *addr) +{ + __asm__ __volatile__ ("set1 %0, [%1]" + : : "r" (nr & 0x7), "r" (addr + (nr >> 3))); +} + +extern __inline__ void __set_bit (int nr, volatile void *addr) +{ + __asm__ __volatile__ ("set1 %0, [%1]" + : : "r" (nr & 0x7), "r" (addr + (nr >> 3))); +} + +/* + * clear_bit () doesn't provide any barrier for the compiler. + */ +#define smp_mb__before_clear_bit() barrier () +#define smp_mb__after_clear_bit() barrier () + +extern __inline__ void clear_bit (int nr, volatile void *addr) +{ + __asm__ __volatile__ ("clr1 %0, [%1]" + : : "r" (nr & 0x7), "r" (addr + (nr >> 3))); +} + +extern __inline__ void change_bit (int nr, volatile void *addr) +{ + __asm__ __volatile__ ("not1 %0, [%1]" + : : "r" (nr & 0x7), "r" (addr + (nr >> 3))); +} + +extern __inline__ void __change_bit (int nr, volatile void *addr) +{ + __asm__ __volatile__ ("not1 %0, [%1]" + : : "r" (nr & 0x7), "r" (addr + (nr >> 3))); +} + +extern __inline__ int test_and_set_bit (int nr, volatile void *addr) +{ + int res, flags; + save_flags_cli (flags); + __asm__ __volatile__ ("tst1 %1, [%2]; setf nz, %0; set1 %1, [%2]" + : "=&r" (res) + : "r" (nr & 0x7), "r" (addr + (nr >> 3))); + restore_flags (flags); + return res; +} + +extern __inline__ int __test_and_set_bit (int nr, volatile void *addr) +{ + int res; + __asm__ __volatile__ ("tst1 %1, [%2]; setf nz, %0; set1 %1, [%2]" + : "=&r" (res) + : "r" (nr & 0x7), "r" (addr + (nr >> 3))); + return res; +} + +extern __inline__ int test_and_clear_bit (int nr, volatile void *addr) +{ + int res, flags; + save_flags_cli (flags); + __asm__ __volatile__ ("tst1 %1, [%2]; setf nz, %0; clr1 %1, [%2]" + : "=&r" (res) + : "r" (nr & 0x7), "r" (addr + (nr >> 3))); + restore_flags (flags); + return res; +} + +extern __inline__ int __test_and_clear_bit (int nr, volatile void *addr) +{ + int res; + __asm__ __volatile__ ("tst1 %1, [%2]; setf nz, %0; clr1 %1, [%2]" + : "=&r" (res) + : "r" (nr & 0x7), "r" (addr + (nr >> 3))); + return res; +} + +extern __inline__ int test_and_change_bit (int nr, volatile void *addr) +{ + int res, flags; + save_flags_cli (flags); + __asm__ __volatile__ ("tst1 %1, [%2]; setf nz, %0; not1 %1, [%2]" + : "=&r" (res) + : "r" (nr & 0x7), "r" (addr + (nr >> 3))); + restore_flags (flags); + return res; +} + +extern __inline__ int __test_and_change_bit (int nr, volatile void *addr) +{ + int res; + __asm__ __volatile__ ("tst1 %1, [%2]; setf nz, %0; not1 %1, [%2]" + : "=&r" (res) + : "r" (nr & 0x7), "r" (addr + (nr >> 3))); + return res; +} + +/* + * This routine doesn't need to be atomic. + */ +#define __constant_test_bit(nr, addr) \ + ({ \ + int res; \ + __asm__ __volatile__ ("tst1 %1, %2[%3]; setf nz, %0" \ + : "=r" (res) \ + : "i" (nr & 0x7), "i" (nr >> 3), "r" (addr)); \ + res; \ + }) + +extern __inline__ int __test_bit (int nr, volatile void *addr) +{ + int res; + __asm__ __volatile__ ("tst1 %1, [%2]; setf nz, %0" + : "=r" (res) + : "r" (nr & 0x7), "r" (addr + (nr >> 3))); + return res; +} + +#define test_bit(nr,addr) \ + (__builtin_constant_p (nr) \ + ? __constant_test_bit ((nr), (addr)) \ + : __test_bit ((nr), (addr))) + +#define find_first_zero_bit(addr, size) \ + find_next_zero_bit ((addr), (size), 0) + +extern __inline__ int find_next_zero_bit (void *addr, int size, int offset) +{ + unsigned long *p = ((unsigned long *) addr) + (offset >> 5); + unsigned long result = offset & ~31UL; + unsigned long tmp; + + if (offset >= size) + return size; + size -= result; + offset &= 31UL; + if (offset) { + tmp = * (p++); + tmp |= ~0UL >> (32-offset); + if (size < 32) + goto found_first; + if (~tmp) + goto found_middle; + size -= 32; + result += 32; + } + while (size & ~31UL) { + if (~ (tmp = * (p++))) + goto found_middle; + result += 32; + size -= 32; + } + if (!size) + return result; + tmp = *p; + + found_first: + tmp |= ~0UL >> size; + found_middle: + return result + ffz (tmp); +} + +#define ffs(x) generic_ffs (x) + +/* + * hweightN: returns the hamming weight (i.e. the number + * of bits set) of a N-bit word + */ +#define hweight32(x) generic_hweight32 (x) +#define hweight16(x) generic_hweight16 (x) +#define hweight8(x) generic_hweight8 (x) + +#define ext2_set_bit test_and_set_bit +#define ext2_clear_bit test_and_clear_bit +#define ext2_test_bit test_bit +#define ext2_find_first_zero_bit find_first_zero_bit +#define ext2_find_next_zero_bit find_next_zero_bit + +/* Bitmap functions for the minix filesystem. */ +#define minix_test_and_set_bit(nr,addr) test_and_set_bit (nr,addr) +#define minix_set_bit(nr,addr) set_bit (nr,addr) +#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit (nr,addr) +#define minix_test_bit(nr,addr) test_bit (nr,addr) +#define minix_find_first_zero_bit(addr,size) find_first_zero_bit (addr,size) + +#endif /* __KERNEL__ */ + +#endif /* __V850_BITOPS_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/blkmem.h linux-2.4.6/include/asm-v850/blkmem.h --- linux-2.4.6.uclinux-orig/include/asm-v850/blkmem.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/blkmem.h Wed Oct 10 14:09:31 2001 @@ -0,0 +1,23 @@ +/* + * include/asm-v850/blkmem.h -- `blkmem' device configuration + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_BLKMEM_H__ +#define __V850_BLKMEM_H__ + +/* Device specific memory array location. */ +#include + +/* Used by the blkmem flash programming code. */ +#define HARD_RESET_NOW() __asm__ __volatile__ ("jmp r0") + +#endif /* __V850_BLKMEM_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/bugs.h linux-2.4.6/include/asm-v850/bugs.h --- linux-2.4.6.uclinux-orig/include/asm-v850/bugs.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/bugs.h Wed Aug 29 10:56:06 2001 @@ -0,0 +1,16 @@ +/* + * include/asm-v850e/bugs.h + * + * Copyright (C) 1994 Linus Torvalds + */ + +/* + * This is included by init/main.c to check for architecture-dependent bugs. + * + * Needs: + * void check_bugs(void); + */ + +static void check_bugs(void) +{ +} diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/byteorder.h linux-2.4.6/include/asm-v850/byteorder.h --- linux-2.4.6.uclinux-orig/include/asm-v850/byteorder.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/byteorder.h Tue Sep 11 15:23:17 2001 @@ -0,0 +1,47 @@ +/* + * include/asm-v850/byteorder.h -- Endian id and conversion ops + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_BYTEORDER_H__ +#define __V850_BYTEORDER_H__ + +#include + +#ifdef __GNUC__ + +static __inline__ __const__ __u32 ___arch__swab32 (__u32 word) +{ + __u32 res; + __asm__ ("bsw %1, %0" : "=r" (res) : "r" (word)); + return res; +} + +static __inline__ __const__ __u16 ___arch__swab16 (__u16 half_word) +{ + __u16 res; + __asm__ ("bsh %1, %0" : "=r" (res) : "r" (half_word)); + return res; +} + +#define __arch__swab32(x) ___arch__swab32(x) +#define __arch__swab16(x) ___arch__swab16(x) + +#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) +# define __BYTEORDER_HAS_U64__ +# define __SWAB_64_THRU_32__ +#endif + +#endif /* __GNUC__ */ + +#include + +#endif /* __V850_BYTEORDER_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/cache.h linux-2.4.6/include/asm-v850/cache.h --- linux-2.4.6.uclinux-orig/include/asm-v850/cache.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/cache.h Wed Oct 10 13:49:57 2001 @@ -0,0 +1,25 @@ +/* + * include/asm-v850/cache.h -- Cache operations + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_CACHE_H__ +#define __V850_CACHE_H__ + +/* All cache operations are machine-dependent. */ +#include + +#ifndef L1_CACHE_BYTES +/* This processor has no cache, so just choose an arbitrary value. */ +#define L1_CACHE_BYTES 16 +#endif + +#endif /* __V850_CACHE_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/checksum.h linux-2.4.6/include/asm-v850/checksum.h --- linux-2.4.6.uclinux-orig/include/asm-v850/checksum.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/checksum.h Tue Sep 11 15:11:43 2001 @@ -0,0 +1,108 @@ +/* + * include/asm-v850/checksum.h -- Checksum ops + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_CHECKSUM_H__ +#define __V850_CHECKSUM_H__ + +/* + * computes the checksum of a memory block at buff, length len, + * and adds in "sum" (32-bit) + * + * returns a 32-bit number suitable for feeding into itself + * or csum_tcpudp_magic + * + * this function must be called with even lengths, except + * for the last fragment, which may be odd + * + * it's best to have buff aligned on a 32-bit boundary + */ +unsigned int csum_partial (const unsigned char * buff, int len, + unsigned int sum); + +/* + * the same as csum_partial, but copies from src while it + * checksums + * + * here even more important to align src and dst on a 32-bit (or even + * better 64-bit) boundary + */ +unsigned int csum_partial_copy (const char *src, char *dst, int len, int sum); + + +/* + * the same as csum_partial_copy, but copies from user space. + * + * here even more important to align src and dst on a 32-bit (or even + * better 64-bit) boundary + */ +extern unsigned int csum_partial_copy_from_user (const char *src, char *dst, + int len, int sum, + int *csum_err); + +#define csum_partial_copy_nocheck(src, dst, len, sum) \ + csum_partial_copy ((src), (dst), (len), (sum)) + +unsigned short ip_fast_csum (unsigned char *iph, unsigned int ihl); + +/* + * Fold a partial checksum + */ +static inline unsigned int csum_fold (unsigned int sum) +{ + sum = (sum & 0xffff) + (sum >> 16); + sum = (sum & 0xffff) + (sum >> 16); + return ~sum; +} + + +/* + * computes the checksum of the TCP/UDP pseudo-header + * returns a 16-bit checksum, already complemented + */ +static inline unsigned int +csum_tcpudp_nofold (unsigned long saddr, unsigned long daddr, + unsigned short len, + unsigned short proto, unsigned int sum) +{ + int __carry; + __asm__ ("add %1, %0;" + "setf c, %2;" + "add %2, %0;" + "add %5, %0;" + "setf c, %2;" + "add %2, %0;" + "add %6, %0;" + "setf c, %2;" + "add %2, %0" + : "=&r" (sum), "=&r" (saddr), "=&r" (__carry) + : "0" (daddr), "1" (saddr), "r" (len + proto), + "r" (sum)); + return sum; +} + +static inline unsigned short int +csum_tcpudp_magic (unsigned long saddr, unsigned long daddr, + unsigned short len, + unsigned short proto, unsigned int sum) +{ + return csum_fold (csum_tcpudp_nofold (saddr,daddr,len,proto,sum)); +} + +/* + * this routine is used for miscellaneous IP-like checksums, mainly + * in icmp.c + */ +extern unsigned short ip_compute_csum (const unsigned char * buff, int len); + + +#endif /* __V850_CHECKSUM_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/clinkage.h linux-2.4.6/include/asm-v850/clinkage.h --- linux-2.4.6.uclinux-orig/include/asm-v850/clinkage.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/clinkage.h Tue Sep 11 15:35:51 2001 @@ -0,0 +1,19 @@ +/* + * include/asm-v850/clinkage.h -- Macros to reflect C symbol-naming conventions + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#include +#include + +#define C_SYMBOL_NAME(name) macrology_paste(_, name) +#define C_ENTRY(name) G_ENTRY(C_SYMBOL_NAME(name)) +#define C_END(name) END(C_SYMBOL_NAME(name)) diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/current.h linux-2.4.6/include/asm-v850/current.h --- linux-2.4.6.uclinux-orig/include/asm-v850/current.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/current.h Tue Sep 11 15:32:19 2001 @@ -0,0 +1,59 @@ +/* + * include/asm-v850/current.h -- Current task + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_CURRENT_H__ +#define __V850_CURRENT_H__ + +#include + + +/* The size allocated for kernel stacks. This _must_ be a power of two! */ +#define KERNEL_STACK_SIZE 0x2000 + + +/* Register used to hold the current task pointer while in the kernel. + Any `call clobbered' register without a special meaning should be OK, + but check asm/v850/kernel/entry.S to be sure. */ +#define CURRENT_TASK_REGNUM 16 +#define CURRENT_TASK macrology_paste (r, CURRENT_TASK_REGNUM) + + +/* The alignment of kernel stacks, with task structures at their base. + Thus, a pointer for a task's task structure can be derived from its + kernel stack pointer. */ +#define CURRENT_TASK_ALIGNMENT KERNEL_STACK_SIZE +#define CURRENT_TASK_MASK (-CURRENT_TASK_ALIGNMENT) + + +#ifdef __ASSEMBLY__ + +/* Put a pointer to the current task structure into REG. Note that this + definition requires CURRENT_TASK_MASK to be representable as a + signed 16-bit value. */ +#define GET_CURRENT_TASK(reg) \ + /* Use `addi' and then `and' instead of just `andi', because \ + `addi' sign-extends the immediate value, whereas `andi' \ + zero-extends it. */ \ + addi CURRENT_TASK_MASK, r0, reg; \ + and sp, reg + +#else /* !__ASSEMBLY__ */ + +/* A pointer to the current task. */ +register struct task_struct *current \ + __asm__ (macrology_stringify (CURRENT_TASK)); + +#endif /* __ASSEMBLY__ */ + + +#endif /* _V850_CURRENT_H */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/delay.h linux-2.4.6/include/asm-v850/delay.h --- linux-2.4.6.uclinux-orig/include/asm-v850/delay.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/delay.h Wed Oct 10 13:50:03 2001 @@ -0,0 +1,46 @@ +/* + * include/asm-v850/delay.h -- Delay routines, using a pre-computed + * "loops_per_second" value + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * Copyright (C) 1994 Hamish Macdonald + * + * 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 __V850_DELAY_H__ +#define __V850_DELAY_H__ + +#include + +extern __inline__ void __delay(unsigned long loops) +{ + __asm__ __volatile__ ("1: add -1, %0; bnz 1b" + : "=r" (loops) : "0" (loops)); +} + +/* + * Use only for very small delays ( < 1 msec). Should probably use a + * lookup table, really, as the multiplications take much too long with + * short delays. This is a "reasonable" implementation, though (and the + * first constant multiplications gets optimized away if the delay is + * a constant) + */ + +extern unsigned long loops_per_jiffy; + +extern __inline__ void udelay(unsigned long usecs) +{ + register unsigned long full_loops, part_loops; + + full_loops = ((usecs * HZ) / 1000000) * loops_per_jiffy; + usecs %= (1000000 / HZ); + part_loops = (usecs * HZ * loops_per_jiffy) / 1000000; + + __delay(full_loops + part_loops); +} + +#endif /* __V850_DELAY_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/div64.h linux-2.4.6/include/asm-v850/div64.h --- linux-2.4.6.uclinux-orig/include/asm-v850/div64.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/div64.h Wed Aug 29 10:59:00 2001 @@ -0,0 +1,11 @@ +#ifndef __V850_DIV64_H__ +#define __V850_DIV64_H__ + +/* We're not 64-bit, but... */ +#define do_div(n,base) ({ \ + int __res; \ + __res = ((unsigned long) n) % (unsigned) base; \ + n = ((unsigned long) n) / (unsigned) base; \ + __res; }) + +#endif /* __V850_DIV64_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/dma.h linux-2.4.6/include/asm-v850/dma.h --- linux-2.4.6.uclinux-orig/include/asm-v850/dma.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/dma.h Wed Aug 29 10:58:28 2001 @@ -0,0 +1,14 @@ +#ifndef __V850_DMA_H__ +#define __V850_DMA_H__ + +/* What should this be? */ +#define MAX_DMA_ADDRESS 0xFFFFFFFF + +/* reserve a DMA channel */ +extern int request_dma (unsigned int dmanr, const char * device_id); +/* release it again */ +extern void free_dma (unsigned int dmanr); + +#define isa_dma_bridge_buggy (0) + +#endif /* __V850_DMA_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/elf.h linux-2.4.6/include/asm-v850/elf.h --- linux-2.4.6.uclinux-orig/include/asm-v850/elf.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/elf.h Tue Sep 25 16:22:44 2001 @@ -0,0 +1,82 @@ +#ifndef __V850_ELF_H__ +#define __V850_ELF_H__ + +/* + * ELF register definitions.. + */ + +#include +#include +#include + +typedef unsigned long elf_greg_t; + +#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t)) +typedef elf_greg_t elf_gregset_t[ELF_NGREG]; + +typedef struct user_fpu_struct 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_CYGNUS_V850 ) + +/* + * These are used to set parameters in the core dumps. + */ +#define ELF_CLASS ELFCLASS32 +#ifdef __LITTLE_ENDIAN__ +#define ELF_DATA ELFDATA2LSB +#else +#define ELF_DATA ELFDATA2MSB +#endif +#define ELF_ARCH EM_CYGNUS_V850 + +#define USE_ELF_CORE_DUMP +#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 (2 * TASK_SIZE / 3) + + +#define ELF_CORE_COPY_REGS(_dest,_regs) \ + memcpy((char *) &_dest, (char *) _regs, \ + sizeof(struct pt_regs)); + +/* This yields a mask that user programs can use to figure out what + instruction set this CPU supports. This could be done in user space, + but it's not easy, and we've already done it here. */ + +#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. + + For the moment, we have only optimizations for the Intel generations, + but that could change... */ + +#define ELF_PLATFORM (NULL) + +#define ELF_PLAT_INIT(_r) \ + do { \ + _r->gpr[0] = _r->gpr[1] = _r->gpr[2] = _r->gpr[3] = \ + _r->gpr[4] = _r->gpr[5] = _r->gpr[6] = _r->gpr[7] = \ + _r->gpr[8] = _r->gpr[9] = _r->gpr[10] = _r->gpr[11] = \ + _r->gpr[12] = _r->gpr[13] = _r->gpr[14] = _r->gpr[15] = \ + _r->gpr[16] = _r->gpr[17] = _r->gpr[18] = _r->gpr[19] = \ + _r->gpr[20] = _r->gpr[21] = _r->gpr[22] = _r->gpr[23] = \ + _r->gpr[24] = _r->gpr[25] = _r->gpr[26] = _r->gpr[27] = \ + _r->gpr[28] = _r->gpr[29] = _r->gpr[30] = _r->gpr[31] = \ + 0; \ + } while (0) + +#ifdef __KERNEL__ +#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) +#endif + +#endif /* __V850_ELF_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/entry.h linux-2.4.6/include/asm-v850/entry.h --- linux-2.4.6.uclinux-orig/include/asm-v850/entry.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/entry.h Wed Oct 10 13:48:51 2001 @@ -0,0 +1,110 @@ +/* + * include/asm-v850/entry.h -- Definitions used by low-level trap handlers + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_ENTRY_H__ +#define __V850_ENTRY_H__ + + +#include +#include + + +/* If true, system calls save and restore all registers (except result + registers, of course). If false, then `call clobbered' registers + will not be preserved, on the theory that system calls are basically + function calls anyway, and the caller should be able to deal with it. + This is a security risk, of course, as `internal' values may leak out + after a system call, but that certainly doesn't matter very much for + a processor with no MMU protection! For a protected-mode kernel, it + would be faster to just zero those registers before returning. */ +#define TRAPS_PRESERVE_CALL_CLOBBERED_REGS 0 + +/* If TRAPS_PRESERVE_CALL_CLOBBERED_REGS is false, then zero `call + clobbered' registers before returning from a system call. */ +#define TRAPS_ZERO_CALL_CLOBBERED_REGS 0 + + +/* These are special variables using by the kernel trap/interrupt code + to save registers in, at a time when there are no spare registers we + can use to do so, and we can't depend on the value of the stack + pointer. This means that they must be within a signed 16-bit + displacement of 0x00000000. */ + +#define KERNEL_VAR_SPACE_ADDR ON_CHIP_RAM_ADDR +#define KERNEL_VAR_SPACE_SIZE 12 + +#ifdef __ASSEMBLY__ +#define KERNEL_VAR(addr) addr[r0] +#else +#define KERNEL_VAR(addr) (*(volatile unsigned long *)(addr)) +#endif + +/* temporary storage for user stack pointer, 4 bytes */ +#define USP_SCRATCH_ADDR KERNEL_VAR_SPACE_ADDR +#define USP_SCRATCH KERNEL_VAR (USP_SCRATCH_ADDR) +/* kernel stack pointer, 4 bytes */ +#define KSP_ADDR (KERNEL_VAR_SPACE_ADDR + 4) +#define KSP KERNEL_VAR (KSP_ADDR) +/* 1 if in kernel-mode, 0 if in user mode, 1 byte */ +#define KM_ADDR (KERNEL_VAR_SPACE_ADDR + 8) +#define KM KERNEL_VAR (KM_ADDR) + +/* Used to detect unexpected resets (since the v850 has no MMU, any call + through a null pointer will jump to the reset vector). We detect + such resets by checking for a magic value, RESET_GUARD_ACTIVE, in + this location. Properly resetting the machine stores zero there, so + it shouldn't trigger the guard; the power-on value is uncertain, but + it's unlikely to be RESET_GUARD_ACTIVE. */ +#define RESET_GUARD_ADDR (KERNEL_VAR_SPACE_ADDR + 12) +#define RESET_GUARD KERNEL_VAR (RESET_GUARD_ADDR) +#define RESET_GUARD_ACTIVE 0xFAB4BEEF + +#ifndef __ASSEMBLY__ + +/* Turn off reset guard, so that resetting the machine works normally. + This should be called in the various machine_halt, etc., functions. */ +static inline void disable_reset_guard (void) +{ + RESET_GUARD = 0; +} + +#endif /* !__ASSEMBLY__ */ + + +/* A `state save frame' is a struct pt_regs preceded by some extra space + suitable for a function call stack frame. */ + +/* Amount of room on the stack reserved for arguments and to satisfy the + C calling conventions, in addition to the space used by the struct + pt_regs that actually holds saved values. */ +#define STATE_SAVE_ARG_SPACE (6*4) /* Up to six arguments. */ + + +#ifdef __ASSEMBLY__ + +/* The size of a state save frame. */ +#define STATE_SAVE_SIZE (PT_SIZE + STATE_SAVE_ARG_SPACE) + +#else /* !__ASSEMBLY__ */ + +/* The size of a state save frame. */ +#define STATE_SAVE_SIZE (sizeof (struct pt_regs) + STATE_SAVE_ARG_SPACE) + +#endif /* __ASSEMBLY__ */ + + +/* Offset of the struct pt_regs in a state save frame. */ +#define STATE_SAVE_PT_OFFSET STATE_SAVE_ARG_SPACE + + +#endif /* __V850_ENTRY_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/errno.h linux-2.4.6/include/asm-v850/errno.h --- linux-2.4.6.uclinux-orig/include/asm-v850/errno.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/errno.h Wed Aug 29 10:57:58 2001 @@ -0,0 +1,132 @@ +#ifndef __V850_ERRNO_H__ +#define __V850_ERRNO_H__ + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ + +#endif /* __V850_ERRNO_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/fcntl.h linux-2.4.6/include/asm-v850/fcntl.h --- linux-2.4.6.uclinux-orig/include/asm-v850/fcntl.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/fcntl.h Wed Aug 29 10:57:50 2001 @@ -0,0 +1,86 @@ +#ifndef __V850_FCNTL_H__ +#define __V850_FCNTL_H__ + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_NOCTTY 0400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#define O_SYNC 010000 +#define FASYNC 020000 /* fcntl, for BSD compatibility */ +#define O_DIRECTORY 040000 /* must be a directory */ +#define O_NOFOLLOW 0100000 /* don't follow links */ +#define O_DIRECT 0200000 /* direct disk access hint - currently ignored */ +#define O_LARGEFILE 0400000 + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get close_on_exec */ +#define F_SETFD 2 /* set/clear close_on_exec */ +#define F_GETFL 3 /* get file->f_flags */ +#define F_SETFL 4 /* set file->f_flags */ +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ + +#define F_GETLK64 12 /* using 'struct flock64' */ +#define F_SETLK64 13 +#define F_SETLKW64 14 + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* for leases */ +#define F_INPROGRESS 16 + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#define LOCK_MAND 32 /* This is a mandatory flock */ +#define LOCK_READ 64 /* ... Which allows concurrent read operations */ +#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */ +#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */ + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +struct flock64 { + short l_type; + short l_whence; + loff_t l_start; + loff_t l_len; + pid_t l_pid; +}; + +#define F_LINUX_SPECIFIC_BASE 1024 +#endif /* __V850_FCNTL_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/hardirq.h linux-2.4.6/include/asm-v850/hardirq.h --- linux-2.4.6.uclinux-orig/include/asm-v850/hardirq.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/hardirq.h Wed Oct 10 13:49:58 2001 @@ -0,0 +1,41 @@ +#ifndef __V850_HARDIRQ_H__ +#define __V850_HARDIRQ_H__ + +#include +#include +#include + +typedef struct { + unsigned int __softirq_pending; + unsigned int __local_irq_count; + unsigned int __local_bh_count; + unsigned int __syscall_count; +} ____cacheline_aligned irq_cpustat_t; + +#include /* Standard mappings for irq_cpustat_t above */ + +/* + * Are we in an interrupt context? Either doing bottom half + * or hardware interrupt processing? + */ +#define in_interrupt() (local_irq_count(smp_processor_id()) + local_bh_count(smp_processor_id()) != 0) + +#define in_irq() (local_irq_count(smp_processor_id()) != 0) + +#ifndef CONFIG_SMP + +#define hardirq_trylock(cpu) (local_irq_count(cpu) == 0) +#define hardirq_endlock(cpu) do { } while (0) + +#define irq_enter(cpu, irq) (local_irq_count(cpu)++) +#define irq_exit(cpu, irq) (local_irq_count(cpu)--) + +#define synchronize_irq() barrier() + +#else + +#error v850 SMP is not available + +#endif /* CONFIG_SMP */ + +#endif /* __V850_HARDIRQ_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/hw_irq.h linux-2.4.6/include/asm-v850/hw_irq.h --- linux-2.4.6.uclinux-orig/include/asm-v850/hw_irq.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/hw_irq.h Thu Sep 6 16:02:13 2001 @@ -0,0 +1,8 @@ +#ifndef __V850_HW_IRQ_H__ +#define __V850_HW_IRQ_H__ + +extern inline void hw_resend_irq (struct hw_interrupt_type *h, unsigned int i) +{ +} + +#endif /* __V850_HW_IRQ_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/io.h linux-2.4.6/include/asm-v850/io.h --- linux-2.4.6.uclinux-orig/include/asm-v850/io.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/io.h Tue Sep 11 14:31:31 2001 @@ -0,0 +1,46 @@ +/* + * include/asm-v850/io.h -- Misc I/O operations + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_IO_H__ +#define __V850_IO_H__ + +#define IO_SPACE_LIMIT 0xFFFFFFFF + +#define readb(addr) \ + ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; }) +#define readw(addr) \ + ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; }) +#define readl(addr) \ + ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; }) + +#define writeb(b,addr) \ + (void)((*(volatile unsigned char *) (addr)) = (b)) +#define writew(b,addr) \ + (void)((*(volatile unsigned short *) (addr)) = (b)) +#define writel(b,addr) \ + (void)((*(volatile unsigned int *) (addr)) = (b)) + +#define inb(addr) readb (addr) +#define inw(addr) readw (addr) +#define inl(addr) readl (addr) +#define outb(x,addr) ((void) writeb (x,addr)) +#define outw(x,addr) ((void) writew (x,addr)) +#define outl(x,addr) ((void) writel (x,addr)) + +#define iounmap(addr) ((void)0) +#define ioremap(physaddr, size) (physaddr) +#define ioremap_nocache(physaddr, size) (physaddr) +#define ioremap_writethrough(physaddr, size) (physaddr) +#define ioremap_fullcache(physaddr, size) (physaddr) + +#endif /* __V850_IO_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/ioctl.h linux-2.4.6/include/asm-v850/ioctl.h --- linux-2.4.6.uclinux-orig/include/asm-v850/ioctl.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/ioctl.h Wed Aug 29 10:58:07 2001 @@ -0,0 +1,80 @@ +/* $Id: ioctl.h,v 1.3 1997/04/16 15:10:07 jes Exp $ + * + * linux/ioctl.h for Linux by H.H. Bergman. + */ + +#ifndef _V850_IOCTL_H +#define _V850_IOCTL_H + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +/* + * I don't really have any idea about what this should look like, so + * for the time being, this is heavily based on the PC definitions. + */ + +/* + * The following is for compatibility across the various Linux + * platforms. The i386 ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#endif /* __V850_IOCTL_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/ioctls.h linux-2.4.6/include/asm-v850/ioctls.h --- linux-2.4.6.uclinux-orig/include/asm-v850/ioctls.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/ioctls.h Wed Aug 29 10:58:24 2001 @@ -0,0 +1,80 @@ +#ifndef __V850_IOCTLS_H__ +#define __V850_IOCTLS_H__ + +#include + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +#endif /* __V850_IOCTLS_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/ipc.h linux-2.4.6/include/asm-v850/ipc.h --- linux-2.4.6.uclinux-orig/include/asm-v850/ipc.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/ipc.h Wed Aug 29 10:59:08 2001 @@ -0,0 +1,31 @@ +#ifndef __V850_IPC_H__ +#define __V850_IPC_H__ + +/* + * These are used to wrap system calls on v850. + * + * See arch/v850/kernel/syscalls.c for ugly details.. + */ +struct ipc_kludge { + struct msgbuf *msgp; + long msgtyp; +}; + +#define SEMOP 1 +#define SEMGET 2 +#define SEMCTL 3 +#define MSGSND 11 +#define MSGRCV 12 +#define MSGGET 13 +#define MSGCTL 14 +#define SHMAT 21 +#define SHMDT 22 +#define SHMGET 23 +#define SHMCTL 24 + +/* Used by the DIPC package, try and avoid reusing it */ +#define DIPC 25 + +#define IPCCALL(version,op) ((version)<<16 | (op)) + +#endif /* __V850_IPC_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/ipcbuf.h linux-2.4.6/include/asm-v850/ipcbuf.h --- linux-2.4.6.uclinux-orig/include/asm-v850/ipcbuf.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/ipcbuf.h Wed Aug 29 10:56:06 2001 @@ -0,0 +1,29 @@ +#ifndef __V850E_IPCBUF_H__ +#define __V850E_IPCBUF_H__ + +/* + * The user_ipc_perm structure for v850e architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 32-bit mode_t and seq + * - 2 miscellaneous 32-bit values + */ + +struct ipc64_perm +{ + __kernel_key_t key; + __kernel_uid32_t uid; + __kernel_gid32_t gid; + __kernel_uid32_t cuid; + __kernel_gid32_t cgid; + __kernel_mode_t mode; + unsigned short __pad1; + unsigned short seq; + unsigned short __pad2; + unsigned long __unused1; + unsigned long __unused2; +}; + +#endif /* __V850E_IPCBUF_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/irq.h linux-2.4.6/include/asm-v850/irq.h --- linux-2.4.6.uclinux-orig/include/asm-v850/irq.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/irq.h Wed Oct 10 13:50:03 2001 @@ -0,0 +1,43 @@ +/* + * include/asm-v850/irq.h -- Machine interrupt handling + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_IRQ_H__ +#define __V850_IRQ_H__ + +#include + +/* v850 processors have 3 non-maskable interrupts. */ +#define NUM_NMIS 3 + +/* Includes both maskable and non-maskable irqs. */ +#define NR_IRQS (NUM_MACH_IRQS + NUM_NMIS) +/* NMIs have IRQ numbers from FIRST_NMI to FIRST_NMI+NUM_NMIS-1. */ +#define FIRST_NMI NUM_MACH_IRQS + + +#ifndef __ASSEMBLY__ + +struct pt_regs; +struct hw_interrupt_type; +struct irqaction; + +/* Initialize irq handling for IRQs BASE to BASE+NUM-1 to IRQ_TYPE. + An IRQ_TYPE of 0 means to use a generic interrupt type. */ +extern void init_irq_handlers (int base_irq, int num, + struct hw_interrupt_type *irq_type); + +typedef void (*irq_handler_t)(int irq, void *data, struct pt_regs *regs); + +#endif /* !__ASSEMBLY__ */ + +#endif /* __V850_IRQ_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/ma.h linux-2.4.6/include/asm-v850/ma.h --- linux-2.4.6.uclinux-orig/include/asm-v850/ma.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/ma.h Wed Oct 10 13:43:14 2001 @@ -0,0 +1,67 @@ +/* + * include/asm-v850/ma.h -- V850E/MA series of cpu chips + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_MA_H__ +#define __V850_MA_H__ + + +/* The MA series uses the NB85E cpu core. */ +#include + + +/* On chip RAM. The amount various between chip models, but there's + always at least 4K, and it should always start at FFFFC000. */ +#define ON_CHIP_RAM_ADDR 0xFFFFC000 + + +/* MA series UART details. */ +#define NB85E_UART_BASE_ADDR 0xFFFFFA00 +#define NB85E_UART_ASIM_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x0) +#define NB85E_UART_ASIS_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x3) +#define NB85E_UART_ASIF_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x5) +#define NB85E_UART_TXB_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x4) +#define NB85E_UART_RXB_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x2) +#define NB85E_UART_CKSR_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x6) +#define NB85E_UART_BRGC_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x7) + +/* This is a function that gets called before configuring the UART. */ +#define NB85E_UART_PRE_CONFIGURE ma_uart_pre_configure +#ifndef __ASSEMBLY__ +extern void ma_uart_pre_configure (unsigned chan, + unsigned cflags, unsigned baud); +#endif + + +/* MA series timer D details. */ +#define NB85E_TIMER_D_BASE_ADDR 0xFFFFF540 +#define NB85E_TIMER_D_TMD_BASE_ADDR (NB85E_TIMER_D_BASE_ADDR + 0x0) +#define NB85E_TIMER_D_CMD_BASE_ADDR (NB85E_TIMER_D_BASE_ADDR + 0x2) +#define NB85E_TIMER_D_TMCD_BASE_ADDR (NB85E_TIMER_D_BASE_ADDR + 0x4) + + +/* Port 4 */ +/* Direct I/O. Bits 0-5 are pins P40-P45. */ +#define MA_PORT4_IO_ADDR 0xFFFFF408 +#define MA_PORT4_IO (*(volatile u8 *)MA_PORT4_IO_ADDR) +/* Port mode (for direct I/O, 0 = output, 1 = input). */ +#define MA_PORT4_PM_ADDR 0xFFFFF428 +#define MA_PORT4_PM (*(volatile u8 *)MA_PORT4_PM_ADDR) +/* Port mode control (0 = direct I/O mode, 1 = alternative I/O mode). */ +#define MA_PORT4_PMC_ADDR 0xFFFFF448 +#define MA_PORT4_PMC (*(volatile u8 *)MA_PORT4_PMC_ADDR) +/* Port function control (for serial interfaces, 0 = CSI, 1 = UART). */ +#define MA_PORT4_PFC_ADDR 0xFFFFF468 +#define MA_PORT4_PFC (*(volatile u8 *)MA_PORT4_PFC_ADDR) + + +#endif /* __V850_MA_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/ma1.h linux-2.4.6/include/asm-v850/ma1.h --- linux-2.4.6.uclinux-orig/include/asm-v850/ma1.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/ma1.h Wed Oct 10 13:44:53 2001 @@ -0,0 +1,46 @@ +/* + * include/asm-v850/ma1.h -- V850E/MA1 cpu chip + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_MA1_H__ +#define __V850_MA1_H__ + +/* Inherit more generic details from MA series. */ +#include + +#define CHIP "v850e/ma1" +#define CHIP_LONG "NEC V850E/MA1" + +/* Hardware-specific interrupt numbers (in the kernel IRQ namespace). */ +#define IRQ_INTOV(n) (n) /* 0-3 */ +#define IRQ_INTOV_NUM 4 +#define IRQ_INTCMD(n) (0x1c + (n)) /* interval timer interrupts 0-3 */ +#define IRQ_INTCMD_NUM 4 +#define IRQ_INTDMA(n) (0x20 + (n)) /* DMA interrupts 0-3 */ +#define IRQ_INTDMA_NUM 4 +#define IRQ_INTCSI(n) (0x24 + (n)*4)/* CSI 0-2 transmit/receive completion */ +#define IRQ_INTCSI_NUM 3 +#define IRQ_INTSER(n) (0x25 + (n)*4) /* UART 0-2 reception error */ +#define IRQ_INTSER_NUM 3 +#define IRQ_INTSR(n) (0x26 + (n)*4) /* UART 0-2 reception completion */ +#define IRQ_INTSR_NUM 3 +#define IRQ_INTST(n) (0x27 + (n)*4) /* UART 0-2 transmission completion */ +#define IRQ_INTST_NUM 3 + +/* For */ +#define NUM_MACH_IRQS 0x30 + +/* The MA1 has a UART with 3 channels. */ +#define NB85E_UART_NUM_CHANNELS 3 + + +#endif /* __V850_MA1_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/machdep.h linux-2.4.6/include/asm-v850/machdep.h --- linux-2.4.6.uclinux-orig/include/asm-v850/machdep.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/machdep.h Wed Oct 10 13:49:57 2001 @@ -0,0 +1,38 @@ +/* + * include/asm-v850/machdep.h -- Machine-dependent definitions + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_MACHDEP_H__ +#define __V850_MACHDEP_H__ + +#include + +/* chips */ +#ifdef CONFIG_V850E_MA1 +#include +#endif +#ifdef CONFIG_V850E_TEG +#include +#endif + +/* platforms */ +#ifdef CONFIG_RTE_MA1_CB +#include +#endif +#ifdef CONFIG_RTE_NB85E_CB +#include +#endif +#ifdef CONFIG_SIM +#include +#endif + +#endif /* __V850_MACHDEP_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/macrology.h linux-2.4.6/include/asm-v850/macrology.h --- linux-2.4.6.uclinux-orig/include/asm-v850/macrology.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/macrology.h Tue Sep 11 15:27:27 2001 @@ -0,0 +1,17 @@ +/* + * include/asm-v850/macrology.h -- Various useful CPP macros + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#define macrology_paste(arg1, arg2) macrology_paste_1(arg1, arg2) +#define macrology_paste_1(arg1, arg2) arg1 ## arg2 +#define macrology_stringify(sym) macrology_stringify_1(sym) +#define macrology_stringify_1(sym) #sym diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/mman.h linux-2.4.6/include/asm-v850/mman.h --- linux-2.4.6.uclinux-orig/include/asm-v850/mman.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/mman.h Wed Aug 29 10:58:36 2001 @@ -0,0 +1,38 @@ +#ifndef __V850_MMAN_H__ +#define __V850_MMAN_H__ + +#define PROT_READ 0x1 /* page can be read */ +#define PROT_WRITE 0x2 /* page can be written */ +#define PROT_EXEC 0x4 /* page can be executed */ +#define PROT_NONE 0x0 /* page can not be accessed */ + +#define MAP_SHARED 0x01 /* Share changes */ +#define MAP_PRIVATE 0x02 /* Changes are private */ +#define MAP_TYPE 0x0f /* Mask for type of mapping */ +#define MAP_FIXED 0x10 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x20 /* don't use a file */ + +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ +#define MAP_LOCKED 0x2000 /* pages are locked */ +#define MAP_NORESERVE 0x4000 /* don't check for reservations */ + +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ + +#define MCL_CURRENT 1 /* lock all current mappings */ +#define MCL_FUTURE 2 /* lock all future mappings */ + +#define MADV_NORMAL 0x0 /* default page-in behavior */ +#define MADV_RANDOM 0x1 /* page-in minimum required */ +#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ +#define MADV_WILLNEED 0x3 /* pre-fault pages */ +#define MADV_DONTNEED 0x4 /* discard these pages */ + +/* compatibility flags */ +#define MAP_ANON MAP_ANONYMOUS +#define MAP_FILE 0 + +#endif /* __V850_MMAN_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/mmu.h linux-2.4.6/include/asm-v850/mmu.h --- linux-2.4.6.uclinux-orig/include/asm-v850/mmu.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/mmu.h Wed Aug 29 10:57:47 2001 @@ -0,0 +1,7 @@ +#ifndef __V850_MMU_H__ +#define __V850_MMU_H__ + +/* Default "unsigned long" context */ +typedef unsigned long mm_context_t; + +#endif /* __V850_MMU_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/mmu_context.h linux-2.4.6/include/asm-v850/mmu_context.h --- linux-2.4.6.uclinux-orig/include/asm-v850/mmu_context.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/mmu_context.h Wed Aug 29 10:58:31 2001 @@ -0,0 +1,10 @@ +#ifndef __V850_MMU_CONTEXT_H__ +#define __V850_MMU_CONTEXT_H__ + +#define destroy_context(mm) ((void)0) +#define init_new_context(tsk,mm) 0 +#define switch_mm(prev,next,tsk,cpu) ((void)0) +#define activate_mm(prev,next) ((void)0) +#define enter_lazy_tlb(mm,tsk,cpu) ((void)0) + +#endif /* __V850_MMU_CONTEXT_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/module.h linux-2.4.6/include/asm-v850/module.h --- linux-2.4.6.uclinux-orig/include/asm-v850/module.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/module.h Wed Aug 29 10:58:33 2001 @@ -0,0 +1,8 @@ +#ifndef __V850_MODULE_H__ +#define __V850_MODULE_H__ + +#define module_map(x) vmalloc(x) +#define module_unmap(x) vfree(x) +#define module_arch_init(x) ((void)0) + +#endif /* __V850_MODULE_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/msgbuf.h linux-2.4.6/include/asm-v850/msgbuf.h --- linux-2.4.6.uclinux-orig/include/asm-v850/msgbuf.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/msgbuf.h Wed Aug 29 10:58:58 2001 @@ -0,0 +1,31 @@ +#ifndef __V850_MSGBUF_H__ +#define __V850_MSGBUF_H__ + +/* + * The msqid64_ds structure for v850 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 64-bit time_t to solve y2038 problem + * - 2 miscellaneous 32-bit values + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; + __kernel_time_t msg_stime; /* last msgsnd time */ + unsigned long __unused1; + __kernel_time_t msg_rtime; /* last msgrcv time */ + unsigned long __unused2; + __kernel_time_t msg_ctime; /* last change time */ + unsigned long __unused3; + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif /* __V850_MSGBUF_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/namei.h linux-2.4.6/include/asm-v850/namei.h --- linux-2.4.6.uclinux-orig/include/asm-v850/namei.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/namei.h Wed Aug 29 10:58:51 2001 @@ -0,0 +1,17 @@ +/* + * linux/include/asm-v850/namei.h + * + * Included from linux/fs/namei.c + */ + +#ifndef __V850_NAMEI_H__ +#define __V850_NAMEI_H__ + +/* This dummy routine maybe changed to something useful + * for /usr/gnemul/ emulation stuff. + * Look at asm-sparc/namei.h for details. + */ + +#define __emul_prefix() NULL + +#endif /* __V850_NAMEI_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/nb85e.h linux-2.4.6/include/asm-v850/nb85e.h --- linux-2.4.6.uclinux-orig/include/asm-v850/nb85e.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/nb85e.h Fri Oct 5 11:34:33 2001 @@ -0,0 +1,128 @@ +/* + * include/asm-v850/nb85e.h -- NB85E cpu core + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_NB85E_H__ +#define __V850_NB85E_H__ + +#ifndef __ASSEMBLY__ +/* A variable holding the frequency of the CPU. */ +extern unsigned long cpu_clock_freq; +#endif + + +/* Interrupt Controller (INTC). */ + +/* There are 4 16-bit `Interrupt Mask Registers' located contiguously + starting from this base. Each interrupt uses a single bit to + indicated enabled/disabled status. */ +#define NB85E_INTC_IMR_BASE_ADDR 0xFFFFF100 +#define NB85E_INTC_IMR_ADDR(irq) (NB85E_INTC_IMR_BASE_ADDR + ((irq) >> 3)) +#define NB85E_INTC_IMR_BIT(irq) ((irq) & 0x7) + +/* Each maskable interrupt has a single-byte control register at this + address. */ +#define NB85E_INTC_IC_BASE_ADDR 0xFFFFF110 +#define NB85E_INTC_IC_ADDR(irq) (NB85E_INTC_IC_BASE_ADDR + ((irq) << 1)) +#define NB85E_INTC_IC(irq) (*(char *)NB85E_INTC_IC_ADDR(irq)) +/* Encode priority PR for storing in an interrupt control register. */ +#define NB85E_INTC_IC_PR(pr) (pr) +/* Interrupt disable bit in an interrupt control register. */ +#define NB85E_INTC_IC_MK_BIT 6 +#define NB85E_INTC_IC_MK (1 << NB85E_INTC_IC_MK_BIT) +/* Interrupt pending flag in an interrupt control register. */ +#define NB85E_INTC_IC_IF_BIT 7 +#define NB85E_INTC_IC_IF (1 << NB85E_INTC_IC_IF_BIT) + +#ifndef __ASSEMBLY__ + +/* Enable interrupt handling for interrupt IRQ. */ +static inline void nb85e_intc_enable_irq (unsigned irq) +{ + __asm__ __volatile__ ("clr1 %0, [%1]" + :: "r" (NB85E_INTC_IMR_BIT (irq)), + "r" (NB85E_INTC_IMR_ADDR (irq)) + : "memory"); +} + +/* Disable interrupt handling for interrupt IRQ. Note that any + interrupts received while disabled will be delivered once the + interrupt is enabled again, unless they are explicitly cleared using + `nb85e_intc_clear_pending_irq'. */ +static inline void nb85e_intc_disable_irq (unsigned irq) +{ + __asm__ __volatile__ ("set1 %0, [%1]" + :: "r" (NB85E_INTC_IMR_BIT (irq)), + "r" (NB85E_INTC_IMR_ADDR (irq)) + : "memory"); +} + +/* Return true if interrupt handling for interrupt IRQ is enabled. */ +static inline int nb85e_intc_irq_enabled (unsigned irq) +{ + int rval; + __asm__ __volatile__ ("tst1 %1, [%2]; setf z, %0" + : "=r" (rval) + : "r" (NB85E_INTC_IMR_BIT (irq)), + "r" (NB85E_INTC_IMR_ADDR (irq))); + return rval; +} + +/* Disable irqs from 0 until LIMIT. LIMIT must be a multiple of 8. */ +static inline void _nb85e_intc_disable_irqs (unsigned limit) +{ + unsigned long addr; + for (addr = NB85E_INTC_IMR_BASE_ADDR; limit >= 8; addr++, limit -= 8) + *(char *)addr = 0xFF; +} + +/* Disable all irqs. This is purposely a macro, because NUM_MACH_IRQS + will be only be defined later. */ +#define nb85e_intc_disable_irqs() _nb85e_intc_disable_irqs (NUM_MACH_IRQS) + +/* Clear any pending interrupts for IRQ. */ +static inline void nb85e_intc_clear_pending_irq (unsigned irq) +{ + __asm__ __volatile__ ("clr1 %0, 0[%1]" + :: "i" (NB85E_INTC_IC_IF_BIT), + "r" (NB85E_INTC_IC_ADDR (irq)) + : "memory"); +} + +/* Return true if interrupt IRQ is pending (but disabled). */ +static inline int nb85e_intc_irq_pending (unsigned irq) +{ + int rval; + __asm__ __volatile__ ("tst1 %1, 0[%2]; setf nz, %0" + : "=r" (rval) + : "i" (NB85E_INTC_IC_IF_BIT), + "r" (NB85E_INTC_IC_ADDR (irq))); + return rval; +} + + +struct nb85e_intc_irq_init { + const char *name; /* name of interrupt type */ + unsigned base, num; /* range of kernel irq numbers for this type */ + unsigned priority; /* interrupt priority to assign */ +}; +struct hw_interrupt_type; /* fwd decl */ + +/* Initialize HW_IRQ_TYPES for INTC-controlled irqs described in array + INITS (which is terminated by an entry with the name field == 0). */ +extern void nb85e_intc_init_irq_types (struct nb85e_intc_irq_init *inits, + struct hw_interrupt_type *hw_irq_types); + +#endif /* !__ASSEMBLY__ */ + + +#endif /* __V850_NB85E_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/nb85e_cache.h linux-2.4.6/include/asm-v850/nb85e_cache.h --- linux-2.4.6.uclinux-orig/include/asm-v850/nb85e_cache.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/nb85e_cache.h Thu Oct 4 15:08:13 2001 @@ -0,0 +1,106 @@ +/* + * include/asm-v850/nb85e_cache_cache.h -- Cache control for NB85E_CACHE212 and + * NB85E_CACHE213 cache memories + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_NB85E_CACHE_H__ +#define __V850_NB85E_CACHE_H__ + +/* Cache control registers. */ +#define NB85E_CACHE_ICC_ADDR 0xFFFFF070 +#define NB85E_CACHE_DCC_ADDR 0xFFFFF078 + +/* Size of a cache line in bytes. */ +#define NB85E_CACHE_LINE_SIZE 16 + + +#ifndef __ASSEMBLY__ + +extern inline void nb85e_cache_flush_cache (unsigned long cache_control_addr) +{ + /* + From the NB85E Instruction/Data Cache manual, how to flush + the instruction cache (ICC is the `Instruction Cache Control + Register'): + + mov 0x3, r2 + LOP0: + ld.h ICC[r0], r1 + cmp r0, r1 + bnz LOP0 + st.h r2, ICC[r0] + LOP1: - First TAG clear + ld.h ICC[r0], r1 + cmp r0, r1 + bnz LOP1 + st.h r2, ICC[r0] + LOP2: - Second TAG clear + ld.h ICC[r0], r1 + cmp r0, r1 + bnz LOP2 + */ + int cache_flush_bits, ccr_contents; + __asm__ __volatile__ ( + " mov 0x3, %1;" + "1: ld.h 0[%2], %0;" + " cmp r0, %0;" + " bnz 1b;" + " st.h %1, 0[%2];" + "2: ld.h 0[%2], %0;" + " cmp r0, %0;" + " bnz 2b;" + " st.h %1, 0[%2];" + "3: ld.h 0[%2], %0;" + " cmp r0, %0;" + " bnz 3b" + : "=&r" (ccr_contents), "=&r" (cache_flush_bits) + : "r" (cache_control_addr) + : "memory"); +} + +extern inline void nb85e_cache_flush_icache (void) +{ + nb85e_cache_flush_cache (NB85E_CACHE_ICC_ADDR); +} + +extern inline void nb85e_cache_flush_dcache (void) +{ + nb85e_cache_flush_cache (NB85E_CACHE_DCC_ADDR); +} + +extern inline void nb85e_cache_flush (void) +{ + nb85e_cache_flush_icache (); + nb85e_cache_flush_dcache (); +} + +#endif /* !__ASSEMBLY__ */ + + +/* Define standard definitions in terms of processor-specific ones. */ + +/* For */ +#define L1_CACHE_BYTES NB85E_CACHE_LINE_SIZE + +/* For */ +#define flush_cache_all() nb85e_cache_flush () +#define flush_cache_mm(mm) nb85e_cache_flush () +#define flush_cache_range(mm, start, end) nb85e_cache_flush () +#define flush_cache_page(vma, vmaddr) nb85e_cache_flush () +#define flush_page_to_ram(page) nb85e_cache_flush () +#define flush_dcache_page(page) nb85e_cache_flush_dcache () +#define flush_icache_range(start, end) nb85e_cache_flush_icache () +#define flush_icache_page(vma,pg) nb85e_cache_flush_icache () +#define flush_icache() nb85e_cache_flush_icache () +#define flush_cache_sigtramp(vaddr) nb85e_cache_flush_icache () + +#endif /* __V850_NB85E_CACHE_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/nb85e_timer_d.h linux-2.4.6/include/asm-v850/nb85e_timer_d.h --- linux-2.4.6.uclinux-orig/include/asm-v850/nb85e_timer_d.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/nb85e_timer_d.h Wed Oct 10 13:53:47 2001 @@ -0,0 +1,54 @@ +/* + * include/asm-v850/nb85e_timer_d.h -- `Timer D' component often used + * with the NB85E cpu core + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_NB85E_TIMER_D_H__ +#define __V850_NB85E_TIMER_D_H__ + +#include +#include /* Pick up chip-specific defs. */ + + +/* Timer D (16-bit interval timers). */ + +/* Count registers for timer D. */ +#define NB85E_TIMER_D_TMD_ADDR(n) (NB85E_TIMER_D_TMD_BASE_ADDR + 0x10 * (n)) +#define NB85E_TIMER_D_TMD(n) (*(volatile u16 *)NB85E_TIMER_D_TMD_ADDR(n)) + +/* Count compare registers for timer D. */ +#define NB85E_TIMER_D_CMD_ADDR(n) (NB85E_TIMER_D_CMD_BASE_ADDR + 0x10 * (n)) +#define NB85E_TIMER_D_CMD(n) (*(u16 *)NB85E_TIMER_D_CMD_ADDR(n)) + +/* Control registers for timer D. */ +#define NB85E_TIMER_D_TMCD_ADDR(n) (NB85E_TIMER_D_TMCD_BASE_ADDR + 0x10 * (n)) +#define NB85E_TIMER_D_TMCD(n) (*(volatile u8 *)NB85E_TIMER_D_TMCD_ADDR(n)) +/* Control bits for timer D. */ +#define NB85E_TIMER_D_TMCD_CE 0x2 /* count enable */ +#define NB85E_TIMER_D_TMCD_CAE 0x1 /* clock action enable */ +/* Clock divider setting (log2). */ +#define NB85E_TIMER_D_TMCD_CS(divlog2) (((divlog2) - NB85E_TIMER_D_TMCD_CS_MIN) << 4) +#define NB85E_TIMER_D_TMCD_CS_MIN 2 /* minimum clock divider setting (log2) */ +#define NB85E_TIMER_D_TMCD_CS_MAX 9 /* maximum clock divider setting (log2) */ + + +#ifndef __ASSEMBLY__ + +/* Start interval timer TIMER (0-3). The timer will issue the + corresponding INTCMD interrupt RATE times per second. This function + does not enable the interrupt. */ +extern void nb85e_timer_d_configure (unsigned timer, unsigned rate); + +#endif /* !__ASSEMBLY__ */ + + +#endif /* __V850_NB85E_TIMER_D_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/nb85e_uart.h linux-2.4.6/include/asm-v850/nb85e_uart.h --- linux-2.4.6.uclinux-orig/include/asm-v850/nb85e_uart.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/nb85e_uart.h Wed Oct 10 13:53:49 2001 @@ -0,0 +1,128 @@ +/* + * include/asm-v850/nb85e_uart.h -- On-chip UART often used with the + * NB85E cpu core + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +/* There's not actually a single UART implementation used by nb85e + derivatives, but rather a series of implementations that are all + `close' to one another. This file attempts to capture some + commonality between them. */ + +#ifndef __V850_NB85E_UART_H__ +#define __V850_NB85E_UART_H__ + +#include +#include /* Pick up chip-specific defs. */ + +/* UART config registers. */ +#define NB85E_UART_ASIM_ADDR(n) (NB85E_UART_ASIM_BASE_ADDR + 0x10 * (n)) +#define NB85E_UART_ASIM(n) (*(volatile u8 *)NB85E_UART_ASIM_ADDR(n)) +/* Control bits for config registers. */ +#define NB85E_UART_ASIM_CAE 0x80 /* clock enable */ +#define NB85E_UART_ASIM_TXE 0x40 /* transmit enable */ +#define NB85E_UART_ASIM_RXE 0x20 /* receive enable */ +#define NB85E_UART_ASIM_PS_MASK 0x18 /* mask covering parity-select bits */ +#define NB85E_UART_ASIM_PS_NONE 0x00 /* no parity */ +#define NB85E_UART_ASIM_PS_ZERO 0x08 /* zero parity */ +#define NB85E_UART_ASIM_PS_ODD 0x10 /* odd parity */ +#define NB85E_UART_ASIM_PS_EVEN 0x18 /* even parity */ +#define NB85E_UART_ASIM_CL_8 0x04 /* char len is 8 bits (otherwise, 7) */ +#define NB85E_UART_ASIM_SL_2 0x02 /* 2 stop bits (otherwise, 1) */ +#define NB85E_UART_ASIM_ISRM 0x01 /* generate INTSR interrupt on errors + (otherwise, generate INTSER) */ + +/* UART serial interface status registers. */ +#define NB85E_UART_ASIS_ADDR(n) (NB85E_UART_ASIS_BASE_ADDR + 0x10 * (n)) +#define NB85E_UART_ASIS(n) (*(volatile u8 *)NB85E_UART_ASIS_ADDR(n)) +/* Control bits for status registers. */ +#define NB85E_UART_ASIS_PE 0x04 /* parity error */ +#define NB85E_UART_ASIS_FE 0x02 /* framing error */ +#define NB85E_UART_ASIS_OVE 0x01 /* overrun error */ + +/* UART serial interface transmission status registers. */ +#define NB85E_UART_ASIF_ADDR(n) (NB85E_UART_ASIF_BASE_ADDR + 0x10 * (n)) +#define NB85E_UART_ASIF(n) (*(volatile u8 *)NB85E_UART_ASIF_ADDR(n)) +#define NB85E_UART_ASIF_TXBF 0x02 /* transmit buffer flag (data in TXB) */ +#define NB85E_UART_ASIF_TXSF 0x01 /* transmit shift flag (sending data) */ + +/* UART receive buffer register. */ +#define NB85E_UART_RXB_ADDR(n) (NB85E_UART_RXB_BASE_ADDR + 0x10 * (n)) +#define NB85E_UART_RXB(n) (*(volatile u8 *)NB85E_UART_RXB_ADDR(n)) + +/* UART transmit buffer register. */ +#define NB85E_UART_TXB_ADDR(n) (NB85E_UART_TXB_BASE_ADDR + 0x10 * (n)) +#define NB85E_UART_TXB(n) (*(volatile u8 *)NB85E_UART_TXB_ADDR(n)) + +/* UART baud-rate generator control registers. */ +#define NB85E_UART_CKSR_ADDR(n) (NB85E_UART_CKSR_BASE_ADDR + 0x10 * (n)) +#define NB85E_UART_CKSR(n) (*(volatile u8 *)NB85E_UART_CKSR_ADDR(n)) +#define NB85E_UART_CKSR_MAX 11 +#define NB85E_UART_CKSR_MAX_FREQ (25*1000*1000) +#define NB85E_UART_BRGC_ADDR(n) (NB85E_UART_BRGC_BASE_ADDR + 0x10 * (n)) +#define NB85E_UART_BRGC(n) (*(volatile u8 *)NB85E_UART_BRGC_ADDR(n)) + + +/* This UART doesn't implement RTS/CTS by default, but some platforms + implement them externally, so check to see if defined + anything. */ +#ifdef NB85E_UART_CTS +#define nb85e_uart_cts(n) NB85E_UART_CTS(n) +#else +#define nb85e_uart_cts(n) (1) +#endif + +/* Do the same for RTS. */ +#ifdef NB85E_UART_SET_RTS +#define nb85e_uart_set_rts(n,v) NB85E_UART_SET_RTS(n,v) +#else +#define nb85e_uart_set_rts(n,v) ((void)0) +#endif + +/* Return true if all characters awaiting transmission on uart channel N + have been transmitted. */ +#define nb85e_uart_xmit_done(n) \ + (! (NB85E_UART_ASIF(n) & NB85E_UART_ASIF_TXBF)) +/* Wait for this to be true. */ +#define nb85e_uart_wait_for_xmit_done(n) \ + do { } while (! nb85e_uart_xmit_done (n)) + +/* Return true if uart channel N is ready to transmit a character. */ +#define nb85e_uart_xmit_ok(n) \ + (nb85e_uart_xmit_done(n) && nb85e_uart_cts(n)) +/* Wait for this to be true. */ +#define nb85e_uart_wait_for_xmit_ok(n) \ + do { } while (! nb85e_uart_xmit_ok (n)) + +/* Write character CH to uart channel N. */ +#define nb85e_uart_putc(n, ch) (NB85E_UART_TXB(n) = (ch)) + + +#define NB85E_UART_MINOR_BASE 64 + + +#ifndef __ASSEMBLY__ + +/* Setup a console using channel 0 of the builtin uart. */ +extern void nb85e_uart_cons_setup (void); + +/* Configure and turn on uart channel CHAN, using the termios `control + modes' bits in CFLAGS, and a baud-rate of BAUD. */ +void nb85e_uart_configure (unsigned chan, unsigned cflags, unsigned baud); + +/* If the macro NB85E_UART_PRE_CONFIGURE is defined (presumably by a + ), it is called from nb85e_uart_pre_configure before + anything else is done, with interrupts disabled. */ + +#endif /* !__ASSEMBLY__ */ + + +#endif /* __V850_NB85E_UART_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/nb85e_utils.h linux-2.4.6/include/asm-v850/nb85e_utils.h --- linux-2.4.6.uclinux-orig/include/asm-v850/nb85e_utils.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/nb85e_utils.h Fri Sep 21 16:21:40 2001 @@ -0,0 +1,35 @@ +/* + * include/asm-v850/nb85e_utils.h -- Utility functions associated with + * the NB85E cpu core + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_NB85E_UTILS_H__ +#define __V850_NB85E_UTILS_H__ + +/* Calculate counter clock-divider and count values to attain the + desired frequency RATE from the base frequency BASE_FREQ. The + counter is expected to have a clock-divider, which can divide the + system cpu clock by a power of two value from MIN_DIVLOG2 to + MAX_DIV_LOG2, and a word-size of COUNTER_SIZE bits (the counter + counts up and resets whenever it's equal to the compare register, + generating an interrupt or whatever when it does so). The returned + values are: *DIVLOG2 -- log2 of the desired clock divider and *COUNT + -- the counter compare value to use. Returns true if it was possible + to find a reasonable value, otherwise false (and the other return + values will be set to be as good as possible). */ +extern int calc_counter_params (unsigned long base_freq, + unsigned long rate, + unsigned min_divlog2, unsigned max_divlog2, + unsigned counter_size, + unsigned *divlog2, unsigned *count); + +#endif /* __V850_NB85E_UTILS_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/page.h linux-2.4.6/include/asm-v850/page.h --- linux-2.4.6.uclinux-orig/include/asm-v850/page.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/page.h Tue Sep 25 16:05:06 2001 @@ -0,0 +1,127 @@ +/* + * include/asm-v850/page.h -- VM ops + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_PAGE_H__ +#define __V850_PAGE_H__ + +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +/* + * PAGE_OFFSET -- the first address of the first page of memory. For archs with + * no MMU this corresponds to the first free page in physical memory (aligned + * on a page boundary). + */ +#define PAGE_OFFSET 0x0000000 + +/* + * MAP_NR -- given an address, calculate the index of the page struct which + * points to the address's page. + */ +#define MAP_NR(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> PAGE_SHIFT) + +#ifdef __KERNEL__ +#ifndef __ASSEMBLY__ + +#define STRICT_MM_TYPECHECKS + +#define clear_page(page) memset ((void *)(page), 0, PAGE_SIZE) +extern void copy_page(void *to, void *from); + +#define clear_user_page(page, vaddr) clear_page (page) +#define copy_user_page(to, from, vaddr) copy_page (to, from) + +#ifdef STRICT_MM_TYPECHECKS +/* + * These are used to make use of C type-checking.. + */ + +typedef struct { unsigned long pte; } pte_t; +typedef struct { unsigned long pmd; } pmd_t; +typedef struct { unsigned long pgd; } pgd_t; +typedef struct { unsigned long pgprot; } pgprot_t; + +#define pte_val(x) ((x).pte) +#define pmd_val(x) ((x).pmd) +#define pgd_val(x) ((x).pgd) +#define pgprot_val(x) ((x).pgprot) + +#define __pte(x) ((pte_t) { (x) } ) +#define __pmd(x) ((pmd_t) { (x) } ) +#define __pgd(x) ((pgd_t) { (x) } ) +#define __pgprot(x) ((pgprot_t) { (x) } ) + +#else /* !STRICT_MM_TYPECHECKS */ +/* + * .. while these make it easier on the compiler + */ + +typedef unsigned long pte_t; +typedef unsigned long pmd_t; +typedef unsigned long pgd_t; +typedef unsigned long pgprot_t; + +#define pte_val(x) (x) +#define pmd_val(x) (x) +#define pgd_val(x) (x) +#define pgprot_val(x) (x) + +#define __pte(x) (x) +#define __pmd(x) (x) +#define __pgd(x) (x) +#define __pgprot(x) (x) + +#endif /* STRICT_MM_TYPECHECKS */ + +#endif /* !__ASSEMBLY__ */ + +/* to align the pointer to the (next) page boundary */ +#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) + +#ifndef __ASSEMBLY__ + +extern void __bug(const char *file, int line, void *data); + +#define BUG() __bug(__FILE__, __LINE__, NULL) +#define PAGE_BUG(page) __bug(__FILE__, __LINE__, page) + +/* Pure 2^n version of get_order */ +extern __inline__ int get_order (unsigned long size) +{ + int order; + + size = (size-1) >> (PAGE_SHIFT-1); + order = -1; + do { + size >>= 1; + order++; + } while (size); + return order; +} + +#endif /* !__ASSEMBLY__ */ + +#define __pa(x) __virt_to_phys ((unsigned long)(x)) +#define __va(x) ((void *)__phys_to_virt ((unsigned long)(x))) + +/* No current v850 processor has virtual memory. */ +#define __virt_to_phys(addr) (addr) +#define __phys_to_virt(addr) (addr) + +#define virt_to_page(kaddr) (mem_map + MAP_NR (kaddr)) +#define VALID_PAGE(page) ((page - mem_map) < max_mapnr) + +#endif /* KERNEL */ + +#endif /* __V850_PAGE_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/param.h linux-2.4.6/include/asm-v850/param.h --- linux-2.4.6.uclinux-orig/include/asm-v850/param.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/param.h Wed Oct 10 13:49:57 2001 @@ -0,0 +1,35 @@ +/* + * include/asm-v850/param.h -- Varions kernel parameters + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_PARAM_H__ +#define __V850_PARAM_H__ + +#include /* For HZ */ + +#define EXEC_PAGESIZE 4096 + +#ifndef NGROUPS +#define NGROUPS 32 +#endif + +#ifndef NOGROUP +#define NOGROUP (-1) +#endif + +#define MAXHOSTNAMELEN 64 /* max length of hostname */ + +#ifdef __KERNEL__ +# define CLOCKS_PER_SEC HZ +#endif + +#endif /* __V850_PARAM_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/pgalloc.h linux-2.4.6/include/asm-v850/pgalloc.h --- linux-2.4.6.uclinux-orig/include/asm-v850/pgalloc.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/pgalloc.h Wed Oct 10 13:49:58 2001 @@ -0,0 +1,92 @@ +/* + * include/asm-v850/pgalloc.h + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_PGALLOC_H__ +#define __V850_PGALLOC_H__ + +#include + +#include + +/* + * Cache handling functions + */ + +#ifndef flush_cache_all +/* If there's no flush_cache_all macro defined by , then + this processor has no cache, so just define these as nops. */ + +#define flush_cache_all() ((void)0) +#define flush_cache_mm(mm) ((void)0) +#define flush_cache_range(mm, start, end) ((void)0) +#define flush_cache_page(vma, vmaddr) ((void)0) +#define flush_page_to_ram(page) ((void)0) +#define flush_dcache_page(page) ((void)0) +#define flush_icache_range(start, end) ((void)0) +#define flush_icache_page(vma,pg) ((void)0) +#define flush_icache() ((void)0) +#define flush_cache_sigtramp(vaddr) ((void)0) + +#endif /* !flush_cache_all */ + +/* + * flush all user-space atc entries. + */ +static inline void __flush_tlb(void) +{ + BUG(); +} + +static inline void __flush_tlb_one(unsigned long addr) +{ + BUG(); +} + +#define flush_tlb() __flush_tlb() + +/* + * flush all atc entries (both kernel and user-space entries). + */ +static inline void flush_tlb_all(void) +{ + BUG(); +} + +static inline void flush_tlb_mm(struct mm_struct *mm) +{ + BUG(); +} + +static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr) +{ + BUG(); +} + +static inline void flush_tlb_range(struct mm_struct *mm, + unsigned long start, unsigned long end) +{ + BUG(); +} + +extern inline void flush_tlb_kernel_page(unsigned long addr) +{ + BUG(); +} + +extern inline void flush_tlb_pgtables(struct mm_struct *mm, + unsigned long start, unsigned long end) +{ + BUG(); +} + +#endif /* _V850_PGALLOC_H */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/pgtable.h linux-2.4.6/include/asm-v850/pgtable.h --- linux-2.4.6.uclinux-orig/include/asm-v850/pgtable.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/pgtable.h Tue Sep 11 15:32:20 2001 @@ -0,0 +1,20 @@ +#ifndef __V850_PGTABLE_H__ +#define __V850_PGTABLE_H__ + +#include +#include + +#define page_address(page) ({ if (!(page)->virtual) BUG(); (page)->virtual;}) +#define __page_address(page) (PAGE_OFFSET + (((page) - mem_map) << PAGE_SHIFT)) +#define pgd_present(pgd) (1) /* pages are always present on NO_MM */ +#define kern_addr_valid(addr) (1) + +#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 */ + +extern void paging_init(void); + +#endif /* __V850_PGTABLE_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/poll.h linux-2.4.6/include/asm-v850/poll.h --- linux-2.4.6.uclinux-orig/include/asm-v850/poll.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/poll.h Wed Aug 29 10:58:39 2001 @@ -0,0 +1,22 @@ +#ifndef __V850_POLL_H__ +#define __V850_POLL_H__ + +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 +#define POLLRDNORM 0x0040 +#define POLLWRNORM POLLOUT +#define POLLRDBAND 0x0080 +#define POLLWRBAND 0x0100 +#define POLLMSG 0x0400 + +struct pollfd { + int fd; + short events; + short revents; +}; + +#endif /* __V850_POLL_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/posix_types.h linux-2.4.6/include/asm-v850/posix_types.h --- linux-2.4.6.uclinux-orig/include/asm-v850/posix_types.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/posix_types.h Tue Sep 11 18:11:39 2001 @@ -0,0 +1,93 @@ +/* + * include/asm-v850/posix_types.h -- Kernel versions of standard types + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_POSIX_TYPES_H__ +#define __V850_POSIX_TYPES_H__ + +typedef unsigned int __kernel_dev_t; +typedef unsigned long __kernel_ino_t; +typedef unsigned int __kernel_mode_t; +typedef unsigned int __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned int __kernel_uid_t; +typedef unsigned int __kernel_gid_t; +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +typedef long __kernel_time_t; +typedef long __kernel_suseconds_t; +typedef long __kernel_clock_t; +typedef int __kernel_daddr_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; + +typedef unsigned short __kernel_old_uid_t; +typedef unsigned short __kernel_old_gid_t; + +#ifdef __GNUC__ +typedef long long __kernel_loff_t; +#endif + +typedef struct { +#if defined(__KERNEL__) || defined(__USE_ALL) + int val[2]; +#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ + int __val[2]; +#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ +} __kernel_fsid_t; + +#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) + +#undef __FD_SET +#define __FD_SET(fd,fdsetp) \ + do { \ + int __fd = (fd); \ + void *__addr = (void *)&((__kernel_fd_set *)fdsetp)->fds_bits; \ + __asm__ __volatile__ ("set1 %0, [%1]" \ + : /*nothing*/ \ + : "r" (__fd & 0x7), "r" (__addr + (__fd >> 3)));\ + } while (0) + +#undef __FD_CLR +#define __FD_CLR(fd,fdsetp) \ + do { \ + int __fd = (fd); \ + void *__addr = (void *)&((__kernel_fd_set *)fdsetp)->fds_bits; \ + __asm__ __volatile__ ("clr1 %0, [%1]" \ + : /*nothing*/ \ + : "r" (__fd & 0x7), "r" (__addr + (__fd >> 3)));\ + } while (0) + +#undef __FD_ISSET +#define __FD_ISSET(fd,fdsetp) \ + ({ \ + int __fd = (fd); \ + void *__addr = (void *)&((__kernel_fd_set *)fdsetp)->fds_bits; \ + int res; \ + __asm__ ("tst1 %1, [%2]; setf nz, %0" \ + : "=r" (res) \ + : "r" (__fd & 0x7), "r" (__addr + (__fd >> 3))); \ + res; \ + }) + +#undef __FD_ZERO +#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp))) + +#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ + +#endif /* __V850_POSIX_TYPES_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/processor.h linux-2.4.6/include/asm-v850/processor.h --- linux-2.4.6.uclinux-orig/include/asm-v850/processor.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/processor.h Wed Oct 10 13:48:57 2001 @@ -0,0 +1,140 @@ +/* + * include/asm-v850/processor.h + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_PROCESSOR_H__ +#define __V850_PROCESSOR_H__ + +#include + +#include +#include +#include + +/* Some code expects `segment' stuff to be defined here. */ +#include + + +/* + * 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 (0x3FFEFFFUL) + + +#define THREAD_SIZE (2*PAGE_SIZE) + + +#ifndef __ASSEMBLY__ + +/* + * Default implementation of macro that returns current + * instruction pointer ("program counter"). + */ +#define current_text_addr() ({ __label__ _l; _l: &&_l;}) + + +/* + * Bus types + */ +#define EISA_bus 0 +#define EISA_bus__is_a_macro /* for versions in ksyms.c */ +#define MCA_bus 0 +#define MCA_bus__is_a_macro /* for versions in ksyms.c */ + +/* + * This initializes a vm_area_struct. According to the uClinux patch for + * linux/mm.h, this struct is only used in do_mmap. Even though the m68knommu + * version initializes the vm_mm field, this field is not defined in the + * uClinux version of the struct. I think that's probably a bug so I won't do + * that. + * --gmcnutt [from include/asm-armnommu/processor.h] + */ +#define INIT_MMAP { \ + vm_start: PAGE_OFFSET, \ + vm_end: PAGE_OFFSET + 0x02000000, \ + vm_flags: VM_READ | VM_WRITE | VM_EXEC, \ + vm_offset: 0 \ +} + + +/* If you change this, you must change the associated assembly-languages + constants defined below, THREAD_*. */ +struct thread_struct { + /* kernel stack pointer (must be first field in structure) */ + unsigned long ksp; +}; + +#define INIT_THREAD { sizeof init_stack + (unsigned long)init_stack } + + +/* Do necessary setup to start up a newly executed thread. */ +extern inline void start_thread (struct pt_regs *regs, + unsigned long pc, unsigned long usp) +{ + regs->pc = pc; + regs->gpr[GPR_SP] = usp; + regs->kernel_mode = 0; +} + +/* Free all resources held by a thread. */ +extern inline void release_thread (struct task_struct *dead_task) +{ +} + +extern int kernel_thread (int (*fn)(void *), void * arg, unsigned long flags); + +/* Free current thread data structures etc. */ +static inline void exit_thread (void) +{ +} + +/* Return saved (kernel) PC of a blocked thread. */ +extern inline unsigned long thread_saved_pc (struct thread_struct *t) +{ + struct pt_regs *r = (struct pt_regs *)(t->ksp + STATE_SAVE_PT_OFFSET); + /* Actually, we return the LP register, because the thread is + actually blocked in switch_thread, and we're interested in + the PC it will _return_ to. */ + return r->gpr[GPR_LP]; +} + +unsigned long get_wchan (struct task_struct *p); + + +/* Return some info about the user process TASK. */ +#define __KSTK_TOS(task) ((unsigned long)(task) + KERNEL_STACK_SIZE) +#define __KSTK_REGS(task) ((struct pt_regs *)__KSTK_TOS(task) - 1) +#define KSTK_EIP(task) (__KSTK_REGS(task)->pc) +#define KSTK_ESP(task) (__KSTK_REGS(task)->gpr[GPR_SP]) + + +/* Allocation and freeing of basic task resources. */ +#define alloc_task_struct() \ + ((struct task_struct *)__get_free_pages(GFP_KERNEL,1)) +#define free_task_struct(p) free_pages ((unsigned long)(p),1) +#define get_task_struct(tsk) atomic_inc (&mem_map[MAP_NR(tsk)].count) + +#define init_task (init_task_union.task) +#define init_stack (init_task_union.stack) + + +#else /* !__ASSEMBLY__ */ + + +#define THREAD_KSP 0 + + +#endif /* __ASSEMBLY__ */ + + +#endif /* __V850_PROCESSOR_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/ptrace.h linux-2.4.6/include/asm-v850/ptrace.h --- linux-2.4.6.uclinux-orig/include/asm-v850/ptrace.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/ptrace.h Tue Sep 11 16:14:01 2001 @@ -0,0 +1,114 @@ +/* + * include/asm-v850/ptrace.h -- Access to CPU registers + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_PTRACE_H__ +#define __V850_PTRACE_H__ + + +/* v850 general purpose registers with special meanings. */ +#define GPR_ZERO 0 /* constant zero */ +#define GPR_ASM 1 /* reserved for assembler */ +#define GPR_SP 3 /* stack pointer */ +#define GPR_GP 4 /* global data pointer */ +#define GPR_TP 5 /* `text pointer' */ +#define GPR_EP 30 /* `element pointer' */ +#define GPR_LP 31 /* link pointer (current return address) */ + +/* These aren't official names, but they make some code more descriptive. */ +#define GPR_ARG0 6 +#define GPR_ARG1 7 +#define GPR_ARG2 8 +#define GPR_ARG3 9 +#define GPR_RVAL0 10 +#define GPR_RVAL1 11 +#define GPR_RVAL GPR_RVAL0 + +#define NUM_GPRS 32 + +/* v850 `system' registers. */ +#define SR_EIPC 0 +#define SR_EIPSW 1 +#define SR_FEPC 2 +#define SR_FEPSW 3 +#define SR_ECR 4 +#define SR_PSW 5 +#define SR_CTPC 16 +#define SR_CTPSW 17 +#define SR_DBPC 18 +#define SR_DBPSW 19 +#define SR_CTBP 20 +#define SR_DIR 21 +#define SR_ASID 23 + + +#ifndef __ASSEMBLY__ + +typedef unsigned long v850_reg_t; + +/* How processor state is stored on the stack during a syscall/signal. + If you change this structure, change the associated assembly-language + macros below too (PT_*)! */ +struct pt_regs +{ + /* General purpose registers. */ + v850_reg_t gpr[NUM_GPRS]; + + v850_reg_t pc; /* program counter */ + v850_reg_t psw; /* program status word */ + + /* Registers used by `callt' instruction: */ + v850_reg_t ctpc; /* saved program counter */ + v850_reg_t ctpsw; /* saved psw */ + v850_reg_t ctbp; /* base pointer for callt table */ + + char kernel_mode; /* 1 if in `kernel mode', 0 if user mode */ +}; + + +#define instruction_pointer(regs) ((regs)->pc) +#define user_mode(regs) (!(regs)->kernel_mode) + +/* When a struct pt_regs is used to save user state for a system call in + the kernel, the system call is stored in the space for R0 (since it's + never used otherwise, R0 being a constant 0). Non-system-calls + simply store 0 there. */ +#define PT_REGS_SYSCALL(regs) (regs)->gpr[0] +#define PT_REGS_SET_SYSCALL(regs, val) ((regs)->gpr[0] = (val)) + +#else /* __ASSEMBLY__ */ + + +/* The number of bytes used to store each register. */ +#define _PT_REG_SIZE 4 + +/* Offset of a general purpose register in a stuct pt_regs. */ +#define PT_GPR(num) ((num) * _PT_REG_SIZE) + +/* Offsets of various special registers & fields in a struct pt_regs. */ +#define PT_PC ((NUM_GPRS + 0) * _PT_REG_SIZE) +#define PT_PSW ((NUM_GPRS + 1) * _PT_REG_SIZE) +#define PT_CTPC ((NUM_GPRS + 2) * _PT_REG_SIZE) +#define PT_CTPSW ((NUM_GPRS + 3) * _PT_REG_SIZE) +#define PT_CTBP ((NUM_GPRS + 4) * _PT_REG_SIZE) +#define PT_KERNEL_MODE ((NUM_GPRS + 5) * _PT_REG_SIZE) + +#define PT_SYSCALL PT_GPR(0) + +/* Size of struct pt_regs, including alignment. */ +#define PT_SIZE ((NUM_GPRS + 6) * _PT_REG_SIZE) + + +#endif /* __ASSEMBLY__ */ + + +#endif /* __V850_PTRACE_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/resource.h linux-2.4.6/include/asm-v850/resource.h --- linux-2.4.6.uclinux-orig/include/asm-v850/resource.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/resource.h Wed Aug 29 10:58:01 2001 @@ -0,0 +1,47 @@ +#ifndef __V850_RESOURCE_H__ +#define __V850_RESOURCE_H__ + +/* + * Resource limits + */ + +#define RLIMIT_CPU 0 /* CPU time in ms */ +#define RLIMIT_FSIZE 1 /* Maximum filesize */ +#define RLIMIT_DATA 2 /* max data size */ +#define RLIMIT_STACK 3 /* max stack size */ +#define RLIMIT_CORE 4 /* max core file size */ +#define RLIMIT_RSS 5 /* max resident set size */ +#define RLIMIT_NPROC 6 /* max number of processes */ +#define RLIMIT_NOFILE 7 /* max number of open files */ +#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ +#define RLIMIT_AS 9 /* address space limit */ +#define RLIMIT_LOCKS 10 /* maximum file locks held */ + +#define RLIM_NLIMITS 11 + +/* + * SuS says limits have to be unsigned. + * Which makes a ton more sense anyway. + */ +#define RLIM_INFINITY (~0UL) + +#ifdef __KERNEL__ + +#define INIT_RLIMITS \ +{ \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { _STK_LIM, RLIM_INFINITY }, \ + { 0, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { 0, 0 }, \ + { INR_OPEN, INR_OPEN }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ +} + +#endif /* __KERNEL__ */ + +#endif /* __V850_RESOURCE_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/rte_cb.h linux-2.4.6/include/asm-v850/rte_cb.h --- linux-2.4.6.uclinux-orig/include/asm-v850/rte_cb.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/rte_cb.h Thu Oct 4 15:53:30 2001 @@ -0,0 +1,40 @@ +/* + * include/asm-v850/rte_cb.h -- Midas labs RTE-CB series of evaluation boards + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_RTE_CB_H__ +#define __V850_RTE_CB_H__ + + +/* For */ +#ifndef HZ +#define HZ 100 +#endif + + +#ifndef __ASSEMBLY__ + +/* For */ +/* This gives us a single arena. */ +#define CAT_ROMARRAY +/* These should be defined by the linker map. */ +extern char _blkmem_0_start, _blkmem_0_end; +/* Make the single arena point use them. */ +#define FIXUP_ARENAS \ + arena[0].rw = BLKMEM_0_RW; \ + arena[0].address = (unsigned long)&_blkmem_0_start; \ + arena[0].length = &_blkmem_0_end - &_blkmem_0_start; + +#endif /* !__ASSEMBLY__ */ + + +#endif /* __V850_RTE_CB_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/rte_ma1_cb.h linux-2.4.6/include/asm-v850/rte_ma1_cb.h --- linux-2.4.6.uclinux-orig/include/asm-v850/rte_ma1_cb.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/rte_ma1_cb.h Fri Oct 5 17:25:49 2001 @@ -0,0 +1,106 @@ +/* + * include/asm-v850/rte_ma1_cb.h -- Midas labs RTE-V850/MA1-CB board + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_RTE_MA1_CB_H__ +#define __V850_RTE_MA1_CB_H__ + +#include /* Common defs for Midas RTE-CB boards. */ + +#define PLATFORM "rte-v850e/ma1-cb" +#define PLATFORM_LONG "Midas Labs RTE-V850E/MA1-CB" + +#define CPU_CLOCK_FREQ 50000000 /* 50MHz */ + +/* 1MB of onboard SRAM. Note that the monitor ROM uses parts of this + for its own purposes, so care must be taken. Some address lines are + not decoded, so the SRAM area is mirrored every 1MB from 0x400000 to + 0x800000 (exclusive). */ +#define SRAM_ADDR 0x00400000 +#define SRAM_SIZE 0x00100000 /* 1MB */ + +/* 32MB of onbard SDRAM. */ +#define SDRAM_ADDR 0x00800000 +#define SDRAM_SIZE 0x02000000 /* 32MB */ + + +#ifdef CONFIG_ROM_KERNEL +/* Kernel is in ROM, starting at address 0. */ + +#define INTV_BASE 0 +#define BLKMEM_0_RW 0 + +#else /* !CONFIG_ROM_KERNEL */ + +/* It's in RAM anyway, so might as well allow writing to it. */ +#define BLKMEM_0_RW 1 + +#ifdef CONFIG_RTE_CB_MULTI +/* Using RAM kernel with ROM monitor for Multi debugger. */ + +/* The chip's real interrupt vectors are in ROM, but they jump to a + secondary interrupt vector table in RAM. */ +#define INTV_BASE 0x004F8000 + +/* Scratch memory used by the ROM monitor, which shouldn't be used by + linux (except for the alternate interrupt vector area, defined + above). */ +#define MON_SCRATCH_ADDR 0x004F8000 +#define MON_SCRATCH_SIZE 0x00008000 /* 32KB */ + +#else /* !CONFIG_RTE_CB_MULTI */ +/* Using RAM-kernel. Assume some sort of boot-loader got us loaded at + address 0. */ + +#define INTV_BASE 0 +#define BLKMEM_0_RW 1 + +#endif /* CONFIG_RTE_CB_MULTI */ + +#endif /* CONFIG_ROM_KERNEL */ + + +/* Some misc. on-board devices. */ + +/* Seven-segment LED display (two digits). Write-only. */ +#define LED_ADDR(n) (0x07802000 + (n)) +#define LED(n) (*(volatile unsigned char *)LED_ADDR(n)) +#define LED_NUM_DIGITS 2 + + +/* Override the basic MA uart pre-initialization so that we can + initialize extra stuff. */ +#undef NB85E_UART_PRE_CONFIGURE /* should be defined by */ +#define NB85E_UART_PRE_CONFIGURE rte_ma1_cb_uart_pre_configure +#ifndef __ASSEMBLY__ +extern void rte_ma1_cb_uart_pre_configure (unsigned chan, + unsigned cflags, unsigned baud); +#endif + +/* This board supports RTS/CTS for the on-chip UART, but only for channel 0. */ + +/* CTS for UART channel 0 is pin P43 (bit 3 of port 4). */ +#define NB85E_UART_CTS(chan) ((chan) == 0 ? !(MA_PORT4_IO & 0x8) : 1) +/* RTS for UART channel 0 is pin P42 (bit 2 of port 4). */ +#define NB85E_UART_SET_RTS(chan, val) \ + do { \ + if (chan == 0) { \ + unsigned old = MA_PORT4_IO; \ + if (val) \ + MA_PORT4_IO = old & ~0x4; \ + else \ + MA_PORT4_IO = old | 0x4; \ + } \ + } while (0) + + +#endif /* __V850_RTE_MA1_CB_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/rte_nb85e_cb.h linux-2.4.6/include/asm-v850/rte_nb85e_cb.h --- linux-2.4.6.uclinux-orig/include/asm-v850/rte_nb85e_cb.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/rte_nb85e_cb.h Thu Oct 4 15:55:31 2001 @@ -0,0 +1,68 @@ +/* + * include/asm-v850/rte_nb85e_cb.h -- Midas labs RTE-V850/NB85E-CB board + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_RTE_NB85E_CB_H__ +#define __V850_RTE_NB85E_CB_H__ + +#include /* Common defs for Midas RTE-CB boards. */ + +#define PLATFORM "rte-v850e/nb85e-cb" +#define PLATFORM_LONG "Midas Labs RTE-V850E/NB85E-CB" + +#define CPU_CLOCK_FREQ 50000000 /* 50MHz */ + +/* 1MB of onboard SRAM. Note that the monitor ROM uses parts of this + for its own purposes, so care must be taken. */ +#define SRAM_ADDR 0x03C00000 +#define SRAM_SIZE 0x00100000 /* 1MB */ + +/* 16MB of onbard SDRAM. */ +#define SDRAM_ADDR 0x01000000 +#define SDRAM_SIZE 0x01000000 /* 16MB */ + + +#ifdef CONFIG_ROM_KERNEL +/* Kernel is in ROM, starting at address 0. */ + +#define INTV_BASE 0 + +#define BLKMEM_0_RW 0 + +#else /* !CONFIG_ROM_KERNEL */ +/* We're using the ROM monitor. */ + +/* The chip's real interrupt vectors are in ROM, but they jump to a + secondary interrupt vector table in RAM. */ +#define INTV_BASE 0x004F8000 + +/* It's in RAM anyway, so might as well allow writing to it. */ +#define BLKMEM_0_RW 1 + +/* Scratch memory used by the ROM monitor, which shouldn't be used by + linux (except for the alternate interrupt vector area, defined + above). */ +#define MON_SCRATCH_ADDR 0x03CE8000 +#define MON_SCRATCH_SIZE 0x00008000 /* 32KB */ + +#endif /* CONFIG_ROM_KERNEL */ + + +/* Some misc. on-board devices. */ + +/* Seven-segment LED display (two digits). Write-only. */ +#define LED_ADDR(n) (0x03802000 + (n)) +#define LED(n) (*(volatile unsigned char *)LED_ADDR(n)) +#define LED_NUM_DIGITS 4 + + +#endif /* __V850_RTE_NB85E_CB_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/segment.h linux-2.4.6/include/asm-v850/segment.h --- linux-2.4.6.uclinux-orig/include/asm-v850/segment.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/segment.h Wed Aug 29 10:58:38 2001 @@ -0,0 +1,36 @@ +#ifndef __V850_SEGMENT_H__ +#define __V850_SEGMENT_H__ + + +#ifndef __ASSEMBLY__ + +typedef unsigned long mm_segment_t; /* domain register */ + +#endif /* !__ASSEMBLY__ */ + + +#define __KERNEL_CS 0x0 +#define __KERNEL_DS 0x0 + +#define __USER_CS 0x1 +#define __USER_DS 0x1 + +#define KERNEL_DS __KERNEL_DS +#define KERNEL_CS __KERNEL_CS +#define USER_DS __USER_DS +#define USER_CS __USER_CS + +#define segment_eq(a,b) ((a) == (b)) + +#define get_ds() (KERNEL_DS) +#define get_fs() (USER_DS) + +#define set_fs(seg) ((void)0) + + +#define copy_segments(task, mm) ((void)0) +#define release_segments(mm) ((void)0) +#define forget_segments() ((void)0) + + +#endif /* __V850_SEGMENT_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/semaphore.h linux-2.4.6/include/asm-v850/semaphore.h --- linux-2.4.6.uclinux-orig/include/asm-v850/semaphore.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/semaphore.h Wed Oct 10 13:48:57 2001 @@ -0,0 +1,86 @@ +#ifndef __V850_SEMAPHORE_H__ +#define __V850_SEMAPHORE_H__ + +#include +#include +#include +#include + +#include + +struct semaphore { + atomic_t count; + int sleepers; + wait_queue_head_t wait; +}; + +#define __SEMAPHORE_INITIALIZER(name,count) \ + { ATOMIC_INIT (count), 0, \ + __WAIT_QUEUE_HEAD_INITIALIZER ((name).wait) } + +#define __MUTEX_INITIALIZER(name) \ + __SEMAPHORE_INITIALIZER (name,1) + +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \ + struct semaphore name = __SEMAPHORE_INITIALIZER (name,count) + +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC (name,1) +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC (name,0) + +extern inline void sema_init (struct semaphore *sem, int val) +{ + *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val); +} + +static inline void init_MUTEX (struct semaphore *sem) +{ + sema_init (sem, 1); +} + +static inline void init_MUTEX_LOCKED (struct semaphore *sem) +{ + sema_init (sem, 0); +} + +/* + * special register calling convention + */ +asmlinkage void __down_failed (void); +asmlinkage int __down_interruptible_failed (void); +asmlinkage int __down_trylock_failed (void); +asmlinkage void __up_wakeup (void); + +extern void __down (struct semaphore * sem); +extern int __down_interruptible (struct semaphore * sem); +extern int __down_trylock (struct semaphore * sem); +extern void __up (struct semaphore * sem); + +extern inline void down (struct semaphore * sem) +{ + if (atomic_dec_return (&sem->count) < 0) + __down (sem); +} + +extern inline int down_interruptible (struct semaphore * sem) +{ + int ret = 0; + if (atomic_dec_return (&sem->count) < 0) + ret = __down_interruptible (sem); + return ret; +} + +extern inline int down_trylock (struct semaphore *sem) +{ + int ret = 0; + if (atomic_dec_return (&sem->count) < 0) + ret = __down_trylock (sem); + return ret; +} + +extern inline void up (struct semaphore * sem) +{ + if (atomic_inc_return (&sem->count) <= 0) + __up (sem); +} + +#endif /* __V850_SEMAPHORE_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/sembuf.h linux-2.4.6/include/asm-v850/sembuf.h --- linux-2.4.6.uclinux-orig/include/asm-v850/sembuf.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/sembuf.h Wed Aug 29 10:58:26 2001 @@ -0,0 +1,25 @@ +#ifndef __V850_SEMBUF_H__ +#define __V850_SEMBUF_H__ + +/* + * The semid64_ds structure for v850 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 64-bit time_t to solve y2038 problem + * - 2 miscellaneous 32-bit values + */ + +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ + __kernel_time_t sem_otime; /* last semop time */ + unsigned long __unused1; + __kernel_time_t sem_ctime; /* last change time */ + unsigned long __unused2; + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long __unused3; + unsigned long __unused4; +}; + +#endif /* __V850_SEMBUF_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/setup.h linux-2.4.6/include/asm-v850/setup.h --- linux-2.4.6.uclinux-orig/include/asm-v850/setup.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/setup.h Tue Sep 11 15:10:10 2001 @@ -0,0 +1,37 @@ +/* + * include/asm-v850/setup.h + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_SETUP_H__ +#define __V850_SETUP_H__ + +/* Linux/v850 platforms. This corresponds roughly to what the outside + the CPU looks like. */ +#define MACH_SIM 1 /* GDB architectural simulator */ + +/* v850 cpu architectures. This is what a user-program would be + concerned with. */ +#define CPU_ARCH_V850E 1 +#define CPU_ARCH_V850E2 2 + +/* v850 cpu `cores'. These are system-level extensions to the basic CPU, + defining such things as interrupt-handling. */ +#define CPU_CORE_NB85E 1 +#define CPU_CORE_NB85ET 2 +#define CPU_CORE_NU85E 3 +#define CPU_CORE_NU85ET 4 + +/* Specific v850 cpu chips. These each incorporate a `core', and add + varions peripheral services. */ +#define CPU_CHIP_MA1 1 + +#endif /* __V850_SETUP_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/shmbuf.h linux-2.4.6/include/asm-v850/shmbuf.h --- linux-2.4.6.uclinux-orig/include/asm-v850/shmbuf.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/shmbuf.h Wed Aug 29 10:58:49 2001 @@ -0,0 +1,42 @@ +#ifndef __V850_SHMBUF_H__ +#define __V850_SHMBUF_H__ + +/* + * The shmid64_ds structure for v850 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 64-bit time_t to solve y2038 problem + * - 2 miscellaneous 32-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ + __kernel_time_t shm_atime; /* last attach time */ + unsigned long __unused1; + __kernel_time_t shm_dtime; /* last detach time */ + unsigned long __unused2; + __kernel_time_t shm_ctime; /* last change time */ + unsigned long __unused3; + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused4; + unsigned long __unused5; +}; + +struct shminfo64 { + unsigned long shmmax; + unsigned long shmmin; + unsigned long shmmni; + unsigned long shmseg; + unsigned long shmall; + unsigned long __unused1; + unsigned long __unused2; + unsigned long __unused3; + unsigned long __unused4; +}; + +#endif /* __V850_SHMBUF_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/shmparam.h linux-2.4.6/include/asm-v850/shmparam.h --- linux-2.4.6.uclinux-orig/include/asm-v850/shmparam.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/shmparam.h Wed Aug 29 10:58:46 2001 @@ -0,0 +1,6 @@ +#ifndef __V850_SHMPARAM_H__ +#define __V850_SHMPARAM_H__ + +#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */ + +#endif /* __V850_SHMPARAM_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/sigcontext.h linux-2.4.6/include/asm-v850/sigcontext.h --- linux-2.4.6.uclinux-orig/include/asm-v850/sigcontext.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/sigcontext.h Tue Sep 11 16:14:09 2001 @@ -0,0 +1,25 @@ +/* + * include/asm-v850/sigcontext.h -- Signal contexts + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_SIGCONTEXT_H__ +#define __V850_SIGCONTEXT_H__ + +#include + +struct sigcontext +{ + struct pt_regs regs; + unsigned long oldmask; +}; + +#endif /* __V850_SIGCONTEXT_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/siginfo.h linux-2.4.6/include/asm-v850/siginfo.h --- linux-2.4.6.uclinux-orig/include/asm-v850/siginfo.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/siginfo.h Mon Sep 17 16:54:36 2001 @@ -0,0 +1,242 @@ +#ifndef __V850_SIGINFO_H__ +#define __V850_SIGINFO_H__ + +#include + +/* This is copied from asm-alpha/siginfo.h. */ + +typedef union sigval { + int sival_int; + void *sival_ptr; +} sigval_t; + +#define SI_MAX_SIZE 128 +#define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 3) + +typedef struct siginfo { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[SI_PAD_SIZE]; + + /* kill() */ + struct { + __kernel_pid_t _pid; /* sender's pid */ + __kernel_uid_t _uid; /* backwards compatibility */ + __kernel_uid32_t _uid32; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + unsigned int _timer1; + unsigned int _timer2; + } _timer; + + /* POSIX.1b signals */ + struct { + __kernel_pid_t _pid; /* sender's pid */ + __kernel_uid_t _uid; /* backwards compatibility */ + sigval_t _sigval; + __kernel_uid32_t _uid32; /* sender's uid */ + } _rt; + + /* SIGCHLD */ + struct { + __kernel_pid_t _pid; /* which child */ + __kernel_uid_t _uid; /* backwards compatibility */ + int _status; /* exit code */ + clock_t _utime; + clock_t _stime; + __kernel_uid32_t _uid32; /* sender's uid */ + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + void *_addr; /* faulting insn/memory ref. */ + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} siginfo_t; + +#define UID16_SIGINFO_COMPAT_NEEDED + +/* + * How these fields are to be accessed. + */ +#define si_pid _sifields._kill._pid +#ifdef __KERNEL__ +#define si_uid _sifields._kill._uid32 +#define si_uid16 _sifields._kill._uid +#else +#define si_uid _sifields._kill._uid +#endif /* __KERNEL__ */ +#define si_status _sifields._sigchld._status +#define si_utime _sifields._sigchld._utime +#define si_stime _sifields._sigchld._stime +#define si_value _sifields._rt._sigval +#define si_int _sifields._rt._sigval.sival_int +#define si_ptr _sifields._rt._sigval.sival_ptr +#define si_addr _sifields._sigfault._addr +#define si_band _sifields._sigpoll._band +#define si_fd _sifields._sigpoll._fd + +#ifdef __KERNEL__ +#define __SI_MASK 0xffff0000 +#define __SI_KILL (0 << 16) +#define __SI_TIMER (1 << 16) +#define __SI_POLL (2 << 16) +#define __SI_FAULT (3 << 16) +#define __SI_CHLD (4 << 16) +#define __SI_RT (5 << 16) +#define __SI_CODE(T,N) ((T) << 16 | ((N) & 0xffff)) +#else +#define __SI_KILL 0 +#define __SI_TIMER 0 +#define __SI_POLL 0 +#define __SI_FAULT 0 +#define __SI_CHLD 0 +#define __SI_RT 0 +#define __SI_CODE(T,N) (N) +#endif + +/* + * si_code values + * Digital reserves positive values for kernel-generated signals. + */ +#define SI_USER 0 /* sent by kill, sigsend, raise */ +#define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ +#define SI_QUEUE -1 /* sent by sigqueue */ +#define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */ +#define SI_MESGQ -3 /* sent by real time mesq state change */ +#define SI_ASYNCIO -4 /* sent by AIO completion */ +#define SI_SIGIO -5 /* sent by queued SIGIO */ + +#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0) +#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0) + +/* + * SIGILL si_codes + */ +#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ +#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ +#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ +#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ +#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ +#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ +#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ +#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ +#define NSIGILL 8 + +/* + * SIGFPE si_codes + */ +#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ +#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ +#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ +#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ +#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ +#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ +#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ +#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ +#define NSIGFPE 8 + +/* + * SIGSEGV si_codes + */ +#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ +#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ +#define NSIGSEGV 2 + +/* + * SIGBUS si_codes + */ +#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ +#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ +#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ +#define NSIGBUS 3 + +/* + * SIGTRAP si_codes + */ +#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ +#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ +#define NSIGTRAP 2 + +/* + * SIGCHLD si_codes + */ +#define CLD_EXITED (__SI_CHLD|1) /* child has exited */ +#define CLD_KILLED (__SI_CHLD|2) /* child was killed */ +#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ +#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ +#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ +#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ +#define NSIGCHLD 6 + +/* + * SIGPOLL si_codes + */ +#define POLL_IN (__SI_POLL|1) /* data input available */ +#define POLL_OUT (__SI_POLL|2) /* output buffers available */ +#define POLL_MSG (__SI_POLL|3) /* input message available */ +#define POLL_ERR (__SI_POLL|4) /* i/o error */ +#define POLL_PRI (__SI_POLL|5) /* high priority input available */ +#define POLL_HUP (__SI_POLL|6) /* device disconnected */ +#define NSIGPOLL 6 + +/* + * sigevent definitions + * + * It seems likely that SIGEV_THREAD will have to be handled from + * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the + * thread manager then catches and does the appropriate nonsense. + * However, everything is written out here so as to not get lost. + */ +#define SIGEV_SIGNAL 0 /* notify via signal */ +#define SIGEV_NONE 1 /* other notification: meaningless */ +#define SIGEV_THREAD 2 /* deliver via thread creation */ + +#define SIGEV_MAX_SIZE 64 +#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) + +typedef struct sigevent { + sigval_t sigev_value; + int sigev_signo; + int sigev_notify; + union { + int _pad[SIGEV_PAD_SIZE]; + + struct { + void (*_function)(sigval_t); + void *_attribute; /* really pthread_attr_t */ + } _sigev_thread; + } _sigev_un; +} sigevent_t; + +#define sigev_notify_function _sigev_un._sigev_thread._function +#define sigev_notify_attributes _sigev_un._sigev_thread._attribute + +#ifdef __KERNEL__ +#include + +extern inline void copy_siginfo(siginfo_t *to, siginfo_t *from) +{ + if (from->si_code < 0) + memcpy(to, from, sizeof(siginfo_t)); + else + /* _sigchld is currently the largest know union member */ + memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld)); +} + +extern int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from); + +#endif /* __KERNEL__ */ + +#endif /* __V850_SIGINFO_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/signal.h linux-2.4.6/include/asm-v850/signal.h --- linux-2.4.6.uclinux-orig/include/asm-v850/signal.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/signal.h Mon Sep 17 16:54:36 2001 @@ -0,0 +1,193 @@ +#ifndef __V850_SIGNAL_H__ +#define __V850_SIGNAL_H__ + +#include + +/* Avoid too many header ordering problems. */ +struct siginfo; + + +#ifdef __KERNEL__ + +/* 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; + +#else /* !__KERNEL__ */ + +/* Here we must cater to libcs that poke about in kernel headers. */ + +#define NSIG 32 +typedef unsigned long sigset_t; + +#endif /* __KERNEL__ */ + + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#define SIGRTMAX (_NSIG-1) + +/* + * SA_FLAGS values: + * + * SA_ONSTACK indicates that a registered stack_t will be used. + * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the + * SA_RESTART flag to get restarting signals (which were the default long ago) + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. + * SA_RESETHAND clears the handler when the signal is delivered. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. + * SA_NODEFER prevents the current signal from being masked in the handler. + * + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single + * Unix names RESETHAND and NODEFER respectively. + */ +#define SA_NOCLDSTOP 0x00000001 +#define SA_NOCLDWAIT 0x00000002 /* not supported yet */ +#define SA_SIGINFO 0x00000004 +#define SA_ONSTACK 0x08000000 +#define SA_RESTART 0x10000000 +#define SA_NODEFER 0x40000000 +#define SA_RESETHAND 0x80000000 + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND +#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */ + +#define SA_RESTORER 0x04000000 + +/* + * sigaltstack controls + */ +#define SS_ONSTACK 1 +#define SS_DISABLE 2 + +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 + + +#ifdef __KERNEL__ +/* + * These values of sa_flags are used only by the kernel as part of the + * irq handling routines. + * + * SA_INTERRUPT is also used by the irq handling routines. + * SA_SHIRQ is for shared interrupt support on PCI and EISA. + */ +#define SA_PROBE SA_ONESHOT +#define SA_SAMPLE_RANDOM SA_RESTART +#define SA_SHIRQ 0x04000000 +#endif /* __KERNEL__ */ + + +#define SIG_BLOCK 0 /* for blocking signals */ +#define SIG_UNBLOCK 1 /* for unblocking signals */ +#define SIG_SETMASK 2 /* for setting the signal mask */ + +/* Type of a signal handler. */ +typedef void (*__sighandler_t)(int); + +#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ +#define SIG_IGN ((__sighandler_t)1) /* ignore signal */ +#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */ + + +#ifdef __KERNEL__ + +struct old_sigaction { + __sighandler_t sa_handler; + old_sigset_t sa_mask; + unsigned long sa_flags; + void (*sa_restorer)(void); +}; + +struct sigaction { + __sighandler_t sa_handler; + unsigned long sa_flags; + void (*sa_restorer)(void); + sigset_t sa_mask; /* mask last for extensibility */ +}; + +struct k_sigaction { + struct sigaction sa; +}; + +#else /* !__KERNEL__ */ + +/* Here we must cater to libcs that poke about in kernel headers. */ + +struct sigaction { + union { + __sighandler_t _sa_handler; + void (*_sa_sigaction)(int, struct siginfo *, void *); + } _u; + sigset_t sa_mask; + unsigned long sa_flags; + void (*sa_restorer)(void); +}; + +#define sa_handler _u._sa_handler +#define sa_sigaction _u._sa_sigaction + +#endif /* __KERNEL__ */ + + +typedef struct sigaltstack { + void *ss_sp; + int ss_flags; + size_t ss_size; +} stack_t; + +#ifdef __KERNEL__ + +#include +#undef __HAVE_ARCH_SIG_BITOPS + +#endif /* __KERNEL__ */ + +#endif /* __V850_SIGNAL_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/sim.h linux-2.4.6/include/asm-v850/sim.h --- linux-2.4.6.uclinux-orig/include/asm-v850/sim.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/sim.h Wed Oct 10 13:49:46 2001 @@ -0,0 +1,48 @@ +/* + * include/asm-v850/sim.h -- Machine-dependent defs for GDB v850e simulator + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_SIM_H__ +#define __V850_SIM_H__ + + +/* For */ +#define ON_CHIP_RAM_ADDR 0xFFFFF000 + + +/* For */ +#ifndef HZ +#define HZ 24 /* Minimum supported frequency. */ +#endif + +/* For */ +#define NUM_MACH_IRQS 6 + + +#ifndef __ASSEMBLY__ + +/* For */ +/* This gives us a single arena. */ +#define CAT_ROMARRAY +/* These should be defined by sim startup. */ +extern unsigned long blkmem_0_addr, blkmem_0_len; +extern int blkmem_0_rw; +/* Make the single arena point use them. */ +#define FIXUP_ARENAS \ + arena[0].rw = blkmem_0_rw; \ + arena[0].address = blkmem_0_addr; \ + arena[0].length = blkmem_0_len; + +#endif /* !__ASSEMBLY__ */ + + +#endif /* __V850_SIM_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/simsyscall.h linux-2.4.6/include/asm-v850/simsyscall.h --- linux-2.4.6.uclinux-orig/include/asm-v850/simsyscall.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/simsyscall.h Tue Sep 11 14:34:41 2001 @@ -0,0 +1,99 @@ +/* + * include/asm-v850/simsyscall.h -- `System calls' under the v850e emulator + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_SIMSYSCALL_H__ +#define __V850_SIMSYSCALL_H__ + +#define V850_SIM_SYS_exit(a...) V850_SIM_SYSCALL_1 (1 , ##a) +#define V850_SIM_SYS_fork(a...) V850_SIM_SYSCALL_0 (2 , ##a) +#define V850_SIM_SYS_read(a...) V850_SIM_SYSCALL_3 (3 , ##a) +#define V850_SIM_SYS_write(a...) V850_SIM_SYSCALL_3 (4 , ##a) +#define V850_SIM_SYS_open(a...) V850_SIM_SYSCALL_2 (5 , ##a) +#define V850_SIM_SYS_close(a...) V850_SIM_SYSCALL_1 (6 , ##a) +#define V850_SIM_SYS_wait4(a...) V850_SIM_SYSCALL_4 (7 , ##a) +/* #define V850_SIM_SYS_creat(a...) V850_SIM_SYSCALL_1 (8 , ##a) */ +/* #define V850_SIM_SYS_link(a...) V850_SIM_SYSCALL_1 (9 , ##a) */ +/* #define V850_SIM_SYS_unlink(a...) V850_SIM_SYSCALL_1 (10 , ##a) */ +#define V850_SIM_SYS_execv(a...) V850_SIM_SYSCALL_2 (11 , ##a) +/* #define V850_SIM_SYS_chdir(a...) V850_SIM_SYSCALL_1 (12 , ##a) */ +/* #define V850_SIM_SYS_mknod(a...) V850_SIM_SYSCALL_1 (14 , ##a) */ +#define V850_SIM_SYS_chmod(a...) V850_SIM_SYSCALL_2 (15 , ##a) +#define V850_SIM_SYS_chown(a...) V850_SIM_SYSCALL_2 (16 , ##a) +#define V850_SIM_SYS_lseek(a...) V850_SIM_SYSCALL_3 (19 , ##a) +/* #define V850_SIM_SYS_getpid(a...) V850_SIM_SYSCALL_1 (20 , ##a) */ +/* #define V850_SIM_SYS_isatty(a...) V850_SIM_SYSCALL_1 (21 , ##a) */ +/* #define V850_SIM_SYS_fstat(a...) V850_SIM_SYSCALL_1 (22 , ##a) */ +#define V850_SIM_SYS_time(a...) V850_SIM_SYSCALL_1 (23 , ##a) +#define V850_SIM_SYS_poll(a...) V850_SIM_SYSCALL_3 (24 , ##a) +#define V850_SIM_SYS_stat(a...) V850_SIM_SYSCALL_2 (38 , ##a) +#define V850_SIM_SYS_pipe(a...) V850_SIM_SYSCALL_1 (42 , ##a) +#define V850_SIM_SYS_times(a...) V850_SIM_SYSCALL_1 (43 , ##a) +#define V850_SIM_SYS_execve(a...) V850_SIM_SYSCALL_3 (59 , ##a) +#define V850_SIM_SYS_gettimeofday(a...) V850_SIM_SYSCALL_2 (116 , ##a) +/* #define V850_SIM_SYS_utime(a...) V850_SIM_SYSCALL_2 (201 , ##a) */ +/* #define V850_SIM_SYS_wait(a...) V850_SIM_SYSCALL_1 (202 , ##a) */ + +#define V850_SIM_SYS_make_raw(a...) V850_SIM_SYSCALL_1 (1024 , ##a) + + +#define V850_SIM_SYSCALL_0(_call) \ +({ \ + register int call __asm__ ("r6") = _call; \ + register int rval __asm__ ("r10"); \ + __asm__ __volatile__ ("trap 31" \ + : "=r" (rval) \ + : "r" (call) \ + : "r11", "memory"); \ + rval; \ +}) +#define V850_SIM_SYSCALL_1(_call, _arg0) \ +({ \ + register int call __asm__ ("r6") = _call; \ + register long arg0 __asm__ ("r7") = (long)_arg0; \ + register int rval __asm__ ("r10"); \ + __asm__ __volatile__ ("trap 31" \ + : "=r" (rval) \ + : "r" (call), "r" (arg0) \ + : "r11", "memory"); \ + rval; \ +}) +#define V850_SIM_SYSCALL_2(_call, _arg0, _arg1) \ +({ \ + register int call __asm__ ("r6") = _call; \ + register long arg0 __asm__ ("r7") = (long)_arg0; \ + register long arg1 __asm__ ("r8") = (long)_arg1; \ + register int rval __asm__ ("r10"); \ + __asm__ __volatile__ ("trap 31" \ + : "=r" (rval) \ + : "r" (call), "r" (arg0), "r" (arg1) \ + : "r11", "memory"); \ + rval; \ +}) +#define V850_SIM_SYSCALL_3(_call, _arg0, _arg1, _arg2) \ +({ \ + register int call __asm__ ("r6") = _call; \ + register long arg0 __asm__ ("r7") = (long)_arg0; \ + register long arg1 __asm__ ("r8") = (long)_arg1; \ + register long arg2 __asm__ ("r9") = (long)_arg2; \ + register int rval __asm__ ("r10"); \ + __asm__ __volatile__ ("trap 31" \ + : "=r" (rval) \ + : "r" (call), "r" (arg0), "r" (arg1), "r" (arg2)\ + : "r11", "memory"); \ + rval; \ +}) + +#define V850_SIM_SYSCALL(call, args...) \ + V850_SIM_SYS_##call (args) + +#endif /* __V850_SIMSYSCALL_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/socket.h linux-2.4.6/include/asm-v850/socket.h --- linux-2.4.6.uclinux-orig/include/asm-v850/socket.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/socket.h Wed Aug 29 10:58:13 2001 @@ -0,0 +1,64 @@ +#ifndef __V850_SOCKET_H__ +#define __V850_SOCKET_H__ + +#include + +/* For setsockoptions(2) */ +#define SOL_SOCKET 1 + +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 13 +#define SO_BSDCOMPAT 14 +/* To add :#define SO_REUSEPORT 15 */ +#define SO_PASSCRED 16 +#define SO_PEERCRED 17 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 + +/* Security levels - as per NRL IPv6 - don't actually do anything */ +#define SO_SECURITY_AUTHENTICATION 22 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define SO_SECURITY_ENCRYPTION_NETWORK 24 + +#define SO_BINDTODEVICE 25 + +/* Socket filtering */ +#define SO_ATTACH_FILTER 26 +#define SO_DETACH_FILTER 27 + +#define SO_PEERNAME 28 +#define SO_TIMESTAMP 29 +#define SCM_TIMESTAMP SO_TIMESTAMP + +#define SO_ACCEPTCONN 30 + +/* Nast libc5 fixup - bletch */ +#if defined(__KERNEL__) +/* Socket types. */ +#define SOCK_STREAM 1 /* stream (connection) socket */ +#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ +#define SOCK_RAW 3 /* raw socket */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequential packet socket */ +#define SOCK_PACKET 10 /* linux specific way of */ + /* getting packets at the dev */ + /* level. For writing rarp and */ + /* other similar things on the */ + /* user level. */ +#define SOCK_MAX (SOCK_PACKET+1) +#endif + +#endif /* __V850_SOCKET_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/sockios.h linux-2.4.6/include/asm-v850/sockios.h --- linux-2.4.6.uclinux-orig/include/asm-v850/sockios.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/sockios.h Wed Aug 29 10:58:10 2001 @@ -0,0 +1,12 @@ +#ifndef __V850_SOCKIOS_H__ +#define __V850_SOCKIOS_H__ + +/* Socket-level I/O control calls. */ +#define FIOSETOWN 0x8901 +#define SIOCSPGRP 0x8902 +#define FIOGETOWN 0x8903 +#define SIOCGPGRP 0x8904 +#define SIOCATMARK 0x8905 +#define SIOCGSTAMP 0x8906 /* Get stamp */ + +#endif /* __V850_SOCKIOS_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/softirq.h linux-2.4.6/include/asm-v850/softirq.h --- linux-2.4.6.uclinux-orig/include/asm-v850/softirq.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/softirq.h Wed Oct 10 13:49:58 2001 @@ -0,0 +1,21 @@ +#ifndef __V850_SOFTIRQ_H__ +#define __V850_SOFTIRQ_H__ + +#include +#include + +#define __cpu_bh_enable(cpu) \ + do { barrier(); local_bh_count(cpu)--; } while (0) +#define cpu_bh_disable(cpu) \ + do { local_bh_count(cpu)++; barrier(); } while (0) + +#define local_bh_disable() cpu_bh_disable(smp_processor_id()) +#define __local_bh_enable() __cpu_bh_enable(smp_processor_id()) +#define __cpu_raise_softirq(cpu,nr) set_bit((nr), &softirq_pending(cpu)); +#define raise_softirq(nr) __cpu_raise_softirq(smp_processor_id(), (nr)) + +#define in_softirq() (local_bh_count(smp_processor_id()) != 0) + +#define local_bh_enable() __local_bh_enable() + +#endif /* __V850_SOFTIRQ_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/stat.h linux-2.4.6/include/asm-v850/stat.h --- linux-2.4.6.uclinux-orig/include/asm-v850/stat.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/stat.h Wed Aug 29 10:57:55 2001 @@ -0,0 +1,80 @@ +#ifndef __V850_STAT_H__ +#define __V850_STAT_H__ + +struct __old_kernel_stat { + unsigned short st_dev; + unsigned short st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned long st_size; + unsigned long st_atime; + unsigned long st_mtime; + unsigned long st_ctime; +}; + +struct stat { + unsigned short st_dev; + unsigned short __pad1; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned short __pad2; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long __unused1; + unsigned long st_mtime; + unsigned long __unused2; + unsigned long st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; + +/* This matches struct stat64 in glibc2.1, hence the absolutely + * insane amounts of padding around dev_t's. + */ +struct stat64 { + unsigned char __pad0[6]; + unsigned short st_dev; + unsigned char __pad1[4]; + +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + + unsigned int st_mode; + unsigned int st_nlink; + + unsigned long st_uid; + unsigned long st_gid; + + unsigned char __pad2[6]; + unsigned short st_rdev; + unsigned char __pad3[4]; + + long long st_size; + unsigned long st_blksize; + + unsigned long __pad4; /* future possible st_blocks high bits */ + unsigned long st_blocks; /* Number 512-byte blocks allocated. */ + + unsigned long st_atime; + unsigned long __pad5; + + unsigned long st_mtime; + unsigned long __pad6; + + unsigned long st_ctime; + unsigned long __pad7; /* will be high 32 bits of ctime someday */ + + unsigned long long st_ino; +}; + +#endif /* __V850_STAT_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/statfs.h linux-2.4.6/include/asm-v850/statfs.h --- linux-2.4.6.uclinux-orig/include/asm-v850/statfs.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/statfs.h Mon Sep 17 16:54:35 2001 @@ -0,0 +1,25 @@ +#ifndef __V850_STATFS_H__ +#define __V850_STATFS_H__ + +#ifndef __KERNEL_STRICT_NAMES + +#include + +typedef __kernel_fsid_t fsid_t; + +#endif + +struct statfs { + long f_type; + long f_bsize; + long f_blocks; + long f_bfree; + long f_bavail; + long f_files; + long f_ffree; + __kernel_fsid_t f_fsid; + long f_namelen; + long f_spare[6]; +}; + +#endif /* __V850_STATFS_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/string.h linux-2.4.6/include/asm-v850/string.h --- linux-2.4.6.uclinux-orig/include/asm-v850/string.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/string.h Wed Aug 29 10:58:17 2001 @@ -0,0 +1,4 @@ +#ifndef __V850_STRING_H__ +#define __V850_STRING_H__ + +#endif /* __V850_STRING_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/system.h linux-2.4.6/include/asm-v850/system.h --- linux-2.4.6.uclinux-orig/include/asm-v850/system.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/system.h Wed Oct 10 10:53:55 2001 @@ -0,0 +1,117 @@ +/* + * include/asm-v850/system.h -- Low-level interrupt/thread ops + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_SYSTEM_H__ +#define __V850_SYSTEM_H__ + +#include +#include + + +#define prepare_to_switch() do { } while (0) + +/* + * switch_to(n) should switch tasks to task ptr, first checking that + * ptr isn't the current task, in which case it does nothing. + */ +struct thread_struct; +extern void *switch_thread (struct thread_struct *last, + struct thread_struct *next); +#define switch_to(prev,next,last) \ + do { \ + if (prev != next) { \ + (last) = switch_thread (&prev->thread, &next->thread); \ + } \ + } while (0) + + +/* Enable/disable interrupts. */ +#define __sti() \ + __asm__ __volatile__ ("ei" ::: "memory") +#define __cli() \ + __asm__ __volatile__ ("di" ::: "memory") + +#define __save_flags(flags) \ + __asm__ __volatile__ ("stsr %1, %0" : "=r" (flags) : "i" (SR_PSW)) +#define __restore_flags(flags) \ + __asm__ __volatile__ ("ldsr %0, %1" :: "r" (flags), "i" (SR_PSW)) +#define __save_flags_cli(flags) \ + do { __save_flags (flags); __cli (); } while (0) + + +/* For spinlocks etc */ +#define local_irq_save(flags) __save_flags_cli (flags) +#define local_irq_restore(flags) __restore_flags (flags) +#define local_irq_disable() __cli () +#define local_irq_enable() __sti () + +#define cli() __cli () +#define sti() __sti () +#define save_flags(flags) __save_flags (flags) +#define restore_flags(flags) __restore_flags (flags) +#define save_flags_cli(flags) __save_flags_cli (flags) + +/* + * Force strict CPU ordering. + * Not really required on v850... + */ +#define nop() __asm__ __volatile__ ("nop") +#define mb() __asm__ __volatile__ ("" ::: "memory") +#define rmb() mb () +#define wmb() mb () +#define set_rmb(var, value) do { xchg (&var, value); } while (0) +#define set_mb(var, value) set_rmb (var, value) +#define set_wmb(var, value) do { var = value; wmb (); } while (0) + +#ifdef CONFIG_SMP +#define smp_mb() mb () +#define smp_rmb() rmb () +#define smp_wmb() wmb () +#else +#define smp_mb() barrier () +#define smp_rmb() barrier () +#define smp_wmb() barrier () +#endif + +#define xchg(ptr, with) \ + ((__typeof__ (*(ptr)))__xchg ((unsigned long)(with), (ptr), sizeof (*(ptr)))) +#define tas(ptr) (xchg ((ptr), 1)) + +extern inline unsigned long __xchg (unsigned long with, + __volatile__ void *ptr, int size) +{ + unsigned long tmp, flags; + + save_flags_cli (flags); + + switch (size) { + case 1: + tmp = *(unsigned char *)ptr; + *(unsigned char *)ptr = with; + break; + case 2: + tmp = *(unsigned short *)ptr; + *(unsigned short *)ptr = with; + break; + case 4: + tmp = *(unsigned long *)ptr; + *(unsigned long *)ptr = with; + break; + } + + restore_flags (flags); + + return tmp; +} + +#endif /* __V850_SYSTEM_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/teg.h linux-2.4.6/include/asm-v850/teg.h --- linux-2.4.6.uclinux-orig/include/asm-v850/teg.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/teg.h Fri Oct 5 11:34:35 2001 @@ -0,0 +1,57 @@ +/* + * include/asm-v850/nb85e_teg.h -- NB85E-TEG cpu chip + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_NB85E_TEG_H__ +#define __V850_NB85E_TEG_H__ + +/* The NB85E_TEG uses the NB85E cpu core. */ +#include + +#define CHIP "v850e/nb85e-teg" +#define CHIP_LONG "NEC V850E/NB85E TEG" + +/* Hardware-specific interrupt numbers (in the kernel IRQ namespace). */ +#define IRQ_INTOV(n) (n) /* 0-3 */ +#define IRQ_INTOV_NUM 4 +#define IRQ_INTCMD(n) (0x1c + (n)) /* interval timer interrupts 0-3 */ +#define IRQ_INTCMD_NUM 4 +#define IRQ_INTDMA(n) (0x20 + (n)) /* DMA interrupts 0-3 */ +#define IRQ_INTDMA_NUM 4 +#define IRQ_INTCSI(n) (0x24 + (n)) /* CSI 0-2 transmit/receive completion */ +#define IRQ_INTCSI_NUM 3 +#define IRQ_INTSER(n) (0x25 + (n)) /* UART 0-2 reception error */ +#define IRQ_INTSER_NUM 3 +#define IRQ_INTSR(n) (0x26 + (n)) /* UART 0-2 reception completion */ +#define IRQ_INTSR_NUM 3 +#define IRQ_INTST(n) (0x27 + (n)) /* UART 0-2 transmission completion */ +#define IRQ_INTST_NUM 3 + +/* For */ +#define NUM_MACH_IRQS 0x30 + +/* TEG UART details. */ +#define NB85E_UART_NUM_CHANNELS 3 +#define NB85E_UART_BASE_ADDR 0xFFFFF600 +#define NB85E_UART_ASIM_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x0) +#define NB85E_UART_ASIS_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x2) +#define NB85E_UART_ASIF_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x6) +#define NB85E_UART_TXB_BASE_ADDR (NB85E_UART_BASE_ADDR + 0xA) +#define NB85E_UART_RXB_BASE_ADDR (NB85E_UART_BASE_ADDR + 0xC) +#define NB85E_UART_CKSR_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x6) +#define NB85E_UART_BRGC_BASE_ADDR (NB85E_UART_BASE_ADDR + 0x8) + +/* The TEG RTPU. */ +#define NB85E_RTPU_BASE_ADDR 0xFFFFF210 + + +#endif /* __V850_NB85E_TEG_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/termbits.h linux-2.4.6/include/asm-v850/termbits.h --- linux-2.4.6.uclinux-orig/include/asm-v850/termbits.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/termbits.h Thu Sep 13 11:19:54 2001 @@ -0,0 +1,174 @@ +#ifndef __V850_TERMBITS_H__ +#define __V850_TERMBITS_H__ + +#include + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 + +/* c_cflag bit meaning */ +#define CBAUD 0010017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CBAUDEX 0010000 +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 +#define CIBAUD 002003600000 /* input baud rate (not used) */ +#define CMSPAR 010000000000 /* mark or space (stick) parity */ +#define CRTSCTS 020000000000 /* flow control */ + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 + + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +#endif /* __V850_TERMBITS_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/termios.h linux-2.4.6/include/asm-v850/termios.h --- linux-2.4.6.uclinux-orig/include/asm-v850/termios.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/termios.h Thu Sep 13 11:19:54 2001 @@ -0,0 +1,106 @@ +#ifndef __V850_TERMIOS_H__ +#define __V850_TERMIOS_H__ + +#include +#include + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 +#define N_STRIP 4 +#define N_AX25 5 +#define N_X25 6 /* X.25 async */ +#define N_6PACK 7 +#define N_MASC 8 /* Reserved for Mobitex module */ +#define N_R3964 9 /* Reserved for Simatic R3964 module */ +#define N_PROFIBUS_FDL 10 /* Reserved for Profibus */ +#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */ +#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */ +#define N_HDLC 13 /* synchronous HDLC */ +#define N_SYNC_PPP 14 /* synchronous PPP */ +#define N_HCI 15 /* Bluetooth HCI UART */ + +#ifdef __KERNEL__ + +/* intr=^C quit=^\ erase=del kill=^U + eof=^D vtime=\0 vmin=\1 sxtc=\0 + start=^Q stop=^S susp=^Z eol=\0 + reprint=^R discard=^U werase=^W lnext=^V + eol2=\0 +*/ +#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" + +/* + * Translate a "termio" structure into a "termios". Ugh. + */ +#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \ + unsigned short __tmp; \ + get_user(__tmp,&(termio)->x); \ + *(unsigned short *) &(termios)->x = __tmp; \ +} + +#define user_termio_to_kernel_termios(termios, termio) \ +({ \ + SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ + SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ + SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ + SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ + copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ +}) + +/* + * Translate a "termios" structure into a "termio". Ugh. + */ +#define kernel_termios_to_user_termio(termio, termios) \ +({ \ + put_user((termios)->c_iflag, &(termio)->c_iflag); \ + put_user((termios)->c_oflag, &(termio)->c_oflag); \ + put_user((termios)->c_cflag, &(termio)->c_cflag); \ + put_user((termios)->c_lflag, &(termio)->c_lflag); \ + put_user((termios)->c_line, &(termio)->c_line); \ + copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ +}) + +#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios)) +#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios)) + +#endif /* __KERNEL__ */ + +#endif /* __V850_TERMIOS_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/timex.h linux-2.4.6/include/asm-v850/timex.h --- linux-2.4.6.uclinux-orig/include/asm-v850/timex.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/timex.h Wed Aug 29 10:58:04 2001 @@ -0,0 +1,22 @@ +/* + * linux/include/asm-v850/timex.h + * + * v850 architecture timex specifications + */ +#ifndef __V850_TIMEX_H__ +#define __V850_TIMEX_H__ + +#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ +#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */ +#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \ + (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \ + << (SHIFT_SCALE-SHIFT_HZ)) / HZ) + +typedef unsigned long cycles_t; + +static inline cycles_t get_cycles(void) +{ + return 0; +} + +#endif /* __V850_TIMEX_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/types.h linux-2.4.6/include/asm-v850/types.h --- linux-2.4.6.uclinux-orig/include/asm-v850/types.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/types.h Wed Aug 29 10:57:53 2001 @@ -0,0 +1,58 @@ +#ifndef __V850_TYPES_H__ +#define __V850_TYPES_H__ + +/* + * This file is never included by application software unless + * explicitly requested (e.g., via linux/types.h) in which case the + * application is Linux specific so (user-) name space pollution is + * not a major issue. However, for interoperability, libraries still + * need to be careful to avoid a name clashes. + */ + +typedef unsigned short umode_t; + +/* + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space + */ + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + +/* + * These aren't exported outside the kernel to avoid name space clashes + */ +#ifdef __KERNEL__ + +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +typedef signed long long s64; +typedef unsigned long long u64; + +#define BITS_PER_LONG 32 + +/* Dma addresses are 32-bits wide. */ + +typedef u32 dma_addr_t; + +#endif /* __KERNEL__ */ + +#endif /* __V850_TYPES_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/uaccess.h linux-2.4.6/include/asm-v850/uaccess.h --- linux-2.4.6.uclinux-orig/include/asm-v850/uaccess.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/uaccess.h Wed Oct 10 13:50:02 2001 @@ -0,0 +1,142 @@ +#ifndef __V850_UACCESS_H__ +#define __V850_UACCESS_H__ + +/* + * User space memory access functions + */ +#include +#include + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +extern inline int access_ok (int type, const void *addr, unsigned long size) +{ + /* Rather bogus... XXX */ + return (unsigned long)addr < 0x10f00000; +} + +extern inline int verify_area (int type, const void *addr, unsigned long size) +{ + return access_ok (type, addr, size) ? 0 : -EFAULT; +} + +/* + * The exception table consists of pairs of addresses: the first is the + * address of an instruction that is allowed to fault, and the second is + * the address at which the program should continue. No registers are + * modified, so it is entirely up to the continuation code to figure out + * what to do. + * + * All the routines below use bits of fixup code that are out of line + * with the main instruction path. This means when everything is well, + * we don't even have to jump over them. Further, they do not intrude + * on our cache or tlb entries. + */ + +struct exception_table_entry +{ + unsigned long insn, fixup; +}; + +/* Returns 0 if exception not found and fixup otherwise. */ +extern unsigned long search_exception_table (unsigned long); + + +/* + * These are the main single-value transfer routines. They automatically + * use the right size if we just have the right pointer type. + */ + +extern int bad_user_access_length (void); + +#define __get_user(var, ptr) \ + ({ \ + int __gu_err = 0; \ + typeof(*(ptr)) __gu_val = 0; \ + switch (sizeof (*(ptr))) { \ + case 1: \ + case 2: \ + case 4: \ + __gu_val = *(ptr); \ + break; \ + default: \ + __gu_val = 0; \ + __gu_err = __get_user_bad (); \ + break; \ + } \ + (var) = __gu_val; \ + __gu_err; \ + }) +#define __get_user_bad() (bad_user_access_length (), (-EFAULT)) + +#define __put_user(var, ptr) \ + ({ \ + int __pu_err = 0; \ + switch (sizeof (*(ptr))) { \ + case 1: \ + case 2: \ + case 4: \ + *(ptr) = (var); \ + break; \ + default: \ + __pu_err = __put_user_bad (); \ + break; \ + } \ + __pu_err; \ + }) +#define __put_user_bad() (bad_user_access_length (), (-EFAULT)) + +#define put_user(x, ptr) __put_user(x, ptr) +#define get_user(x, ptr) __get_user(x, ptr) + +#define __copy_from_user(to, from, n) (memcpy (to, from, n), 0) +#define __copy_to_user(to, from, n) (memcpy(to, from, n), 0) + +#define copy_from_user(to, from, n) __copy_from_user (to, from, n) +#define copy_to_user(to, from, n) __copy_to_user(to, from, n) + +#define copy_to_user_ret(to,from,n,retval) \ + ({ if (copy_to_user (to,from,n)) return retval; }) + +#define copy_from_user_ret(to,from,n,retval) \ + ({ if (copy_from_user (to,from,n)) return retval; }) + +/* + * Copy a null terminated string from userspace. + */ + +static inline long +strncpy_from_user (char *dst, const char *src, long count) +{ + char *tmp; + strncpy (dst, src, count); + for (tmp = dst; *tmp && count > 0; tmp++, count--) + ; + return tmp - dst; +} + +/* + * Return the size of a string (including the ending 0) + * + * Return 0 on exception, a value greater than N if too long + */ +static inline long strnlen_user (const char *src, long n) +{ + return strlen (src) + 1; +} + +#define strlen_user(str) strnlen_user (str, 32767) + +/* + * Zero Userspace + */ + +static inline unsigned long +clear_user (void *to, unsigned long n) +{ + memset (to, 0, n); + return 0; +} + +#endif /* __V850_UACCESS_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/ucontext.h linux-2.4.6/include/asm-v850/ucontext.h --- linux-2.4.6.uclinux-orig/include/asm-v850/ucontext.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/ucontext.h Tue Sep 11 16:17:59 2001 @@ -0,0 +1,14 @@ +#ifndef __V850_UCONTEXT_H__ +#define __V850_UCONTEXT_H__ + +#include + +struct ucontext { + unsigned long uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + struct sigcontext uc_mcontext; + sigset_t uc_sigmask; /* mask last for extensibility */ +}; + +#endif /* __V850_UCONTEXT_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/unaligned.h linux-2.4.6/include/asm-v850/unaligned.h --- linux-2.4.6.uclinux-orig/include/asm-v850/unaligned.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/unaligned.h Tue Sep 11 15:12:53 2001 @@ -0,0 +1,130 @@ +/* + * include/asm-v850/unaligned.h -- Unaligned memory access + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * This file is a copy of the arm version, include/asm-arm/unaligned.h + * + * Note that some v850 chips support unaligned access, but it seems too + * annoying to use. + */ + +#ifndef __V850_UNALIGNED_H__ +#define __V850_UNALIGNED_H__ + +#include + +extern int __bug_unaligned_x(void *ptr); + +/* + * What is the most efficient way of loading/storing an unaligned value? + * + * That is the subject of this file. Efficiency here is defined as + * minimum code size with minimum register usage for the common cases. + * It is currently not believed that long longs are common, so we + * trade efficiency for the chars, shorts and longs against the long + * longs. + * + * Current stats with gcc 2.7.2.2 for these functions: + * + * ptrsize get: code regs put: code regs + * 1 1 1 1 2 + * 2 3 2 3 2 + * 4 7 3 7 3 + * 8 20 6 16 6 + * + * gcc 2.95.1 seems to code differently: + * + * ptrsize get: code regs put: code regs + * 1 1 1 1 2 + * 2 3 2 3 2 + * 4 7 4 7 4 + * 8 19 8 15 6 + * + * which may or may not be more efficient (depending upon whether + * you can afford the extra registers). Hopefully the gcc 2.95 + * is inteligent enough to decide if it is better to use the + * extra register, but evidence so far seems to suggest otherwise. + * + * Unfortunately, gcc is not able to optimise the high word + * out of long long >> 32, or the low word from long long << 32 + */ + +#define __get_unaligned_2(__p) \ + (__p[0] | __p[1] << 8) + +#define __get_unaligned_4(__p) \ + (__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24) + +#define get_unaligned(ptr) \ + ({ \ + __typeof__(*(ptr)) __v; \ + __u8 *__p = (__u8 *)(ptr); \ + switch (sizeof(*(ptr))) { \ + case 1: __v = *(ptr); break; \ + case 2: __v = __get_unaligned_2(__p); break; \ + case 4: __v = __get_unaligned_4(__p); break; \ + case 8: { \ + unsigned int __v1, __v2; \ + __v2 = __get_unaligned_4((__p+4)); \ + __v1 = __get_unaligned_4(__p); \ + __v = ((unsigned long long)__v2 << 32 | __v1); \ + } \ + break; \ + default: __v = __bug_unaligned_x(__p); break; \ + } \ + __v; \ + }) + + +extern inline void __put_unaligned_2(__u32 __v, register __u8 *__p) +{ + *__p++ = __v; + *__p++ = __v >> 8; +} + +extern inline void __put_unaligned_4(__u32 __v, register __u8 *__p) +{ + __put_unaligned_2(__v >> 16, __p + 2); + __put_unaligned_2(__v, __p); +} + +extern inline void __put_unaligned_8(const unsigned long long __v, register __u8 *__p) +{ + /* + * tradeoff: 8 bytes of stack for all unaligned puts (2 + * instructions), or an extra register in the long long + * case - go for the extra register. + */ + __put_unaligned_4(__v >> 32, __p+4); + __put_unaligned_4(__v, __p); +} + +/* + * Try to store an unaligned value as efficiently as possible. + */ +#define put_unaligned(val,ptr) \ + ({ \ + switch (sizeof(*(ptr))) { \ + case 1: \ + *(ptr) = (val); \ + break; \ + case 2: __put_unaligned_2((val),(__u8 *)(ptr)); \ + break; \ + case 4: __put_unaligned_4((val),(__u8 *)(ptr)); \ + break; \ + case 8: __put_unaligned_8((val),(__u8 *)(ptr)); \ + break; \ + default: __bug_unaligned_x(ptr); \ + break; \ + } \ + (void) 0; \ + }) + + +#endif /* __V850_UNALIGNED_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/unistd.h linux-2.4.6/include/asm-v850/unistd.h --- linux-2.4.6.uclinux-orig/include/asm-v850/unistd.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/unistd.h Tue Sep 11 14:36:14 2001 @@ -0,0 +1,414 @@ +/* + * include/asm-v850/unistd.h -- System call numbers and invocation mechanism + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_UNISTD_H__ +#define __V850_UNISTD_H__ + +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_waitpid 7 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_time 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_chown 16 +#define __NR_break 17 +#define __NR_oldstat 18 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_stime 25 +#define __NR_ptrace 26 +#define __NR_alarm 27 +#define __NR_oldfstat 28 +#define __NR_pause 29 +#define __NR_utime 30 +#define __NR_stty 31 +#define __NR_gtty 32 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_ftime 35 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_prof 44 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_signal 48 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_umount2 52 +#define __NR_lock 53 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_mpx 56 +#define __NR_setpgid 57 +#define __NR_ulimit 58 +#define __NR_oldolduname 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_sgetmask 68 +#define __NR_ssetmask 69 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_old_getrlimit 76 +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_select 82 +#define __NR_symlink 83 +#define __NR_oldlstat 84 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_readdir 89 +#define __NR_mmap 90 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_profil 98 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_ioperm 101 +#define __NR_socketcall 102 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_olduname 109 +#define __NR_iopl /* 110 */ not supported +#define __NR_vhangup 111 +#define __NR_idle /* 112 */ Obsolete +#define __NR_vm86 /* 113 */ not supported +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_ipc 117 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_cacheflush 123 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_create_module 127 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_get_kernel_syms 130 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 +#define __NR_setresuid 164 +#define __NR_getresuid 165 +#define __NR_query_module 167 +#define __NR_poll 168 +#define __NR_nfsservctl 169 +#define __NR_setresgid 170 +#define __NR_getresgid 171 +#define __NR_prctl 172 +#define __NR_rt_sigreturn 173 +#define __NR_rt_sigaction 174 +#define __NR_rt_sigprocmask 175 +#define __NR_rt_sigpending 176 +#define __NR_rt_sigtimedwait 177 +#define __NR_rt_sigqueueinfo 178 +#define __NR_rt_sigsuspend 179 +#define __NR_pread 180 +#define __NR_pwrite 181 +#define __NR_lchown 182 +#define __NR_getcwd 183 +#define __NR_capget 184 +#define __NR_capset 185 +#define __NR_sigaltstack 186 +#define __NR_sendfile 187 +#define __NR_getpmsg 188 /* some people actually want streams */ +#define __NR_putpmsg 189 /* some people actually want streams */ +#define __NR_vfork 190 +#define __NR_getrlimit 191 +#define __NR_mmap2 192 +#define __NR_truncate64 193 +#define __NR_ftruncate64 194 +#define __NR_stat64 195 +#define __NR_lstat64 196 +#define __NR_fstat64 197 +#define __NR_chown32 198 +#define __NR_getuid32 199 +#define __NR_getgid32 200 +#define __NR_geteuid32 201 +#define __NR_getegid32 202 +#define __NR_setreuid32 203 +#define __NR_setregid32 204 +#define __NR_getgroups32 205 +#define __NR_setgroups32 206 +#define __NR_fchown32 207 +#define __NR_setresuid32 208 +#define __NR_getresuid32 209 +#define __NR_setresgid32 210 +#define __NR_getresgid32 211 +#define __NR_lchown32 212 +#define __NR_setuid32 213 +#define __NR_setgid32 214 +#define __NR_setfsuid32 215 +#define __NR_setfsgid32 216 + +/* user-visible error numbers are in the range -1 - -122: see + */ + +/* Syscall protocol: + Syscall number in r12, args in r6-r9, r13-r14 + Return value in r10 + Trap 0 for `short' syscalls, where all the args can fit in function + call argument registers, and trap 1 when there are additional args in + r13-r14. */ + +#define SYSCALL_NUM "r12" +#define SYSCALL_ARG0 "r6" +#define SYSCALL_ARG1 "r7" +#define SYSCALL_ARG2 "r8" +#define SYSCALL_ARG3 "r9" +#define SYSCALL_ARG4 "r13" +#define SYSCALL_ARG5 "r14" +#define SYSCALL_RET "r10" + +#define SYSCALL_SHORT_TRAP "0" +#define SYSCALL_LONG_TRAP "1" + +/* Registers clobbered by a syscall. */ +#define SYSCALL_CLOBBERS "r1", "r5", "r11", "r12", "r13", "r14", \ + "r15", "r16", "r17", "r18", "r19" + +#define __syscall_return(type, res) \ + do { \ + if ((unsigned long)(res) >= (unsigned long)(-125)) { \ + errno = -(res); \ + res = -1; \ + } \ + return (type) (res); \ + } while (0) + +#define _syscall0(type, name) \ +type name (void) \ +{ \ + register unsigned long __ret __asm__ (SYSCALL_RET); \ + __asm__ __volatile__ ("mov %1, " SYSCALL_NUM ";" \ + "trap " SYSCALL_SHORT_TRAP \ + : "=r" (__ret) \ + : "i" (__NR_##name) \ + : SYSCALL_NUM, SYSCALL_CLOBBERS); \ + __syscall_return (type, __ret); \ +} + +#define _syscall1(type, name, atype, a) \ +type name (atype a) \ +{ \ + register unsigned long __ret __asm__ (SYSCALL_RET); \ + register atype __a __asm__ (SYSCALL_ARG0) = a; \ + __asm__ __volatile__ ("mov %1, " SYSCALL_NUM ";" \ + "trap " SYSCALL_SHORT_TRAP \ + : "=r" (__ret) \ + : "i" (__NR_##name), "r" (__a) \ + : SYSCALL_NUM, SYSCALL_CLOBBERS); \ + __syscall_return (type, __ret); \ +} + +#define _syscall2(type, name, atype, a, btype, b) \ +type name (atype a, btype b) \ +{ \ + register unsigned long __ret __asm__ (SYSCALL_RET); \ + register atype __a __asm__ (SYSCALL_ARG0) = a; \ + register btype __b __asm__ (SYSCALL_ARG1) = b; \ + __asm__ __volatile__ ("mov %1, " SYSCALL_NUM ";" \ + "trap " SYSCALL_SHORT_TRAP \ + : "=r" (__ret) \ + : "i" (__NR_##name), "r" (__a), "r" (__b) \ + : SYSCALL_NUM, SYSCALL_CLOBBERS); \ + __syscall_return (type, __ret); \ +} + +#define _syscall3(type, name, atype, a, btype, b, ctype, c) \ +type name (atype a, btype b, ctype c) \ +{ \ + register unsigned long __ret __asm__ (SYSCALL_RET); \ + register atype __a __asm__ (SYSCALL_ARG0) = a; \ + register btype __b __asm__ (SYSCALL_ARG1) = b; \ + register ctype __c __asm__ (SYSCALL_ARG2) = c; \ + __asm__ __volatile__ ("mov %1, " SYSCALL_NUM ";" \ + "trap " SYSCALL_SHORT_TRAP \ + : "=r" (__ret) \ + : "i" (__NR_##name), "r" (__a), "r" (__b), "r" (__c) \ + : SYSCALL_NUM, SYSCALL_CLOBBERS); \ + __syscall_return (type, __ret); \ +} + +#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \ +type name (atype a, btype b, ctype c, dtype d) \ +{ \ + register unsigned long __ret __asm__ (SYSCALL_RET); \ + register atype __a __asm__ (SYSCALL_ARG0) = a; \ + register btype __b __asm__ (SYSCALL_ARG1) = b; \ + register ctype __c __asm__ (SYSCALL_ARG2) = c; \ + register dtype __d __asm__ (SYSCALL_ARG3) = d; \ + __asm__ __volatile__ ("mov %1, " SYSCALL_NUM ";" \ + "trap " SYSCALL_SHORT_TRAP \ + : "=r" (__ret) \ + : "i" (__NR_##name), \ + "r" (__a), "r" (__b), "r" (__c), "r" (__d) \ + : SYSCALL_NUM, SYSCALL_CLOBBERS); \ + __syscall_return (type, __ret); \ +} + +#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype,e)\ +type name (atype a, btype b, ctype c, dtype d, etype e) \ +{ \ + register unsigned long __ret __asm__ (SYSCALL_RET); \ + register atype __a __asm__ (SYSCALL_ARG0) = a; \ + register btype __b __asm__ (SYSCALL_ARG1) = b; \ + register ctype __c __asm__ (SYSCALL_ARG2) = c; \ + register dtype __d __asm__ (SYSCALL_ARG3) = d; \ + register etype __e __asm__ (SYSCALL_ARG4) = e; \ + __asm__ __volatile__ ("mov %1, " SYSCALL_NUM ";" \ + "trap " SYSCALL_LONG_TRAP \ + : "=r" (__ret) \ + : "i" (__NR_##name), \ + "r" (__a), "r" (__b), "r" (__c), "r" (__d), "r" (__e) \ + : SYSCALL_NUM, SYSCALL_CLOBBERS); \ + __syscall_return (type, __ret); \ +} + +#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \ +type name (atype a, btype b, ctype c, dtype d, etype e, ftype f) \ +{ \ + register unsigned long __ret __asm__ (SYSCALL_RET); \ + register atype __a __asm__ (SYSCALL_ARG0) = a; \ + register btype __b __asm__ (SYSCALL_ARG1) = b; \ + register ctype __c __asm__ (SYSCALL_ARG2) = c; \ + register dtype __d __asm__ (SYSCALL_ARG3) = d; \ + register etype __e __asm__ (SYSCALL_ARG4) = e; \ + register etype __f __asm__ (SYSCALL_ARG5) = f; \ + __asm__ __volatile__ ("mov %1, " SYSCALL_NUM ";" \ + "trap " SYSCALL_LONG_TRAP \ + : "=r" (__ret) \ + : "i" (__NR_##name), \ + "r" (__a), "r" (__b), "r" (__c), "r" (__d), \ + "r" (__e), "r" (__f) \ + : SYSCALL_NUM, SYSCALL_CLOBBERS); \ + __syscall_return (type, __ret); \ +} + + +#ifdef __KERNEL_SYSCALLS__ + +/* + * we need this inline - forking from kernel space will result + * in NO COPY ON WRITE (!!!), until an execve is executed. This + * is no problem, but for the stack. This is handled by not letting + * main() use the stack at all after fork(). Thus, no function + * calls - which means inline code for fork too, as otherwise we + * would use the stack upon exit from 'fork()'. + * + * Actually only pause and fork are needed inline, so that there + * won't be any messing with the stack from main(), but we define + * some others too. + */ +#define __NR__exit __NR_exit +extern inline _syscall0(int,pause) +extern inline _syscall0(int,sync) +extern inline _syscall0(pid_t,setsid) +extern inline _syscall3(int,write,int,fd,const char *,buf,off_t,count) +extern inline _syscall3(int,read,int,fd,char *,buf,off_t,count) +extern inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count) +extern inline _syscall1(int,dup,int,fd) +extern inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp) +extern inline _syscall3(int,open,const char *,file,int,flag,int,mode) +extern inline _syscall1(int,close,int,fd) +extern inline _syscall1(int,_exit,int,exitcode) +extern inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options) +extern inline _syscall1(int,delete_module,const char *,name) + +extern inline pid_t wait(int * wait_stat) +{ + return waitpid (-1, wait_stat, 0); +} + +#endif + +#endif /* __V850_UNISTD_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/user.h linux-2.4.6/include/asm-v850/user.h --- linux-2.4.6.uclinux-orig/include/asm-v850/user.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/user.h Tue Sep 25 16:20:18 2001 @@ -0,0 +1,56 @@ +#ifndef __V850_USER_H__ +#define __V850_USER_H__ + +/* Adapted from . */ + +#ifdef __KERNEL__ + +#include +#include + +/* + * 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, NOT the osf-core). The 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 handy at some point. All of the registers + * are stored as part of the upage. The upage should always be + * only one page long. + * data: The data segment follows next. We use current->end_text to + * current->brk to pick up all of the user variables, plus any memory + * that may have been sbrk'ed. 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 usp to + * current->start_stack, so we round each of these in order to be able + * to write an integer number of pages. + */ +struct user { + struct pt_regs regs; /* entire machine state */ + size_t u_tsize; /* text size (pages) */ + size_t u_dsize; /* data size (pages) */ + size_t u_ssize; /* stack size (pages) */ + unsigned long start_code; /* text starting address */ + unsigned long start_data; /* data starting address */ + unsigned long start_stack; /* stack starting address */ + long int signal; /* signal causing core dump */ + struct regs * u_ar0; /* help gdb find registers */ + unsigned long magic; /* identifies a core file */ + char u_comm[32]; /* user command name */ +}; + +#define NBPG PAGE_SIZE +#define UPAGES 1 +#define HOST_TEXT_START_ADDR (u.start_code) +#define HOST_DATA_START_ADDR (u.start_data) +#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) + +#endif /* __KERNEL__ */ + +#endif /* __V850_USER_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/include/asm-v850/virtconvert.h linux-2.4.6/include/asm-v850/virtconvert.h --- linux-2.4.6.uclinux-orig/include/asm-v850/virtconvert.h Thu Jan 1 09:00:00 1970 +++ linux-2.4.6/include/asm-v850/virtconvert.h Tue Sep 25 16:18:53 2001 @@ -0,0 +1,32 @@ +/* + * include/asm-v850/virtconvert.h -- conversion between virtual and + * physical mappings + * + * Copyright (C) 2001 NEC Corporation + * Copyright (C) 2001 Miles Bader + * + * 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. + * + * Written by Miles Bader + */ + +#ifndef __V850_VIRTCONVERT_H__ +#define __V850_VIRTCONVERT_H__ + +#ifdef __KERNEL__ + +#include + +#define mm_ptov(addr) ((void *)__phys_to_virt (addr)) +#define mm_vtop(addr) ((unsigned long)__virt_to_phys (addr)) +#define phys_to_virt(addr) ((void *)__phys_to_virt (addr)) +#define virt_to_phys(addr) ((unsigned long)__virt_to_phys (addr)) + +#define virt_to_bus virt_to_phys +#define bus_to_virt phys_to_virt + +#endif /* __KERNEL__ */ + +#endif /* __V850_VIRTCONVERT_H__ */ diff -ruP -Xcludes linux-2.4.6.uclinux-orig/init/main.c linux-2.4.6/init/main.c --- linux-2.4.6.uclinux-orig/init/main.c Thu Jun 21 03:10:27 2001 +++ linux-2.4.6/init/main.c Wed Jul 25 15:07:21 2001 @@ -77,7 +77,8 @@ * with a gcc that is known to be too old from the very beginning. */ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 91) -#error Sorry, your GCC is too old. It builds incorrect kernels. +/* #error Sorry, your GCC is too old. It builds incorrect kernels. */ +#warning Sorry, your GCC is too old. It builds incorrect kernels. #endif extern char _stext, _etext;