source: trunk/libs/newlib/src/libgloss/or1k/boards/optimsoc.S @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.8 KB
Line 
1/* optimsoc.S -- Support for OpTiMSoC systems.
2 *
3 * Copyright (c) 2014 Authors
4 *
5 * Contributor Stefan Wallentowitz <stefan.wallentowitz@saunalahti.fi>
6 *
7 * The authors hereby grant permission to use, copy, modify, distribute,
8 * and license this software and its documentation for any purpose, provided
9 * that existing copyright notices are retained in all copies and that this
10 * notice is included verbatim in any distributions. No written agreement,
11 * license, or royalty fee is required for any of the authorized uses.
12 * Modifications to this software may be copyrighted by their authors
13 * and need not follow the licensing terms described here, provided that
14 * the new terms are clearly indicated on the first page of each file where
15 * they apply.
16 */
17
18#include "../include/or1k-asm.h"
19#include "../include/or1k-nop.h"
20
21#define OPTIMSOC_NA_BASE 0xe0000000
22
23#define OPTIMSOC_NA_REGS       OPTIMSOC_NA_BASE + 0x00000
24#define OPTIMSOC_NA_LMEM_SIZE  OPTIMSOC_NA_REGS + 0x24
25#define OPTIMSOC_NA_GMEM_SIZE  OPTIMSOC_NA_REGS + 0x1c
26
27#define OPTIMSOC_GZLL_STRING 0x677a6c6c
28#define OPTIMSOC_GZLL_IMAGE_LAYOUT 0x2000
29/*
30 * Define symbols to be used during startup - file is linked at compile time
31 *
32 */
33.weak _or1k_board_mem_base
34.weak _or1k_board_mem_size
35.weak _or1k_board_clk_freq
36
37_or1k_board_mem_base:   .long   0x0
38_or1k_board_mem_size:   .long   0x0
39
40_or1k_board_clk_freq:   .long   50000000
41
42.weak _or1k_board_uart_base
43.weak _or1k_board_uart_baud
44.weak _or1k_board_uart_IRQ
45_or1k_board_uart_base:  .long   0x0
46_or1k_board_uart_baud:  .long   0
47_or1k_board_uart_IRQ:   .long   0
48
49.weak _or1k_board_exit
50_or1k_board_exit:
51        l.nop OR1K_NOP_K_EXIT
52.Lexitloop:
53        OR1K_DELAYED_NOP(l.j .Lexitloop)
54
55.extern _or1k_heap_start
56
57.global _or1k_board_init_early
58_or1k_board_init_early:
59#ifndef __OR1K_MULTICORE__
60        l.nop   0x1
61.die:
62        OR1K_DELAYED_NOP(l.j .die)
63#endif
64        l.movhi r1,hi(OPTIMSOC_NA_LMEM_SIZE)
65        l.ori   r1,r1,lo(OPTIMSOC_NA_LMEM_SIZE)
66        l.lwz   r1,0(r1)
67        l.movhi r2,hi(_or1k_board_mem_size)
68        l.ori   r2,r2,lo(_or1k_board_mem_size)
69        l.sw    0(r2),r1
70        // Set stack beyond apps if single image in local memory
71        // Is this a kernel running?
72        l.movhi r3,hi(OPTIMSOC_GZLL_STRING)
73        l.ori   r3,r3,lo(OPTIMSOC_GZLL_STRING)
74        l.movhi r4,hi(OPTIMSOC_GZLL_IMAGE_LAYOUT)
75        l.ori   r4,r4,lo(OPTIMSOC_GZLL_IMAGE_LAYOUT)
76        l.lwz   r5,0(r4)
77        l.sfeq  r3,r5
78        // If not, we are done
79        OR1K_DELAYED_NOP(l.bnf ._or1k_board_init_early_done)
80        // Else: are we running with global memory (loading)?
81        l.movhi r6,hi(OPTIMSOC_NA_GMEM_SIZE)
82        l.ori   r6,r6,lo(OPTIMSOC_NA_GMEM_SIZE)
83        l.lwz   r6,0(r6)
84        l.sfeqi r6,0
85        // If yes, we are done
86        OR1K_DELAYED_NOP(l.bnf ._or1k_board_init_early_done)
87        // Else: Read end of apps
88        l.lwz   r7,12(r4)
89        l.movhi r8,hi(_or1k_heap_start)
90        l.ori   r8,r8,lo(_or1k_heap_start)
91        l.sw    0(r8),r7
92._or1k_board_init_early_done:
93        OR1K_DELAYED_NOP(l.jr r9)
94
95.weak _or1k_board_init
96_or1k_board_init:
97        OR1K_DELAYED_NOP(l.jr r9)
Note: See TracBrowser for help on using the repository browser.