diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-nios/bitops.h | 37 | ||||
-rw-r--r-- | include/asm-nios/byteorder.h | 31 | ||||
-rw-r--r-- | include/asm-nios/global_data.h | 46 | ||||
-rw-r--r-- | include/asm-nios/io.h | 1 | ||||
-rw-r--r-- | include/asm-nios/posix_types.h | 63 | ||||
-rw-r--r-- | include/asm-nios/processor.h | 1 | ||||
-rw-r--r-- | include/asm-nios/psr.h | 29 | ||||
-rw-r--r-- | include/asm-nios/ptrace.h | 36 | ||||
-rw-r--r-- | include/asm-nios/string.h | 25 | ||||
-rw-r--r-- | include/asm-nios/system.h | 4 | ||||
-rw-r--r-- | include/asm-nios/types.h | 57 | ||||
-rw-r--r-- | include/asm-nios/u-boot.h | 42 | ||||
-rw-r--r-- | include/configs/DK1C20.h | 171 | ||||
-rw-r--r-- | include/image.h | 1 | ||||
-rw-r--r-- | include/nios-io.h | 96 | ||||
-rw-r--r-- | include/nios.h | 77 |
16 files changed, 717 insertions, 0 deletions
diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h new file mode 100644 index 0000000..7744212 --- /dev/null +++ b/include/asm-nios/bitops.h @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2003, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef _ASM_NIOS_BITOPS_H_ +#define _ASM_NIOS_BITOPS_H_ + + +extern void set_bit(int nr, volatile void * a); +extern void clear_bit(int nr, volatile void * a); +extern int test_and_clear_bit(int nr, volatile void * a); +extern void change_bit(unsigned long nr, volatile void *addr); +extern int test_and_set_bit(int nr, volatile void * a); +extern int test_and_change_bit(int nr, volatile void * addr); +extern int test_bit(int nr, volatile void * a); +extern int ffs(int i); + +#endif /* _ASM_NIOS_BITOPS_H */ diff --git a/include/asm-nios/byteorder.h b/include/asm-nios/byteorder.h new file mode 100644 index 0000000..851032c --- /dev/null +++ b/include/asm-nios/byteorder.h @@ -0,0 +1,31 @@ +/* +* (C) Copyright 2003, Psyent Corporation <www.psyent.com> +* Scott McNutt <smcnutt@psyent.com> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* 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. +* +* This program 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 this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#ifndef __ASM_NIOS_BYTEORDER_H +#define __ASM_NIOS_BYTEORDER_H + +#include <asm/types.h> +#include <linux/byteorder/little_endian.h> + +#endif + diff --git a/include/asm-nios/global_data.h b/include/asm-nios/global_data.h new file mode 100644 index 0000000..75dd3fc --- /dev/null +++ b/include/asm-nios/global_data.h @@ -0,0 +1,46 @@ +/* + * (C) Copyright 2003, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef __ASM_NIOS_GLOBALDATA_H +#define __ASM_NIOS_GLOBALDATA_H + +typedef struct global_data { + bd_t *bd; + unsigned long flags; + unsigned long baudrate; + unsigned long cpu_clk; /* CPU clock in Hz! */ + unsigned long have_console; /* serial_init() was called */ + unsigned long ram_size; /* RAM size */ + unsigned long reloc_off; /* Relocation Offset */ + unsigned long env_addr; /* Address of Environment struct */ + unsigned long env_valid; /* Checksum of Environment valid */ + void **jt; /* Standalone app jump table */ +} gd_t; + +/* flags */ +#define GD_FLG_RELOC 0x00001 /* Code was relocated to RAM */ +#define GD_FLG_DEVINIT 0x00002 /* Devices have been initialized */ + +#define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm ("%g7") + +#endif /* __ASM_NIOS_GLOBALDATA_H */ diff --git a/include/asm-nios/io.h b/include/asm-nios/io.h new file mode 100644 index 0000000..3cdb703 --- /dev/null +++ b/include/asm-nios/io.h @@ -0,0 +1 @@ +/*FIXME: Implement this! */ diff --git a/include/asm-nios/posix_types.h b/include/asm-nios/posix_types.h new file mode 100644 index 0000000..eb74214 --- /dev/null +++ b/include/asm-nios/posix_types.h @@ -0,0 +1,63 @@ +#ifndef __ASM_NIOS_POSIX_TYPES_H +#define __ASM_NIOS_POSIX_TYPES_H + +/* + * This file is generally used by user-level software, so you need to + * be a little careful about namespace pollution etc. Also, we cannot + * assume GCC is being used. + */ + +typedef unsigned short __kernel_dev_t; +typedef unsigned long __kernel_ino_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned short __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +typedef unsigned long __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(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) + +#undef __FD_CLR +#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) + +#undef __FD_ISSET +#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) + +#undef __FD_ZERO +#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp))) + +#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ + +#endif diff --git a/include/asm-nios/processor.h b/include/asm-nios/processor.h new file mode 100644 index 0000000..78b8976 --- /dev/null +++ b/include/asm-nios/processor.h @@ -0,0 +1 @@ +/* FIXME: Implement this! */ diff --git a/include/asm-nios/psr.h b/include/asm-nios/psr.h new file mode 100644 index 0000000..de54684 --- /dev/null +++ b/include/asm-nios/psr.h @@ -0,0 +1,29 @@ +/* + * (C) Copyright 2003, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef _NIOS_PSR_H +#define _NIOS_PSR_H + + + +#endif /* _NIOS_PSR_H */ diff --git a/include/asm-nios/ptrace.h b/include/asm-nios/ptrace.h new file mode 100644 index 0000000..73754c8 --- /dev/null +++ b/include/asm-nios/ptrace.h @@ -0,0 +1,36 @@ +/* + * (C) Copyright 2003, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef _NIOS_PTRACE_H +#define _NIOS_PTRACE_H + +struct pt_regs { + unsigned global[8]; + unsigned in[8]; + unsigned status; + unsigned istatus; + unsigned retaddr; +}; + + +#endif /* _NIOS_PTRACE_H */ diff --git a/include/asm-nios/string.h b/include/asm-nios/string.h new file mode 100644 index 0000000..fa33275 --- /dev/null +++ b/include/asm-nios/string.h @@ -0,0 +1,25 @@ +#ifndef __ASM_NIOS_STRING_H +#define __ASM_NIOS_STRING_H + +#undef __HAVE_ARCH_STRRCHR +extern char * strrchr(const char * s, int c); + +#undef __HAVE_ARCH_STRCHR +extern char * strchr(const char * s, int c); + +#undef __HAVE_ARCH_MEMCPY +extern void * memcpy(void *, const void *, __kernel_size_t); + +#undef __HAVE_ARCH_MEMMOVE +extern void * memmove(void *, const void *, __kernel_size_t); + +#undef __HAVE_ARCH_MEMCHR +extern void * memchr(const void *, int, __kernel_size_t); + +#undef __HAVE_ARCH_MEMSET +extern void * memset(void *, int, __kernel_size_t); + +#undef __HAVE_ARCH_MEMZERO +extern void memzero(void *ptr, __kernel_size_t n); + +#endif diff --git a/include/asm-nios/system.h b/include/asm-nios/system.h new file mode 100644 index 0000000..9a9383d --- /dev/null +++ b/include/asm-nios/system.h @@ -0,0 +1,4 @@ +#ifndef _ASM_NIOS_SYSTEM_H_ +#define _ASM_NIOS_SYSTEM_H_ + +#endif /* _ASM_NIOS_SYSTEM_H */ diff --git a/include/asm-nios/types.h b/include/asm-nios/types.h new file mode 100644 index 0000000..43fd8f6 --- /dev/null +++ b/include/asm-nios/types.h @@ -0,0 +1,57 @@ +#ifndef _NIOS_TYPES_H +#define _NIOS_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 /* _NIOS_TYPES_H */ diff --git a/include/asm-nios/u-boot.h b/include/asm-nios/u-boot.h new file mode 100644 index 0000000..94007dc --- /dev/null +++ b/include/asm-nios/u-boot.h @@ -0,0 +1,42 @@ +/* + * (C) Copyright 2003 + * Psyent Corporation + * Scott McNutt <smcnutt@psyent.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef _U_BOOT_H_ +#define _U_BOOT_H_ + +typedef struct bd_info { + unsigned long bi_memstart; /* start of DRAM memory */ + unsigned long bi_memsize; /* size of DRAM memory in bytes */ + unsigned long bi_flashstart; /* start of FLASH memory */ + unsigned long bi_flashsize; /* size of FLASH memory */ + unsigned long bi_flashoffset; /* reserved area for startup monitor */ + unsigned long bi_sramstart; /* start of SRAM memory */ + unsigned long bi_sramsize; /* size of SRAM memory */ + unsigned long bi_ip_addr; /* IP Address */ + unsigned char bi_enetaddr[6]; /* Ethernet adress */ + unsigned long bi_baudrate; /* Console Baudrate */ +} bd_t; + + +#endif /* _U_BOOT_H_ */ diff --git a/include/configs/DK1C20.h b/include/configs/DK1C20.h new file mode 100644 index 0000000..ddb1a2f --- /dev/null +++ b/include/configs/DK1C20.h @@ -0,0 +1,171 @@ +/* + * (C) Copyright 2003, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +/*------------------------------------------------------------------------ + * BOARD/CPU -- TOP-LEVEL + *----------------------------------------------------------------------*/ +#define CONFIG_NIOS 1 /* NIOS-32 core */ +#define CONFIG_DK1C20 1 /* Cyclone DK-1C20 board*/ +#define CONFIG_SYS_CLK_FREQ 50000000 /* 50 MHz core clock */ + +/*------------------------------------------------------------------------ + * BASE ADDRESSES + *----------------------------------------------------------------------*/ +#define CFG_FLASH_BASE 0x00000000 /* Flash memory base */ +#define CFG_SRAM_BASE 0x00800000 /* External SRAM */ +#define CFG_SRAM_SIZE 0x00100000 /* 1 MByte */ +#define CFG_SDRAM_BASE 0x01000000 /* SDRAM base addr */ +#define CFG_SDRAM_SIZE 0x01000000 /* 16 MByte */ +#define CFG_VECT_BASE 0x008fff00 /* Vector table addr */ + +/*------------------------------------------------------------------------ + * MEMORY ORGANIZATION - For the most part, you can put things pretty + * much anywhere. This is pretty flexible for Nios. So here we make some + * arbitrary choices & assume that the monitor is placed at the end of + * a memory resource (so you must make sure TEXT_BASE is chosen + * appropriately). + * + * -The heap is placed below the monitor. + * -Global data is placed below the heap. + * -The stack is placed below global data (&grows down). + *----------------------------------------------------------------------*/ +#define CFG_MONITOR_LEN (256 * 1024) /* Reserve 256k */ +#define CFG_ENV_SIZE 0x10000 /* 64 KByte (1 sector) */ +#define CFG_GBL_DATA_SIZE 128 /* Global data size rsvd*/ +#define CFG_MALLOC_LEN (CFG_ENV_SIZE + 128*1024) + +#define CFG_MONITOR_BASE TEXT_BASE +#define CFG_MALLOC_BASE (CFG_MONITOR_BASE - CFG_MALLOC_LEN) +#define CFG_GBL_DATA_OFFSET (CFG_MALLOC_BASE -CFG_GBL_DATA_SIZE) +#define CFG_INIT_SP CFG_GBL_DATA_OFFSET + +/*------------------------------------------------------------------------ + * FLASH + *----------------------------------------------------------------------*/ +#define CFG_MAX_FLASH_SECT 128 /* Max # sects per bank */ +#define CFG_MAX_FLASH_BANKS 1 /* Max # of flash banks */ +#define CFG_FLASH_ERASE_TOUT 8000 /* Erase timeout (msec) */ +#define CFG_FLASH_WRITE_TOUT 100 /* Write timeout (msec) */ + +/*------------------------------------------------------------------------ + * ENVIRONMENT + *----------------------------------------------------------------------*/ +#define CFG_ENV_IS_IN_FLASH 1 /* Environment in flash */ +#define CFG_ENV_ADDR 0x00000000 /* Mem addr of env */ +#define CONFIG_ENV_OVERWRITE /* Serial/eth change Ok */ + +/*------------------------------------------------------------------------ + * CONSOLE + *----------------------------------------------------------------------*/ +#define CFG_NIOS_CONSOLE 0x00920900 /* Cons uart base addr */ +#define CFG_NIOS_FIXEDBAUD 1 /* Baudrate is fixed */ +#define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } +#define CONFIG_BAUDRATE 115200 + +/*------------------------------------------------------------------------ + * TIMER FOR TIMEBASE -- Nios doesn't have the equivalent of ppc PIT, + * so an avalon bus timer is required. + *----------------------------------------------------------------------*/ +#define CFG_NIOS_TMRBASE 0x009209e0 +#define CFG_NIOS_TMRIRQ 50 +#define CFG_NIOS_TMRMS 10 + +/*------------------------------------------------------------------------ + * Ethernet -- needs work! + *----------------------------------------------------------------------*/ +#if 0 +#define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ +#define CONFIG_SMC91111_BASE 0x00910000 /* Base address */ +#undef CONFIG_SMC91111_EXT_PHY /* No external PHY */ +#define CONFIG_SMC_USE_32_BIT 1 /* 32-bit i/f */ +#endif + +#define CONFIG_ETHADDR 08:00:3e:26:0a:5b +#define CONFIG_NETMASK 255.255.255.0 +#define CONFIG_IPADDR 192.168.2.21 +#define CONFIG_SERVERIP 192.168.2.16 + +/*------------------------------------------------------------------------ + * COMMANDS + *----------------------------------------------------------------------*/ +#define CONFIG_COMMANDS (CFG_CMD_ALL & ~( \ + CFG_CMD_ASKENV | \ + CFG_CMD_BEDBUG | \ + CFG_CMD_BMP | \ + CFG_CMD_BSP | \ + CFG_CMD_CACHE | \ + CFG_CMD_DATE | \ + CFG_CMD_DOC | \ + CFG_CMD_DTT | \ + CFG_CMD_EEPROM | \ + CFG_CMD_ELF | \ + CFG_CMD_FAT | \ + CFG_CMD_FDC | \ + CFG_CMD_FDOS | \ + CFG_CMD_HWFLOW | \ + CFG_CMD_IDE | \ + CFG_CMD_I2C | \ + CFG_CMD_JFFS2 | \ + CFG_CMD_KGDB | \ + CFG_CMD_NAND | \ + CFG_CMD_NET | \ + CFG_CMD_MMC | \ + CFG_CMD_MII | \ + CFG_CMD_PCI | \ + CFG_CMD_PCMCIA | \ + CFG_CMD_SCSI | \ + CFG_CMD_SPI | \ + CFG_CMD_VFD | \ + CFG_CMD_USB ) ) + + +#include <cmd_confdefs.h> + +/*------------------------------------------------------------------------ + * KGDB + *----------------------------------------------------------------------*/ +#if (CONFIG_COMMANDS & CFG_CMD_KGDB) +#define CONFIG_KGDB_BAUDRATE 9600 +#endif + +/*------------------------------------------------------------------------ + * MISC + *----------------------------------------------------------------------*/ +#define CFG_LONGHELP /* undef to save memory */ +#define CFG_PROMPT "==> " /* Monitor Command Prompt */ +#define CFG_CBSIZE 256 /* Console I/O Buffer Size */ +#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */ +#define CFG_MAXARGS 16 /* max number of command args */ +#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */ +#undef CFG_CLKS_IN_HZ +#define CFG_HZ 1562500 +#define CFG_LOAD_ADDR 0x00800000 /* Default load address */ + +#define CFG_MEMTEST_START 0x00000000 +#define CFG_MEMTEST_END 0x00000000 + + +#endif /* __CONFIG_H */ diff --git a/include/image.h b/include/image.h index 7be17e5..d4fdb05 100644 --- a/include/image.h +++ b/include/image.h @@ -65,6 +65,7 @@ #define IH_CPU_SPARC 10 /* Sparc */ #define IH_CPU_SPARC64 11 /* Sparc 64 Bit */ #define IH_CPU_M68K 12 /* M68K */ +#define IH_CPU_NIOS 13 /* Nios-32 */ /* * Image Types diff --git a/include/nios-io.h b/include/nios-io.h new file mode 100644 index 0000000..9fec644 --- /dev/null +++ b/include/nios-io.h @@ -0,0 +1,96 @@ +/* + * (C) Copyright 2003, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/************************************************************************* + * Altera Nios Standard Peripherals + ************************************************************************/ + +#ifndef __NIOSIO_H__ +#define __NIOSIO_H__ + +/*------------------------------------------------------------------------ + * UART + *----------------------------------------------------------------------*/ +typedef volatile struct nios_uart_t { + unsigned rxdata; /* Rx data reg */ + unsigned txdata; /* Tx data reg */ + unsigned status; /* Status reg */ + unsigned control; /* Control reg */ + unsigned divisor; /* Baud rate divisor reg */ + unsigned endofpacket; /* End-of-packet reg */ +}nios_uart_t; + +/* status register */ +#define NIOS_UART_PE (1 << 0) /* parity error */ +#define NIOS_UART_FE (1 << 1) /* frame error */ +#define NIOS_UART_BRK (1 << 2) /* break detect */ +#define NIOS_UART_ROE (1 << 3) /* rx overrun */ +#define NIOS_UART_TOE (1 << 4) /* tx overrun */ +#define NIOS_UART_TMT (1 << 5) /* tx empty */ +#define NIOS_UART_TRDY (1 << 6) /* tx ready */ +#define NIOS_UART_RRDY (1 << 7) /* rx ready */ +#define NIOS_UART_E (1 << 8) /* exception */ +#define NIOS_UART_DCTS (1 << 10) /* cts change */ +#define NIOS_UART_CTS (1 << 11) /* cts */ +#define NIOS_UART_EOP (1 << 12) /* eop detected */ + +/* control register */ +#define NIOS_UART_IPE (1 << 0) /* parity error int ena*/ +#define NIOS_UART_IFE (1 << 1) /* frame error int ena */ +#define NIOS_UART_IBRK (1 << 2) /* break detect int ena */ +#define NIOS_UART_IROE (1 << 3) /* rx overrun int ena */ +#define NIOS_UART_ITOE (1 << 4) /* tx overrun int ena */ +#define NIOS_UART_ITMT (1 << 5) /* tx empty int ena */ +#define NIOS_UART_ITRDY (1 << 6) /* tx ready int ena */ +#define NIOS_UART_IRRDY (1 << 7) /* rx ready int ena */ +#define NIOS_UART_IE (1 << 8) /* exception int ena */ +#define NIOS_UART_TBRK (1 << 9) /* transmit break */ +#define NIOS_UART_IDCTS (1 << 10) /* cts change int ena */ +#define NIOS_UART_RTS (1 << 11) /* rts */ +#define NIOS_UART_IEOP (1 << 12) /* eop detected int ena */ + + +/*------------------------------------------------------------------------ + * TIMER + *----------------------------------------------------------------------*/ +typedef volatile struct nios_timer_t { + unsigned status; /* Timer status reg */ + unsigned control; /* Timer control reg */ + unsigned periodl; /* Timeout period low */ + unsigned periodh; /* Timeout period high */ + unsigned snapl; /* Snapshot low */ + unsigned snaph; /* Snapshot high */ +}nios_timer_t; + +/* status register */ +#define NIOS_TIMER_TO (1 << 0) /* Timeout */ +#define NIOS_TIMER_RUN (1 << 1) /* Timer running */ + +/* control register */ +#define NIOS_TIMER_ITO (1 << 0) /* Timeout int ena */ +#define NIOS_TIMER_CONT (1 << 1) /* Continuous mode */ +#define NIOS_TIMER_START (1 << 2) /* Start timer */ +#define NIOS_TIMER_STOP (1 << 3) /* Stop timer */ + +#endif /* __NIOSIO_H__ */ + diff --git a/include/nios.h b/include/nios.h new file mode 100644 index 0000000..46b685a --- /dev/null +++ b/include/nios.h @@ -0,0 +1,77 @@ +/* + * (C) Copyright 2003, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef __NIOS_H__ +#define __NIOS_H__ + +/*------------------------------------------------------------------------ + * Control registers -- use with wrctl() & rdctl() + *----------------------------------------------------------------------*/ +#define CTL_STATUS 0x00 /* Processor status */ +#define CTL_ISTATUS 0x01 /* Saved status (exception) */ +#define CTL_WVALID 0x02 /* Valid window limit */ +#define CTL_ICACHE 0x05 /* I-cache line-invalidate */ +#define CTL_CPU_ID 0x06 /* CPU version id */ +#define CTL_DCACHE 0x07 /* D-cache line-invalidate */ +#define CTL_CLR_IE 0x08 /* Interrupt clear (disable) */ +#define CTL_SET_IE 0x09 /* Interrupt set (enable) */ + +/*------------------------------------------------------------------------ + * Access to control regs + *----------------------------------------------------------------------*/ +#define _str_(s) #s + +#define rdctl(reg)\ + ({unsigned int val;\ + asm volatile( "pfx " _str_(reg) "\n\t rdctl %0"\ + : "=r" (val) ); val;}) + +#define wrctl(reg,val)\ + asm volatile( "pfx " _str_(reg) "\n\t wrctl %0 \n\t nop"\ + : : "r" (val)) + +/*------------------------------------------------------------------------ + * Control reg bit masks + *----------------------------------------------------------------------*/ +#define STATUS_DC (1<<17) /* Data cache enable */ +#define STATUS_IC (1<<16) /* Instruction cache enable */ +#define STATUS_IE (1<<15) /* Interrupt enable */ +#define STATUS_IPRI (0x3f<<9) /* Interrupt priority */ +#define STATUS_CWP (0x1f<<4) /* Current window pointer */ +#define STATUS_N (1<<3) /* Condition code: negative */ +#define STATUS_V (1<<2) /* Condition code: overflow */ +#define STATUS_Z (1<<1) /* Condition code: zero */ +#define STATUS_C (1<<0) /* Condition code: carry/borrow */ + +static inline unsigned ipri( unsigned prio ) +{ + unsigned tmp; + unsigned status = rdctl(CTL_STATUS); + prio = (prio << 9) & STATUS_IPRI; + tmp = (status & ~STATUS_IPRI) | prio; + wrctl(CTL_STATUS,tmp); + return( (status & STATUS_IPRI) >> 9); +} + + +#endif /* __NIOS_H__ */ |