/* * 0xFFFF - Open Free Fiasco Firmware Flasher * Copyright (C) 2007 pancake * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include "main.h" void (*fiasco_callback)(struct header_t *header) = NULL; int openfiasco(char *name) { struct header_t header; unsigned char buf[128]; unsigned char data[128]; unsigned int namelen; int i; int fd = open(name, O_RDONLY); if (fd == -1) { fprintf(stderr, "Cannot open %s\n", name); return 1; } /* read header */ read(fd, buf, 5); if (buf[0] != 0xb4) { printf("Invalid header\n"); return close(fd); } memcpy(&namelen,buf+1,4); namelen = ntohl(namelen); if (namelen>128) { printf("Stupid length at header. Is this a joke?\n"); return close(fd); } memset(buf,'\0', 128); read(fd, buf, namelen); // 6 first bytes are unknown // buf 00 00 00 VERSION e8 0e // printf("6Bytes: %02x %02x %02x %02x %02x %02x\n", // buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); printf("Fiasco version: %2d\n", buf[3]); strcpy(header.fwname, buf+6); for(i=6;i'0' && buf[8] < '9') { if (read(fd, data, 1)<1) break; i = data[0]; if (read(fd, data, i)name); printf("DATA: %02x\n", header->data[0]); } int main(int argc, char **argv) { if (argc!=2) { printf("Usage: unfiasco [file]\n"); return 1; } /* fd = fiasco_new("myfiasco", "pancake-edition"); fiasco_add(fd, "kernel", "zImage", "2.6.22"); close(fd); */ // fiasco_callback = &my_callback; return openfiasco(argv[1]); } #endif