unsigned char itemsize; /* size of each item (in bytes) */
} bytecode_reserve;
+typedef struct bytecode_incbin {
+ /*@only@*/ char *filename; /* file to include data from */
+
+ /* starting offset to read from (NULL=0) */
+ /*@only@*/ /*@null@*/ expr *start;
+
+ /* maximum number of bytes to read (NULL=no limit) */
+ /*@only@*/ /*@null@*/ expr *maxlen;
+} bytecode_incbin;
+
/* Static structures for when NULL is passed to conversion functions. */
/* for Convert*ToBytes() */
unsigned char bytes_static[16];
return bc;
}
+bytecode *
+bc_new_incbin(char *filename, expr *start, expr *maxlen)
+{
+ bytecode *bc = bc_new_common(BC_INCBIN, sizeof(bytecode_incbin));
+ bytecode_incbin *incbin = bc_get_data(bc);
+
+ incbin->filename = filename;
+ incbin->start = start;
+ incbin->maxlen = maxlen;
+
+ return bc;
+}
+
void
bc_delete(bytecode *bc)
{
bytecode_data *data;
bytecode_reserve *reserve;
+ bytecode_incbin *incbin;
if (!bc)
return;
reserve = bc_get_data(bc);
expr_delete(reserve->numitems);
break;
+ case BC_INCBIN:
+ incbin = bc_get_data(bc);
+ xfree(incbin->filename);
+ expr_delete(incbin->start);
+ expr_delete(incbin->maxlen);
+ break;
default:
if (bc->type < cur_arch->bc.type_max)
cur_arch->bc.bc_delete(bc);
{
const bytecode_data *data;
const bytecode_reserve *reserve;
+ const bytecode_incbin *incbin;
switch (bc->type) {
case BC_EMPTY:
fprintf(f, "\n%*sItem Size=%u\n", indent_level, "",
(unsigned int)reserve->itemsize);
break;
+ case BC_INCBIN:
+ incbin = bc_get_const_data(bc);
+ fprintf(f, "%*s_IncBin_\n", indent_level, "");
+ fprintf(f, "%*sFilename=`%s'\n", indent_level, "",
+ incbin->filename);
+ fprintf(f, "%*sStart=", indent_level, "");
+ if (!incbin->start)
+ fprintf(f, "nil (0)");
+ else
+ expr_print(f, incbin->start);
+ fprintf(f, "%*sMax Len=", indent_level, "");
+ if (!incbin->maxlen)
+ fprintf(f, "nil (unlimited)");
+ else
+ expr_print(f, incbin->maxlen);
+ fprintf(f, "\n");
+ break;
default:
if (bc->type < cur_arch->bc.type_max)
cur_arch->bc.bc_print(f, bc);
typedef enum {
BC_EMPTY = 0,
BC_DATA,
- BC_RESERVE
+ BC_RESERVE,
+ BC_INCBIN
} bytecode_type;
-#define BYTECODE_TYPE_BASE BC_RESERVE+1
+#define BYTECODE_TYPE_BASE BC_INCBIN+1
/*@only@*/ immval *imm_new_int(unsigned long int_val);
/*@only@*/ immval *imm_new_expr(/*@keep@*/ expr *e);
/*@only@*/ bytecode *bc_new_data(datavalhead *datahead, unsigned char size);
/*@only@*/ bytecode *bc_new_reserve(/*@keep@*/ expr *numitems,
unsigned char itemsize);
+/*@only@*/ bytecode *bc_new_incbin(/*@only@*/ char *filename,
+ /*@only@*/ /*@null@*/ expr *start,
+ /*@only@*/ /*@null@*/ expr *maxlen);
void bc_delete(/*@only@*/ /*@null@*/ bytecode *bc);
;
exp: instr
- | DECLARE_DATA datavals { $$ = bc_new_data(&$2, $1); }
- | RESERVE_SPACE expr { $$ = bc_new_reserve($2, $1); }
+ | DECLARE_DATA datavals { $$ = bc_new_data(&$2, $1); }
+ | RESERVE_SPACE expr { $$ = bc_new_reserve($2, $1); }
+ | INCBIN STRING { $$ = bc_new_incbin($2, NULL, NULL); }
+ | INCBIN STRING ',' expr { $$ = bc_new_incbin($2, $4, NULL); }
+ | INCBIN STRING ',' expr ',' expr { $$ = bc_new_incbin($2, $4, $6); }
;
datavals: dataval { dvs_initialize(&$$); dvs_append(&$$, $1); }
;
exp: instr
- | DECLARE_DATA datavals { $$ = bc_new_data(&$2, $1); }
- | RESERVE_SPACE expr { $$ = bc_new_reserve($2, $1); }
+ | DECLARE_DATA datavals { $$ = bc_new_data(&$2, $1); }
+ | RESERVE_SPACE expr { $$ = bc_new_reserve($2, $1); }
+ | INCBIN STRING { $$ = bc_new_incbin($2, NULL, NULL); }
+ | INCBIN STRING ',' expr { $$ = bc_new_incbin($2, $4, NULL); }
+ | INCBIN STRING ',' expr ',' expr { $$ = bc_new_incbin($2, $4, $6); }
;
datavals: dataval { dvs_initialize(&$$); dvs_append(&$$, $1); }
unsigned char itemsize; /* size of each item (in bytes) */
} bytecode_reserve;
+typedef struct bytecode_incbin {
+ /*@only@*/ char *filename; /* file to include data from */
+
+ /* starting offset to read from (NULL=0) */
+ /*@only@*/ /*@null@*/ expr *start;
+
+ /* maximum number of bytes to read (NULL=no limit) */
+ /*@only@*/ /*@null@*/ expr *maxlen;
+} bytecode_incbin;
+
/* Static structures for when NULL is passed to conversion functions. */
/* for Convert*ToBytes() */
unsigned char bytes_static[16];
return bc;
}
+bytecode *
+bc_new_incbin(char *filename, expr *start, expr *maxlen)
+{
+ bytecode *bc = bc_new_common(BC_INCBIN, sizeof(bytecode_incbin));
+ bytecode_incbin *incbin = bc_get_data(bc);
+
+ incbin->filename = filename;
+ incbin->start = start;
+ incbin->maxlen = maxlen;
+
+ return bc;
+}
+
void
bc_delete(bytecode *bc)
{
bytecode_data *data;
bytecode_reserve *reserve;
+ bytecode_incbin *incbin;
if (!bc)
return;
reserve = bc_get_data(bc);
expr_delete(reserve->numitems);
break;
+ case BC_INCBIN:
+ incbin = bc_get_data(bc);
+ xfree(incbin->filename);
+ expr_delete(incbin->start);
+ expr_delete(incbin->maxlen);
+ break;
default:
if (bc->type < cur_arch->bc.type_max)
cur_arch->bc.bc_delete(bc);
{
const bytecode_data *data;
const bytecode_reserve *reserve;
+ const bytecode_incbin *incbin;
switch (bc->type) {
case BC_EMPTY:
fprintf(f, "\n%*sItem Size=%u\n", indent_level, "",
(unsigned int)reserve->itemsize);
break;
+ case BC_INCBIN:
+ incbin = bc_get_const_data(bc);
+ fprintf(f, "%*s_IncBin_\n", indent_level, "");
+ fprintf(f, "%*sFilename=`%s'\n", indent_level, "",
+ incbin->filename);
+ fprintf(f, "%*sStart=", indent_level, "");
+ if (!incbin->start)
+ fprintf(f, "nil (0)");
+ else
+ expr_print(f, incbin->start);
+ fprintf(f, "%*sMax Len=", indent_level, "");
+ if (!incbin->maxlen)
+ fprintf(f, "nil (unlimited)");
+ else
+ expr_print(f, incbin->maxlen);
+ fprintf(f, "\n");
+ break;
default:
if (bc->type < cur_arch->bc.type_max)
cur_arch->bc.bc_print(f, bc);
typedef enum {
BC_EMPTY = 0,
BC_DATA,
- BC_RESERVE
+ BC_RESERVE,
+ BC_INCBIN
} bytecode_type;
-#define BYTECODE_TYPE_BASE BC_RESERVE+1
+#define BYTECODE_TYPE_BASE BC_INCBIN+1
/*@only@*/ immval *imm_new_int(unsigned long int_val);
/*@only@*/ immval *imm_new_expr(/*@keep@*/ expr *e);
/*@only@*/ bytecode *bc_new_data(datavalhead *datahead, unsigned char size);
/*@only@*/ bytecode *bc_new_reserve(/*@keep@*/ expr *numitems,
unsigned char itemsize);
+/*@only@*/ bytecode *bc_new_incbin(/*@only@*/ char *filename,
+ /*@only@*/ /*@null@*/ expr *start,
+ /*@only@*/ /*@null@*/ expr *maxlen);
void bc_delete(/*@only@*/ /*@null@*/ bytecode *bc);
;
exp: instr
- | DECLARE_DATA datavals { $$ = bc_new_data(&$2, $1); }
- | RESERVE_SPACE expr { $$ = bc_new_reserve($2, $1); }
+ | DECLARE_DATA datavals { $$ = bc_new_data(&$2, $1); }
+ | RESERVE_SPACE expr { $$ = bc_new_reserve($2, $1); }
+ | INCBIN STRING { $$ = bc_new_incbin($2, NULL, NULL); }
+ | INCBIN STRING ',' expr { $$ = bc_new_incbin($2, $4, NULL); }
+ | INCBIN STRING ',' expr ',' expr { $$ = bc_new_incbin($2, $4, $6); }
;
datavals: dataval { dvs_initialize(&$$); dvs_append(&$$, $1); }
;
exp: instr
- | DECLARE_DATA datavals { $$ = bc_new_data(&$2, $1); }
- | RESERVE_SPACE expr { $$ = bc_new_reserve($2, $1); }
+ | DECLARE_DATA datavals { $$ = bc_new_data(&$2, $1); }
+ | RESERVE_SPACE expr { $$ = bc_new_reserve($2, $1); }
+ | INCBIN STRING { $$ = bc_new_incbin($2, NULL, NULL); }
+ | INCBIN STRING ',' expr { $$ = bc_new_incbin($2, $4, NULL); }
+ | INCBIN STRING ',' expr ',' expr { $$ = bc_new_incbin($2, $4, $6); }
;
datavals: dataval { dvs_initialize(&$$); dvs_append(&$$, $1); }