Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/std Add another exception condition (XXX...I'm gonna...
details: https://anonhg.NetBSD.org/src/rev/a27cb0021f01
branches: trunk
changeset: 524916:a27cb0021f01
user: jmc <jmc%NetBSD.org@localhost>
date: Tue Apr 02 10:10:54 2002 +0000
description:
Add another exception condition (XXX...I'm gonna have to give in and just
put in support for the new p1212 spec that isn't a standard yet).
Also, minor cleanups and one off by one error when copying text descriptors.
diffstat:
sys/dev/std/ieee1212.c | 63 +++++++++++++++++++++++++---------------------
sys/dev/std/ieee1212reg.h | 3 +-
2 files changed, 36 insertions(+), 30 deletions(-)
diffs (200 lines):
diff -r aade7988e7cd -r a27cb0021f01 sys/dev/std/ieee1212.c
--- a/sys/dev/std/ieee1212.c Tue Apr 02 09:48:27 2002 +0000
+++ b/sys/dev/std/ieee1212.c Tue Apr 02 10:10:54 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee1212.c,v 1.1 2002/02/27 04:58:50 jmc Exp $ */
+/* $NetBSD: ieee1212.c,v 1.2 2002/04/02 10:10:54 jmc Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -168,8 +168,8 @@
len = newlen;
newlen = 0;
for (i = 0; i < len; i++) {
- type = P1212_DIRENT_GET_KEYTYPE((ntohl(t[offset + i])));
- val = P1212_DIRENT_GET_VALUE((ntohl(t[offset + i])));
+ type = P1212_DIRENT_GET_KEYTYPE((ntohl(t[offset+i])));
+ val = P1212_DIRENT_GET_VALUE((ntohl(t[offset+i])));
switch (type) {
case P1212_KEYTYPE_Immediate:
case P1212_KEYTYPE_Offset:
@@ -198,7 +198,8 @@
*/
test--;
- infolen = P1212_DIRENT_GET_LEN((ntohl(t[test])));
+ infolen =
+ P1212_DIRENT_GET_LEN((ntohl(t[test])));
test++;
test += infolen;
if ((test > *size) && (test > newlen)) {
@@ -217,12 +218,12 @@
}
/*
- * Can't just walk the ROM looking at type codes
- * since these are only valid on directory
- * entries. So save any directories
+ * Can't just walk the ROM looking at type
+ * codes since these are only valid on
+ * directory entries. So save any directories
* we find into a queue and the bottom of the
- * while loop will pop the last one off and walk
- * that directory.
+ * while loop will pop the last one off and
+ * walk that directory.
*/
test--;
@@ -318,7 +319,7 @@
if (rom->len) {
rom->data = malloc(sizeof(u_int32_t) * rom->len, M_DEVBUF,
M_WAITOK);
- /* Add 2 to account for info/crc and bus name we're skipping. */
+ /* Add 2 to account for info/crc and bus name skipped. */
for (i = 0; i < rom->len; i++)
rom->data[i] = t[i + 2];
}
@@ -332,7 +333,7 @@
* parse/print/match routines have a standard layout to work against.
*/
- rom->root = malloc(sizeof(struct p1212_dir), M_DEVBUF, M_WAITOK|M_ZERO);
+ rom->root = malloc(sizeof(*rom->root), M_DEVBUF, M_WAITOK|M_ZERO);
rom->root->com.key.key_type = P1212_KEYTYPE_Directory;
rom->root->com.key.key_value = 0;
rom->root->com.key.key = (u_int8_t)P1212_KEYTYPE_Directory;
@@ -410,7 +411,7 @@
* Sanity check for valid types/locations/etc.
*
* See pages 79-100 of
- * ISO/IEC 13213:1194 (ANSI/IEEE Std 1212, 1994 edition)
+ * ISO/IEC 13213:1194(ANSI/IEEE Std 1212, 1994 edition)
* for specifics.
*
* XXX: These all really should be broken out into
@@ -446,8 +447,8 @@
case P1212_KEYTYPE_Immediate:
if (p1212_validate_immed(val, mask)) {
DPRINTF(("Invalid ROM: Can't have an "
- "immediate type with %s value. Key "
- "used at location 0x%0x in ROM\n",
+ "immediate type with %s value. Key"
+ " used at location 0x%0x in ROM\n",
p1212_keyvalue_strings[val],
(unsigned int)(&t[i]-&addr[0])));
return 1;
@@ -476,8 +477,8 @@
case P1212_KEYTYPE_Directory:
if (p1212_validate_dir(val, mask)) {
DPRINTF(("Invalid ROM: Can't have a "
- "directory type with %s value. Key "
- "used at location 0x%0x in ROM\n",
+ "directory type with %s value. Key"
+ " used at location 0x%0x in ROM\n",
p1212_keyvalue_strings[val],
(unsigned int)(&t[i]-&addr[0])));
return 1;
@@ -514,8 +515,8 @@
if (val == P1212_KEYVALUE_Module_Sw_Version) {
if (node_sw_flag) {
- DPRINTF(("Can't have a module software "
- "version along with a node "
+ DPRINTF(("Can't have a module software"
+ " version along with a node "
"software version entry\n"));
return 1;
}
@@ -561,8 +562,9 @@
* preventing one from putting text descriptors after
* directory descriptors. Also they can be a single
* value or a list of them in a directory format so
- * account for either. Finally if they're in a directory
- * those can be the only types in a directory.
+ * account for either. Finally if they're in a
+ * directory those can be the only types in a
+ * directory.
*/
if (val == P1212_KEYVALUE_Textual_Descriptor) {
@@ -572,8 +574,8 @@
leafoff += i;
if (com == NULL) {
- DPRINTF(("Can't have a text descriptor "
- "as the first entry in a "
+ DPRINTF(("Can't have a text descriptor"
+ " as the first entry in a "
"directory\n"));
return 1;
}
@@ -591,9 +593,9 @@
com->text[0] =
p1212_parse_text_desc(&t[leafoff]);
if (com->text[0] == NULL) {
- DPRINTF(("Got an error parsing "
- "text descriptor at offset "
- "0x%0x\n",
+ DPRINTF(("Got an error parsing"
+ " text descriptor at "
+ "offset 0x%0x\n",
&t[leafoff]-&addr[0]));
free(com->text, M_DEVBUF);
return 1;
@@ -658,7 +660,7 @@
sdir->match = sdir->com.key.val + i;
TAILQ_INIT(&sdir->data_root);
TAILQ_INIT(&sdir->subdir_root);
- TAILQ_INSERT_TAIL(&dir->subdir_root, sdir, dir);
+ TAILQ_INSERT_TAIL(&dir->subdir_root, sdir,dir);
}
}
@@ -741,7 +743,7 @@
M_WAITOK);
leafdata->len = crclen;
for (i = 0; i < crclen; i++)
- leafdata->data[i] = t[i];
+ leafdata->data[i] = ntohl(t[i]);
return leafdata;
}
@@ -840,9 +842,9 @@
t++;
t++;
crclen -= 2;
- size = (crclen * sizeof(u_int32_t)) + 1;
+ size = (crclen * sizeof(u_int32_t));
- text->text = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO);
+ text->text = malloc(size + 1, M_DEVBUF, M_WAITOK|M_ZERO);
memcpy(text->text, &t[0], size);
@@ -1333,6 +1335,9 @@
case P1212_KEYVALUE_Unit_Dependent_Info:
break;
default:
+ if ((mask & P1212_ALLOW_VENDOR_DIRECTORY_TYPE) &&
+ (val == P1212_KEYVALUE_Module_Vendor_Id))
+ break;
return 1;
break;
}
diff -r aade7988e7cd -r a27cb0021f01 sys/dev/std/ieee1212reg.h
--- a/sys/dev/std/ieee1212reg.h Tue Apr 02 09:48:27 2002 +0000
+++ b/sys/dev/std/ieee1212reg.h Tue Apr 02 10:10:54 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee1212reg.h,v 1.6 2002/02/27 04:55:58 jmc Exp $ */
+/* $NetBSD: ieee1212reg.h,v 1.7 2002/04/02 10:10:54 jmc Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -251,5 +251,6 @@
/* Same thing applies for immediate types. */
#define P1212_ALLOW_DEPENDENT_INFO_IMMED_TYPE 0x2
+#define P1212_ALLOW_VENDOR_DIRECTORY_TYPE 0x4
#endif /* _DEV_STD_IEEE1212REG_H_ */
Home |
Main Index |
Thread Index |
Old Index