2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 #include <aros/config.h>
10 #include <exec/types.h>
11 #include <exec/nodes.h>
12 #include <exec/memory.h>
13 #include <exec/resident.h>
14 #include <exec/libraries.h>
15 #include <exec/execbase.h>
16 #include <proto/oop.h>
17 #include <proto/exec.h>
19 #include <devices/keyboard.h>
20 #define mybug(col,var) __asm__ __volatile__("move.l #"#col",0xf9002000+"#var"" :: );
21 //#define mybug(col,var)
23 #include <aros/debug.h>
24 #include <aros/core.h>
25 #include <asm/registers.h>
35 #include "exec_intern.h"
45 #define rkprintf(x...) scr_RawPutChars(tab, snprintf(tab,126, x))
47 extern void scr_RawPutChars(char *chr
, int lim
);
49 extern unsigned long _end
;
50 struct mac68k_init_stuff init_stuff
;
51 //extern struct init_stuff init_stuff;
53 extern struct ExecBase
* PrepareExecBase(struct MemHeader
*);
54 extern void switch_to_user_mode(void *, ULONG
*);
55 extern void main_init_cont(void);
56 extern struct MemHeader
* detect_memory(void);
57 extern void screen_init(void);
58 extern void fontinit(void);
59 void get_initial_epinfo(void);
62 unsigned long address
;
67 * Just to be sure all of these modules get linked into the
68 * final module, this structure should stay here, because
69 * otherwise the linker might not take it if there is no
70 * reference to a certain module at all.
72 extern const struct Resident
73 // Expansion_resident,
80 Mathieeesingbas_resident
,
92 hiddgraphics_resident
,
104 con_handler_resident
,
108 /* This list MUST be in the correct order (priority). */
109 static const struct Resident
*romtagList
[] =
111 // &Expansion_resident,
116 &Mathieeesingbas_resident
,
130 &hiddgraphics_resident
,
131 &displayHidd_resident
,
132 &hiddserial_resident
,
139 &con_handler_resident
143 /************************************************************************************/
145 void processor_init(void)
148 /************ CPU setup *******************/
149 /* switch to supervisor, Emile/Penguin already does it for us ? */
151 __asm__
__volatile__("oriw #0x0700,%%sr" :: );
155 __asm__
__volatile__ ( \
156 "move.l #0xf9000080,%%a0\n" \
158 "move.l 0x00ff00ff,(%%a0)+\n" \
164 /************************************************************************************/
165 extern ULONG initial_ssp
;
171 UWORD
* rom_ranges
[] = {(UWORD
*)0x1000 , (UWORD
*)&_end
, (UWORD
*)~0};
172 struct MemHeader
* mh
= NULL
;
173 char *Processor_type
[] = { "68020", "68030", "68040", "68060" };
177 get_initial_epinfo();
180 rkprintf("AROS - The AROS Research OS - Mac68k\nCompiled %s\n\n",__DATE__
);
181 rkprintf("CPU: %s, MEM: %ld\n", Processor_type
[init_stuff
.cpu
], init_stuff
.mem
);
182 rkprintf("MacModel: %ld\nVidBase: 0x%lx, VidDepth: %ld, ScreenWidth: %ld, ScreenHeight: %ld\n", \
183 init_stuff
.model
, init_stuff
.vidaddr
, init_stuff
.viddepth
, init_stuff
.vidwidth
, init_stuff
.vidheight
);
193 * create entry for first chunk of system mem with information from the bootloader
196 #define MEM_START ((unsigned long)&_end + 0x10000)
198 rkprintf("MEM_START: 0x%lx\n, memchunksize[0]: 0x%lx\n", MEM_START
, init_stuff
.memchunksize
[0]);
200 mh
=(struct MemHeader
*)MEM_START
;
201 mh
->mh_Node
.ln_Succ
= NULL
;
202 mh
->mh_Node
.ln_Pred
= NULL
;
203 mh
->mh_Node
.ln_Type
= NT_MEMORY
;
204 mh
->mh_Node
.ln_Name
= "chip memory";
205 mh
->mh_Node
.ln_Pri
= -5;
206 mh
->mh_Attributes
= MEMF_CHIP
| MEMF_PUBLIC
| MEMF_LOCAL
| MEMF_24BITDMA
|
208 mh
->mh_First
= (struct MemChunk
*)((UBYTE
*)mh
+MEMHEADER_TOTAL
);
209 mh
->mh_First
->mc_Next
= NULL
;
210 mh
->mh_First
->mc_Bytes
= ((ULONG
) init_stuff
.memchunksize
[0] - MEM_START
) - MEMHEADER_TOTAL
;
212 mh
->mh_Lower
= mh
->mh_First
;
213 mh
->mh_Upper
= (APTR
)(init_stuff
.memchunksize
[0]);
214 mh
->mh_Free
= mh
->mh_First
->mc_Bytes
;
217 We have to put somewhere in this function checking for ColdStart,
218 CoolStart and many other Exec vectors!
222 It is OK to place ExecBase here. Remember that interrupt table starts
223 at 0x0100UL address, so 4UL is quite safe.
224 Even with MP this addr is OK for ExecBase. We may write an int handler
225 which detects "read from 4UL" commands.
228 rkprintf("PrepareExecBase\n");
231 PrepareExecBase(mh
, NULL
);
232 rkprintf("SysBase = 4\n");
233 *(APTR
*)0x4 = SysBase
;
236 Setup ChkBase (checksum for base ptr), ChkSum (for library)
237 SysBase+ChkBase should be -1 otherwise somebody has destroyed ExecBase!
239 SysBase
->ChkBase
=~(ULONG
)SysBase
;
240 #warning TODO: SysBase->ChkSum=.....
242 if(NULL
== AllocAbs(&_end
-0x1000+0x10000,(APTR
)0x1000))
244 rkprintf("Kernel protection failed !!\n");
247 if (NULL
== (m68k_USP
=(ULONG
*)AllocMem(AROS_STACKSIZE
,MEMF_PUBLIC
))) {
250 m68k_USP
= (ULONG
*)(((ULONG
)m68k_USP
) + AROS_STACKSIZE
);
251 rkprintf("USP alloc\n");
254 * Allocate memory for the SSP. The SSP is already set
255 * but I need to AllocAbs() it so nobody else will step on this
259 if (NULL
== AllocAbs(AROS_STACKSIZE
,
260 (APTR
)(initial_ssp
+sizeof(ULONG
)-AROS_STACKSIZE
))) {
261 D(bug("Alloc for SSP failed!\n"));
263 D(bug("SSP: %x\n",initial_ssp
));
265 //SysBase->ResModules=Exec_RomTagScanner(SysBase, rom_ranges);
267 rkprintf("init core\n");
272 rkprintf("Init traps\n");
275 * This is the last place where I am in supervisor mode.
276 * so let me switch into user mode and continue there.
277 * The user mode function will then call main_init_cont.
279 rkprintf("going to UserMode\n");
280 switch_to_user_mode(main_init_cont
, m68k_USP
);
283 void get_initial_epinfo(void)
285 struct ep_entry
*epinfo
= (struct ep_entry
*)&_end
;
288 while(epinfo
->tag
!= EP_LAST
)
293 init_stuff
.vidaddr
= epinfo
->data
[0];
296 init_stuff
.viddepth
= epinfo
->data
[0];
299 init_stuff
.vidrow
= epinfo
->data
[0];
302 init_stuff
.vidwidth
= epinfo
->data
[0] & 0xffff;
303 init_stuff
.vidheight
= epinfo
->data
[0] >> 16;
306 init_stuff
.model
= epinfo
->data
[0];
309 init_stuff
.cpu
= epinfo
->data
[0];
312 init_stuff
.mem
= epinfo
->data
[0];
315 init_stuff
.memchunk
[memchunks
] = epinfo
->data
[0];
316 init_stuff
.memchunksize
[memchunks
] = epinfo
->data
[1];
322 epinfo
= (struct ep_entry
*)((unsigned long)epinfo
+epinfo
->size
);
326 * The following function will be executed when AROS is in user mode
328 void main_init_cont(void)
330 InitCode(RTF_SINGLETASK
, 0);
333 All done. In normal cases CPU should never reach this point
336 *(ULONG
*)0xc0debad0 = 0;