1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
/****************************************************************************
** **
** SysStart.c - Startet Exec MIT Betriebssystem **
** **
*****************************************************************************
** **
** Modification History **
** -------------------- **
** **
** 24-Feb-91 CHW Created this file from Start.S **
** **
****************************************************************************/
#include <proto/exec.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <graphics/gfxbase.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <hardware/intbits.h>
//#include <resources/cia.h>
#include <string.h> /* z.B. für __builtin_memcpy */
#include <dos.h>
#include <chlib.h>
char ident[] = "$VER: SysStart 5.0 by Christian A. Weber (" __DATE__ ")";
char CLI_Template[] = "CS=CHIPSIZE/N,FS=FASTSIZE/N,MOD/K,PRI/N";
char CLI_Help[] = "Usage: SysStart [CHIPSIZE kbytes] [FASTSIZE kbytes] [MOD name] [PRI pri]";
extern __regargs void Exit(LONG);
extern void RawPrintfFunc(char *, ...);
extern struct ExecBase *SysBase;
extern struct GfxBase *GfxBase;
extern BPTR StdErr; /* Standard Error output stream */
extern struct Custom far volatile custom;
extern void __asm __far InitExec(
register __d0 LONG, register __d1 LONG,
register __d2 LONG, register __d3 LONG, register __d4 LONG,
register __a0 void *,register __a1 void *,
register __a2 void *,register __a3 void *);
struct
{
LONG *ChipSizePtr;
LONG *FastSizePtr;
char *ModName;
LONG *PriPtr;
} argv;
UBYTE *chipbase; /* Startadresse des CHIP-RAMs für Exec */
LONG chipsize; /* Grösse des CHIP-RAMs für Exec */
UBYTE *fastbase; /* Startadresse des FAST-RAMs für Exec */
LONG fastsize; /* Grösse des FAST-RAMs für Exec */
UWORD dmaconsave, intenasave;
ULONG attnflags, vblankfreq, sysbplcon0;
BYTE oldtaskpri;
/***************************************************************************/
/* Alles freigeben, back to DOS */
__saveds void ExitRoutine(void)
{
int i;
custom.color[0] = 0x173; /* Grünlich */
RawPrintfFunc("SysStart: ExitRoutine()\r\n");
printf("done.\n");
WaitBlit();
DisownBlitter();
custom.cop1lc = (ULONG)GfxBase->copinit; /* Bild wieder einschalten */
custom.dmacon = 0x7FFF;
custom.dmacon = dmaconsave | DMAF_SETCLR; /* Original dmacon zurückholen */
custom.intena = 0x7FFF;
custom.intena = intenasave | INTF_SETCLR; /* Dito mit intena */
for(i=0; i<8; ++i)
custom.spr[i].dataa = custom.spr[i].datab = 0;
RemakeDisplay();
SetTaskPri(SysBase->ThisTask, oldtaskpri);
if (fastbase)
{
FreeMem(fastbase, fastsize);
fastbase = NULL;
}
if (chipbase)
{
FreeMem(chipbase, chipsize);
chipbase = NULL;
}
CloseIntLib();
CloseGfxLib();
Exit(RETURN_OK);
}
/***************************************************************************/
/* Hauptprogramm */
LONG Main(LONG arglen, char *argline)
{
char *module = "MainPrg";
LONG taskpri=4;
OpenGfxLib();
OpenIntLib();
Puts(ident+6);
AllocMem(0x40000000,0); /* Flushlibs */
AllocMem(0x40000000,0);
if (argv.ChipSizePtr)
{
chipsize = *argv.ChipSizePtr << 10; /* KBytes to Bytes */
if(chipsize < 100000)
{
Puts("CHIP size must be > 100K, please try again!");
return RETURN_ERROR;
}
}
else
{
chipsize = (AvailMem(MEMF_CHIP|MEMF_LARGEST) - 30000) & ~0xff;
if(chipsize > 1000000)
chipsize = (3*chipsize)/4;
}
if (argv.FastSizePtr)
{
fastsize = *argv.FastSizePtr << 10;
}
else
{
fastsize = (AvailMem(MEMF_FAST|MEMF_LARGEST) - 50000) & ~0xff;
if(fastsize > 1000000)
fastsize = (3*fastsize)/4;
}
if (argv.ModName)
module = argv.ModName;
if (argv.PriPtr)
taskpri = *argv.PriPtr;
if (chipbase = AllocMem(chipsize, MEMF_CHIP|MEMF_CLEAR))
{
printf("Chip RAM: $%08lx (%ldK)\n", chipbase, chipsize >> 10);
if (fastbase = AllocMem(fastsize, MEMF_FAST|MEMF_CLEAR))
{
printf("Fast RAM: $%08lx (%ldK)\n", fastbase, fastsize >> 10);
}
else
{
fastsize = 0;
Puts("Not enough FAST RAM available");
}
OwnBlitter();
WaitBlit();
oldtaskpri = SetTaskPri(SysBase->ThisTask,taskpri);
/* System-Status für MyExec merken/retten etc. */
dmaconsave = custom.dmaconr; // &~DMAF_SPRITE;
intenasave = custom.intenar; // &~INTF_INTEN;
attnflags = SysBase->AttnFlags;
vblankfreq = SysBase->VBlankFrequency;
sysbplcon0 = GfxBase->system_bplcon0;
custom.color[0] = 0xF00; /* Bildschirm rot */
printf("Running %s ... ", module);
RawPrintfFunc("%s: Running %s ...\r\n", ident+6, module);
InitExec( attnflags, /* D0 */
sysbplcon0, /* D1 */
vblankfreq, /* D2 */
0, /* D3 : Product-Code */
(LONG)module, /* D4 : MainPrg-Name */
chipbase, /* A0 : CHIP-Startadresse */
chipbase+chipsize, /* A1 : CHIP-Grösse */
fastbase, /* A2 : FAST-Startadresse */
fastbase+fastsize /* A3 : FAST-Endadresse */
);
ExitRoutine();
/* not reached */
}
else printf("Can't get %ldK CHIP RAM!\n",chipsize/1024);
return RETURN_WARN;
}
|