Deleted Added
full compact
fwcrom.c (120660) fwcrom.c (127468)
1/*-
2 * Copyright (c) 2002-2003
3 * Hidetoshi Shimokawa. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
1/*-
2 * Copyright (c) 2002-2003
3 * Hidetoshi Shimokawa. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#ifdef __FreeBSD__
35#include <sys/cdefs.h>
36#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/dev/firewire/fwcrom.c 120660 2003-10-02 04:06:56Z simokawa $");
37__FBSDID("$FreeBSD: head/sys/dev/firewire/fwcrom.c 127468 2004-03-26 23:17:10Z simokawa $");
38#endif
37
38#include <sys/param.h>
39#if defined(_KERNEL) || defined(TEST)
40#include <sys/queue.h>
41#endif
42#ifdef _KERNEL
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#else
46#include <netinet/in.h>
47#include <fcntl.h>
48#include <stdio.h>
49#include <err.h>
50#include <stdlib.h>
51#include <string.h>
52#endif
39
40#include <sys/param.h>
41#if defined(_KERNEL) || defined(TEST)
42#include <sys/queue.h>
43#endif
44#ifdef _KERNEL
45#include <sys/systm.h>
46#include <sys/kernel.h>
47#else
48#include <netinet/in.h>
49#include <fcntl.h>
50#include <stdio.h>
51#include <err.h>
52#include <stdlib.h>
53#include <string.h>
54#endif
55
56#ifdef __DragonFly__
57#include "firewire.h"
58#include "iec13213.h"
59#else
53#include <dev/firewire/firewire.h>
54#include <dev/firewire/iec13213.h>
60#include <dev/firewire/firewire.h>
61#include <dev/firewire/iec13213.h>
62#endif
55
56#define MAX_ROM (1024 - sizeof(u_int32_t) * 5)
57#define CROM_END(cc) ((vm_offset_t)(cc)->stack[0].dir + MAX_ROM - 1)
58
59void
60crom_init_context(struct crom_context *cc, u_int32_t *p)
61{
62 struct csrhdr *hdr;
63
64 hdr = (struct csrhdr *)p;
63
64#define MAX_ROM (1024 - sizeof(u_int32_t) * 5)
65#define CROM_END(cc) ((vm_offset_t)(cc)->stack[0].dir + MAX_ROM - 1)
66
67void
68crom_init_context(struct crom_context *cc, u_int32_t *p)
69{
70 struct csrhdr *hdr;
71
72 hdr = (struct csrhdr *)p;
65 if (hdr->info_len == 1) {
66 /* minimum ROM */
73 if (hdr->info_len <= 1) {
74 /* minimum or invalid ROM */
67 cc->depth = -1;
75 cc->depth = -1;
76 return;
68 }
69 p += 1 + hdr->info_len;
70
71 /* check size of root directory */
72 if (((struct csrdirectory *)p)->crc_len == 0) {
73 cc->depth = -1;
74 return;
75 }

--- 355 unchanged lines hidden (view full) ---

431{
432 struct csrtext *tl;
433 u_int32_t *p;
434 int len, i;
435 char t[MAX_TEXT];
436
437 len = strlen(buf);
438 if (len > MAX_TEXT) {
77 }
78 p += 1 + hdr->info_len;
79
80 /* check size of root directory */
81 if (((struct csrdirectory *)p)->crc_len == 0) {
82 cc->depth = -1;
83 return;
84 }

--- 355 unchanged lines hidden (view full) ---

440{
441 struct csrtext *tl;
442 u_int32_t *p;
443 int len, i;
444 char t[MAX_TEXT];
445
446 len = strlen(buf);
447 if (len > MAX_TEXT) {
439#if __FreeBSD_version < 500000
448#if defined(__DragonFly__) || __FreeBSD_version < 500000
440 printf("text(%d) trancated to %d.\n", len, MAX_TEXT);
441#else
442 printf("text(%d) trancated to %td.\n", len, MAX_TEXT);
443#endif
444 len = MAX_TEXT;
445 }
446
447 tl = (struct csrtext *) &chunk->data;

--- 121 unchanged lines hidden (view full) ---

569 STAILQ_INIT(&src.chunk_list);
570
571 /* Root directory */
572 crom_add_chunk(&src, NULL, &root, 0);
573 crom_add_entry(&root, CSRKEY_NCAP, 0x123456);
574 /* private company_id */
575 crom_add_entry(&root, CSRKEY_VENDOR, 0xacde48);
576
449 printf("text(%d) trancated to %d.\n", len, MAX_TEXT);
450#else
451 printf("text(%d) trancated to %td.\n", len, MAX_TEXT);
452#endif
453 len = MAX_TEXT;
454 }
455
456 tl = (struct csrtext *) &chunk->data;

--- 121 unchanged lines hidden (view full) ---

578 STAILQ_INIT(&src.chunk_list);
579
580 /* Root directory */
581 crom_add_chunk(&src, NULL, &root, 0);
582 crom_add_entry(&root, CSRKEY_NCAP, 0x123456);
583 /* private company_id */
584 crom_add_entry(&root, CSRKEY_VENDOR, 0xacde48);
585
586#ifdef __DragonFly__
587 crom_add_simple_text(&src, &root, &text1, "DragonFly");
588 crom_add_entry(&root, CSRKEY_HW, __DragonFly_cc_version);
589 crom_add_simple_text(&src, &root, &text2, "DragonFly-1");
590#else
577 crom_add_simple_text(&src, &root, &text1, "FreeBSD");
578 crom_add_entry(&root, CSRKEY_HW, __FreeBSD_version);
579 crom_add_simple_text(&src, &root, &text2, "FreeBSD-5");
591 crom_add_simple_text(&src, &root, &text1, "FreeBSD");
592 crom_add_entry(&root, CSRKEY_HW, __FreeBSD_version);
593 crom_add_simple_text(&src, &root, &text2, "FreeBSD-5");
594#endif
580
581 /* SBP unit directory */
582 crom_add_chunk(&src, &root, &unit1, CROM_UDIR);
583 crom_add_entry(&unit1, CSRKEY_SPEC, CSRVAL_ANSIT10);
584 crom_add_entry(&unit1, CSRKEY_VER, CSRVAL_T10SBP2);
585 crom_add_entry(&unit1, CSRKEY_COM_SPEC, CSRVAL_ANSIT10);
586 crom_add_entry(&unit1, CSRKEY_COM_SET, CSRVAL_SCSI);
587 /* management_agent */

--- 32 unchanged lines hidden ---
595
596 /* SBP unit directory */
597 crom_add_chunk(&src, &root, &unit1, CROM_UDIR);
598 crom_add_entry(&unit1, CSRKEY_SPEC, CSRVAL_ANSIT10);
599 crom_add_entry(&unit1, CSRKEY_VER, CSRVAL_T10SBP2);
600 crom_add_entry(&unit1, CSRKEY_COM_SPEC, CSRVAL_ANSIT10);
601 crom_add_entry(&unit1, CSRKEY_COM_SET, CSRVAL_SCSI);
602 /* management_agent */

--- 32 unchanged lines hidden ---