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
|
/* $OpenBSD: dev_socppc.c,v 1.4 2014/07/13 09:26:08 jasper Exp $ */
/*
* Copyright (c) 2008 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 = nitems(cdevs);
void
devboot(dev_t dev, char *p)
{
strlcpy(p, "wd0a", 5);
}
int
cnspeed(dev_t dev, int sp)
{
return CONSPEED;
}
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;
}
|