void writeSD(unsigned long adr, unsigned char *data, unsigned short len) { unsigned int i; unsigned char *buf = &writeData[0][0]; cmd(16, 512); cmd17(adr&0xfffffe00); for (i=0; i<512; i++) buf[i] = readByte(); readByte(); readByte(); // discard CRC bytes memcp(&(buf[adr&0x1ff]), data, len); PORTB |= (1<<SD_CS); PORTB &= ~(1<<SD_CS); cmd(24,adr&0xfffffe00); writeByte(0xff); writeByte(0xfe); for (i=0; i<512; i++) writeByte(buf[i]); writeByte(0xff); writeByte(0xff); readByte(); waitFinish(); PORTB |= (1<<SD_CS); PORTB &= ~(1<<SD_CS); }
// create a NIC image file int createNic(unsigned char *name) { unsigned short re, clusterNum; unsigned long ft, adr; unsigned short d, i; unsigned char c, dirEntry[32], at; static unsigned char last[2] = {0xff, 0xff}; for (i=0; i<32; i++) dirEntry[i]=0; memcp(dirEntry, name, 8); memcp(dirEntry+8, (unsigned char *)"NIC", 3); *(unsigned long *)(dirEntry+28) = (unsigned long)286720; // search a root directory entry for (re=0; re<512; re++) { cmd(16, 1); cmd17(rootAddr+re*32+0); c = readByte(); readByte(); readByte(); // discard CRC bytes cmd17(rootAddr+re*32+11); at = readByte(); readByte(); readByte(); // discard CRC bytes if (((c==0xe5)||(c==0x00))&&(at!=0xf)) break; // find a RDE! } if (re==512) return 0; // write a directory entry writeSD(rootAddr+re*32, dirEntry, 32); // search the first fat entry adr = (rootAddr+re*32+26); clusterNum = 0; for (ft=2; (clusterNum<((560+sectorsPerCluster-1)>>sectorsPerCluster2)); ft++) { cmd(16, 2); cmd17(fatAddr+ft*2); d = readByte(); d += (unsigned short)readByte()*0x100; readByte(); readByte(); // discard CRC bytes if (d==0) { clusterNum++; writeSD(adr, (unsigned char *)&ft, 2); adr = fatAddr+ft*2; } } writeSD(adr, last, 2); duplicateFat(); return 1; }
int WINAPI wine_zmq_send_int_array ( char* array,int size, void*socket,int flags) { zmq_msg_t reply; zmq_msg_init_size (&reply, sizeof(int)*size); int i; memcp((char*)zmq_msg_data(&reply),array,sizeof(int)*size); int ret = zmq_send (socket, &reply, flags); zmq_msg_close (&reply); return ret; }
EXPORT int WINAPI _zmq_send_double_array ( char* array,int size, void*socket,int flags) { int ret; zmq_msg_t reply; zmq_msg_init_size (&reply, sizeof(double)*size); memcp((char*)zmq_msg_data(&reply),array,sizeof(double)*size); ret = zmq_send (socket, &reply, flags); zmq_msg_close (&reply); return ret; }