diff options
52 files changed, 3419 insertions, 6 deletions
@@ -2,6 +2,23 @@ Changes for U-Boot 1.0.0: ====================================================================== +* Patch by Scott McNutt, 04 Oct 2003: + - add support for Altera Nios-32 CPU + - add support for Nios Cyclone Development Kit (DK-1C20) + +* Patch by Steven Scholz, 29 Sep 2003: + - A second parameter for bootm overwrites the load address for + "Standalone Application" images. + - bootm sets environment variable "filesize" to the resulting + (uncompressed) data length for "Standalone Application" images + when autostart is set to "no". Now you can do something like + if bootm $fpgadata $some_free_ram ; then + fpga load 0 $some_free_ram $filesize + fi + +* Patch by Denis Peter, 25 Sept 2003: + add support for the MIP405 Rev. C board + * Patch by Yuli Barcohen, 25 Sep 2003: add support for Zephyr Engineering ZPC.1900 board @@ -16,7 +33,6 @@ Changes for U-Boot 1.0.0: enable timed autoboot on PXA * Patch by David Müller, 22 Sep 2003: - - add $(CFLAGS) to "-print-libgcc-filename" so compiler driver returns correct libgcc file path - "latency" reduction of busy-loop waiting to improve "U-Boot" boot @@ -219,6 +219,10 @@ N: David Müller E: d.mueller@elsoft.ch D: Support for Samsung ARM920T SMDK2410 eval board +N: Scott McNutt +E: smcnutt@psyent.com +D: Support for Altera Nios-32 CPU, for Nios Cyclone Development Kit (DK-1C20) + N: Rolf Offermanns E: rof@sysgo.de D: Initial support for SSV-DNP1110, SMC91111 driver diff --git a/MAINTAINERS b/MAINTAINERS index 7752b6d74e..635120eafa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25,6 +25,10 @@ Pantelis Antoniou <panto@intracom.gr> NETVIA MPC8xx +Yuli Barcohen <yuli@arabellasw.com> + + ZPC1900 MPC8265 + Jerry Van Baren <gerald.vanbaren@smiths-aerospace.com> sacsng MPC8260 @@ -334,5 +338,16 @@ Wolfgang Denk <wd@denx.de> purple MIPS64 5Kc ######################################################################### +# Nios-32 Systems: # +# # +# Maintainer Name, Email Address # +# Board CPU # +######################################################################### + +Scott McNutt <smcnutt@psyent.com> + + DK1C20 Nios-32 + +######################################################################### # End of MAINTAINERS list # ######################################################################### @@ -69,6 +69,9 @@ endif ifeq ($(ARCH),mips) CROSS_COMPILE = mips_4KC- endif +ifeq ($(ARCH),nios) +CROSS_COMPILE = nios-elf- +endif endif endif @@ -941,6 +944,17 @@ incaip_config: unconfig purple_config : unconfig @./mkconfig $(@:_config=) mips mips purple +#======================================================================== +# Nios +#======================================================================== +######################################################################### +## Nios32 +######################################################################### + +DK1C20_config: unconfig + @./mkconfig $(@:_config=) nios nios dk1c20 + + ######################################################################### ######################################################################### diff --git a/board/dk1c20/Makefile b/board/dk1c20/Makefile new file mode 100644 index 0000000000..1fd71c72db --- /dev/null +++ b/board/dk1c20/Makefile @@ -0,0 +1,48 @@ +# +# (C) Copyright 2001 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. +# +# 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 +# + +include $(TOPDIR)/config.mk + +LIB = lib$(BOARD).a + +OBJS := $(BOARD).o flash.o + +SOBJS = vectors.o + +$(LIB): $(OBJS) $(SOBJS) + $(AR) crv $@ $^ + +clean: + rm -f $(SOBJS) $(OBJS) + +distclean: clean + rm -f $(LIB) core *.bak .depend + +######################################################################### + +.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c) + $(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@ + +-include .depend + +######################################################################### diff --git a/board/dk1c20/config.mk b/board/dk1c20/config.mk new file mode 100644 index 0000000000..12c74e6f96 --- /dev/null +++ b/board/dk1c20/config.mk @@ -0,0 +1,30 @@ +# +# (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 +# + +TEXT_BASE = 0x018c0000 + +ifeq ($(debug),1) +PLATFORM_CPPFLAGS += -DDEBUG +endif + diff --git a/board/dk1c20/dk1c20.c b/board/dk1c20/dk1c20.c new file mode 100644 index 0000000000..ff0b91d765 --- /dev/null +++ b/board/dk1c20/dk1c20.c @@ -0,0 +1,45 @@ +/* + * (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 + */ + +#include <common.h> + +void _default_hdlr (void) +{ + printf ("default_hdlr\n"); +} + +int board_pre_init (void) +{ + return 0; +} + +int checkboard (void) +{ + puts ("Board: Altera Nios 1C20 Development Kit\n"); + return 0; +} + +long int initdram (int board_type) +{ + return (0); +} diff --git a/board/dk1c20/flash.c b/board/dk1c20/flash.c new file mode 100644 index 0000000000..c64f7dc358 --- /dev/null +++ b/board/dk1c20/flash.c @@ -0,0 +1,226 @@ +/* + * (C) Copyright 2000 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * 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 + */ + + +#include <common.h> +#include <nios.h> + +/*---------------------------------------------------------------------*/ +#define BANKSZ (8 * 1024 * 1024) +#define SECTSZ (64 * 1024) +#define USERFLASH (2 * 1024 * 1024) /* bottom 2 MB for user */ + +flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; + +#define FLASH_WORD_SIZE unsigned char + +/*---------------------------------------------------------------------*/ + +unsigned long flash_init (void) +{ + int i; + unsigned long addr; + flash_info_t *fli = &flash_info[0]; + + fli->size = BANKSZ; + fli->sector_count = CFG_MAX_FLASH_SECT; + fli->flash_id = FLASH_MAN_AMD; + + addr = CFG_FLASH_BASE; + for (i = 0; i < fli->sector_count; ++i) { + fli->start[i] = addr; + addr += SECTSZ; + + /* Protect all but 2 MByte user area */ + if (addr < (CFG_FLASH_BASE + USERFLASH)) + fli->protect[i] = 0; + else + fli->protect[i] = 1; + } + + return (BANKSZ); +} + +/*--------------------------------------------------------------------*/ +void flash_print_info (flash_info_t * info) +{ + int i, k; + unsigned long size; + int erased; + volatile unsigned char *flash; + + printf (" Size: %ld KB in %d Sectors\n", + info->size >> 10, info->sector_count); + printf (" Sector Start Addresses:"); + for (i = 0; i < info->sector_count; ++i) { + + /* Check if whole sector is erased */ + if (i != (info->sector_count - 1)) + size = info->start[i + 1] - info->start[i]; + else + size = info->start[0] + info->size - info->start[i]; + erased = 1; + flash = (volatile unsigned char *) info->start[i]; + for (k = 0; k < size; k++) { + if (*flash++ != 0xff) { + erased = 0; + break; + } + } + + /* Print the info */ + if ((i % 5) == 0) + printf ("\n "); + printf (" %08lX%s%s", info->start[i], erased ? " E" : " ", + info->protect[i] ? "RO " : " "); + } + printf ("\n"); +} + +/*-------------------------------------------------------------------*/ + + +int flash_erase (flash_info_t * info, int s_first, int s_last) +{ + volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *) (info->start[0]); + volatile FLASH_WORD_SIZE *addr2; + int prot, sect; + int any = 0; + unsigned oldpri; + ulong start; + + /* Some sanity checking */ + if ((s_first < 0) || (s_first > s_last)) { + printf ("- no sectors to erase\n"); + return 1; + } + + prot = 0; + for (sect = s_first; sect <= s_last; ++sect) { + if (info->protect[sect]) { + prot++; + } + } + if (prot) { + printf ("- Warning: %d protected sectors will not be erased!\n", + prot); + } else { + printf ("\n"); + } + + /* NOTE: disabling interrupts on Nios can be very bad since it + * also disables the LO_LIMIT exception. It's better here to + * set the interrupt priority to 3 & restore it when we're done. + */ + oldpri = ipri (3); + + /* It's ok to erase multiple sectors provided we don't delay more + * than 50 usec between cmds ... at which point the erase time-out + * occurs. So don't go and put printf() calls in the loop ... it + * won't be very helpful ;-) + */ + for (sect = s_first; sect <= s_last; sect++) { + if (info->protect[sect] == 0) { /* not protected */ + addr2 = (FLASH_WORD_SIZE *) (info->start[sect]); + *addr = 0xaa; + *addr = 0x55; + *addr = 0x80; + *addr = 0xaa; + *addr = 0x55; + *addr2 = 0x30; + any = 1; + } + } + + /* Now just wait for 0xff & provide some user feedback while + * we wait. + */ + if (any) { + addr2 = (FLASH_WORD_SIZE *) (info->start[sect]); + start = get_timer (0); + while (*addr2 != 0xff) { + udelay (1000 * 1000); + putc ('.'); + if (get_timer (start) > CFG_FLASH_ERASE_TOUT) { + printf ("timeout\n"); + return 1; + } + } + printf ("\n"); + } + + /* Restore interrupt priority */ + ipri (oldpri); + + return 0; +} + +/*----------------------------------------------------------------------- + * Copy memory to flash, returns: + * 0 - OK + * 1 - write timeout + * 2 - Flash not erased + */ + +int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt) +{ + + vu_char *cmd = (vu_char *) info->start[0]; + vu_char *dst = (vu_char *) addr; + unsigned char b; + unsigned oldpri; + ulong start; + + while (cnt) { + /* Check for sufficient erase */ + b = *src; + if ((*dst & b) != b) { + printf ("%02x : %02x\n", *dst, b); + return (2); + } + + /* Disable interrupts other than window underflow + * (interrupt priority 2) + */ + oldpri = ipri (3); + *cmd = 0xaa; + *cmd = 0x55; + *cmd = 0xa0; + *dst = b; + + /* Verify write */ + start = get_timer (0); + while (*dst != b) { + if (get_timer (start) > CFG_FLASH_WRITE_TOUT) { + ipri (oldpri); + return 1; + } + } + dst++; + src++; + cnt--; + ipri (oldpri); + } + + return (0); +} diff --git a/board/dk1c20/u-boot.lds b/board/dk1c20/u-boot.lds new file mode 100644 index 0000000000..beedd54fe1 --- /dev/null +++ b/board/dk1c20/u-boot.lds @@ -0,0 +1,70 @@ +/* + * (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 + */ + + +OUTPUT_FORMAT("elf32-nios") +OUTPUT_ARCH(nios) +ENTRY(_start) + +SECTIONS +{ + .text : + { + cpu/nios/start.o (.text) + *(.text) + } + __text_end = .; + + . = ALIGN(4); + .rodata : + { + *(.rodata) + } + __rodata_end = .; + + . = ALIGN(4); + .data : + { + *(.data) + } + . = ALIGN(4); + __data_end = .; + + __u_boot_cmd_start = .; + .u_boot_cmd : + { + *(.u_boot_cmd) + } + . = ALIGN(4); + __u_boot_cmd_end = .; + + __bss_start = .; + . = ALIGN(4); + .bss : + { + *(.bss) + } + . = ALIGN(4); + __bss_end = .; +} + diff --git a/board/dk1c20/vectors.S b/board/dk1c20/vectors.S new file mode 100644 index 0000000000..e2baaf5d31 --- /dev/null +++ b/board/dk1c20/vectors.S @@ -0,0 +1,124 @@ +/* + * (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 + */ + + +/************************************************************************* + * Exception Vector Table + * + * This could have gone in the cpu soure tree, but the whole point of + * Nios is customization -- and polluting the cpu source tree with + * board-specific ifdef's really defeats the purpose, no? With this in + * the board-specific tree, each board has the freedom to organize + * vectors/traps, etc anyway it wants. The init code copies this table + * to the proper location. + * + * Each board can do what it likes here. But there are four "standard" + * handlers availble: + * + * _cwp_lolimit -Handles register window underflows. + * _cwp_hilimit -Handles register window overflows. + * _timebase_int -Increments the timebase. + * _def_xhandler -Default exception handler. + * + * _timebase_int handles a Nios Timer interrupt and increments the + * timestamp used for the get_timer(), reset_timer(), etc. routines. It + * expects the timer to be configured like the standard-32 low priority + * timer. + * + * _def_xhandler dispatches exceptions/traps via the external_interrupt() + * routine. This lets you use the irq_install_handler() and handle your + * interrupts/traps with code written in C. + ************************************************************************/ + + .data + .global _vectors + .align 4 +_vectors: + + .long _def_xhandler@h /* Vector 0 - NMI */ + .long _cwp_lolimit@h /* Vector 1 - underflow */ + .long _cwp_hilimit@h /* Vector 2 - overflow */ + + .long _def_xhandler@h /* Vector 3 - GNUPro debug */ + .long _def_xhandler@h /* Vector 4 - GNUPro debug */ + .long _def_xhandler@h /* Vector 5 - GNUPro debug */ + .long _def_xhandler@h /* Vector 6 - future reserved */ + .long _def_xhandler@h /* Vector 7 - future reserved */ + .long _def_xhandler@h /* Vector 8 - future reserved */ + .long _def_xhandler@h /* Vector 9 - future reserved */ + .long _def_xhandler@h /* Vector 10 - future reserved */ + .long _def_xhandler@h /* Vector 11 - future reserved */ + .long _def_xhandler@h /* Vector 12 - future reserved */ + .long _def_xhandler@h /* Vector 13 - future reserved */ + .long _def_xhandler@h /* Vector 14 - future reserved */ + .long _def_xhandler@h /* Vector 15 - future reserved */ + .long _def_xhandler@h /* Vector 16 */ + .long _def_xhandler@h /* Vector 17 */ + .long _def_xhandler@h /* Vector 18 */ + .long _def_xhandler@h /* Vector 19 */ + .long _def_xhandler@h /* Vector 20 */ + .long _def_xhandler@h /* Vector 21 */ + .long _def_xhandler@h /* Vector 22 */ + .long _def_xhandler@h /* Vector 23 */ + .long _def_xhandler@h /* Vector 24 */ + .long _def_xhandler@h /* Vector 25 */ + .long _def_xhandler@h /* Vector 26 */ + .long _def_xhandler@h /* Vector 27 */ + .long _def_xhandler@h /* Vector 28 */ + .long _def_xhandler@h /* Vector 29 */ + .long _def_xhandler@h /* Vector 30 */ + .long _def_xhandler@h /* Vector 31 */ + .long _def_xhandler@h /* Vector 32 */ + .long _def_xhandler@h /* Vector 33 */ + .long _def_xhandler@h /* Vector 34 */ + .long _def_xhandler@h /* Vector 35 */ + .long _def_xhandler@h /* Vector 36 */ + .long _def_xhandler@h /* Vector 37 */ + .long _def_xhandler@h /* Vector 38 */ + .long _def_xhandler@h /* Vector 39 */ + .long _def_xhandler@h /* Vector 40 */ + .long _def_xhandler@h /* Vector 41 */ + .long _def_xhandler@h /* Vector 42 */ + .long _def_xhandler@h /* Vector 43 */ + .long _def_xhandler@h /* Vector 44 */ + .long _def_xhandler@h /* Vector 45 */ + .long _def_xhandler@h /* Vector 46 */ + .long _def_xhandler@h /* Vector 47 */ + .long _def_xhandler@h /* Vector 48 */ + .long _def_xhandler@h /* Vector 49 */ + .long _timebase_int@h /* Vector 50 - lopri timer*/ + .long _def_xhandler@h /* Vector 51 */ + .long _def_xhandler@h /* Vector 52 */ + .long _def_xhandler@h /* Vector 53 */ + .long _def_xhandler@h /* Vector 54 */ + .long _def_xhandler@h /* Vector 55 */ + .long _def_xhandler@h /* Vector 56 */ + .long _def_xhandler@h /* Vector 57 */ + .long _def_xhandler@h /* Vector 58 */ + .long _def_xhandler@h /* Vector 59 */ + .long _def_xhandler@h /* Vector 60 */ + .long _def_xhandler@h /* Vector 61 */ + .long _def_xhandler@h /* Vector 62 */ + .long _def_xhandler@h /* Vector 63 */ + + diff --git a/board/mpl/common/flash.c b/board/mpl/common/flash.c index 99f97d7738..98cfb0d318 100644 --- a/board/mpl/common/flash.c +++ b/board/mpl/common/flash.c @@ -155,7 +155,7 @@ void setup_cs_reloc(void) unsigned long flash_init (void) { - unsigned long size_b0, size_b1,flashcr; + unsigned long size_b0, size_b1,flashcr, size_reg; int mode, i; extern char version_string; char *p=&version_string; @@ -196,6 +196,21 @@ unsigned long flash_init (void) size_b1 = 0 ; flash_info[0].size = size_b0; /* set up flash cs according to the size */ + size_reg=(flash_info[0].size >>20); + switch (size_reg) { + case 0: + case 1: i=0; break; /* <= 1MB */ + case 2: i=1; break; /* = 2MB */ + case 4: i=2; break; /* = 4MB */ + case 8: i=3; break; /* = 8MB */ + case 16: i=4; break; /* = 16MB */ + case 32: i=5; break; /* = 32MB */ + case 64: i=6; break; /* = 64MB */ + case 128: i=7; break; /*= 128MB */ + default: + printf("\n #### ERROR, wrong size %ld MByte reset board #####\n",size_reg); + while(1); + } if(mode & BOOT_MPS) { /* flash is on CS1 */ mtdcr(ebccfga, pb1cr); @@ -203,7 +218,7 @@ unsigned long flash_init (void) /* we map the flash high in every case */ flashcr&=0x0001FFFF; /* mask out address bits */ flashcr|= ((0-flash_info[0].size) & 0xFFF00000); /* start addr */ - flashcr|= (((flash_info[0].size >>21) & 0x07) << 17); /* size addr */ + flashcr|= (i << 17); /* size addr */ mtdcr(ebccfga, pb1cr); mtdcr(ebccfgd, flashcr); } @@ -214,7 +229,7 @@ unsigned long flash_init (void) /* we map the flash high in every case */ flashcr&=0x0001FFFF; /* mask out address bits */ flashcr|= ((0-flash_info[0].size) & 0xFFF00000); /* start addr */ - flashcr|= (((flash_info[0].size >>21) & 0x07) << 17); /* size addr */ + flashcr|= (i << 17); /* size addr */ mtdcr(ebccfga, pb0cr); mtdcr(ebccfgd, flashcr); } diff --git a/board/mpl/mip405/mip405.c b/board/mpl/mip405/mip405.c index 70eb5f4dca..c1471751c9 100644 --- a/board/mpl/mip405/mip405.c +++ b/board/mpl/mip405/mip405.c @@ -167,6 +167,15 @@ const sdram_t sdram_table[] = { 3, /* Address Mode = 3 */ 5, /* size value */ 1}, /* ECC enabled */ + { 0x2f, /* Rev C, 128MByte -3 Board */ + 3, /* Case Latenty = 3 */ + 3, /* trp 20ns / 7.5 ns datain[27] */ + 3, /* trcd 20ns /7.5 ns (datain[29]) */ + 6, /* tras 44ns /7.5 ns (datain[30]) */ + 4, /* tcpt 44 - 20ns = 24ns */ + 3, /* Address Mode = 3 */ + 5, /* size value */ + 1}, /* ECC enabled */ { 0xff, /* terminator */ 0xff, 0xff, @@ -550,7 +559,8 @@ void get_pcbrev_var(unsigned char *pcbrev, unsigned char *var) tmp >>= 1; } rc++; - if((((bc>>4) & 0xf)==0x1) /* Rev B PCB with */ + if(( (((bc>>4) & 0xf)==0x2) /* Rev C PCB or */ + || (((bc>>4) & 0xf)==0x1)) /* Rev B PCB with */ && (rc==0x1)) /* Population Option 1 is a -3 */ rc=3; *pcbrev=(bc >> 4) & 0xf; diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index dd9a4899cb..ceffe6a775 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -95,6 +95,33 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 0; } +#elif defined(CONFIG_NIOS) /* NIOS*/ + +int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + DECLARE_GLOBAL_DATA_PTR; + + int i; + bd_t *bd = gd->bd; + + print_num ("memstart", (ulong)bd->bi_memstart); + print_num ("memsize", (ulong)bd->bi_memsize); + print_num ("flashstart", (ulong)bd->bi_flashstart); + print_num ("flashsize", (ulong)bd->bi_flashsize); + print_num ("flashoffset", (ulong)bd->bi_flashoffset); + + printf ("ethaddr ="); + for (i=0; i<6; ++i) { + printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); + } + printf ("\nip_addr = "); + print_IPaddr (bd->bi_ip_addr); + printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate); + + return 0; +} + + #else /* ! PPC, which leaves MIPS */ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) diff --git a/common/cmd_boot.c b/common/cmd_boot.c index b2f0331dc9..5b58d4e2f1 100644 --- a/common/cmd_boot.c +++ b/common/cmd_boot.c @@ -59,7 +59,14 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) */ argv[0] = (char *)gd; #endif +#if !defined(CONFIG_NIOS) rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]); +#else + /* + * Nios function pointers are address >> 1 + */ + rc = ((ulong (*)(int, char *[]))(addr>>1)) (--argc, &argv[1]); +#endif if (rc != 0) rcode = 1; printf ("## Application terminated, rc = 0x%lX\n", rc); diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 45c4f33be9..79b763ec13 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -235,6 +235,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (hdr->ih_arch != IH_CPU_I386) #elif defined(__mips__) if (hdr->ih_arch != IH_CPU_MIPS) +#elif defined(__nios__) + if (hdr->ih_arch != IH_CPU_NIOS) #else # error Unknown CPU type #endif @@ -247,6 +249,10 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) switch (hdr->ih_type) { case IH_TYPE_STANDALONE: name = "Standalone Application"; + /* A second argument overwrites the load address */ + if (argc > 2) { + hdr->ih_load = simple_strtoul(argv[2], NULL, 16); + } break; case IH_TYPE_KERNEL: name = "Kernel Image"; break; @@ -347,8 +353,12 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* load (and uncompress), but don't start if "autostart" * is set to "no" */ - if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0)) + if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0)) { + char buf[32]; + sprintf(buf, "%lX", len); + setenv("filesize", buf); return 0; + } appl = (int (*)(cmd_tbl_t *, int, int, char *[]))ntohl(hdr->ih_ep); (*appl)(cmdtp, flag, argc-1, &argv[1]); return 0; diff --git a/cpu/nios/Makefile b/cpu/nios/Makefile new file mode 100644 index 0000000000..baf752f170 --- /dev/null +++ b/cpu/nios/Makefile @@ -0,0 +1,44 @@ +# +# (C) Copyright 2000 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. +# +# 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 +# + +include $(TOPDIR)/config.mk + +LIB = lib$(CPU).a + +START = start.o +AOBJS = traps.o +OBJS = cpu.o interrupts.o serial.o + +all: .depend $(START) $(LIB) + +$(LIB): $(OBJS) $(AOBJS) + $(AR) crv $@ $(OBJS) $(AOBJS) + +######################################################################### + +.depend: Makefile $(START:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S) + $(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S) > $@ + +sinclude .depend + +######################################################################### diff --git a/cpu/nios/config.mk b/cpu/nios/config.mk new file mode 100644 index 0000000000..9e95a0c9df --- /dev/null +++ b/cpu/nios/config.mk @@ -0,0 +1,25 @@ +# +# (C) Copyright 2000 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. +# +# 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 +# + +PLATFORM_RELFLAGS += + diff --git a/cpu/nios/cpu.c b/cpu/nios/cpu.c new file mode 100644 index 0000000000..5cf1883bc5 --- /dev/null +++ b/cpu/nios/cpu.c @@ -0,0 +1,78 @@ +/* + * (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 + */ + +#include <common.h> +#include <nios.h> + + +int checkcpu (void) +{ + unsigned val; + unsigned rev_major; + unsigned rev_minor; + short nregs, hi_limit, lo_limit; + + /* Get cpu version info */ + val = rdctl (CTL_CPU_ID); + printf ("CPU: "); + printf ("%s", (val & 0x00008000) ? "Nios-16 " : "Nios-32 "); + rev_major = (val>>12) & 0x07; + rev_minor = val & 0x0f; + printf ("Rev. %d.%02d (0x%04x)", rev_major, rev_minor, + val & 0xffff); + if (rev_major == 0x08) + printf (" [OpenCore (R) Plus]"); + printf ("\n"); + + /* Check register file */ + val = rdctl (CTL_WVALID); + lo_limit = val & 0x01f; + hi_limit = (val>>5) & 0x1f; + nregs = (hi_limit + 2) * 16; + printf ("Reg file size: %d LO_LIMIT/HI_LIMIT: %d/%d\n", + nregs, lo_limit, hi_limit); + + return (0); +} + + +int do_reset (void) +{ + /* trap 0 does the trick ... at least with the OCI debug + * present -- haven't tested without it yet (stm). + */ + disable_interrupts (); + ipri (1); + asm volatile ("trap 0\n"); + + /* No return ;-) */ + + return(0); +} + + +#if defined(CONFIG_WATCHDOG) +void watchdog_reset (void) +{ +} +#endif /* CONFIG_WATCHDOG */ diff --git a/cpu/nios/interrupts.c b/cpu/nios/interrupts.c new file mode 100644 index 0000000000..981b8f7d80 --- /dev/null +++ b/cpu/nios/interrupts.c @@ -0,0 +1,184 @@ +/* + * (C) Copyright 2000-2002 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * (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 + */ + + +#include <nios.h> +#include <nios-io.h> +#include <asm/ptrace.h> +#include <common.h> +#include <command.h> + +/****************************************************************************/ + +struct irq_action { + interrupt_handler_t *handler; + void *arg; + int count; +}; + +static struct irq_action irq_vecs[64]; + +/*************************************************************************/ +volatile ulong timestamp = 0; + +void reset_timer (void) +{ + timestamp = 0; +} + +ulong get_timer (ulong base) +{ + return (timestamp - base); +} + +void set_timer (ulong t) +{ + timestamp = t; +} + + +/* The board must handle this interrupt if a timer is not + * provided. + */ +#if defined(CFG_NIOS_TMRBASE) +void timer_interrupt (struct pt_regs *regs) +{ + /* Interrupt is cleared by writing anything to the + * status register. + */ + nios_timer_t *tmr = (nios_timer_t *)CFG_NIOS_TMRBASE; + tmr->status = 0; + timestamp += CFG_NIOS_TMRMS; +} +#endif + +/*************************************************************************/ +int disable_interrupts (void) +{ + int val = 0; + + /* Writing anything to CLR_IE disables interrupts */ + val = rdctl (CTL_STATUS); + wrctl (CTL_CLR_IE, 0); + return (val & STATUS_IE); +} + +void enable_interrupts( void ) +{ + /* Writing anything SET_IE enables interrupts */ + wrctl (CTL_SET_IE, 0); +} + +void external_interrupt (struct pt_regs *regs) +{ + unsigned vec; + + vec = (regs->status & STATUS_IPRI) >> 9; /* ipri */ + + irq_vecs[vec].count++; + if (irq_vecs[vec].handler != NULL) { + (*irq_vecs[vec].handler)(irq_vecs[vec].arg); + } else { + /* A sad side-effect of masking a bogus interrupt is + * that lower priority interrupts will also be disabled. + * This is probably not what we want ... so hang insted. + */ + printf ("Unhandled interrupt: 0x%x\n", vec); + disable_interrupts (); + hang (); + } +} + +/*************************************************************************/ +int interrupt_init (void) +{ + int vec; + +#if defined(CFG_NIOS_TMRBASE) + nios_timer_t *tmr = (nios_timer_t *)CFG_NIOS_TMRBASE; + + tmr->control &= ~NIOS_TIMER_ITO; + tmr->control |= NIOS_TIMER_STOP; +#endif + + for (vec=0; vec<64; vec++ ) { + irq_vecs[vec].handler = NULL; + irq_vecs[vec].arg = NULL; + irq_vecs[vec].count = 0; + } + + /* Need timus interruptus -- start the lopri timer */ +#if defined(CFG_NIOS_TMRBASE) + tmr->control |= ( NIOS_TIMER_ITO | + NIOS_TIMER_CONT | + NIOS_TIMER_START ); + ipri (CFG_NIOS_TMRIRQ + 1); +#endif + enable_interrupts (); + return (0); +} + +void irq_install_handler (int vec, interrupt_handler_t *handler, void *arg) +{ + struct irq_action *irqa = irq_vecs; + int i = vec; + int flag; + + if (irqa[i].handler != NULL) { + printf ("Interrupt vector %d: handler 0x%x " + "replacing 0x%x\n", + vec, (uint)handler, (uint)irqa[i].handler); + } + + flag = disable_interrupts (); + irqa[i].handler = handler; + irqa[i].arg = arg; + if (flag ) + enable_interrupts (); +} + +/*************************************************************************/ +#if (CONFIG_COMMANDS & CFG_CMD_IRQ) +int do_irqinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int vec; + + printf ("\nInterrupt-Information:\n"); + printf ("Nr Routine Arg CouIt's ok to cnt\n"); + + for (vec=0; vec<64; vec++) { + if (irq_vecs[vec].handler != NULL) { + printf ("%02d %08lx %08lx %d\n", + vec, + (ulong)irq_vecs[vec].handler<<1, + (ulong)irq_vecs[vec].arg, + irq_vecs[vec].count); + } + } + + return (0); +} +#endif /* CONFIG_COMMANDS & CFG_CMD_IRQ */ diff --git a/cpu/nios/serial.c b/cpu/nios/serial.c new file mode 100644 index 0000000000..61b26ab149 --- /dev/null +++ b/cpu/nios/serial.c @@ -0,0 +1,86 @@ +/* + * (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 + */ + + +#include <common.h> +#include <nios-io.h> + + +static nios_uart_t *uart = (nios_uart_t *)CFG_NIOS_CONSOLE; + +#if defined(CFG_NIOS_FIXEDBAUD) + +/* Everything's already setup for fixed-baud PTF + * assignment + */ +void serial_setbrg( void ){ return; } +int serial_init( void ) { return(0);} + +#else + +void serial_setbrg( void ) +{ + DECLARE_GLOBAL_DATA_PTR; + unsigned div; + + div = (CONFIG_SYS_CLK_FREQ/gd->baudrate)-1; + uart->divisor = div; + return; +} + +int serial_init( void ) +{ + serial_setbrg(); + return(0); +} + +#endif /* CFG_NIOS_FIXEDBAUD */ + + +void serial_putc( char c ) +{ + if (c == '\n') + serial_putc('\r'); + while( (uart->status & NIOS_UART_TRDY) == 0 ) + ; + uart->txdata = (unsigned char)c; +} + +void serial_puts( const char *s ) +{ + while( *s != 0 ) { + serial_putc( *s++ ); + } +} + +int serial_tstc( void ) +{ + return( uart->status & NIOS_UART_RRDY); +} + +int serial_getc( void ) +{ + while( serial_tstc() == 0 ) + ; + return( uart->rxdata & 0x00ff ); +} diff --git a/cpu/nios/start.S b/cpu/nios/start.S new file mode 100644 index 0000000000..7cbd1a78f0 --- /dev/null +++ b/cpu/nios/start.S @@ -0,0 +1,186 @@ +/* + * (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 + */ + + +#include <config.h> +#include <version.h> + +#if !defined(CONFIG_IDENT_STRING) +#define CONFIG_IDENT_STRING "" +#endif + +#define STATUS_INIT 0x8600 /* IE=1, IPRI=2 */ + +/************************************************************************* + * RESTART + ************************************************************************/ + + .text + .global _start + +_start: + bsr 0f + nop + .long _start + + /* GERMS -- The "standard-32" configuration GERMS monitor looks + * for the string "Nios" at flash_base + 0xc (actually it only + * tests for 'N', 'i'). You can leave support for this in place + * as it's only a few words. + */ + . = _start + 0x000c + .string "Nios" + + .align 4 +0: + /* + * Early setup -- set cwp = HI_LIMIT, IPRI = 2, IE = 1 to + * enable underflow exceptions. Disable cache. + * NOTE: %o7 has return addr -- save in %g7 use later. + */ + mov %g7, %o7 + + pfx 2 /* WVALID */ + rdctl %g0 + lsri %g0, 1 + pfx %hi(STATUS_INIT) + or %g0, %lo(STATUS_INIT) + wrctl %g0 /* update status */ + nop + + /* + * STACK + */ + pfx %hi(CFG_INIT_SP) + movi %sp, %lo(CFG_INIT_SP) + pfx %xhi(CFG_INIT_SP) + movhi %sp, %xlo(CFG_INIT_SP) + mov %fp, %sp + + pfx %hi(4*16) + subi %sp, %lo(4*16) /* Space for reg window mgmt */ + + /* + * RELOCATE -- %g7 has return addr from bsr at _start. + */ + pfx %hi(__u_boot_cmd_end) + movi %g5, %lo(__u_boot_cmd_end) + pfx %xhi(__u_boot_cmd_end) + movhi %g5, %xlo(__u_boot_cmd_end) /* %g5 <- end address */ + + lsli %g7, 1 /* mem = retaddr << 1 */ + mov %g6, %g7 + subi %g6, 4 /* %g6 <- src addr */ + ld %g7, [%g7] /* %g7 <- dst addr */ + +1: cmp %g7, %g5 + skps cc_nz + br 2f + nop /* delay slot */ + + ld %g0, [%g6] + addi %g6, 4 /* src++ */ + st [%g7], %g0 + addi %g7, 4 /* dst++ */ + br 1b + nop /* delay slot */ +2: + + /* + * Jump to relocation address + */ + pfx %hi(reloc@h) + movi %g0, %lo(reloc@h) + pfx %xhi(reloc@h) + movhi %g0, %xlo(reloc@h) + jmp %g0 +reloc: + + /* + * CLEAR BSS + */ + pfx %hi(__bss_end) + movi %g5, %lo(__bss_end) + pfx %xhi(__bss_end) + movhi %g5, %xlo(__bss_end) /* %g5 <- end address */ + pfx %hi(__bss_start) + movi %g7, %lo(__bss_start) + pfx %xhi(__bss_start) + movhi %g7, %xlo(__bss_start) /* %g7 <- end address */ + + movi %g0, 0 +3: cmp %g7, %g5 + skps cc_nz + br 4f + nop /* delay slot */ + + st [%g7], %g0 + addi %g7, 4 /* (delay slot) dst++ */ + br 3b + nop /* delay slot */ +4: + + /* + * Call board_init -- never returns + */ + pfx %hi(board_init@h) + movi %g1, %lo(board_init@h) + pfx %xhi(board_init@h) + movhi %g1, %xlo(board_init@h) + call %g1 + nop /* Delaly slot */ + /* NEVER RETURNS */ + +/* + * dly_clks -- Nios doesn't have a time/clk reference for simple + * delay loops, so we do our best by counting instruction cycles. + * A control register that counts system clock cycles would be + * a handy feature -- hint for Altera ;-) + */ + .globl dly_clks + /* Each loop is 4 instructions as delay slot is always + * executed. Each instruction is approximately 4 clocks + * (according to some lame info from Altera). So ... + * ... each loop is about 16 clocks. + */ + +dly_clks: + lsri %o0, 4 /* cnt/16 */ + +8: skprnz %o0 + br 9f + subi %o0, 1 /* cnt--, Delay slot */ + br 8b + nop + +9: lret + nop /* Delay slot */ + + + .data + .globl version_string + +version_string: + .ascii U_BOOT_VERSION + .ascii " (", __DATE__, " - ", __TIME__, ")" + .ascii CONFIG_IDENT_STRING, "\0" diff --git a/cpu/nios/traps.S b/cpu/nios/traps.S new file mode 100644 index 0000000000..655fc63588 --- /dev/null +++ b/cpu/nios/traps.S @@ -0,0 +1,559 @@ +/* + * (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 + */ + +#include <config.h> + +/************************************************************************* + * Register window underflow + * + * The register window underflow exception occurs whenever the lowest + * valid register window is in use (CWP=LO_LIMIT) and a save instruction + * is issued. The save moves CWP below LO_LIMIT, %sp is set as normal, + * then the exception is generated prior to executing the instruction + * after the save. + ************************************************************************/ + .text + .global _cwp_lolimit + .align 4 + +_cwp_lolimit: + + /* Sixteen words are always allocated by the compiler in every + * procedure's stack frame, always starting at %sp, for saving + * 'in' and 'local' registers on a window overflow. + * + * Save the 'global' and 'in' regs on stack. They are restored + * at cwp = HI_LIMIT. The 'local' regs aren't in-use at this point. + */ + sts [%sp,0], %g0 /* Save 'global' regs*/ + sts [%sp,1], %g1 + sts [%sp,2], %g2 + sts [%sp,3], %g3 + sts [%sp,4], %g4 + sts [%sp,5], %g5 + sts [%sp,6], %g6 + sts [%sp,7], %g7 + + sts [%sp,8], %i0 /* Save 'in' regs */ + sts [%sp,9], %i1 + sts [%sp,10], %i2 + sts [%sp,11], %i3 + sts [%sp,12], %i4 + sts [%sp,13], %i5 + sts [%sp,14], %i6 + sts [%sp,15], %i7 + + /* Save current %sp and return address in a global so they are + * available at cwp = HI_LIMIT ... where the 'global'/'in' regs + * are restored. NOTE: %sp changes with cwp. + */ + mov %g7, %o7 + mov %g6, %sp + + /* Get LO_LIMIT/HI_LIMIT to know where to start & stop. Note: in + * the underflow exception, cwp is __NOT__ guaranteed to be zero. + * If the OCI debug module is enabled the reset value for LO_LIMIT + * is 2, not 1 -- so cwp can be 1 or 0. + */ + pfx 2 /* WVALID */ + rdctl %g1 + mov %g2, %g1 + pfx 0 + and %g1, 0x1f /* g1 <- LO_LIMIT */ + lsri %g2, 5 + pfx 0 + and %g2,0x1f /* g2 <- HI_LIMIT */ + + /* Set istatus so cwp = HI_LIMIT after tret + */ + movi %g5, 0x1f + lsli %g5, 4 + not %g5 /* mask to clr cwp */ + pfx 1 /* istatus */ + rdctl %g0 + and %g0, %g5 /* clear cwp field */ + + mov %g4, %g2 + lsli %g4, 4 + or %g0, %g4 /* cwp = HI_LIMIT */ + pfx 1 + wrctl %g0 /* update istatus */ + + /* Now move up the register file, saving as we go. When loop + * is first entered, %g1 is at LO_LIMIT. + */ +0: + restore /* cwp++ */ + sts [%sp,0], %l0 /* Save "local" regs*/ + sts [%sp,1], %l1 + sts [%sp,2], %l2 + sts [%sp,3], %l3 + sts [%sp,4], %l4 + sts [%sp,5], %l5 + sts [%sp,6], %l6 + sts [%sp,7], %l7 + + sts [%sp,8], %i0 /* Save 'in' regs */ + sts [%sp,9], %i1 + sts [%sp,10], %i2 + sts [%sp,11], %i3 + sts [%sp,12], %i4 + sts [%sp,13], %i5 + sts [%sp,14], %i6 + sts [%sp,15], %i7 + + cmp %g1, %g2 /* cwp == HI_LIMIT ? */ + skps cc_ne /* if so, we're done */ + br 1f + nop /* delay slot */ + + inc %g1 /* g1 <- cwp++ */ + br 0b + nop /* delay slot */ + + /* At this point cwp = HI_LIMIT, so the global/in regs that were + * in place when the underflow occurred must be restored using + * the original stack pointer (saved in g6). + */ +1: + mov %o7, %g7 /* restore return addr */ + mov %sp, %g6 /* Restore original sp */ + + lds %g0, [%sp,0] /* Restore 'global' regs*/ + lds %g1, [%sp,1] + lds %g2, [%sp,2] + lds %g3, [%sp,3] + lds %g4, [%sp,4] + lds %g5, [%sp,5] + lds %g6, [%sp,6] + lds %g7, [%sp,7] + + lds %i0, [%sp,8] /* Restore 'in' regs*/ + lds %i1, [%sp,9] + lds %i2, [%sp,10] + lds %i3, [%sp,11] + lds %i4, [%sp,12] + lds %i5, [%sp,13] + lds %i6, [%sp,14] + lds %i7, [%sp,15] + + tret %o7 /* All done */ + +/************************************************************************* + * Register window overflow + * + * The register window overflow exception occurs whenever the highest + * valid register window is in use (cwp = HI_LIMIT) and a restore + * instruction is issued. Control is transferred to the overflow handler + * before the instruction following restore is executed. + * + * When a register window overflow exception is taken, the exception + * handler sees cwp at HI_LIMIT. + ************************************************************************/ + .text + .global _cwp_hilimit + .align 4 + +_cwp_hilimit: + + /* Save 'global'/'in' regs on the stack -- will restore when cwp + * is at LO_LIMIT. Locals don't need saving as they are going away. + */ + sts [%sp,0], %g0 /* Save "global" regs*/ + sts [%sp,1], %g1 + sts [%sp,2], %g2 + sts [%sp,3], %g3 + sts [%sp,4], %g4 + sts [%sp,5], %g5 + sts [%sp,6], %g6 + sts [%sp,7], %g7 + + sts [%sp,8], %i0 /* Save 'in' regs */ + sts [%sp,9], %i1 + sts [%sp,10], %i2 + sts [%sp,11], %i3 + sts [%sp,12], %i4 + sts [%sp,13], %i5 + sts [%sp,14], %i6 + sts [%sp,15], %i7 + + /* The current %sp must be available in global to restore regs + * saved on stack. Need return addr as well ;-) + */ + mov %g7, %o7 + mov %g6, %sp + + /* Get HI_LIMIT & LO_LIMIT + */ + pfx 2 /* WVALID */ + rdctl %g1 + mov %g2, %g1 + pfx 0 + and %g1, 0x1f /* g1 <- LO_LIMIT */ + lsri %g2, 5 + pfx 0 + and %g2,0x1f /* g2 <- HI_LIMIT */ + + /* Set istatus so cwp = LO_LIMIT after tret + */ + movi %g5, 0x1f + lsli %g5, 4 + not %g5 /* mask to clr cwp */ + pfx 1 /* istatus */ + rdctl %g0 + and %g0, %g5 /* clear cwp field */ + + mov %g4, %g1 /* g4 <- LO_LIMIT */ + lsli %g4, 4 + or %g0, %g4 /* cwp = LO_LIMIT */ + pfx 1 + wrctl %g0 /* update istatus */ + + /* Move to cwp = LO_LIMIT-1 and restore 'in' regs. + */ + subi %g4,(1 << 4) /* g4 <- LO_LIMIT - 1 */ + rdctl %g0 + and %g0, %g5 /* clear cwp field */ + or %g0, %g4 /* cwp = LO_LIMIT - 1 */ + wrctl %g0 /* update status */ + nop + + mov %sp, %g6 /* Restore sp */ + lds %i0, [%sp,8] /* Restore 'in' regs */ + lds %i1, [%sp,9] + lds %i2, [%sp,10] + lds %i3, [%sp,11] + lds %i4, [%sp,12] + lds %i5, [%sp,13] + lds %i6, [%sp,14] /* sp in next window */ + lds %i7, [%sp,15] + + /* Starting at LO_LIMIT-1, move up the register file, restoring + * along the way. + */ +0: + restore /* cwp++ */ + lds %l0, [%sp,0] /* Restore 'local' regs*/ + lds %l1, [%sp,1] + lds %l2, [%sp,2] + lds %l3, [%sp,3] + lds %l4, [%sp,4] + lds %l5, [%sp,5] + lds %l6, [%sp,6] + lds %l7, [%sp,7] + + lds %i0, [%sp,8] /* Restore 'in' regs */ + lds %i1, [%sp,9] + lds %i2, [%sp,10] + lds %i3, [%sp,11] + lds %i4, [%sp,12] + lds %i5, [%sp,13] + lds %i6, [%sp,14] /* sp in next window */ + lds %i7, [%sp,15] + + cmp %g1, %g2 /* cwp == HI_LIMIT ? */ + skps cc_ne /* if so, we're done */ + br 1f + nop /* delay slot */ + + inc %g1 /* cwp++ */ + br 0b + nop /* delay slot */ + + /* All windows have been updated at this point, but the globals + * still need to be restored. Go to cwp = LO_LIMIT-1 to get + * some registers to use. + */ +1: + rdctl %g0 + and %g0, %g5 /* clear cwp field */ + or %g0, %g4 /* cwp = LO_LIMIT - 1 */ + wrctl %g0 /* update status */ + nop + + /* Now there are some registers available to use in restoring + * the globals. + */ + mov %sp, %g6 + mov %o7, %g7 + + lds %g0, [%sp,0] /* Restore "global" regs*/ + lds %g1, [%sp,1] + lds %g2, [%sp,2] + lds %g3, [%sp,3] + lds %g4, [%sp,4] + lds %g5, [%sp,5] + lds %g6, [%sp,6] + lds %g7, [%sp,7] + + /* The tret moves istatus -> status. istatus was already set for + * cwp = LO_LIMIT. + */ + + tret %o7 /* done */ + +/************************************************************************* + * Default exception handler + * + * The default handler passes control to external_interrupt(). So trap + * or hardware interrupt hanlders can be installed using the familiar + * irq_install_handler(). + * + * Here, the stack is fixed-up and cwp is incremented prior to calling + * external_interrupt(). This lets the underflow and overflow handlers + * operate normally during the exception. + ************************************************************************/ + .text + .global _def_xhandler + .align 4 + +_def_xhandler: + + /* Allocate some stack space: 16 words at %sp to accomodate + * a reg window underflow, 8 words to save interrupted task's + * 'out' regs (which are now the 'in' regs), 8 words to preserve + * the 'global' regs and 3 words to save the return address, + * status and istatus. istatus must be saved in the event an + * underflow occurs in a dispatched handler. status is saved so + * a handler can access it on stack. + */ + pfx %hi((16+16+3) * 4) + subi %fp, %lo((16+16+3) * 4) + mov %sp, %fp + + /* Save the 'global' regs and the interrupted task's 'out' regs + * (our 'in' regs) along with the return addr, status & istatus. + * First 16 words are for underflow exception. + */ + rdctl %l0 /* status */ + pfx 1 /* istatus */ + rdctl %l1 + + sts [%sp,16+0], %g0 /* Save 'global' regs*/ + sts [%sp,16+1], %g1 + sts [%sp,16+2], %g2 + sts [%sp,16+3], %g3 + sts [%sp,16+4], %g4 + sts [%sp,16+5], %g5 + sts [%sp,16+6], %g6 + sts [%sp,16+7], %g7 + + sts [%sp,16+8], %i0 /* Save 'in' regs */ + sts [%sp,16+9], %i1 + sts [%sp,16+10], %i2 + sts [%sp,16+11], %i3 + sts [%sp,16+12], %i4 + sts [%sp,16+13], %i5 + sts [%sp,16+14], %i6 + sts [%sp,16+15], %i7 + + sts [%sp,16+16], %l0 /* status */ + sts [%sp,16+17], %l1 /* istatus */ + sts [%sp,16+18], %o7 /* return addr */ + + /* Move to cwp+1 ... this guarantees cwp is at or above LO_LIMIT. + * Need to set IPRI=3 and IE=1 to enable underflow exceptions. + * NOTE: only the 'out' regs have been saved ... can't touch + * the 'in' or 'local' here. + */ + restore /* cwp++ */ + rdctl %o0 /* o0 <- status */ + + pfx %hi(0x7e00) + movi %o1, %lo(0x7e00) + not %o1 + and %o0, %o1 /* clear IPRI */ + + pfx %hi(0x8600) + movi %o1, %lo(0x8600) + or %o0, %o1 /* IPRI=3, IE=1 */ + + wrctl %o0 /* o0 -> status */ + nop + + /* It's ok to call a C routine now since cwp >= LO_LIMIT, + * interrupt task's registers are/will be preserved, and + * underflow exceptions can be handled. + */ + pfx %hi(external_interrupt@h) + movi %o1, %lo(external_interrupt@h) + pfx %xhi(external_interrupt@h) + movhi %o1, %xlo(external_interrupt@h) + bgen %o0, 4+2 /* 16 * 4 */ + add %o0, %sp /* Ptr to regs */ + call %o1 + nop + + /* Move back to the exception register window, restore the 'out' + * registers, then return from exception. + */ + rdctl %o0 /* o0 <- status */ + subi %o0, 16 + wrctl %o0 /* cwp-- */ + nop + + mov %sp, %fp + lds %g0, [%sp,16+0] /* Restore 'global' regs*/ + lds %g1, [%sp,16+1] + lds %g2, [%sp,16+2] + lds %g3, [%sp,16+3] + lds %g4, [%sp,16+4] + lds %g5, [%sp,16+5] + lds %g6, [%sp,16+6] + lds %g7, [%sp,16+7] + + lds %i0, [%sp,16+8] /* Restore 'in' regs*/ + lds %i1, [%sp,16+9] + lds %i2, [%sp,16+10] + lds %i3, [%sp,16+11] + lds %i4, [%sp,16+12] + lds %i5, [%sp,16+13] + lds %i6, [%sp,16+14] + lds %i7, [%sp,16+15] + + lds %l0, [%sp,16+16] /* status */ + lds %l1, [%sp,16+17] /* istatus */ + lds %o7, [%sp,16+18] /* return addr */ + + pfx 1 + wrctl %l1 /* restore istatus */ + + pfx %hi((16+16+3) * 4) + addi %sp, %lo((16+16+3) * 4) + mov %fp, %sp + + tret %o7 /* Done */ + + +/************************************************************************* + * Timebase Timer Interrupt -- This has identical structure to above, + * but calls timer_interrupt(). Doing it this way keeps things similar + * to other architectures (e.g. ppc). + ************************************************************************/ + .text + .global _timebase_int + .align 4 + +_timebase_int: + + /* Allocate stack space. + */ + pfx %hi((16+16+3) * 4) + subi %fp, %lo((16+16+3) * 4) + mov %sp, %fp + + /* Save the 'global' regs & 'out' regs (our 'in' regs) + */ + rdctl %l0 /* status */ + pfx 1 /* istatus */ + rdctl %l1 + + sts [%sp,16+0], %g0 /* Save 'global' regs*/ + sts [%sp,16+1], %g1 + sts [%sp,16+2], %g2 + sts [%sp,16+3], %g3 + sts [%sp,16+4], %g4 + sts [%sp,16+5], %g5 + sts [%sp,16+6], %g6 + sts [%sp,16+7], %g7 + + sts [%sp,16+8], %i0 /* Save 'in' regs */ + sts [%sp,16+9], %i1 + sts [%sp,16+10], %i2 + sts [%sp,16+11], %i3 + sts [%sp,16+12], %i4 + sts [%sp,16+13], %i5 + sts [%sp,16+14], %i6 + sts [%sp,16+15], %i7 + + sts [%sp,16+16], %l0 /* status */ + sts [%sp,16+17], %l1 /* istatus */ + sts [%sp,16+18], %o7 /* return addr */ + + /* Move to cwp+1. + */ + restore /* cwp++ */ + rdctl %o0 /* o0 <- status */ + + pfx %hi(0x7e00) + movi %o1, %lo(0x7e00) + not %o1 + and %o0, %o1 /* clear IPRI */ + + pfx %hi(0x8600) + movi %o1, %lo(0x8600) + or %o0, %o1 /* IPRI=3, IE=1 */ + + wrctl %o0 /* o0 -> status */ + nop + + /* Call timer_interrupt() + */ + pfx %hi(timer_interrupt@h) + movi %o1, %lo(timer_interrupt@h) + pfx %xhi(timer_interrupt@h) + movhi %o1, %xlo(timer_interrupt@h) + bgen %o0, 4+2 /* 16 * 4 */ + add %o0, %sp /* Ptr to regs */ + call %o1 + nop + + /* Move back to the exception register window, restore the 'out' + * registers, then return from exception. + */ + rdctl %o0 /* o0 <- status */ + subi %o0, 16 + wrctl %o0 /* cwp-- */ + nop + + mov %sp, %fp + lds %g0, [%sp,16+0] /* Restore 'global' regs*/ + lds %g1, [%sp,16+1] + lds %g2, [%sp,16+2] + lds %g3, [%sp,16+3] + lds %g4, [%sp,16+4] + lds %g5, [%sp,16+5] + lds %g6, [%sp,16+6] + lds %g7, [%sp,16+7] + + lds %i0, [%sp,16+8] /* Restore 'in' regs*/ + lds %i1, [%sp,16+9] + lds %i2, [%sp,16+10] + lds %i3, [%sp,16+11] + lds %i4, [%sp,16+12] + lds %i5, [%sp,16+13] + lds %i6, [%sp,16+14] + lds %i7, [%sp,16+15] + + lds %l0, [%sp,16+16] /* status */ + lds %l1, [%sp,16+17] /* istatus */ + lds %o7, [%sp,16+18] /* return addr */ + + pfx 1 + wrctl %l1 /* restore istatus */ + + pfx %hi((16+16+3) * 4) + addi %sp, %lo((16+16+3) * 4) + mov %fp, %sp + + tret %o7 /* Done */ diff --git a/doc/README.dk1c20 b/doc/README.dk1c20 new file mode 100644 index 0000000000..b052433b67 --- /dev/null +++ b/doc/README.dk1c20 @@ -0,0 +1,84 @@ + + Nios Development Kit + Cyclone Editions + + Last Update: October 4, 2003 +==================================================================== + +This file contains information regarding U-Boot and the Altera +Nios Development Kit, Cyclone Edition (DK-1C20). For general Nios +information see doc/README.nios. + +For those interested in contributing ... see HELP WANTED section +in doc/README.nios. + + +Files +------ + board/dk1c20/* + include/configs/DK1C20.h + +Memory Organization +-------------------- + + -The heap is placed below the monitor (U-Boot code). + -Global data is placed below the heap. + -The stack is placed below global data (&grows down). + +Misc +----- + +The hello_world example works fine. + + +Programming U-Boot into FLASH with GERMS +----------------------------------------- +The current version of the DK-1C20 port occupies less than +60 KByte. So everything will fit into a single Flash sector. +To program U-Boot into the DK-1C20 flash using GERMS do the +following: + +1. From the command line, download U-Boot using the nios-run: + + $ nios-run -r u-boot.srec + +This takes about 45 seconds (GERMS is not very speedy here). +After u-boot is downloaded it will be executed. You should +see the following: + + U-Boot 1.0.0-pre (Oct 4 2003 - 07:39:24) + + CPU: Nios-32 Rev. 3.08 (0x3018) + Reg file size: 256 LO_LIMIT/HI_LIMIT: 2/14 + Board: Altera Nios 1C20 Development Kit + In: serial + Out: serial + Err: serial + ==> + + +2. Quit nios-run and start your terminal application (e.g. start +Hyperterminal or minicom). + +3. From the U-Boot command prompt, erase a sector of flash at 0x40000: + + ==> erase 40000 4ffff + +4. Download the u-boot code to RAM. When using Hyperterminal, do the +following: + + --From the u-boot command prompt start a binary download to SRAM: + + ==> loadb 800000 + + --Download u-boot.bin using kermit. + +5. Copy the binary image from SRAM to flash: + + ==> cp.b 800000 40000 10000 + +U-Boot will now automatically start when the board is powered on or +reset using the Standard-32 configuration. To start U-Boot with the +Safe-32 configuration, enter the following GERMS command: + + + g 40000 diff --git a/doc/README.nios b/doc/README.nios new file mode 100644 index 0000000000..2cee723347 --- /dev/null +++ b/doc/README.nios @@ -0,0 +1,196 @@ + + U-Boot for Nios-32 + + Last Update: October 4, 2003 +==================================================================== + +This file contains information regarding U-Boot and the Altera +Nios CPU. For information regarding U-Boot and the Nios Development +Kit, Cyclone Edition (DK-1C20), see doc/README.dk1c20. + +For those interested in contributing ... see HELP WANTED below. + + +1. OVERVIEW +------------ + +U-Boot has been successfully tested on the Nios Cyclone development +board using both the 'safe' and 'standard 32' configurations with +Nios CPU revision 3.08 (CPU_ID = 0x3008). U-Boot can be used with +or without the GERMS monitor. The initial version of U-Boot for the +Cyclone development kit is about 60 Kbyte and will fit in a single +sector of on-board FLASH. Only the Nios 32-bit CPU is supported. + +1.1 GERMS Monitor +------------------ +If GERMS is just not enough, then U-Boot is a great antibiotic. +You will be very pleased with its high degree of configurability +and its rich feature set. + +A few of the most obvious limitations of GERMS are overcome by +using U-Boot (See 'Brain Damage'). Most notably, you can use +minicom or Hyperterminal (duh). + +1.2 Altera Source Code +----------------------- +The Nios port does NOT include ANY sources that Altera has the +copyright. This was a conscious decision ... not an accident. +The Altera license is not clear in terms of distributing Altera +sources (when altera silicon is not involved). This isn't really +a problem as little, if any, of the Altera source contains +features that are not already available in U-Boot. + +The Nios port also does not use the long-winded peripheral +structure definitions from the Nios SDK. + + + +2. CONFIGURATION OPTIONS/SETTINGS +---------------------------------- + +2.1 Nios-specific Options/Settings +----------------------------------- +All configuration options/settings that are specific to Nios begin +with "CONFIG_NIOS_" or "CFG_NIOS_". The following is a list of +currently defined Nios-specific options/parameters. If any options +are related to Standard-32 Nios SDK excalibur.h definitions, the +related definition follows the description). + + +CONFIG_NIOS -- defined for all Nios-32 boards. + +CFG_NIOS_CONSOLE -- the base address of the console UART. + (standard-32: na_uart1_base). + +CFG_NIOS_FIXEDBAUD -- defined if the console UART PTF fixed_baud + parameter is set to '1'. + +CFG_NIOS_MULT_HW -- use full hardware multiply (not yet implemented). + +CFG_NIOS_MULT_MSTEP -- use hardware assisted multiply using the + MSTEP instruction (not yet implemented). + +CFG_NIOS_TMRBASE -- the base address of the timer used to support + xxx_timer routines (e.g. set_timer(), get_timer(), etc.). + (standard-32: na_lo_priority_timer2_base). + +CFG_NIOS_TMRIRQ -- the interrupt request (vector number) assigned to + the timer. (standard-32: na_low_priority_timer2_irq). + +CFG_NIOS_TMRMS -- the period of the timer in milliseconds. + +2.2 Differences in U-Boot Options/Settings +------------------------------------------- +Some 'standard' U-Boot options/settings are treated differently in +the Nios port. These are described below. + +CFG_GBL_DATA_OFFSET -- in the Nios port, this is the offset of the + global data structure in the Nios memory space. More simply, + the address of global data. + + +3. ASSEMBLY CODING +------------------- + +In browsing the assembly source files, you may notice the absence +of the 'magic macros' (e.g. MOVIA, MOVIP, ADDIP etc.). This is +deliberate. The documentation for the magic macros is scant and +it is hard to find ... it does not appear in the Nios programmer's +manual, nor does it appear in the assembler manual. Regardless, +the macros actually do very little to improve readability anyway. + +With this in mind, all assembler modules use only instructions that +appear in the Nios programmer's manual OR are directly supported +by the nios-elf toolchain. For example, the 'dec %rB' instruction +is an alias for 'subi %rB,1' that is supported by the assembler +but does not appear in the programmer's manual. + + +4. BRAIN DAMAGE +---------------- + +This section describes some of the unfortunate and avoidable aspects +of working with the Nios CPU ... and some things you can do to +reduce your pain. + +4.1 GERMS doesn't work with Hyperterminal +------------------------------------------ +GERMS doesn't do CR/LF mapping that is compatible with Hyperterminal +(or minicom) -- geez. Regardless of you opion of Hyperterminal, this +sad design decision is remedied by using U-Boot. + +4.2 cygwin Incompatibility +--------------------------- +The version of cygwin distributed with the nios GNUPro toolchain is +out-of-date and incompatible with the latest cygwin distributions. +In addition, many of the standard utilities are very dated as well. +If you try to download and build the lastest version of grep for +example, you'll quickly realize that a native gcc is not available +(the next topic) which leads to U-Boot build problems (following +topic). + +The solution ... well, you can wait for Altera ... or build as +set of tools for linux. + +4.3 No native gcc +------------------ +I'm not sure how this one slipped through the cracks ... but it is +a real pain. Basically, if you want to build anything for the native +environment -- forget it! A native (cygwin) gcc is not distributed, +and the old version of cygwin makes locating one challenging. + +The solution ... same as above. Just download the gcc source from +Altera and build up a set of cross tools for your favorite linux +distro. + +4.4 Can't build default U-Boot +------------------------------- +By default, when you build U-Boot you will be building some native +tools along with the target elf, bin, and srec files. Without a +native gcc, this (obviously) causes problems. + +For developers using the Altera cygwin tools you can remove the +'tools' directory from SUBDIRS in the top-level Makefile. You will +also have to edit common/Makefile: + +Replace: +environment.o: environment.c ../tools/envcrc + $(CC) $(AFLAGS) -Wa,--no-warn \ + -DENV_CRC=$(shell ../tools/envcrc) \ + -c -o $@ environment.c + +With: +environment.o: environment.c ../tools/envcrc + $(CC) $(AFLAGS) -Wa,--no-warn \ + -DENV_CRC=0 \ + -c -o $@ environment.c + +BTW, thats a 'zero' ... not the letter 'O'. + + +5. HELP WANTED +--------------- + +There are plenty of areas where help is needed. Here's are some ideas +for those interested in contributing: + +-SMC 91C111 support. E.g. add in tftpboot, etc. + +-CompactFlash. Port & test CF/FAT. + +-ASMI support. Use ASMI for environment, etc. + +-Bedbug. Develop bedbug for Nios ... or at least provide a disassemble + command. + +-Add boot support for ucLinux (niosnommu). + +-Implement (don't copy Altera code) the __mulxx routines using the + MSTEP and MUL instructions (e.g. CFG_NIOS_MULT_HW and CFG_NIOS_MULT_MSTEP). + + + +Regards, + +--Scott +<smcnutt@psyent.com> diff --git a/examples/Makefile b/examples/Makefile index febc501e9f..90d26550b0 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -37,6 +37,10 @@ ifeq ($(ARCH),mips) LOAD_ADDR = 0x80200000 -T mips.lds endif +ifeq ($(ARCH),nios) +LOAD_ADDR = 0x01000000 -L $(gcclibdir)/m32 -T nios.lds +endif + include $(TOPDIR)/config.mk SREC = hello_world.srec diff --git a/examples/nios.lds b/examples/nios.lds new file mode 100644 index 0000000000..105999f548 --- /dev/null +++ b/examples/nios.lds @@ -0,0 +1,61 @@ +/* + * (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 + */ + + +OUTPUT_FORMAT("elf32-nios") +OUTPUT_ARCH(nios) +ENTRY(_start) + +SECTIONS +{ + .text : + { + *(.text) + } + __text_end = .; + + . = ALIGN(4); + .rodata : + { + *(.rodata) + } + __rodata_end = .; + + . = ALIGN(4); + .data : + { + *(.data) + } + . = ALIGN(4); + __data_end = .; + + __bss_start = .; + . = ALIGN(4); + .bss : + { + *(.bss) + } + . = ALIGN(4); + __bss_end = .; +} + diff --git a/examples/stubs.c b/examples/stubs.c index 9c4c51b0e4..6ca6d78694 100644 --- a/examples/stubs.c +++ b/examples/stubs.c @@ -61,6 +61,23 @@ gd_t *global_data; " lw $25, %1($25)\n" \ " jr $25\n" \ : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "t9"); +#elif defined(CONFIG_NIOS) +/* + * %g7 holds the pointer to the global_data. %g0 is call clobbered. + */ +#define EXPORT_FUNC(x) \ + asm volatile ( \ +" .globl " #x "\n" \ +#x ":\n" \ +" pfx %%hi(%0)\n" \ +" movi %%g0, %%lo(%0)\n" \ +" add %%g0, %%g7\n" \ +" ld %%g0, [%%g0]\n" \ +" pfx %1\n" \ +" ld %%g0, [%%g0]\n" \ +" jmp %%g0\n" \ +" nop \n" \ + : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x) : "r0"); #else #error stubs definition missing for this architecture #endif diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h new file mode 100644 index 0000000000..7744212b45 --- /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 0000000000..851032c262 --- /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 0000000000..75dd3fca55 --- /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 0000000000..3cdb7039ff --- /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 0000000000..eb7421489f --- /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 0000000000..78b8976ca3 --- /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 0000000000..de54684aac --- /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 0000000000..73754c8696 --- /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 0000000000..fa33275010 --- /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 0000000000..9a9383d161 --- /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 0000000000..43fd8f6d2b --- /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 0000000000..94007dc2ce --- /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 0000000000..ddb1a2fb13 --- /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 7be17e5eba..d4fdb05282 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 0000000000..9fec6441bc --- /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 0000000000..46b685ab9d --- /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__ */ diff --git a/lib_nios/Makefile b/lib_nios/Makefile new file mode 100644 index 0000000000..eff46db819 --- /dev/null +++ b/lib_nios/Makefile @@ -0,0 +1,44 @@ +# +# (C) Copyright 2000 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. +# +# 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 +# + +include $(TOPDIR)/config.mk + +LIB = lib$(ARCH).a + +AOBJS = + +COBJS = board.o cache.o divmod.o nios_linux.o mult.o time.o + +OBJS = $(AOBJS) $(COBJS) + +$(LIB): .depend $(OBJS) + $(AR) crv $@ $(OBJS) + +######################################################################### + +.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c) + $(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@ + +sinclude .depend + +######################################################################### diff --git a/lib_nios/board.c b/lib_nios/board.c new file mode 100644 index 0000000000..c81c0011e2 --- /dev/null +++ b/lib_nios/board.c @@ -0,0 +1,166 @@ +/* + * (C) Copyright 2003, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * (C) Copyright 2000-2002 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * 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 + */ + +#include <common.h> +#include <devices.h> +#include <watchdog.h> + + +/* + * All attempts to come up with a "common" initialization sequence + * that works for all boards and architectures failed: some of the + * requirements are just _too_ different. To get rid of the resulting + * mess of board dependend #ifdef'ed code we now make the whole + * initialization sequence configurable to the user. + * + * The requirements for any new initalization function is simple: it + * receives a pointer to the "global data" structure as it's only + * argument, and returns an integer return code, where 0 means + * "continue" and != 0 means "fatal error, hang the system". + */ + + +extern void malloc_bin_reloc (void); +typedef int (init_fnc_t) (void); +extern unsigned _vectors[]; + +/* + * Begin and End of memory area for malloc(), and current "brk" + */ +static ulong mem_malloc_start = 0; +static ulong mem_malloc_end = 0; +static ulong mem_malloc_brk = 0; + +/* + * The Malloc area is immediately below the monitor copy in RAM + */ +static void mem_malloc_init (void) +{ + mem_malloc_start = CFG_MALLOC_BASE; + mem_malloc_end = mem_malloc_start + CFG_MALLOC_LEN; + mem_malloc_brk = mem_malloc_start; + memset ((void *) mem_malloc_start, + 0, + mem_malloc_end - mem_malloc_start); +} + +void *sbrk (ptrdiff_t increment) +{ + ulong old = mem_malloc_brk; + ulong new = old + increment; + + if ((new < mem_malloc_start) || (new > mem_malloc_end)) { + return (NULL); + } + mem_malloc_brk = new; + return ((void *) old); +} + + +/************************************************************************ + * Initialization sequence * + ***********************************************************************/ + +init_fnc_t *init_sequence[] = { + +#if defined(CONFIG_BOARD_PRE_INIT) + board_pre_init, /* Call board-specific init code early.*/ +#endif + + env_init, + serial_init, + console_init_f, + display_options, + checkcpu, + checkboard, + NULL, /* Terminate this list */ +}; + + +/***********************************************************************/ +void board_init (void) +{ + DECLARE_GLOBAL_DATA_PTR; + + bd_t *bd; + init_fnc_t **init_fnc_ptr; + + /* Pointer is writable since we allocated a register for it. + * Nios treats CFG_GBL_DATA_OFFSET as an address. + */ + gd = (gd_t *)CFG_GBL_DATA_OFFSET; + memset( gd, 0, CFG_GBL_DATA_SIZE ); + + /* Copy exception vectors to the correct location. + */ + memcpy( (void *)CFG_VECT_BASE, _vectors, 256 ); + + gd->bd = (bd_t *)(gd+1); /* At end of global data */ + gd->baudrate = CONFIG_BAUDRATE; + gd->cpu_clk = CONFIG_SYS_CLK_FREQ; + + bd = gd->bd; + bd->bi_memstart = CFG_SDRAM_BASE; + bd->bi_memsize = CFG_SDRAM_SIZE; + bd->bi_flashstart = CFG_FLASH_BASE; + bd->bi_sramstart= CFG_SRAM_BASE; + bd->bi_sramsize = CFG_SRAM_SIZE; + bd->bi_baudrate = CONFIG_BAUDRATE; + + for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { + if ((*init_fnc_ptr) () != 0) { + hang (); + } + } + + bd->bi_flashsize = flash_init(); + + mem_malloc_init(); + malloc_bin_reloc(); + env_relocate(); + + devices_init(); + jumptable_init(); + console_init_r(); + /* + */ + + interrupt_init (); + /* main_loop */ + for (;;) { + WATCHDOG_RESET (); + main_loop (); + } +} + + +/***********************************************************************/ + +void hang (void) +{ + puts("### ERROR ### Please reset board ###\n"); + for (;;); +} diff --git a/lib_nios/cache.c b/lib_nios/cache.c new file mode 100644 index 0000000000..87dbab1734 --- /dev/null +++ b/lib_nios/cache.c @@ -0,0 +1,32 @@ +/* + * (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 + */ + +#include <common.h> + + +void flush_cache (ulong addr, ulong size) +{ + /* Nios cache is write-thru -- nothing to do here. + */ + return; +} diff --git a/lib_nios/divmod.c b/lib_nios/divmod.c new file mode 100644 index 0000000000..3c7e71e975 --- /dev/null +++ b/lib_nios/divmod.c @@ -0,0 +1,101 @@ +/* + * 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. + */ + + +#include "math.h" + +USItype udivmodsi4 (USItype num, USItype den, word_type modwanted) +{ + USItype bit = 1; + USItype res = 0; + + while (den < num && bit && !(den & (1L << 31))) { + den <<= 1; + bit <<= 1; + } + while (bit) { + if (num >= den) { + num -= den; + res |= bit; + } + bit >>= 1; + den >>= 1; + } + if (modwanted) + return num; + return res; +} + + +SItype __divsi3 (SItype a, SItype b) +{ + word_type neg = 0; + SItype res; + + if (a < 0) { + a = -a; + neg = !neg; + } + + if (b < 0) { + b = -b; + neg = !neg; + } + + res = udivmodsi4 (a, b, 0); + + if (neg) + res = -res; + + return res; +} + + +SItype __modsi3 (SItype a, SItype b) +{ + word_type neg = 0; + SItype res; + + if (a < 0) { + a = -a; + neg = 1; + } + + if (b < 0) + b = -b; + + res = udivmodsi4 (a, b, 1); + + if (neg) + res = -res; + + return res; +} + + +SItype __udivsi3 (SItype a, SItype b) +{ + return udivmodsi4 (a, b, 0); +} + + +SItype __umodsi3 (SItype a, SItype b) +{ + return udivmodsi4 (a, b, 1); +} diff --git a/lib_nios/math.h b/lib_nios/math.h new file mode 100644 index 0000000000..ccffbbc2e7 --- /dev/null +++ b/lib_nios/math.h @@ -0,0 +1,16 @@ +#define BITS_PER_UNIT 8 + +typedef int HItype __attribute__ ((mode (HI))); +typedef unsigned int UHItype __attribute__ ((mode (HI))); + +typedef int SItype __attribute__ ((mode (SI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); + +typedef int word_type __attribute__ ((mode (__word__))); + +struct SIstruct {HItype low, high;}; + +typedef union { + struct SIstruct s; + SItype ll; +} SIunion; diff --git a/lib_nios/mult.c b/lib_nios/mult.c new file mode 100644 index 0000000000..66bb64d0c1 --- /dev/null +++ b/lib_nios/mult.c @@ -0,0 +1,56 @@ +/* + * 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. + */ + + +#include <common.h> + +#if !defined(CFG_NIOS_MULT_HW) && !defined(CFG_NIOS_MULT_MSTEP) + +#include "math.h" + +USItype __mulsi3 (USItype a, USItype b) +{ + USItype c = 0; + + while (a != 0) { + if (a & 1) + c += b; + a >>= 1; + b <<= 1; + } + + return c; +} + + +UHItype __mulhi3 (UHItype a, UHItype b) +{ + UHItype c = 0; + + while (a != 0) { + if (a & 1) + c += b; + a >>= 1; + b <<= 1; + } + + return c; +} + +#endif /*!defined(CFG_NIOS_MULT_HW) && !defined(CFG_NIOS_MULT_MSTEP) */ diff --git a/lib_nios/nios_linux.c b/lib_nios/nios_linux.c new file mode 100644 index 0000000000..eef17573f9 --- /dev/null +++ b/lib_nios/nios_linux.c @@ -0,0 +1,34 @@ +/* + * (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 + */ + +#include <common.h> +#include <command.h> + +/* FIXME: Once we find a stable version of uC-linux for nios + * we can get this working. ;-) + * + */ +void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], + ulong addr, ulong *len_ptr, int verify) +{ +} diff --git a/lib_nios/time.c b/lib_nios/time.c new file mode 100644 index 0000000000..765b9c1989 --- /dev/null +++ b/lib_nios/time.c @@ -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 + */ + +#include <common.h> + + +extern void dly_clks( unsigned long ticks ); + +void udelay(unsigned long usec) +{ + /* The Nios core doesn't have a timebase, so we do our + * best for now and call a low-level loop that counts + * cpu clocks. + */ + unsigned long cnt = (CONFIG_SYS_CLK_FREQ/1000000) * usec; + dly_clks (cnt); +} diff --git a/nios_config.mk b/nios_config.mk new file mode 100644 index 0000000000..2e610eb7d5 --- /dev/null +++ b/nios_config.mk @@ -0,0 +1,25 @@ +# +# (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 +# + +PLATFORM_CPPFLAGS += -m32 -DCONFIG_NIOS -ffixed-g7 |