source: cpu/arm/boot.fth

Last change on this file was 1896, checked in by wmb, 4 years ago

ARM MMP2 - can now boot Linux.

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1\ Contents: Boot-code for ARM Risc_OS Code
2\ See license at end of file
3
4hex
5nuser memtop            \ The top of the memory used by Forth
60 value #args           \ The process's argument count
70 value  args           \ The process's argument list
8
90 constant main-task    \ This pointer will be changed at boot
10
11code start-forth        ( r6: header r7: syscall-vec r8: memtop )
12                        ( r10: argc  r11: argv  r12: initial-heap-size )
13    \ Binary relocation.  This code reads the relocation bitmap and
14    \ relocates each longword marked by a 1 bit in the bitmap.  Each
15    \ bit in the bitmap represents an aligned address in the program
16    \ image, thus there is one relocation bit for each 32-bit word in
17    \ the program image.  The bits in relocation bitmap are numbered
18    \ in big-endian order.
19    \ The 0x80 bit corresponds to a lower address than then 0x40 bit, etc.
20   add     r0,r6,#0x80             \ forth-image
21   ldr     r1,[r0,#0x10]           \ /dictionary
22   ldr     r3,[r0,#0x14]           \ old origin
23   mov     r2,r1,asr #2            \ words to relocate
24   add     r1,r0,r1           \ dictionary size plus forth-image
25   cmp     r3,r0             
26   <> if
27      dec     r2,#1               
28      \ variables:
29      \ r0: The startof the program image
30      \ r1: The ending address of the program image,
31      \     equal to the starting address of the relocation bitmap
32      \ r2: bit-to-relocate
33      \ r3: origin at saving time
34
35      begin 
36         and     r4,r2,#7     
37         mov     r5,#0x80         
38         mov     r4,r5,lsr r4
39         ldrb    r5,[r1,r2,asr #3]
40         ands    r4,r4,r5     
41         0<> if
42            ldr     r4,[r0,r2,lsl #2]
43            sub     r4,r4,r3     
44            add     r4,r4,r0             
45            str     r4,[r0,r2,lsl #2]
46         then
47         subs    r2,r2,#1     
48      <= until
49   then
50
51   \ set user-pointer up
52   
53   add     up,r0,`init-user-area #`    \ set user-pointer
54   str     r1,'user dp                 \ set here
55
56   str     r8,'user memtop
57   sub     sp,r8,#0x40                 \ Guard band
58   \ Now the stacks are just below the end of our memory
59
60   str     r7,'user syscall-vec
61   str     r10,'user #args
62   str     r11,'user args
63
64   \ At this point, the stack pointer is at the top of the unused
65   \ memory and the user pointer has been set to the bottom of the
66   \ initial user area image.
67   str     up,'user up0
68   str     up,[pc,`'body main-task swap here 8 + - swap`]
69   mov     rp,sp                \ set return-stack pointer
70   str     rp,'user rp0
71   rs-size-t 100 + #
72   dec     sp,*
73   dec     sp,#0x20             
74   str     sp,'user sp0
75
76   mov     r8,sp
77
78   ps-size-t #
79   dec     r8,*
80   sub     r8,r8,r12            \ Heap size
81   str     r8,'user limit       \ Initial heap will be from limit to bottom of stack
82
83   inc     sp,1cell             \ account for the top of stack register
84
85   adr     ip,'body cold
86c;
87
88code cold-code          ( r0: loadaddr  r1: functions  r2: memtop ... )
89                        ( r3: argc      sp[0]: argv )
90   here-t  8  put-call
91
92   \ Put the arguments in safe registers
93   mov     r6,r0            \ r6 points to header
94   mov     r7,r1            \ r7: functions
95   mov     r8,r2            \ r8: memtop
96   \  r9 is up
97   mov     r10,r3           \ r10: argc
98   ldr     r11,[sp]         \ r11: argv
99   mov     r12,#0           \ r11: initial-heap-size
100
101   b       'code start-forth
102end-code
103
104: init-user  ;
105
106\ LICENSE_BEGIN
107\ Copyright (c) 2006 FirmWorks
108\
109\ Permission is hereby granted, free of charge, to any person obtaining
110\ a copy of this software and associated documentation files (the
111\ "Software"), to deal in the Software without restriction, including
112\ without limitation the rights to use, copy, modify, merge, publish,
113\ distribute, sublicense, and/or sell copies of the Software, and to
114\ permit persons to whom the Software is furnished to do so, subject to
115\ the following conditions:
116\
117\ The above copyright notice and this permission notice shall be
118\ included in all copies or substantial portions of the Software.
119\
120\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
121\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
123\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
124\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
125\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
126\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127\
128\ LICENSE_END
Note: See TracBrowser for help on using the repository browser.