use the -newos toolchain even if -elf is present.
[newos.git] / boot / m68k / stage2_nextmon.c
blob4ec725d9f48b1b5b8bd10ab6e56f26355fef4ec7
1 /*
2 ** Copyright 2002, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 #include "stage2_priv.h"
7 #define MG_simm 0
8 #define MG_flags 4
9 #define MG_sid 6
10 #define MG_pagesize 10
11 #define MG_mon_stack 14
12 #define MG_vbr 18
13 #define MG_nvram 22
14 #define MG_inetntoa 54
15 #define MG_inputline 72
16 #define MG_region 200
17 #define MG_alloc_base 232
18 #define MG_alloc_brk 236
19 #define MG_boot_dev 240
20 #define MG_boot_arg 244
21 #define MG_boot_info 248
22 #define MG_boot_file 252
23 #define MG_bootfile 256
24 #define MG_boot_how 320
25 #define MG_km 324
26 #define MG_km_flags 368
27 #define MG_mon_init 370
28 #define MG_si 374
29 #define MG_time 378
30 #define MG_sddp 382
31 #define MG_dgp 386
32 #define MG_s5cp 390
33 #define MG_odc 394
34 #define MG_odd 398
35 #define MG_radix 402
36 #define MG_dmachip 404
37 #define MG_diskchip 408
38 #define MG_intrstat 412
39 #define MG_intrmask 416
40 #define MG_nofault 420
41 #define MG_fmt 424
42 #define MG_addr 426
43 #define MG_na 458
44 #define MG_mx 462
45 #define MG_my 466
46 #define MG_cursor_save 470
47 #define MG_getc 726
48 #define MG_try_getc 730
49 #define MG_putc 734
50 #define MG_alert 738
51 #define MG_alert_confirm 742
52 #define MG_alloc 746
53 #define MG_boot_slider 750
54 #define MG_eventc 754
55 #define MG_event_high 758
56 #define MG_animate 762
57 #define MG_anim_time 766
58 #define MG_scsi_intr 770
59 #define MG_scsi_intrarg 774
60 #define MG_minor 778
61 #define MG_seq 780
62 #define MG_anim_run 782
63 #define MG_major 786
64 #define MG_con_slot 844
65 #define MG_con_fbnum 845
66 #define MG_con_map_vaddr0 860
67 #define MG_con_map_vaddr1 872
68 #define MG_con_map_vaddr2 884
69 #define MG_con_map_vaddr3 896
70 #define MG_con_map_vaddr4 908
71 #define MG_con_map_vaddr5 920
73 #define MG_clientetheraddr 788
74 #define MG_machine_type 936
75 #define MG_board_rev 937
77 #define N_SIMM 4 /* number of SIMMs in machine */
79 /* SIMM types */
80 #define SIMM_SIZE 0x03
81 #define SIMM_SIZE_EMPTY 0x00
82 #define SIMM_SIZE_16MB 0x01
83 #define SIMM_SIZE_4MB 0x02
84 #define SIMM_SIZE_1MB 0x03
85 #define SIMM_PAGE_MODE 0x04
86 #define SIMM_PARITY 0x08 /* ?? */
88 #define NEXT_RAMBASE 0x4000000
90 /* Machine types */
91 #define NeXT_CUBE 0
92 #define NeXT_WARP9 1
93 #define NeXT_X15 2
94 #define NeXT_WARP9C 3
95 #define NeXT_TURBO 4
96 #define NeXT_TURBO_COLOR 5
98 typedef int (*getcptr)(void);
99 typedef int (*putcptr)(int);
101 #define MON(type, off) (*(type *)((unsigned int) (mg) + off))
103 static char *mg = 0;
105 int init_nextmon(char *monitor)
107 mg = monitor;
109 return 0;
112 int probe_memory(kernel_args *ka)
114 int i, r;
115 char machine_type = MON(char,MG_machine_type);
116 int msize1, msize4, msize16;
118 /* depending on the machine, the bank layout is different */
119 dprintf("machine type: 0x%x\n", machine_type);
120 switch(machine_type) {
121 case NeXT_WARP9:
122 case NeXT_X15:
123 msize16 = 0x10000000;
124 msize4 = 0x400000;
125 msize1 = 0x100000;
126 break;
127 case NeXT_WARP9C:
128 msize16 = 0x800000;
129 msize4 = 0x200000;
130 msize1 = 0x80000;
131 break;
132 case NeXT_TURBO:
133 case NeXT_TURBO_COLOR:
134 msize16 = 0x2000000;
135 msize4 = 0x800000;
136 msize1 = 0x200000;
137 break;
138 default:
139 msize16 = 0x100000;
140 msize4 = 0x100000;
141 msize1 = 0x100000;
144 /* start probing ram */
145 dprintf("memory probe:\n");
146 ka->num_phys_mem_ranges = 0;
147 for(i=0; i<N_SIMM; i++) {
148 char probe = MON(char,MG_simm+i);
150 if((probe & SIMM_SIZE) != SIMM_SIZE_EMPTY) {
151 ka->phys_mem_range[ka->num_phys_mem_ranges].start = NEXT_RAMBASE + (msize16 * i);
153 switch(probe & SIMM_SIZE) {
154 case SIMM_SIZE_16MB:
155 ka->phys_mem_range[ka->num_phys_mem_ranges].size = msize16;
156 break;
157 case SIMM_SIZE_4MB:
158 ka->phys_mem_range[ka->num_phys_mem_ranges].size = msize4;
159 break;
160 case SIMM_SIZE_1MB:
161 ka->phys_mem_range[ka->num_phys_mem_ranges].size = msize1;
162 break;
164 dprintf("bank %i: start 0x%x, size 0x%x\n", i,
165 ka->phys_mem_range[ka->num_phys_mem_ranges].start, ka->phys_mem_range[ka->num_phys_mem_ranges].size);
166 ka->num_phys_mem_ranges++;
169 dprintf("alloc_base: 0x%x\n", MON(int, MG_alloc_base));
170 dprintf("alloc_brk: 0x%x\n", MON(int, MG_alloc_brk));
171 dprintf("mon_stack: 0x%x\n", MON(int, MG_mon_stack));
173 /* record allocated ram */
174 ka->num_phys_alloc_ranges = 1;
175 ka->phys_alloc_range[0].start = ROUNDOWN(MON(int, MG_alloc_base), PAGE_SIZE);
177 return 0;
180 void putc(int c)
182 MON(putcptr,MG_putc)(c);
185 int getc(void)
187 return(MON(getcptr,MG_getc)());