00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __srec_h
00009 #define __srec_h 1
00010
00011 #include <system/config.h>
00012
00013 __BEGIN_SYS
00014
00015 class SREC
00016 {
00017 public:
00018 SREC() {}
00019
00020 bool valid() {
00021 return ((((char*)this)[0] == 'S') &&
00022 (((char*)this)[1] == '0'));
00023 }
00024
00025 void * entry();
00026
00027 int segments() {
00028 return (1);
00029 }
00030
00031 void * segment_address(int i) {
00032 return ((void *) this->entry());
00033 }
00034
00035 int segment_size(int i);
00036 int load_segment(int i, void * addr = 0);
00037
00038 private:
00039
00040 static signed char ctab[];
00041 static int ltab[];
00042
00043 typedef struct srec_t {
00044 unsigned char type;
00045 unsigned int addr;
00046 unsigned char count;
00047 unsigned char data[256];
00048 };
00049
00050 inline int C1(unsigned char* l, unsigned char p) {
00051 return(ctab[l[p]]);
00052 };
00053
00054 inline int C2(unsigned char* l, unsigned char p) {
00055 return( (C1(l,p)<<4) | (C1(l,p+1)) );
00056 };
00057
00058 bool srec_decode(srec_t *srec, char *_line);
00059
00060 };
00061
00062 __END_SYS
00063
00064 #endif
00065