root/tools/ghidra_scripts/datatypes/fw_types.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2 types for ghidra
   3 pulled from various parts of the CHDK source
   4 
   5 see fw_functions.h for required defines and other details
   6 */
   7 
   8 #ifndef FW_TYPES_H
   9 #define FW_TYPES_H
  10 struct led_control {int led_num; int action; int brightness; int blink_count;};
  11 
  12 #if !CAM_DRYOS_REL
  13 
  14 struct  __stat  // VxWorks
  15 {
  16     unsigned long       st_dev;         /* device ID number */
  17     unsigned long       st_ino;         /* file serial number */
  18     unsigned short      st_mode;        /* file mode (see below) */
  19     short               st_nlink;       /* number of links to file */
  20     short               st_uid;         /* user ID of file's owner */
  21     short               st_gid;         /* group ID of file's group */
  22     unsigned long       st_rdev;        /* device ID, only if special file */
  23     unsigned long       st_size;        /* size of file, in bytes */
  24     unsigned long       st_atime;       /* time of last access */
  25     unsigned long       st_mtime;       /* time of last modification */
  26     unsigned long       st_ctime;       /* time of last change of file status */
  27     long                st_blksize;
  28     long                st_blocks;
  29     unsigned char       st_attrib;      /* file attribute byte (dosFs only) */
  30     int                 reserved1;      /* reserved for future use */
  31     int                 reserved2;      /* reserved for future use */
  32     int                 reserved3;      /* reserved for future use */
  33     int                 reserved4;      /* reserved for future use */
  34     int                 reserved5;      /* reserved for future use */
  35     int                 reserved6;      /* reserved for future use */
  36 };
  37 
  38 #elif CAM_DRYOS_REL < 39
  39 struct  __stat  // DryOS pre R39
  40     {
  41     unsigned long       st_dev;         //?
  42     unsigned long       st_ino;         //?
  43     unsigned short      st_mode;        //?
  44     short               st_nlink;       //?
  45     short               st_uid;         //?
  46     short               st_gid;         //?
  47     unsigned long       st_atime;       //?
  48     unsigned long       st_mtime;       //?
  49     unsigned long       st_ctime;       //?
  50     unsigned long       st_size;
  51     long                st_blksize;     //?
  52     long                st_blocks;      //?
  53     unsigned char       st_attrib;
  54     int                 reserved1;      //
  55     int                 reserved2;      //
  56     int                 reserved3;      //
  57     int                 reserved4;      //
  58     int                 reserved5;      //
  59     int                 reserved6;      //
  60 };
  61 
  62 #elif CAM_DRYOS_REL < 59
  63 
  64 struct __stat   // DryOS R39...R58
  65 {
  66     unsigned long       st_unknown_1;
  67     unsigned long       st_attrib;
  68     unsigned long       st_size;
  69     unsigned long       st_ctime;
  70     unsigned long       st_mtime;
  71     unsigned long       st_unknown_2;
  72 };
  73 
  74 #else
  75 
  76 struct __stat   // DryOS >= R59
  77 {
  78     unsigned long       st_unknown_1;
  79     unsigned long       st_attrib;
  80     unsigned long       st_size;        // fixme: very likely 64bit, upper 32 bit is st_unknown_2
  81     unsigned long       st_unknown_2;
  82     unsigned long       st_ctime;
  83     unsigned long       st_mtime;
  84     unsigned long       st_unknown_3;
  85 };
  86 
  87 #endif//CAM_DRYOS_REL
  88 
  89 // from ptp_chdk.h
  90 typedef struct {
  91     int code;
  92     int sess_id;
  93     int trans_id;
  94     int num_param;
  95     int param1;
  96     int param2;
  97     int param3;
  98     int param4;
  99     int param5;
 100 } PTPContainer;
 101 
 102 typedef struct {
 103     int handle;
 104     int (*send_data)(int handle, const char *buf, int part_size, int total_size, int, int, int); // (0xFF9F525C), total_size should be 0 except for the first call
 105     int (*recv_data)(int handle, char *buf, int size, int, int); // (0xFF9F5500)
 106 #ifdef VX_OLD_PTP
 107     int (*send_resp)(int handle, PTPContainer *resp, int zero); // (0xFF9F5688), ixus30/40 needs a third argument, which is always 0
 108 #else
 109     int (*send_resp)(int handle, PTPContainer *resp); // extra param messes up analysis
 110 #endif
 111     int (*get_data_size)(int handle); // (0xFF9F5830)
 112     int (*send_err_resp)(int handle, PTPContainer *resp); // (0xFF9F5784)
 113     int unknown1; // ???
 114     int (*f2)(); // ??? (0xFF8D5B24)
 115     int (*f3)(); // ??? (0xFF8D5B5C)
 116     int more[1];
 117     // more??
 118 } ptp_data;
 119 
 120 typedef int (*ptp_handler)(int, ptp_data*, int, int, int, int, int, int, int, int);
 121 
 122 // made up, for eventproc table functions
 123 typedef struct {
 124     const char *name;
 125     int (*func)();
 126 } eventproc_table_entry;
 127 
 128 // based on include/std/stdio.h
 129 // reverse engineered file struct. Appears to be valid for both vxworks and dryos
 130 // don't use this directly unless you absolutely need to
 131 // don't EVER try to create one yourself, as this isn't the full structure.
 132 typedef struct FILE_S {
 133     int fd;         // used by Read/Write
 134     unsigned len;   // +4 verfied in Fseek_FileStream
 135     int unk0;       // +8
 136     unsigned pos;   // +0xC verified in Fseek_FileStream
 137     /* below not used in CHDK */
 138     int unk1;        // +0x10
 139     int unk2;        // +0x14
 140     char * io_buf;      // +0x18 32k uncached allocated in Fopen_FileStream
 141     int unk3;        // +0x20 related to StartFileAccess_Sem
 142     char name[127]; // in reality, allocated dynamically but giving length gives better decompilation
 143 } FILE;
 144 
 145 
 146 // first parameter to mzrm_createmsg / mzrm_sendmsg
 147 typedef struct mzrm_context_s mzrm_context;
 148 typedef struct mzrm_context_s {
 149     int unk0;
 150     int sem;
 151     unsigned alloc_avail;
 152     int unk1;
 153     int index1; // probably a circular buffer of some kind?
 154     int index2;
 155     int unk2[3];
 156     void (*maybe_wait_fn)(mzrm_context *ctx);
 157     int unk3[2]; // possibly more
 158 };
 159 
 160 typedef struct mzrm_msg_s {
 161     int msg_type;
 162     int unk;
 163     int payload_size;
 164     int payload[16]; // actual size varies
 165 } mzrm_msg;
 166 
 167 typedef int (*controller_fn)(void *controller_data, int event_id, void *unk1, void *unk2);
 168 typedef struct controller_s controller_t;
 169 struct controller_s {
 170     controller_fn fn;
 171     void *data;
 172     controller_t *next;
 173 #if defined(CAM_DRYOS_REL)
 174 #if CAM_DRYOS_REL <= 52
 175     int unk[2]; // all <= r52 seem to be 5 words total
 176 #else
 177     int unk[7]; // actual size varies, g*x and M cams seem to be 10 words total, others mostly 5
 178 #endif
 179 #else
 180     int unk; // vx appears to always be 4 words total
 181 #endif
 182 };
 183 
 184 // dry52 may be different per https://chdk.setepontos.com/index.php?topic=12788.msg145589#msg145589
 185 #if defined(CAM_DRYOS_REL) && CAM_DRYOS_REL > 52
 186 // Ximr layer
 187 typedef struct {
 188     unsigned char   unk1[7];
 189     unsigned char   scale;
 190     unsigned int    unk2;
 191     unsigned short  color_type;
 192     unsigned short  visibility;
 193     unsigned short  unk3;
 194     unsigned short  src_y;
 195     unsigned short  src_x;
 196     unsigned short  src_h;
 197     unsigned short  src_w;
 198     unsigned short  dst_y;
 199     unsigned short  dst_x;
 200     unsigned short  enabled;
 201     unsigned int    marv_sig;
 202     unsigned int    bitmap;
 203     unsigned int    opacity;
 204     unsigned int    color;
 205     unsigned int    width;
 206     unsigned int    height;
 207     unsigned int    unk4;
 208 } ximr_layer;
 209 
 210 // Ximr context
 211 typedef struct {
 212     unsigned short  unk1;
 213     unsigned short  width1;
 214     unsigned short  height1;
 215     unsigned short  unk2[17];
 216     unsigned int    output_marv_sig;
 217     unsigned int    output_buf;
 218     unsigned int    output_opacitybuf;
 219     unsigned int    output_color;
 220     int             buffer_width;
 221     int             buffer_height;
 222     unsigned int    unk3[2];
 223     ximr_layer      layers[8];
 224     unsigned int    unk4[24];
 225     unsigned char   denomx;
 226     unsigned char   numerx;
 227     unsigned char   denomy;
 228     unsigned char   numery;
 229     unsigned int    unk5;
 230     short           width;
 231     short           height;
 232     unsigned int    unk6[27];
 233 } ximr_context;
 234 #endif // CAM_DRYOS_REL

/* [<][>][^][v][top][bottom][index][help] */