]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/hal/sh/cq7708/v2_0/misc/mkcqrom.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / hal / sh / cq7708 / v2_0 / misc / mkcqrom.c
1 /* Split ROM data Program for CqREEK SH-3 (Thanks Yamanaka-san) */
2 /* Nihon Cygnus Solutions  KASHIWAYA Haruki  '00-4-13 */
3
4 /* This program separate ROM data for one ROM socket.
5    The cq board has two ROM sockets, and those bus size can
6    switch to 8bit or 16bit with JP6.
7    If your program is smaller than 32kByte, you can use
8    a 256k bit ROM with 8bit bus mode.
9    However, the board curcuit connection is peculiar.
10    A0 is connected to A14 in 8bit bus mode (See the curcuit diagram),
11    this mean's all odd data are assigned from 0x4000 offset.
12    You must use this program and separate ROM data when you use
13    a 256k bit ROM with 8bit bus mode.
14
15    If your program is bigger than 32kByte, simply, you can use
16    two 256k bit(or bigger) ROM with 16bit bus mode.
17    You do *not* need to use this program.
18    (Details, separate ROM data to odd and even, and write each data to
19    each ROMs, and attach odd's ROM to IC4, even's ROM to IC8.)
20
21 */
22
23 #include <stdio.h>
24 #include <errno.h>
25
26 #define ROMSIZE (32 * 1024)
27
28 main(int argc, char **argv)
29 {
30         FILE *fpr, *fpw;
31         int i, c;
32         char *s, *p;
33
34         if(argc != 3) {
35                 printf("Usage: mkcqrom <input-filename> <output-filename>\n Please see comments in mkcqrom.c.\n");
36                 exit(1);
37         }
38
39         p = (char *)malloc(ROMSIZE);
40         if(p == NULL) {
41                 printf("malloc error\n");
42                 exit(1);
43         }
44         fpr = fopen(*++argv, "rb");
45         if(fpr == NULL) {
46                 printf("open error %s %d\n", *argv, errno);
47                 exit(1);
48         }
49         memset(p, 0xff, ROMSIZE);
50
51     /* split even data to 0x4000 offset (A0 is assigned to A14) */
52         i = 0;
53         while(1) {
54                 c = getc(fpr);
55                 if(c == EOF) break;
56                 s = p + (i / 2) + (i % 2) * 0x4000;
57                 *s = (char)c;
58                 i++;
59         }
60         fclose(fpr);
61
62         fpw = fopen(*++argv, "wb");
63         if(fpw == NULL) {
64                 printf("open error %s %d\n", *argv, errno);
65                 exit(1);
66         }
67         fwrite(p, ROMSIZE, sizeof(char), fpw);
68         fclose(fpw);
69 }
70 \1a