Sat Oct 17 11:18:18 2009 UTC ()
Add a serial console mode for the bootblock. In this mode all console
output will be echoed to the serial port and input will be accepted
from either keyboard or serial port. The bootblock serial console is
limited to 9600bps 8N1 as it uses the AmigaOS kernel debug routines.

To enable this you have to uncomment the SERCONSOLE define in
boot/Makefile.

Also note that the handling of a serial console in the kernel is
independent of this, you need to a build a kernel with 'options
SERCONSOLE'.


(mlelstv)
diff -r1.39 -r1.40 src/sys/arch/amiga/stand/bootblock/boot/Makefile
diff -r1.12 -r1.13 src/sys/arch/amiga/stand/bootblock/boot/console.c
diff -r1.6 -r1.7 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
diff -r1.9 -r1.10 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s

cvs diff -r1.39 -r1.40 src/sys/arch/amiga/stand/bootblock/boot/Makefile (expand / switch to unified diff)

--- src/sys/arch/amiga/stand/bootblock/boot/Makefile 2009/01/12 07:42:30 1.39
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile 2009/10/17 11:18:17 1.40
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.39 2009/01/12 07:42:30 tsutsui Exp $ 1# $NetBSD: Makefile,v 1.40 2009/10/17 11:18:17 mlelstv Exp $
2 2
3.include <bsd.sys.mk> # for HOST_SH 3.include <bsd.sys.mk> # for HOST_SH
4 4
5### what we need: 5### what we need:
6 6
7#XX# lines replace similar lines, or are added, in case we want to 7#XX# lines replace similar lines, or are added, in case we want to
8#XX# compile LIBZ ourselves to save a few bytes (think TXLT) 8#XX# compile LIBZ ourselves to save a few bytes (think TXLT)
9 9
10#XX#DIR_LIBZ = ${DIR_TOP}/../common/dist/zlib 10#XX#DIR_LIBZ = ${DIR_TOP}/../common/dist/zlib
11 11
12DIR_TOP= ${.CURDIR}/../../../../.. 12DIR_TOP= ${.CURDIR}/../../../../..
13DIR_SA = ${DIR_TOP}/lib/libsa 13DIR_SA = ${DIR_TOP}/lib/libsa
14DIR_LIBZ= 14DIR_LIBZ=
@@ -41,26 +41,27 @@ COBJS = main.o console.o xd.o twiddle.o  @@ -41,26 +41,27 @@ COBJS = main.o console.o xd.o twiddle.o
41COBJS+= lseek.o open.o read.o close.o dev.o errno.o 41COBJS+= lseek.o open.o read.o close.o dev.o errno.o
42COBJS+= ufs.o ustarfs.o panic.o vers.o files.o 42COBJS+= ufs.o ustarfs.o panic.o vers.o files.o
43COBJS+= divdi3.o moddi3.o qdivrem.o 43COBJS+= divdi3.o moddi3.o qdivrem.o
44 44
45SOBJS = alloc.o ashrdi3.o ashldi3.o bcopy.o muldi3.o printf.o startit.o 45SOBJS = alloc.o ashrdi3.o ashldi3.o bcopy.o muldi3.o printf.o startit.o
46SOBJS += strlen.o memcmp.o memset.o strerror.o strncmp.o 46SOBJS += strlen.o memcmp.o memset.o strerror.o strncmp.o
47SOBJS += libstubs.o 47SOBJS += libstubs.o
48 48
49OBJS= $(SOBJS) $(COBJS) 49OBJS= $(SOBJS) $(COBJS)
50 50
51#XX#DEFS = -D_STANDALONE -DINSECURE -DDYNAMIC_CRC_TABLE -DNOBYFOUR -UBYFOUR  51#XX#DEFS = -D_STANDALONE -DINSECURE -DDYNAMIC_CRC_TABLE -DNOBYFOUR -UBYFOUR
52DEFS = -D_STANDALONE -DINSECURE  52DEFS = -D_STANDALONE -DINSECURE
53DEFS += -D__INTERNAL_LIBSA_CREAD 53DEFS += -D__INTERNAL_LIBSA_CREAD
 54#DEFS += -DSERCONSOLE
