source: rtems/c/src/lib/libbsp/sh/gensh2/start/start.ram @ 4a238002

4.104.114.84.95
Last change on this file since 4a238002 was 4a238002, checked in by Joel Sherrill <joel.sherrill@…>, on 11/18/99 at 21:22:58

Patch from "John M. Mills" <jmills@…> with subsequent cleanup from
Ralf Corsepius <corsepiu@…> that adds initial Hitachi SH-2
support to RTEMS. Ralf's comments are:

Changes:
------

  1. SH-Port:
  • Many files renamed.
  • CONSOLE_DEVNAME and MHZ defines removed from libcpu.
  • console.c moved to libbsp/sh/shared, build in libbsp/sh/<BSP>/console applying VPATH.
  • CONSOLE_DEVNAME made BSP-specific, replacement is defined in bsp.h
  • MHZ define replaced with HZ (extendent resolution) in custom/*.cfg
  • -DHZ=HZ used in bspstart.c, only
  • Makefile variable HZ used in bsp-dependent directories only.
  1. SH1-Port
  • clock-driver rewritten to provide better resolution for odd CPU frequencies. This driver is only partially tested on hardware, ie. sightly experimental, but I don't expect severe problems with it.
  • Polling SCI-driver added. This driver is experimental and completly untested yet. Therefore it is not yet used for the console (/dev/console is still pointing to /dev/null, cf. gensh1/bsp.h).
  • minor changes to the timer driver
  • SH1 specific delay()/CPU_delay() now is implemented as a function
  1. SH2-Port
  • Merged
  • IMO, the code is still in its infancy. Therefore I have interspersed comments (FIXME) it for items which I think John should look after.
  • sci and console drivers partially rewritten and extended (John, I hope you don't mind).
  • Copyright notices are not yet adapted
  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 *  Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and
3 *           Bernd Becker (becker@faw.uni-ulm.de)
4 *
5 *  COPYRIGHT (c) 1997-1998, FAW Ulm, Germany
6 *
7 *  This program is distributed in the hope that it will be useful,
8 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 *
11 *
12 *  COPYRIGHT (c) 1998.
13 *  On-Line Applications Research Corporation (OAR).
14 *  Copyright assigned to U.S. Government, 1994.
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.OARcorp.com/rtems/license.html.
19 *
20 *  Modified to reflect Hitachi EDK SH7045F:
21 *  John M. Mills (jmills@tga.com)
22 *  TGA Technologies, Inc.
23 *  100 Pinnacle Way, Suite 140
24 *  Norcross, GA 30071 U.S.A.
25 * 
26 *
27 *  This modified file may be copied and distributed in accordance
28 *  the above-referenced license. It is provided for critique and
29 *  developmental purposes without any warranty nor representation
30 *  by the authors or by TGA Technologies.
31 *
32 *  $Id$
33 */
34
35#include "asm.h"
36
37        BEGIN_CODE
38        PUBLIC(start)
39
40SYM (start):
41        ! install the stack pointer
42        mov.l   stack_k,r15
43
44#ifdef  START_HW_INIT   /* from $RTEMS_BSP.cfg */
45        ! Initialize minimal hardware
46        mov.l   hw_init_k, r0
47        jsr @r0
48        nop             !debug dead-slot target
49#endif /* START_HW_INIT */
50
51        ! zero out bss
52        mov.l   edata_k,r0
53        mov.l   end_k,r1
54        mov     #0,r2
550:
56        mov.l   r2,@r0
57        add     #4,r0
58        cmp/ge  r0,r1
59        bt      0b
60        nop             !debug dead-slot target
61
62        ! copy the vector table from rom to ram
63        mov.l   vects_k,r0      ! vectab
64        mov     #0,r1           ! address of boot vector table
65        mov     #0,r2           ! number of bytes copied
66        mov.w   vects_size,r3   ! size of entries in vectab
671:
68        mov.l   @r1+,r4
69        mov.l   r4,@r0
70        add     #4,r0
71        add     #1,r2
72        cmp/hi  r3,r2
73        bf      1b
74        nop             !debug dead-slot target
75
76        ! overlay monitor vectors onto RTEMS table template
77        ! code adapted  from Hitachi EDK7045F User Manual: "Copyvect.s"
78        mova    vects_k,r0
79        mov.l   @r0, r1 ! Shadow vect tbl addr
80        stc             vbr, r2 ! Original vect tbl addr
81        and             #0, r0
82        mov             r0, r4  ! 0 in r4 and r0
83
84!trapa #32
85        or              #0x80, r0
86        mov.l   @(r0,r2), r3
87        mov.l   r3, @(r0, r1)
88        mov             r4, r0
89
90!cpu addr err
91        or              #0x24, r0
92        mov.l   @(r0, r2), r3
93        mov.l   r3, @(r0, r1)
94        mov             r4, r0
95
96!ill slot
97        or              #0x18, r0
98        mov.l   @(r0, r2), r3
99        mov.l   r3, @(r0, r1)
100        mov             r4, r0
101
102!ill inst
103        or              #0x10, r0
104        mov.l   @(r0, r2), r3
105        mov.l   r3, @(r0, r1)
106        mov             r4, r0
107
108!nmi
109        or              #0x2c, r0
110        mov.l   @(r0, r2), r3
111        mov.l   r3, @(r0, r1)
112        mov             r4, r0
113
114!User brk
115        or              #0x30, r0
116        mov.l   @(r0, r2), r3
117        mov.l   r3, @(r0, r1)
118        mov             r4, r0
119
120!sci0 err
121        or              #0x80, r0
122        rotl    r0
123        rotl    r0
124        mov.l   @(r0, r2), r3
125        mov.l   r3, @(r0, r1)
126        mov             r4, r0
127!sci rx
128        or              #0x81, r0
129        rotl    r0
130        rotl    r0
131        mov.l   @(r0, r2), r3
132        mov.l   r3, @(r0, r1)
133
134        stc     vbr,r3          ! capture copy of monitor vbr
135        mov.l   vbrtemp_k,r0
136        mov.l   r3, @r0
137        mov.l   vects_k,r0      ! point vbr to vectab
138        ldc     r0,vbr
139
140        ! call the mainline     
141        mov #0,r4               ! argc
142        mov #0,r5               ! argv - can place in dead slot
143        mov.l main_k,r0
144        jsr @r0
145        nop             !debug dead-slot target
146
147        ! call exit
148        mov     r0,r4
149        mov.l   exit_k,r0
150        or      r0,r0
151        jsr     @r0
152        nop             !debug dead-slot target
153
154        mov.l   vbrtemp_k,r0    ! restore original vbr
155        mov.l   @r0,r3
156        ldc     r3, vbr
157        trapa   #13             ! UBR capture by monitor
158        nop             !debug dead-slot target
159
160        END_CODE
161
162        .align 2
163stack_k:
164        .long   SYM(stack)     
165edata_k:
166        .long   SYM(edata)
167end_k:
168        .long   SYM(end)
169main_k:
170        .long   SYM(boot_card)
171exit_k:
172        .long   SYM(exit)
173#ifdef  START_HW_INIT   /* from $RTEMS_BSP.cfg */
174hw_init_k:
175        .long   SYM(hw_initialize)
176#endif /* START_HW_INIT */
177vbrtemp_k:
178        .long   SYM(vbrtemp)
179vects_k:
180        .long   SYM(vectab)
181vects_size:
182        .word   255
183
184#ifdef __ELF__
185        .section .stack,"aw"
186#else
187        .section .stack
188#endif
189SYM(stack):
190        .long   0xdeaddead
191
192#ifdef __ELF__
193        .section .bss,"aw"
194#else
195        .section .bss
196#endif
197SYM(vbrtemp):
198        .long   0x0
199
Note: See TracBrowser for help on using the repository browser.