18 #define ROMSTART 0xC8000
19 #define ROMEND 0xE8000
20 #define ROMINCREMENT 0x00800
21 #define ROMMASK 0x03FFF
24 #define MAP_FAILED ((void *)(long long)-1)
27 typedef struct Images
{
33 static void rom_scan(const unsigned char HUGE
*rom
,long offset
,long len
)
35 static Images
*images
= NULL
;
37 /* The assignments to dummy are to overcome a bug in TurboC */
42 if (rom
[offset
] != 0x55 || rom
[dummy
= offset
+1] != 0xAA)
44 size
= (long)rom
[dummy
= offset
+2]*512L;
45 printf("Found ROM header at %04lX:0000; "
46 "announces %ldk image (27C%02d EPROM)\n",
47 offset
/16,(size
+512)/1024,
54 size
<= 65536 ? 512 : 11);
56 printf(" This is a unusual position; not all BIOSs might find it.\n"
57 " Try to move to a 16kB boundary.\n");
59 printf(" This image extends beyond %04X:0000. "
60 "It clashes with the system BIOS\n",
63 for (chksum
=0, i
= size
; i
--; chksum
+= rom
[dummy
= offset
+i
]);
65 printf(" Checksum does not match. This image is not active\n");
66 ptr
= malloc(sizeof(Images
));
71 for (ptr
= ptr
->next
; ptr
!= NULL
; ptr
= ptr
->next
) {
72 for (i
= 0; i
< size
&& i
< ptr
->size
; i
++)
73 if (rom
[dummy
= ptr
->start
+i
] != rom
[dummy
= offset
+i
])
76 printf(" Image is identical with image at %04lX:0000 "
77 "for the first %ld bytes\n",
81 printf(" this means that you misconfigured the EPROM size!\n");
83 printf(" this could suggest that you misconfigured the "
86 printf(" this is probably harmless. Just ignore it...\n"); } }
93 unsigned char HUGE
*rom
;
97 if ((fh
= open("/dev/kmem",O_RDONLY
|O_SYNC
)) < 0) {
98 fprintf(stderr
,"Could not open \"/dev/kmem\": %s\n",0 );//strerror(errno));
100 if ((rom
= mmap(NULL
,ROMEND
-ROMSTART
,PROT_READ
,MAP_SHARED
,fh
,
101 ROMSTART
)) == MAP_FAILED
) {
102 fprintf(stderr
,"Could not mmap \"/dev/kmem\": %s\n",0); //strerror(errno));
107 for (i
= ROMEND
; (i
-= ROMINCREMENT
) >= ROMSTART
; )
109 rom_scan(0,i
,ROMEND
-i
);
111 rom_scan(rom
-ROMSTART
,i
,ROMEND
-i
);
112 munmap(rom
,ROMEND
-ROMSTART
);