54SOBJS += cread.o 55SOBJS += cread.o
55 56
56#XX#SOBJS += adler32.o crc32.o inflate.o trees.o \ 57#XX#SOBJS += adler32.o crc32.o inflate.o trees.o \
57#XX# zutil.o infback.o inftrees.o inffast.o 58#XX# zutil.o infback.o inftrees.o inffast.o
58 59
59#DEFS += -DBOOT_ELF32 -DBOOT_AOUT 60#DEFS += -DBOOT_ELF32 -DBOOT_AOUT
60SOBJS += loadfile.o loadfile_aout.o loadfile_elf32.o 61SOBJS += loadfile.o loadfile_aout.o loadfile_elf32.o
61 62
62NETBSD_VERS!= ${HOST_SH} ${.CURDIR}/../../../../../conf/osrelease.sh 63NETBSD_VERS!= ${HOST_SH} ${.CURDIR}/../../../../../conf/osrelease.sh
63DEFS+= -DNETBSD_VERS='"${NETBSD_VERS}"' 64DEFS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
64 65
65### main target: ### 66### main target: ###
66 67

cvs diff -r1.12 -r1.13 src/sys/arch/amiga/stand/bootblock/boot/console.c (expand / switch to unified diff)

--- src/sys/arch/amiga/stand/bootblock/boot/console.c 2009/10/11 10:00:10 1.12
+++ src/sys/arch/amiga/stand/bootblock/boot/console.c 2009/10/17 11:18:18 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: console.c,v 1.12 2009/10/11 10:00:10 mlelstv Exp $ */ 1/* $NetBSD: console.c,v 1.13 2009/10/17 11:18:18 mlelstv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis. 8 * by Ignatios Souvatzis.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -105,26 +105,30 @@ consinit(void *consptr) { @@ -105,26 +105,30 @@ consinit(void *consptr) {
105 goto err; 105 goto err;
106 106
107 mc->cnior->buf = (void *)mc->w; 107 mc->cnior->buf = (void *)mc->w;
108 if (OpenDevice("console.device", 0, mc->cnior, 0)) 108 if (OpenDevice("console.device", 0, mc->cnior, 0))
109 goto err; 109 goto err;
110 110
111 mc->tmior = (struct TimerIO *)CreateIORequest(mc->cnmp, sizeof(struct TimerIO)); 111 mc->tmior = (struct TimerIO *)CreateIORequest(mc->cnmp, sizeof(struct TimerIO));
112 if (!mc->tmior) 112 if (!mc->tmior)
113 goto err; 113 goto err;
114 114
115 if (OpenDevice("timer.device", 0, (struct AmigaIO*)mc->tmior, 0)) 115 if (OpenDevice("timer.device", 0, (struct AmigaIO*)mc->tmior, 0))
116 goto err; 116 goto err;
117 117
 118#ifdef SERCONSOLE
 119 RawIOInit();
 120#endif
 121
118 ConsoleBase = mc; 122 ConsoleBase = mc;
119 return 0; 123 return 0;
120 124
121err: 125err:
122#ifdef notyet 126#ifdef notyet
123 if (mc->tmior) 127 if (mc->tmior)
124 DeleteIORequest(mc->tmior); 128 DeleteIORequest(mc->tmior);
125 129
126 if (mc->cnior) 130 if (mc->cnior)
127 DeleteIORequest(mc->cnior); 131 DeleteIORequest(mc->cnior);
128 132
129 if (mc->cnmp) 133 if (mc->cnmp)
130 DeleteMsgPort(mc->cnmp); 134 DeleteMsgPort(mc->cnmp);
@@ -173,59 +177,89 @@ consclose(void) @@ -173,59 +177,89 @@ consclose(void)
173 return 0; 177 return 0;
174} 178}
175#endif 179#endif
176 180
177void 181void
178putchar(int c) 182putchar(int c)
179{ 183{
180 struct Console *mc = ConsoleBase; 184 struct Console *mc = ConsoleBase;
181 char buf = c; 185 char buf = c;
182 186
183 mc->cnior->length = 1; 187 mc->cnior->length = 1;
184 mc->cnior->buf = &buf; 188 mc->cnior->buf = &buf;
185 mc->cnior->cmd = Cmd_Wr; 189 mc->cnior->cmd = Cmd_Wr;
 190
 191#ifdef SERCONSOLE
 192 RawPutChar((int32_t)c);
 193#endif
 194
186 (void)DoIO(mc->cnior); 195 (void)DoIO(mc->cnior);
187} 196}
188 197
189void 198void
190puts(char *s) 199puts(char *s)
191{ 200{
192 struct Console *mc = ConsoleBase; 201 struct Console *mc = ConsoleBase;
193 202
194 mc->cnior->length = -1; 203 mc->cnior->length = -1;
195 mc->cnior->buf = s; 204 mc->cnior->buf = s;
196 mc->cnior->cmd = Cmd_Wr; 205 mc->cnior->cmd = Cmd_Wr;
 206
 207#ifdef SERCONSOLE
 208 while (*s)
 209 RawPutChar(*s++);
 210#endif
 211
197 (void)DoIO(mc->cnior); 212 (void)DoIO(mc->cnior);
198} 213}
199 214
200int 215int
201getchar(void) 216getchar(void)
202{ 217{
203 struct AmigaIO *ior; 218 struct AmigaIO *ior;
204 char c = -1; 219 char c = '\n';
205 struct Console *mc = ConsoleBase; 220 struct Console *mc = ConsoleBase;
 221 unsigned long ticks;
 222#ifdef SERCONSOLE
 223 int32_t r;
 224#endif
206 225
207 mc->cnior->length = 1; 226 mc->cnior->length = 1;
208 mc->cnior->buf = &c; 227 mc->cnior->buf = &c;
209 mc->cnior->cmd = Cmd_Rd; 228 mc->cnior->cmd = Cmd_Rd;
210 229
211 SendIO(mc->cnior); 230 SendIO(mc->cnior);
212 231
213 if (timelimit) { 232 ticks = 10 * timelimit;
 233 do {
 234 if (timelimit == 0)
 235 ticks = 2;
 236
214 mc->tmior->cmd = Cmd_Addtimereq; 237 mc->tmior->cmd = Cmd_Addtimereq;
215 mc->tmior->secs = timelimit; 238 mc->tmior->secs = 0;
216 mc->tmior->usec = 2; /* Paranoid */ 239 mc->tmior->usec = 100000;
217 SendIO((struct AmigaIO *)mc->tmior); 240 SendIO((struct AmigaIO *)mc->tmior);
218 241
219 ior = WaitPort(mc->cnmp); 242 ior = WaitPort(mc->cnmp);
220 if (ior == mc->cnior) 243 if (ior == mc->cnior) {
221 AbortIO((struct AmigaIO *)mc->tmior); 244 AbortIO((struct AmigaIO *)mc->tmior);
222 else /* if (ior == mc->tmior) */ { 245 ticks = 1;
223 AbortIO(mc->cnior); 246 } else /* if (ior == mc->tmior) */ {
224 c = '\n'; 247#ifdef SERCONSOLE
 248 r = RawMayGetChar();
 249 if (r != -1) {
 250 c = r;
 251 ticks = 1;
 252 }
 253#endif
 254 if (ticks == 1)
 255 AbortIO((struct AmigaIO *)mc->cnior);
225 } 256 }
226 WaitIO((struct AmigaIO *)mc->tmior); 257 WaitIO((struct AmigaIO *)mc->tmior);
227 timelimit = 0; 258
228 } 259 --ticks;
 260 } while (ticks != 0);
 261 timelimit = 0;
 262
