summaryrefslogtreecommitdiffstats
path: root/mmc/assemble.c
blob: 05bf769440c502d2899e940eaa29710f8c9982fd (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <strings.h>



char buf[204800];

int write_entry(int image,void *ptr)
{
off_t o=(image+1)*16;
lseek(1,o,SEEK_SET);
write(1,ptr,16);
}

int write_image(int image,void *ptr)
{
off_t o=(image*204800)+8192;
lseek(1,o,SEEK_SET);
write(1,ptr,204800);
}


int main(int argc,char *argv[])
{
int image=0;
int fd,i;
uint8_t entry[16];
char *ptr;


bzero(entry,sizeof(entry));
entry[0]=0;
entry[1]=1;
entry[2]=2;
entry[3]=3;
lseek(1,0L,SEEK_SET);
write(1,entry,16);


for (argc--,argv++; argc;argc--,argv++) 
{

bzero(buf,sizeof(buf));
fd=open(*argv,O_RDONLY);
read(fd,buf,sizeof(buf));
close(fd);

ptr=strstr(*argv,".ssd");
if (ptr) *ptr='\0';
ptr=strstr(*argv,".SSD");
if (ptr) *ptr='\0';

bzero(entry,sizeof(entry));
strncpy(entry,*argv,12);


entry[12]=0;
entry[13]=0;
entry[14]=0;
entry[15]=0x0f;

write_image(image,buf);
write_entry(image,entry);

image++;
}

bzero(buf,sizeof(buf));
for (;image<511;++image) {

bzero(entry,sizeof(entry));
entry[15]=0xf0;
write_image(image,buf);
}

}