OpenCores
URL https://opencores.org/ocsvn/altor32/altor32/trunk

Subversion Repositories altor32

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /altor32
    from Rev 21 to Rev 22
    Reverse comparison

Rev 21 → Rev 22

/trunk/sw/rtos_example/libstd.a Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
trunk/sw/rtos_example/libstd.a Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: trunk/sw/rtos_example/serial.c =================================================================== --- trunk/sw/rtos_example/serial.c (nonexistent) +++ trunk/sw/rtos_example/serial.c (revision 22) @@ -0,0 +1,126 @@ +//----------------------------------------------------------------------------- +// AltOR32 +// Alternative Lightweight OpenRISC +// Ultra-Embedded.com +// Copyright 2011 - 2012 +// +// Email: admin@ultra-embedded.com +// +// License: GPL +// Please contact the above address if you would like a version of this +// software with a more permissive license for use in closed source commercial +// applications. +//----------------------------------------------------------------------------- +// +// This file is part of AltOR32 Alternative Lightweight OpenRISC project. +// +// AltOR32 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. +// +// AltOR32 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 AltOR32; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//----------------------------------------------------------------------------- +#include "mem_map.h" +#include "serial.h" + +//----------------------------------------------------------------- +// Registers +//----------------------------------------------------------------- +#define UART_RX_AVAIL (1<<0) +#define UART_TX_AVAIL (1<<1) +#define UART_RX_FULL (1<<2) +#define UART_TX_BUSY (1<<3) +#define UART_RX_ERROR (1<<4) + +//------------------------------------------------------------- +// serial_init: +//------------------------------------------------------------- +void serial_init (void) +{ + +} +//------------------------------------------------------------- +// serial_putchar: Write character to Serial Port (used by printf) +//------------------------------------------------------------- +int serial_putchar(char ch) +{ + if (ch == '\n') + serial_putchar('\r'); + + { + register char t1 asm ("r3") = ch; + asm volatile ("\tl.nop\t%0" : : "K" (0x0004), "r" (t1)); + } + + UART_UDR = ch; + while (UART_USR & UART_TX_BUSY); + + return 0; +} +//------------------------------------------------------------- +// serial_getchar: Read character from Serial Port +//------------------------------------------------------------- +int serial_getchar (void) +{ + // Read character in from UART0 Recieve Buffer and return + if (serial_haschar()) + return UART_UDR; + else + return -1; +} +//------------------------------------------------------------- +// serial_haschar: +//------------------------------------------------------------- +int serial_haschar() +{ + return (UART_USR & UART_RX_AVAIL); +} +//------------------------------------------------------------- +// serial_putstr: +//------------------------------------------------------------- +void serial_putstr(char *str) +{ + while (*str) + serial_putchar(*str++); +} +//------------------------------------------------------------- +// serial_putnum: +//------------------------------------------------------------- +void serial_putnum( int n ) +{ + char* cp; + int negative; + char outbuf[32]; + const char digits[] = "0123456789ABCDEF"; + unsigned long num; + + /* Check if number is negative */ + if (n < 0L) { + negative = 1; + num = -(n); + } + else{ + num = (n); + negative = 0; + } + + /* Build number (backwards) in outbuf */ + cp = outbuf; + do { + *cp++ = digits[(int)(num % 10)]; + } while ((num /= 10) > 0); + if (negative) + *cp++ = '-'; + *cp-- = 0; + + while (cp >= outbuf) + serial_putchar(*cp--); +} Index: trunk/sw/rtos_example/irq.h =================================================================== --- trunk/sw/rtos_example/irq.h (nonexistent) +++ trunk/sw/rtos_example/irq.h (revision 22) @@ -0,0 +1,18 @@ +#ifndef __IRQ_H__ +#define __IRQ_H__ + +//----------------------------------------------------------------- +// Types +//----------------------------------------------------------------- +typedef void (*fn_irq_func)(int irq_number); + +//----------------------------------------------------------------- +// Prototypes +//----------------------------------------------------------------- +void irq_register(int interrupt, fn_irq_func func); +void irq_handler(unsigned int interrupts); +void irq_enable(int interrupt); +void irq_disable(int interrupt); +void irq_acknowledge(int interrupt); + +#endif Index: trunk/sw/rtos_example/mem_map.h =================================================================== --- trunk/sw/rtos_example/mem_map.h (nonexistent) +++ trunk/sw/rtos_example/mem_map.h (revision 22) @@ -0,0 +1,55 @@ +#ifndef __MEM_MAP_H__ +#define __MEM_MAP_H__ + +//----------------------------------------------------------------- +// Defines: +//----------------------------------------------------------------- +#define INT_BASE 0x00000000 +#define EXT_BASE 0x10000000 +#define IO_BASE 0x20000000 + +//----------------------------------------------------------------- +// Macros: +//----------------------------------------------------------------- +#define REG8 (volatile unsigned char*) +#define REG16 (volatile unsigned short*) +#define REG32 (volatile unsigned int*) + +//----------------------------------------------------------------- +// Peripheral Base Addresses +//----------------------------------------------------------------- +#define UART_BASE 0x20000000 +#define TIMER_BASE 0x20000100 +#define INTR_BASE 0x20000200 +#define SPI_FLASH_BASE 0x20000300 + +//----------------------------------------------------------------- +// Interrupts +//----------------------------------------------------------------- +#define IRQ_UART_RX 0 +#define IRQ_TIMER_SYSTICK 1 +#define IRQ_TIMER_HIRES 2 + +//----------------------------------------------------------------- +// Peripheral Registers +//----------------------------------------------------------------- + +#define UART_USR (*(REG32 (UART_BASE + 0x4))) +#define UART_UDR (*(REG32 (UART_BASE + 0x8))) + +#define TIMER_VAL (*(REG32 (TIMER_BASE + 0x0))) +#define SYS_CLK_COUNT (*(REG32 (TIMER_BASE + 0x4))) + +#define IRQ_MASK (*(REG32 (INTR_BASE + 0x00))) +#define IRQ_MASK_SET (*(REG32 (INTR_BASE + 0x00))) +#define IRQ_MASK_CLR (*(REG32 (INTR_BASE + 0x04))) +#define IRQ_STATUS (*(REG32 (INTR_BASE + 0x08))) + #define IRQ_SYSTICK (IRQ_TIMER_SYSTICK) + +#define SPI_PROM_CTRL (*(REG32 (SPI_FLASH_BASE + 0x00))) + #define SPI_PROM_CS (1 << 0) +#define SPI_PROM_STAT (*(REG32 (SPI_FLASH_BASE + 0x00))) + #define SPI_PROM_BUSY (1 << 0) +#define SPI_PROM_DATA (*(REG32 (SPI_FLASH_BASE + 0x04))) + +#endif Index: trunk/sw/rtos_example/boot.S =================================================================== --- trunk/sw/rtos_example/boot.S (nonexistent) +++ trunk/sw/rtos_example/boot.S (revision 22) @@ -0,0 +1,168 @@ +#include "../rtos/arch/altor32/exception.inc" + +#------------------------------------------------------------- +# VECTOR 0x000 - Application Header +#------------------------------------------------------------- +.org 0x000 + +# This code is not executed as execution starts from reset vector +.word 0x00000000 +.word 0x00000000 +.word 0xb00710ad +.word 0x00000000 + +#------------------------------------------------------------- +# VECTOR 0x100 - Reset +#------------------------------------------------------------- +.org 0x100 +vector_reset: + + # Setup SP (R1) + l.movhi r4,hi(_sp); + l.ori r1,r4,lo(_sp); + + # R4 = _bss_start + l.movhi r4,hi(_bss_start); + l.ori r4,r4,lo(_bss_start); + + # R5 = _end + l.movhi r5,hi(_bss_end); + l.ori r5,r5,lo(_bss_end); + +BSS_CLEAR: + l.sw 0x0(r4),r0 # Write 0x00 to mem[r4] + l.sfleu r4,r5 # SR[F] = (r4 < r5) + l.bf BSS_CLEAR # If SR[F] == 0, jump to BSS_CLEAR + l.addi r4, r4, 4 # r4 += 4 + + # Jump to main routine + l.jal main + l.nop + +#------------------------------------------------------------- +# VECTOR 0x200 - Fault / Illegal Instruction +#------------------------------------------------------------- +.org 0x200 +vector_fault: + + # Jump to cpu_fault + l.movhi r10,hi(cpu_fault); + l.ori r10,r10,lo(cpu_fault); + l.jalr r10 + l.nop + +.size vector_fault, .-vector_fault + +#------------------------------------------------------------- +# VECTOR 0x300 - External Interrupt +#------------------------------------------------------------- +.org 0x300 +vector_extint: + + #--------------------------------------------------------- + # Save context + #--------------------------------------------------------- + asm_save_context + + # Load TCB address + l.movhi r10,hi(_currentTCB); + l.ori r10,r10,lo(_currentTCB); + l.lwz r10, 0(r10) + + # _currentTCB == NULL, goto no_tcb + l.sfeq r0, r10 + l.bf no_tcb2 + l.nop + + # Store SP to TCB + l.sw 0(r10), r1 + + no_tcb2: + #--------------------------------------------------------- + + # Setup kernel stack pointer to system stack + l.movhi r1,hi(_sp); + l.ori r1,r1,lo(_sp); + + # Jump to irq handling function + l.movhi r10,hi(cpu_irq); + l.ori r10,r10,lo(cpu_irq); + l.jalr r10 + l.nop + + l.j common_int_end + l.nop + +.size vector_extint, .-vector_extint + +#------------------------------------------------------------- +# VECTOR 0x400 - Syscall +#------------------------------------------------------------- +.org 0x400 +vector_syscall: + + #--------------------------------------------------------- + # Save context + #--------------------------------------------------------- + asm_save_context + + # Load TCB address + l.movhi r10,hi(_currentTCB); + l.ori r10,r10,lo(_currentTCB); + l.lwz r10, 0(r10) + + # _currentTCB == NULL, goto no_tcb + l.sfeq r0, r10 + l.bf no_tcb + l.nop + + # Store SP to TCB + l.sw 0(r10), r1 + + no_tcb: + #--------------------------------------------------------- + + # Setup kernel stack pointer to system stack + l.movhi r1,hi(_sp); + l.ori r1,r1,lo(_sp); + + # Jump to irq handling function + l.movhi r10,hi(cpu_syscall); + l.ori r10,r10,lo(cpu_syscall); + l.jalr r10 + l.nop + + #--------------------------------------------------------- + # Load context + #--------------------------------------------------------- +common_int_end: + + # Get TCB pointer address + l.movhi r13,hi(_currentTCB); + l.ori r13,r13,lo(_currentTCB); + + # Load current TCB address + l.lwz r13, 0(r13) + + # Load stack pointer from TCB + l.lwz r1, 0(r13) + + # Restore context + asm_load_context + #--------------------------------------------------------- + +.size vector_syscall, .-vector_syscall + +#------------------------------------------------------------- +# VECTOR 0x600 - Trap +#------------------------------------------------------------- +.org 0x600 +vector_trap: + + # Jump to cpu_fault + l.movhi r10,hi(cpu_trap); + l.ori r10,r10,lo(cpu_trap); + l.jalr r10 + l.nop + +.size vector_trap, .-vector_trap \ No newline at end of file Index: trunk/sw/rtos_example/main.c =================================================================== --- trunk/sw/rtos_example/main.c (nonexistent) +++ trunk/sw/rtos_example/main.c (revision 22) @@ -0,0 +1,127 @@ +//----------------------------------------------------------------------------- +// AltOR32 +// Alternative Lightweight OpenRISC +// Ultra-Embedded.com +// Copyright 2011 - 2012 +// +// Email: admin@ultra-embedded.com +// +// License: GPL +// Please contact the above address if you would like a version of this +// software with a more permissive license for use in closed source commercial +// applications. +//----------------------------------------------------------------------------- +// +// This file is part of AltOR32 Alternative Lightweight OpenRISC project. +// +// AltOR32 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. +// +// AltOR32 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 AltOR32; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//----------------------------------------------------------------------------- +#include "serial.h" +#include "printf.h" +#include "assert.h" +#include "kernel/rtos.h" + +//----------------------------------------------------------------- +// Defines: +//----------------------------------------------------------------- +#define RTOS_MEM_SIZE (4096) +#define APP_STACK_SIZE (256) + +//----------------------------------------------------------------- +// Prototypes: +//----------------------------------------------------------------- +extern void app_func(void *arg); +static void idle_func(void); +static void thread1_func(void *arg); +static void thread2_func(void *arg); + +//----------------------------------------------------------------- +// Locals: +//----------------------------------------------------------------- +static unsigned char rtos_heap[RTOS_MEM_SIZE]; + +//----------------------------------------------------------------- +// main: +//----------------------------------------------------------------- +int main(void) +{ + printf_register(serial_putchar); + printf("\n\nRunning\n"); + + // Initialise RTOS + rtos_init(); + + // Register system specific functions + rtos_services.printf = printf; + rtos_services.idle = idle_func; + + // RTOS heap init + rtos_heap_init(rtos_heap, RTOS_MEM_SIZE); + + // Add threads + rtos_thread_create("THREAD1", THREAD_MAX_PRIO - 1, thread1_func, NULL, APP_STACK_SIZE); + rtos_thread_create("THREAD2", THREAD_MAX_PRIO - 2, thread2_func, NULL, APP_STACK_SIZE); + + // Start RTOS + printf("Starting RTOS...\n"); + thread_kernel_run(); + + return 0; +} +//----------------------------------------------------------------- +// thread1_func: +//----------------------------------------------------------------- +static void thread1_func(void *arg) +{ + int idx = 0; + + while (1) + { + printf("thread1\n"); + thread_sleep(10); + + if (idx++ == 5) + { + idx = 0; + thread_dump_list(); + } + } +} +//----------------------------------------------------------------- +// thread2_func: +//----------------------------------------------------------------- +static void thread2_func(void *arg) +{ + while (1) + { + printf("thread2\n"); + thread_sleep(1); + } +} +//----------------------------------------------------------------- +// idle_func: +//----------------------------------------------------------------- +static void idle_func(void) +{ + +} +//----------------------------------------------------------------- +// assert_handler: +//----------------------------------------------------------------- +void assert_handler(const char * type, const char *reason, const char *file, int line) +{ + printf("[%s]: %s %s:%d\n", type, reason, file, line); + while (1); +} Index: trunk/sw/rtos_example/serial.h =================================================================== --- trunk/sw/rtos_example/serial.h (nonexistent) +++ trunk/sw/rtos_example/serial.h (revision 22) @@ -0,0 +1,12 @@ +#ifndef __SERIAL_H__ +#define __SERIAL_H__ + +//----------------------------------------------------------------- +// Prototypes: +//----------------------------------------------------------------- +void serial_init (void); +int serial_putchar(char ch); +int serial_getchar(void); +int serial_haschar(); + +#endif // __SERIAL_H__ Index: trunk/sw/rtos_example/assert.h =================================================================== --- trunk/sw/rtos_example/assert.h (nonexistent) +++ trunk/sw/rtos_example/assert.h (revision 22) @@ -0,0 +1,10 @@ +#ifndef __ASSERT_H__ +#define __ASSERT_H__ + +extern void assert_handler(const char * type, const char *reason, const char *file, int line); + +#define assert(exp) do { if (!(exp)) assert_handler("ASSERT", #exp, __FILE__, __LINE__ ); } while (0) +#define panic(reason) do { assert_handler("PANIC", #reason, __FILE__, __LINE__ ); } while (0) + +#endif + Index: trunk/sw/rtos_example/linker_script =================================================================== --- trunk/sw/rtos_example/linker_script (nonexistent) +++ trunk/sw/rtos_example/linker_script (revision 22) @@ -0,0 +1,55 @@ +GROUP("libgcc.a" + "libstd.a") + +MEMORY +{ + sram (rwx) : ORIGIN = 0x00000000, LENGTH = 64K +} + +SECTIONS +{ + .text : + { + _text_start = .; + *(.text .text.*) /* remaining code */ + *(.rodata) /* read-only data (constants) */ + *(.rodata*) + *(.rdata*) + . = ALIGN(4); + _text_end = .; + } > sram + + .data : + { + . = ALIGN(4); + _data_start = .; + + *(.got.plt) *(.got) + *(.shdata) + *(.data .data.* .gnu.linkonce.d.*) + *(.lit8) + *(.lit4) + *(.sdata .sdata.* .gnu.linkonce.s.*) + . = ALIGN (8); + *(.ram) + . = ALIGN (8); + _edata = .; + _data_end = .; + } > sram + + .bss : + { + . = ALIGN(4); + _bss_start = . ; + + *(.bss*) + *(COMMON) + + /* Allocate room for stack */ + . = ALIGN(8) ; + . += 4096 ; + _sp = . - 16; + + _bss_end = .; + } > sram +} Index: trunk/sw/rtos_example/printf.h =================================================================== --- trunk/sw/rtos_example/printf.h (nonexistent) +++ trunk/sw/rtos_example/printf.h (revision 22) @@ -0,0 +1,41 @@ +#ifndef __PRINTF_H__ +#define __PRINTF_H__ + +#include + +//----------------------------------------------------------------- +// Types: +//----------------------------------------------------------------- +typedef int (*FP_OUTCHAR)(char c); + +#ifdef LIBSTD_SIZE_T_2 + typedef long unsigned int libsize_t; +#else + typedef unsigned int libsize_t; +#endif + +//----------------------------------------------------------------- +// Structures +//----------------------------------------------------------------- +struct vbuf +{ + FP_OUTCHAR function; + char * buffer; + int offset; + int max_length; +}; + +//----------------------------------------------------------------- +// Prototypes: +//----------------------------------------------------------------- +int printf(const char* ctrl1, ... ); +void printf_register(FP_OUTCHAR f); +int vsprintf(char *s, const char *format, va_list arg); +int vsnprintf(char *s, libsize_t maxlen, const char *format, va_list arg); +int sprintf(char *s, const char *format, ...); +int snprintf(char *s, libsize_t maxlen, const char *format, ...); +int vbuf_printf(struct vbuf *buf, const char* ctrl1, va_list argp); + +#define PRINTF printf + +#endif // __PRINTF_H__ Index: trunk/sw/rtos_example/README.txt =================================================================== --- trunk/sw/rtos_example/README.txt (nonexistent) +++ trunk/sw/rtos_example/README.txt (revision 22) @@ -0,0 +1,57 @@ +AltOR32 RTOS Example +-------------------- + +To compile, just type... + + make + +To run on the verilator RTL model... + + make run + + +Expected Output: + +Running +Starting RTOS... +thread1 +thread2 +thread2 +thread2 +thread2 +thread2 +thread1 +thread2 +thread2 +thread2 +thread2 +thread2 +thread1 +thread2 +thread2 +thread2 +thread2 +thread2 +thread1 +thread2 +thread2 +thread2 +thread2 +thread2 +thread1 +thread2 +thread2 +thread2 +thread2 +thread2 +thread1 +thread2 +thread2 +thread2 +thread2 +thread2 +Thread Dump: +Num Name Pri State Sleep Runs Free Stack +1: | THREAD2| 8 R 0 36 84 +2: | THREAD1| 9 * 0 7 83 +3: | IDLE_TASK| -1 R 0 60 90 Index: trunk/sw/rtos_example/irq.c =================================================================== --- trunk/sw/rtos_example/irq.c (nonexistent) +++ trunk/sw/rtos_example/irq.c (revision 22) @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +// AltOR32 +// Alternative Lightweight OpenRISC +// Ultra-Embedded.com +// Copyright 2011 - 2012 +// +// Email: admin@ultra-embedded.com +// +// License: GPL +// Please contact the above address if you would like a version of this +// software with a more permissive license for use in closed source commercial +// applications. +//----------------------------------------------------------------------------- +// +// This file is part of AltOR32 Alternative Lightweight OpenRISC project. +// +// AltOR32 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. +// +// AltOR32 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 AltOR32; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//----------------------------------------------------------------------------- +#include +#include +#include "mem_map.h" +#include "irq.h" + +//----------------------------------------------------------------- +// Defines +//----------------------------------------------------------------- +#define IRQ_INTERRUPTS 16 + +//----------------------------------------------------------------- +// Locals +//----------------------------------------------------------------- +static fn_irq_func irq_func[IRQ_INTERRUPTS]; + +//----------------------------------------------------------------- +// irq_register +//----------------------------------------------------------------- +void irq_register(int interrupt, fn_irq_func func) +{ + assert(interrupt < IRQ_INTERRUPTS); + assert(irq_func[interrupt] == NULL); + assert(func != NULL); + + irq_func[interrupt] = func; +} +//----------------------------------------------------------------- +// irq_handler +//----------------------------------------------------------------- +void irq_handler(unsigned int interrupts) +{ + // Skip interrupt 0 (SYSTICK) + int irq = 1; + + // Process all pending interrupts + while (interrupts && irq < IRQ_INTERRUPTS) + { + if (interrupts & (1 << irq)) + { + // Check that this interrupt is enabled! + assert(IRQ_MASK & (1 << irq)); + + // Call interrupt function + assert(irq_func[irq] != NULL); + irq_func[irq](irq); + + // Acknowledge (reset) interrupt + IRQ_STATUS = (1 << irq); + + // Mark interrupt as serviced + interrupts &= ~(1 << irq); + } + + irq++; + } +} +//----------------------------------------------------------------- +// irq_enable +//----------------------------------------------------------------- +void irq_enable(int interrupt) +{ + IRQ_MASK_SET = (1 << interrupt); +} +//----------------------------------------------------------------- +// irq_disable +//----------------------------------------------------------------- +void irq_disable(int interrupt) +{ + IRQ_MASK_CLR = (1 << interrupt); +} +//----------------------------------------------------------------- +// irq_acknowledge +//----------------------------------------------------------------- +void irq_acknowledge(int interrupt) +{ + IRQ_STATUS = (1 << interrupt); +} Index: trunk/sw/rtos_example/makefile =================================================================== --- trunk/sw/rtos_example/makefile (nonexistent) +++ trunk/sw/rtos_example/makefile (revision 22) @@ -0,0 +1,99 @@ +############################################################################### +## Makefile +############################################################################### + +# Tools +TCHAIN = or32-elf +CC = $(TCHAIN)-gcc $(CFLAGS) +AS = $(TCHAIN)-as +LD = $(TCHAIN)-ld +OBJDUMP = $(TCHAIN)-objdump +OBJCOPY = $(TCHAIN)-objcopy + +# Target +TARGET = image + +# Options +LDSCRIPT = linker_script +CFLAGS = -O2 -g -Wall +CFLAGS += -msoft-div -msoft-float -msoft-mul -mno-ror -mno-cmov -mno-sext +CFLAGS += -nostartfiles -nodefaultlibs -nostdlib -lgcc -Ttext 0x00000000 +CFLAGS += -L ./ -lstd -T$(LDSCRIPT) +ASFLAGS = +LDFLAGS = + +# Simulation Configuration +VERILATOR_DIR ?= ../../rtl/sim_verilator +VERILATOR_ARGS ?= -l 0x00000000 + +############################################################################### +# Source Files +############################################################################### +OBJ = + +OBJ += boot.o +OBJ += main.o +OBJ += serial.o +OBJ += irq.o + +# RTOS Flags +CFLAGS += -DINCLUDE_RTOS_MALLOC +CFLAGS += -DINCLUDE_MUTEX +CFLAGS += -DINCLUDE_SEMAPHORE +CFLAGS += -DINCLUDE_TIMERCB +CFLAGS += -DINCLUDE_MAILBOX +CFLAGS += -DINCLUDE_EVENTS +CFLAGS += -DINCLUDE_RECURSIVE_LOCK +CFLAGS += -DINCLUDE_INTERRUPTS +CFLAGS += -DALTOR32_PLATFORM + +# RTOS Kernel +OBJ += ../rtos/kernel/critical.o +OBJ += ../rtos/kernel/event.o +OBJ += ../rtos/kernel/interrupts.o +OBJ += ../rtos/kernel/lock.o +OBJ += ../rtos/kernel/mailbox.o +OBJ += ../rtos/kernel/mem_alloc.o +OBJ += ../rtos/kernel/mutex.o +OBJ += ../rtos/kernel/rtos.o +OBJ += ../rtos/kernel/semaphore.o +OBJ += ../rtos/kernel/thread.o +OBJ += ../rtos/kernel/timer_cb.o + +OBJ += ../rtos/arch/altor32/cpu_thread.o +OBJ += ../rtos/arch/altor32/cpu_interrupts.o + +CFLAGS += -I. -I./../rtos -I./../rtos/kernel + +############################################################################### +# Rules +############################################################################### +all: $(TARGET).elf lst bin + +clean: + -rm *.o *.map *.lst *.hex *.txt *.elf + +%.o : %.S + $(CC) -c $(ASFLAGS) $< -o $@ + +%.o : %.s + $(CC) -c $(ASFLAGS) $< -o $@ + +%.o : %.c + $(CC) -c $(CFLAGS) $< -o $@ + +$(TARGET).elf: $(OBJ) $(LDSCRIPT) makefile + $(CC) $(LDFLAGS) $(LIBS) $(OBJ) -o $@ + +lst: $(TARGET).lst + +%.lst: $(TARGET).elf + $(OBJDUMP) -h -d -S $< > $@ + +bin: $(TARGET).bin + +%.bin: %.elf + $(OBJCOPY) -O binary $< $@ + +run: bin + make -C $(VERILATOR_DIR) TEST_IMAGE=$(CURDIR)/$(TARGET).bin SIMARGS="$(VERILATOR_ARGS)" \ No newline at end of file Index: trunk/sw/rtos_example =================================================================== --- trunk/sw/rtos_example (nonexistent) +++ trunk/sw/rtos_example (revision 22)
trunk/sw/rtos_example Property changes : Added: bugtraq:number ## -0,0 +1 ## +true \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.