229 (void)WaitIO(mc->cnior); 263 (void)WaitIO(mc->cnior);
230 return c; 264 return c;
231} 265}

cvs diff -r1.6 -r1.7 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h (expand / switch to unified diff)

--- src/sys/arch/amiga/stand/bootblock/boot/libstubs.h 2008/04/28 20:23:13 1.6
+++ src/sys/arch/amiga/stand/bootblock/boot/libstubs.h 2009/10/17 11:18:18 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: libstubs.h,v 1.6 2008/04/28 20:23:13 martin Exp $ */ 1/* $NetBSD: libstubs.h,v 1.7 2009/10/17 11:18:18 mlelstv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis. 8 * by Ignatios Souvatzis.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -45,26 +45,30 @@ struct Library *OpenLibrary (const char  @@ -45,26 +45,30 @@ struct Library *OpenLibrary (const char
45void CloseLibrary (struct Library *); 45void CloseLibrary (struct Library *);
46struct MsgPort *CreateMsgPort(void); 46struct MsgPort *CreateMsgPort(void);
47void *CreateIORequest(struct MsgPort *, u_int32_t); 47void *CreateIORequest(struct MsgPort *, u_int32_t);
48void DeleteIORequest(void *); 48void DeleteIORequest(void *);
49void DeleteMsgPort(struct MsgPort *); 49void DeleteMsgPort(struct MsgPort *);
50 50
51u_int8_t DoIO(struct AmigaIO *); 51u_int8_t DoIO(struct AmigaIO *);
52void SendIO(struct AmigaIO *); 52void SendIO(struct AmigaIO *);
53struct AmigaIO *CheckIO(struct AmigaIO *); 53struct AmigaIO *CheckIO(struct AmigaIO *);
54void *WaitPort(struct MsgPort *); 54void *WaitPort(struct MsgPort *);
55void AbortIO(struct AmigaIO *); 55void AbortIO(struct AmigaIO *);
56u_int8_t WaitIO(struct AmigaIO *); 56u_int8_t WaitIO(struct AmigaIO *);
57 57
 58void RawIOInit(void);
 59int32_t RawPutChar(int32_t c);
 60int32_t RawMayGetChar(void);
 61
58int OpenDevice(const char *, u_int32_t, struct AmigaIO *, u_int32_t); 62int OpenDevice(const char *, u_int32_t, struct AmigaIO *, u_int32_t);
59#ifdef _PRIMARY_BOOT 63#ifdef _PRIMARY_BOOT
60void CloseDevice(struct AmigaIO *); 64void CloseDevice(struct AmigaIO *);
61#endif 65#endif
62 66
63void *FindResident(const char *); 67void *FindResident(const char *);
64void *OpenResource(const char *); 68void *OpenResource(const char *);
65 69
66u_int32_t CachePreDMA(u_int32_t, u_int32_t *, int); 70u_int32_t CachePreDMA(u_int32_t, u_int32_t *, int);
67#define DMAF_Continue 2 71#define DMAF_Continue 2
68#define DMAF_NoModify 4 72#define DMAF_NoModify 4
69#define DMAF_ReadFromRAM 8 73#define DMAF_ReadFromRAM 8
70 74

cvs diff -r1.9 -r1.10 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s (expand / switch to unified diff)

--- src/sys/arch/amiga/stand/bootblock/boot/libstubs.s 2008/04/28 20:23:13 1.9
+++ src/sys/arch/amiga/stand/bootblock/boot/libstubs.s 2009/10/17 11:18:18 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: libstubs.s,v 1.9 2008/04/28 20:23:13 martin Exp $ */ 1/* $NetBSD: libstubs.s,v 1.10 2009/10/17 11:18:18 mlelstv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis. 8 * by Ignatios Souvatzis.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -151,26 +151,46 @@ ENTRY_NOPROFILE(AbortIO) @@ -151,26 +151,46 @@ ENTRY_NOPROFILE(AbortIO)
151 jsr %a6@(-0x1e0) 151 jsr %a6@(-0x1e0)
152 movl %sp@+,%a6 152 movl %sp@+,%a6
153 rts 153 rts
154 154
155ENTRY_NOPROFILE(WaitPort) 155ENTRY_NOPROFILE(WaitPort)
156 movl %a6,%sp@- 156 movl %a6,%sp@-
157 movl %pc@(_C_LABEL(SysBase):w),%a6 157 movl %pc@(_C_LABEL(SysBase):w),%a6
158 movl %sp@(8),%a0 158 movl %sp@(8),%a0
159 jsr %a6@(-0x180) 159 jsr %a6@(-0x180)
160 movl %sp@+,%a6 160 movl %sp@+,%a6
161 movl %d0,%a0 | Comply with ELF ABI 161 movl %d0,%a0 | Comply with ELF ABI
162 rts 162 rts
163 163
 164ENTRY_NOPROFILE(RawIOInit)
 165 movl %a6,%sp@-
 166 movl %pc@(_C_LABEL(SysBase):w),%a6
 167 jsr %a6@(-0x1f8)
 168 movl %sp@+,%a6
 169 rts
 170ENTRY_NOPROFILE(RawPutChar)
 171 movl %a6,%sp@-
 172 movl %pc@(_C_LABEL(SysBase):w),%a6
 173 movl %sp@(8),%d0
 174 jsr %a6@(-0x204)
 175 movl %sp@+,%a6
 176 rts
 177ENTRY_NOPROFILE(RawMayGetChar)
 178 movl %a6,%sp@-
 179 movl %pc@(_C_LABEL(SysBase):w),%a6
 180 jsr %a6@(-0x1fe)
 181 movl %sp@+,%a6
 182 rts
 183
164#ifndef DOINLINES 184#ifndef DOINLINES
165ENTRY_NOPROFILE(CacheClearU) 185ENTRY_NOPROFILE(CacheClearU)
166 movl %a6,%sp@- 186 movl %a6,%sp@-
167 movl %pc@(_C_LABEL(SysBase):w),%a6 187 movl %pc@(_C_LABEL(SysBase):w),%a6
168 jsr %a6@(-0x27c) 188 jsr %a6@(-0x27c)
169 movl %sp@+,%a6 189 movl %sp@+,%a6
170 rts 190 rts
171#endif 191#endif
172ENTRY_NOPROFILE(CachePreDMA) 192ENTRY_NOPROFILE(CachePreDMA)
173 movl %a6,%sp@- 193 movl %a6,%sp@-
174 movl %pc@(_C_LABEL(SysBase):w),%a6 194 movl %pc@(_C_LABEL(SysBase):w),%a6
175 movl %sp@(8),%a0 195 movl %sp@(8),%a0
176 movl %sp@(12),%a1 196 movl %sp@(12),%a1