- UID
- 133947
- 性别
- 男
|
/*
* Returns amount of memory which needs to be reserved.
*/
long ed_init(long mem_start, int mem_end)
{
int i,
ep;
short tshort,
version,
length,
s_ofs;
if (register_blkdev(EPROM_MAJOR,"ed",&ed_fops)) {
printk("EPROMDISK: Unable to get major %d.\n", EPROM_MAJOR);
return 0;
}
blk_dev[EPROM_MAJOR].request_fn = DEVICE_REQUEST;
for(i=0;i< 4) {
printk("EPROMDISK: Length (%d) Too short.\n", length);
return 0;
}
ed_length = length * 512;
sector_map = ep + 6;
sector_offset = ep + s_ofs;
printk("EPROMDISK: Version %d installed, %d bytes\n", (int)version, ed_length);
return 0;
}
int get_edisk(unsigned char *buf, int sect, int num_sect)
{
short ss, /* Sector start */
tshort;
int s; /* Sector offset */
for(s=0;s0;) {
sock = bp / EPROM_SIZE;
page = (bp % EPROM_SIZE) / EPAGE_SIZE;
offset = bp % EPAGE_SIZE;
nb = (len+offset)>EPAGE_SIZE?EPAGE_SIZE-(offset%EPAGE_SIZE):len;
cr1 = socket[sock] | ((page << 4) & 0x30) | 0x40; /* no board select for now */
cr2 = (page >> 2) & 0x03;
outb((char)cr1,CONTROL_REG1);
outb((char)cr2,CONTROL_REG2);
memcpy(buf+bofs,(char *)(EPROM_WINDOW + offset),nb);
len -= nb;
bp += nb;
bofs += nb;
}
return 0;
}
med.c代码如下:
/* med.c - make eprom disk image from ramdisk image */
#include
#include
#include
#define DISK_SIZE (6291456)
#define NUM_SECT (DISK_SIZE/512)
void write_eprom_image(FILE *fi, FILE *fo);
int main(int ac, char **av)
{
FILE *fi,
*fo;
char fin[44],
fon[44];
if (ac > 1) {
strcpy(fin,av[1]);
} else {
strcpy(fin,"hda3.ram");
}
if (ac > 2) {
strcpy(fon,av[2]);
} else {
strcpy(fon,"hda3.eprom");
}
fi = fopen(fin,"r");
fo = fopen(fon,"w");
if (fi == 0 || fo == 0) {
printf("Can't open files\n");
exit(0);
}
write_eprom_image(fi,fo);
fclose(fi);
fclose(fo);
} |
51 c8051f(f020,f040) msp430 arm(2410,2510) fpga(xc3s4000) dsp(5116 dm642) keilc vc++ matlab linux protel Ten_layerPCB mpegx h.26x Rscode Turbocode ofdm VideoBroadcasting ldpc_code(now!) |
|