diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-07-29 15:01:50 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-07-29 15:01:50 +0000 |
commit | 20ec1696e0640c3e063f6ce869fe0cfa0c5c4587 (patch) | |
tree | 650b44e18f63a4b9c710be73cf52dad5109e14a1 /sys/arch/armish/stand/boot/dev_armish.c | |
parent | c11c824cade1312eaf5ad0179468c582be542193 (diff) |
ework armish bootloader into an interactive one, much like i386 has.
Make sure disk names match those used by the kernel. This means that now
it boots from wd0 by default, whatever slot it is in.
Diffstat (limited to 'sys/arch/armish/stand/boot/dev_armish.c')
-rw-r--r-- | sys/arch/armish/stand/boot/dev_armish.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/sys/arch/armish/stand/boot/dev_armish.c b/sys/arch/armish/stand/boot/dev_armish.c new file mode 100644 index 00000000000..40e0293f07a --- /dev/null +++ b/sys/arch/armish/stand/boot/dev_armish.c @@ -0,0 +1,115 @@ +/* $OpenBSD: dev_armish.c,v 1.1 2006/07/29 15:01:49 kettenis Exp $ */ + +/* + * Copyright (c) 2006 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <dev/cons.h> + +#include "libsa.h" + +const char cdevs[][4] = { + "cn", "", "", "", "", "", "", "", + "", "", "", "", "com" +}; +const int ncdevs = NENTS(cdevs); + +void +devboot(dev_t dev, char *p) +{ + strlcpy(p, "wd0a", 5); +} + +int +cnspeed(dev_t dev, int sp) +{ + return CONSPEED; +} + +int pch_pos; + +void +putchar(c) + int c; +{ + switch(c) { + case '\177': /* DEL erases */ + cnputc('\b'); + cnputc(' '); + case '\b': + cnputc('\b'); + if (pch_pos) + pch_pos--; + break; + case '\t': + do + cnputc(' '); + while(++pch_pos % 8); + break; + case '\n': + case '\r': + cnputc(c); + pch_pos=0; + break; + default: + cnputc(c); + pch_pos++; + break; + } +} + +int +getchar() +{ + int c = cngetc(); + + if (c == '\r') + c = '\n'; + + if ((c < ' ' && c != '\n') || c == '\177') + return(c); + + putchar(c); + + return(c); +} + +char ttyname_buf[8]; + +char * +ttyname(int fd) +{ + snprintf(ttyname_buf, sizeof ttyname_buf, "%s%d", + cdevs[major(cn_tab->cn_dev)], minor(cn_tab->cn_dev)); + + return ttyname_buf; +} + +dev_t +ttydev(char *name) +{ + int i, unit = -1; + char *no = name + strlen(name) - 1; + + while (no >= name && *no >= '0' && *no <= '9') + unit = (unit < 0 ? 0 : (unit * 10)) + *no-- - '0'; + if (no < name || unit < 0) + return NODEV; + for (i = 0; i < ncdevs; i++) + if (strncmp(name, cdevs[i], no - name + 1) == 0) + return (makedev(i, unit)); + return NODEV; +} |