blob: c47d2ecc43ebd6051e0943cd9eb4f90865b919be (
plain)
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
|
/* $NetBSD: machdep.c,v 1.1.1.1 1995/07/25 23:12:22 chuck Exp $ */
#include <sys/param.h>
#include <sys/types.h>
#include <sys/exec.h>
#include <sys/reboot.h>
#include "config.h"
/*
* get_boothowto: boothowto for kernel
*/
static int get_boothowto(cmd_flags)
char *cmd_flags;
{
int result = 0;
if (cmd_flags == NULL) return(0);
while (*cmd_flags) {
switch (*cmd_flags) {
case 's': result |= RB_SINGLE; break;
case 'a': result |= RB_ASKNAME; break;
default: break;
}
cmd_flags++;
}
return(result);
}
/*
* cmd_parse: parse command line
* expected format: "b[oot] [kernel_name] [-flags]"
*/
char *cmd_parse(cmd_buf, howto)
char *cmd_buf;
int *howto;
{
char *cmd_kernel, *cmd_flags;
u_char *cp;
*howto = 0;
cp = cmd_buf+1; /* skip 'b' */
while (*cp && *cp != ' ') cp++; /* skip to end or space */
while (*cp == ' ') cp++; /* skip spaces */
if (*cp == '\0') return(NULL); /* no args */
if (*cp == '-') { /* only flags? */
*howto = get_boothowto(cp);
return(NULL);
}
cmd_kernel = cp; /* got kernel name */
while (*cp && *cp != ' ') cp++; /* skip to end or space */
if (*cp == ' ') *cp++ = 0; /* null terminate kernel */
while (*cp == ' ') cp++; /* skip spaces */
if (*cp == '\0') return(cmd_kernel); /* no flags */
if (*cp != '-') return(cmd_kernel); /* garbage flags */
cmd_flags = cp; /* save flags */
while (*cp && *cp != ' ') cp++; /* skip to end or space */
if (*cp == ' ') *cp++ = 0; /* null terminate flags */
*howto = get_boothowto(cmd_flags);
return(cmd_kernel);
}
/*
* machdep_common_ether: get ethernet address
*/
void machdep_common_ether(ether)
unsigned char *ether;
{
caddr_t addr;
int *ea = (int *) ETHER_ADDR;
int e = *ea;
if (( e & 0x2fffff00 ) == 0x2fffff00)
panic("ERROR: ethernet address not set!\r\n");
ether[0] = 0x08;
ether[1] = 0x00;
ether[2] = 0x3e;
e = e >> 8;
ether[5] = e & 0xff;
e = e >> 8;
ether[4] = e & 0xff;
e = e >> 8;
ether[3] = e;
}
/*
* console i/o
*/
/*
* hardware
*/
struct zs_hw {
volatile u_char ctl;
volatile u_char data;
};
struct zs_hw *zs = (struct zs_hw *)CONS_ZS_ADDR;
/*
* putchar: put char to console
*/
void putchar(char c)
{
if (c == '\n') putchar('\r');
zs->ctl = 0;
while ((zs->ctl & 0x04) == 0) {
zs->ctl = 0;
}
zs->ctl = 8;
zs->ctl = c;
}
/*
* getchar: get char from console
*/
int
getchar()
{
int i;
while (1) {
zs->ctl = 0;
if ((zs->ctl & 0x1) != 0) break;
for (i = 100 ; i > 0 ; i--)
;
}
zs->ctl = 8;
return(zs->ctl);
}
/*
* peekchar
*/
peekchar()
{
zs->ctl = 0;
return(zs->ctl & 0x1);
}
|