- }
- ret=read(lpc->fwfd,line+1,2);
- line[3]='\0';
- len=atoi(line+1);
- ret=read(lpc->fwfd,line+3,4);
- line[7]='\0';
- addr=strtol(line+3);
-
+ }
+ /* read len */
+ ret=read(lpc->fwfd,buf,2);
+ sscanf(buf,"%02x",&len);
+ if(len%4) {
+ printf("fw to ram: len not a multiple of 4\n");
+ return -1;
+ }
+ /* read addr */
+ ret=read(lpc->fwfd,buf,4);
+ sscanf(buf,"%04x",&addr);
+ /* read type */
+ ret=read(lpc->fwfd,buf,2);
+ sscanf(buf,"%02x",&type);
+ /* successfull return if type is end of file */
+ if(type==0x01)
+ return 0;
+ /* read data (and cksum) */
+ ret=read(lpc->fwfd,buf,2*(len+1));
+ if(ret!=(2*(len+1))) {
+ printf("fw to ram: data missing\n");
+ return -1;
+ }
+ for(ret=0;ret<len;ret++) {
+ sscanf(buf+2*ret,"%02x",&temp);
+ buf[ret]=temp;
+ }
+ /* act according to type */
+ switch(type) {
+ case 0x03:
+ /* get cs and ip */
+ break;
+ case 0x00:
+ write_to_ram(lpc,buf,addr,len);
+ break;
+ default:
+ printf("fw to ram: unknown type %02x\n",type);
+ return -1;