static int ata_identify(struct aoedev *d, struct aoe_atahdr *ata) { char buf[64]; u16 *words = (u16 *)ata->data; u8 *cp; loff_t scnt; memset(words, 0, 512); words[47] = 0x8000; words[49] = 0x0200; words[50] = 0x4000; words[83] = 0x5400; words[84] = 0x4000; words[86] = 0x1400; words[87] = 0x4000; words[93] = 0x400b; sprintf(buf, "V%d.%d\n", 0, 2); setfld(words, 23, 8, buf); setfld(words, 27, nelem(d->model), d->model); setfld(words, 10, nelem(d->sn), d->sn); scnt = d->scnt; cp = (u8 *)&words[100]; *cp++ = scnt; *cp++ = (scnt >>= 8); *cp++ = (scnt >>= 8); *cp++ = (scnt >>= 8); *cp++ = (scnt >>= 8); *cp++ = (scnt >>= 8); scnt = d->scnt; cp = (u8 *)&words[60]; if (scnt & ~ATA_LBA28MAX) scnt = ATA_LBA28MAX; *cp++ = scnt; *cp++ = (scnt >>= 8); *cp++ = (scnt >>= 8); *cp++ = (scnt >>= 8) & 0xf; return 512; }
static naRef f_setfld(naContext c, naRef me, int argc, naRef* args) { naRef s = argc > 0 ? args[0] : naNil(); int bit = argc > 1 ? (int)naNumValue(args[1]).num : -1; int len = argc > 2 ? (int)naNumValue(args[2]).num : -1; naRef val = argc > 3 ? naNumValue(args[3]) : naNil(); if(!argc || !MUTABLE(args[0])|| bit < 0 || len < 0 || IS_NIL(val)) naRuntimeError(c, "missing/bad argument to setfld"); setfld(c, (void*)naStr_data(s), naStr_len(s), bit, len, (unsigned int)val.num); return naNil(); }