SCP: Add support REGister data in arrays of arbitrary structures.

This commit is contained in:
Mark Pizzolato 2016-03-14 15:07:22 -07:00
parent b304d7f4a8
commit 37733cabee
3 changed files with 96 additions and 56 deletions

Binary file not shown.

45
scp.c
View file

@ -6670,7 +6670,7 @@ t_value get_rval (REG *rptr, uint32 idx)
{ {
size_t sz; size_t sz;
t_value val; t_value val;
UNIT *uptr; uint32 *ptr;
sz = SZ_R (rptr); sz = SZ_R (rptr);
if ((rptr->depth > 1) && (rptr->flags & REG_CIRC)) { if ((rptr->depth > 1) && (rptr->flags & REG_CIRC)) {
@ -6678,13 +6678,23 @@ if ((rptr->depth > 1) && (rptr->flags & REG_CIRC)) {
if (idx >= rptr->depth) idx = idx - rptr->depth; if (idx >= rptr->depth) idx = idx - rptr->depth;
} }
if ((rptr->depth > 1) && (rptr->flags & REG_UNIT)) { if ((rptr->depth > 1) && (rptr->flags & REG_UNIT)) {
uptr = ((UNIT *) rptr->loc) + idx; ptr = (uint32 *)(((UNIT *) rptr->loc) + idx);
#if defined (USE_INT64) #if defined (USE_INT64)
if (sz <= sizeof (uint32)) if (sz <= sizeof (uint32))
val = *((uint32 *) uptr); val = *ptr;
else val = *((t_uint64 *) uptr); else val = *((t_uint64 *) ptr);
#else #else
val = *((uint32 *) uptr); val = *ptr;
#endif
}
else if ((rptr->depth > 1) && (rptr->flags & REG_STRUCT)) {
ptr = (uint32 *)(((size_t) rptr->loc) + (idx * rptr->str_size));
#if defined (USE_INT64)
if (sz <= sizeof (uint32))
val = *ptr;
else val = *((t_uint64 *) ptr);
#else
val = *ptr;
#endif #endif
} }
else if (((rptr->depth > 1) || (rptr->flags & REG_FIT)) && else if (((rptr->depth > 1) || (rptr->flags & REG_FIT)) &&
@ -6772,7 +6782,7 @@ void put_rval (REG *rptr, uint32 idx, t_value val)
{ {
size_t sz; size_t sz;
t_value mask; t_value mask;
UNIT *uptr; uint32 *ptr;
#define PUT_RVAL(sz,rp,id,v,m) \ #define PUT_RVAL(sz,rp,id,v,m) \
*(((sz *) rp->loc) + id) = \ *(((sz *) rp->loc) + id) = \
@ -6789,16 +6799,31 @@ if ((rptr->depth > 1) && (rptr->flags & REG_CIRC)) {
idx = idx - rptr->depth; idx = idx - rptr->depth;
} }
if ((rptr->depth > 1) && (rptr->flags & REG_UNIT)) { if ((rptr->depth > 1) && (rptr->flags & REG_UNIT)) {
uptr = ((UNIT *) rptr->loc) + idx; ptr = (uint32 *)(((UNIT *) rptr->loc) + idx);
#if defined (USE_INT64) #if defined (USE_INT64)
if (sz <= sizeof (uint32)) if (sz <= sizeof (uint32))
*((uint32 *) uptr) = (*((uint32 *) uptr) & *ptr = (*ptr &
~(((uint32) mask) << rptr->offset)) | ~(((uint32) mask) << rptr->offset)) |
(((uint32) val) << rptr->offset); (((uint32) val) << rptr->offset);
else *((t_uint64 *) uptr) = (*((t_uint64 *) uptr) else *((t_uint64 *) ptr) = (*((t_uint64 *) ptr)
& ~(mask << rptr->offset)) | (val << rptr->offset); & ~(mask << rptr->offset)) | (val << rptr->offset);
#else #else
*((uint32 *) uptr) = (*((uint32 *) uptr) & *ptr = (*ptr &
~(((uint32) mask) << rptr->offset)) |
(((uint32) val) << rptr->offset);
#endif
}
else if ((rptr->depth > 1) && (rptr->flags & REG_STRUCT)) {
ptr = (uint32 *)(((size_t) rptr->loc) + (idx * rptr->str_size));
#if defined (USE_INT64)
if (sz <= sizeof (uint32))
*((uint32 *) ptr) = (*((uint32 *) ptr) &
~(((uint32) mask) << rptr->offset)) |
(((uint32) val) << rptr->offset);
else *((t_uint64 *) ptr) = (*((t_uint64 *) ptr)
& ~(mask << rptr->offset)) | (val << rptr->offset);
#else
*ptr = (*ptr &
~(((uint32) mask) << rptr->offset)) | ~(((uint32) mask) << rptr->offset)) |
(((uint32) val) << rptr->offset); (((uint32) val) << rptr->offset);
#endif #endif

View file

@ -586,6 +586,7 @@ struct REG {
uint32 depth; /* save depth */ uint32 depth; /* save depth */
const char *desc; /* description */ const char *desc; /* description */
BITFIELD *fields; /* bit fields */ BITFIELD *fields; /* bit fields */
size_t str_size; /* structure size */
uint32 flags; /* flags */ uint32 flags; /* flags */
uint32 qptr; /* circ q ptr */ uint32 qptr; /* circ q ptr */
}; };
@ -597,10 +598,11 @@ struct REG {
#define REG_HIDDEN 00010 /* hidden */ #define REG_HIDDEN 00010 /* hidden */
#define REG_NZ 00020 /* must be non-zero */ #define REG_NZ 00020 /* must be non-zero */
#define REG_UNIT 00040 /* in unit struct */ #define REG_UNIT 00040 /* in unit struct */
#define REG_CIRC 00100 /* circular array */ #define REG_STRUCT 00100 /* in structure array */
#define REG_VMIO 00200 /* use VM data print/parse */ #define REG_CIRC 00200 /* circular array */
#define REG_VMAD 00400 /* use VM addr print/parse */ #define REG_VMIO 00400 /* use VM data print/parse */
#define REG_FIT 01000 /* fit access to size */ #define REG_VMAD 01000 /* use VM addr print/parse */
#define REG_FIT 02000 /* fit access to size */
#define REG_HRO (REG_RO | REG_HIDDEN) /* hidden, read only */ #define REG_HRO (REG_RO | REG_HIDDEN) /* hidden, read only */
#define REG_V_UF 16 /* device specific */ #define REG_V_UF 16 /* device specific */
@ -768,38 +770,45 @@ struct FILEREF {
#if defined (__STDC__) || defined (_WIN32) #if defined (__STDC__) || defined (_WIN32)
/* Right Justified Octal Register Data */ /* Right Justified Octal Register Data */
#define ORDATA(nm,loc,wd) #nm, &(loc), 8, (wd), 0, 1, NULL, NULL #define ORDATA(nm,loc,wd) #nm, &(loc), 8, (wd), 0, 1, NULL, NULL, 0
/* Right Justified Decimal Register Data */ /* Right Justified Decimal Register Data */
#define DRDATA(nm,loc,wd) #nm, &(loc), 10, (wd), 0, 1, NULL, NULL #define DRDATA(nm,loc,wd) #nm, &(loc), 10, (wd), 0, 1, NULL, NULL, 0
/* Right Justified Hexadecimal Register Data */ /* Right Justified Hexadecimal Register Data */
#define HRDATA(nm,loc,wd) #nm, &(loc), 16, (wd), 0, 1, NULL, NULL #define HRDATA(nm,loc,wd) #nm, &(loc), 16, (wd), 0, 1, NULL, NULL, 0
/* One-bit binary flag at an arbitrary offset in a 32-bit word Register */ /* One-bit binary flag at an arbitrary offset in a 32-bit word Register */
#define FLDATA(nm,loc,pos) #nm, &(loc), 2, 1, (pos), 1, NULL, NULL #define FLDATA(nm,loc,pos) #nm, &(loc), 2, 1, (pos), 1, NULL, NULL, 0
/* Arbitrary location and Radix Register */ /* Arbitrary location and Radix Register */
#define GRDATA(nm,loc,rdx,wd,pos) #nm, &(loc), (rdx), (wd), (pos), 1, NULL, NULL #define GRDATA(nm,loc,rdx,wd,pos) #nm, &(loc), (rdx), (wd), (pos), 1, NULL, NULL, 0
/* Arrayed register whose data is kept in a standard C array Register */ /* Arrayed register whose data is kept in a standard C array Register */
#define BRDATA(nm,loc,rdx,wd,dep) #nm, (loc), (rdx), (wd), 0, (dep), NULL, NULL #define BRDATA(nm,loc,rdx,wd,dep) #nm, (loc), (rdx), (wd), 0, (dep), NULL, NULL, 0
/* Arrayed register whose data is part of the UNIT structure */ /* Arrayed register whose data is part of the UNIT structure */
#define URDATA(nm,loc,rdx,wd,off,dep,fl) \ #define URDATA(nm,loc,rdx,wd,off,dep,fl) \
#nm, &(loc), (rdx), (wd), (off), (dep), NULL, NULL, ((fl) | REG_UNIT) #nm, &(loc), (rdx), (wd), (off), (dep), NULL, NULL, 0, ((fl) | REG_UNIT)
/* Arrayed register whose data is part of an arbitrary structure */
#define SRDATA(nm,loc,rdx,wd,off,dep,siz,fl) \
#nm, &(loc), (rdx), (wd), (off), (dep), NULL, NULL, (siz), ((fl) | REG_STRUCT)
/* Same as above, but with additional description initializer */ /* Same as above, but with additional description initializer */
#define ORDATAD(nm,loc,wd,desc) #nm, &(loc), 8, (wd), 0, 1, (desc), NULL #define ORDATAD(nm,loc,wd,desc) #nm, &(loc), 8, (wd), 0, 1, (desc), NULL, 0
#define DRDATAD(nm,loc,wd,desc) #nm, &(loc), 10, (wd), 0, 1, (desc), NULL #define DRDATAD(nm,loc,wd,desc) #nm, &(loc), 10, (wd), 0, 1, (desc), NULL, 0
#define HRDATAD(nm,loc,wd,desc) #nm, &(loc), 16, (wd), 0, 1, (desc), NULL #define HRDATAD(nm,loc,wd,desc) #nm, &(loc), 16, (wd), 0, 1, (desc), NULL, 0
#define FLDATAD(nm,loc,pos,desc) #nm, &(loc), 2, 1, (pos), 1, (desc), NULL #define FLDATAD(nm,loc,pos,desc) #nm, &(loc), 2, 1, (pos), 1, (desc), NULL, 0
#define GRDATAD(nm,loc,rdx,wd,pos,desc) #nm, &(loc), (rdx), (wd), (pos), 1, (desc), NULL #define GRDATAD(nm,loc,rdx,wd,pos,desc) #nm, &(loc), (rdx), (wd), (pos), 1, (desc), NULL, 0
#define BRDATAD(nm,loc,rdx,wd,dep,desc) #nm, (loc), (rdx), (wd), 0, (dep), (desc), NULL #define BRDATAD(nm,loc,rdx,wd,dep,desc) #nm, (loc), (rdx), (wd), 0, (dep), (desc), NULL, 0
#define URDATAD(nm,loc,rdx,wd,off,dep,fl,desc) \ #define URDATAD(nm,loc,rdx,wd,off,dep,fl,desc) \
#nm, &(loc), (rdx), (wd), (off), (dep), (desc), NULL, ((fl) | REG_UNIT) #nm, &(loc), (rdx), (wd), (off), (dep), (desc), NULL, 0, ((fl) | REG_UNIT)
#define SRDATAD(nm,loc,rdx,wd,off,dep,siz,fl,desc) \
#nm, &(loc), (rdx), (wd), (off), (dep), (desc), NULL, (siz), ((fl) | REG_STRUCT)
/* Same as above, but with additional description initializer, and bitfields */ /* Same as above, but with additional description initializer, and bitfields */
#define ORDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 8, (wd), 0, 1, (desc), (flds) #define ORDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 8, (wd), 0, 1, (desc), (flds), 0
#define DRDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 10, (wd), 0, 1, (desc), (flds) #define DRDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 10, (wd), 0, 1, (desc), (flds), 0
#define HRDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 16, (wd), 0, 1, (desc), (flds) #define HRDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 16, (wd), 0, 1, (desc), (flds), 0
#define FLDATADF(nm,loc,pos,desc,flds) #nm, &(loc), 2, 1, (pos), 1, (desc), (flds) #define FLDATADF(nm,loc,pos,desc,flds) #nm, &(loc), 2, 1, (pos), 1, (desc), (flds), 0
#define GRDATADF(nm,loc,rdx,wd,pos,desc,flds) #nm, &(loc), (rdx), (wd), (pos), 1, (desc), (flds) #define GRDATADF(nm,loc,rdx,wd,pos,desc,flds) #nm, &(loc), (rdx), (wd), (pos), 1, (desc), (flds), 0
#define BRDATADF(nm,loc,rdx,wd,dep,desc,flds) #nm, (loc), (rdx), (wd), 0, (dep), (desc), (flds) #define BRDATADF(nm,loc,rdx,wd,dep,desc,flds) #nm, (loc), (rdx), (wd), 0, (dep), (desc), (flds), 0
#define URDATADF(nm,loc,rdx,wd,off,dep,fl,desc,flds) \ #define URDATADF(nm,loc,rdx,wd,off,dep,fl,desc,flds) \
#nm, &(loc), (rdx), (wd), (off), (dep), (desc), (flds), ((fl) | REG_UNIT) #nm, &(loc), (rdx), (wd), (off), (dep), (desc), (flds), 0, ((fl) | REG_UNIT)
#define SRDATADF(nm,loc,rdx,wd,off,dep,siz,fl,desc,flds) \
#nm, &(loc), (rdx), (wd), (off), (dep), (desc), (flds), (siz), ((fl) | REG_STRUCT)
#define BIT(nm) {#nm, 0xffffffff, 1} /* Single Bit definition */ #define BIT(nm) {#nm, 0xffffffff, 1} /* Single Bit definition */
#define BITNC {"", 0xffffffff, 1} /* Don't care Bit definition */ #define BITNC {"", 0xffffffff, 1} /* Don't care Bit definition */
#define BITF(nm,sz) {#nm, 0xffffffff, sz} /* Bit Field definition */ #define BITF(nm,sz) {#nm, 0xffffffff, sz} /* Bit Field definition */
@ -807,30 +816,36 @@ struct FILEREF {
#define BITFFMT(nm,sz,fmt) {#nm, 0xffffffff, sz, NULL, #fmt}/* Bit Field definition with Output format */ #define BITFFMT(nm,sz,fmt) {#nm, 0xffffffff, sz, NULL, #fmt}/* Bit Field definition with Output format */
#define BITFNAM(nm,sz,names) {#nm, 0xffffffff, sz, names} /* Bit Field definition with value->name map */ #define BITFNAM(nm,sz,names) {#nm, 0xffffffff, sz, names} /* Bit Field definition with value->name map */
#else #else
#define ORDATA(nm,loc,wd) "nm", &(loc), 8, (wd), 0, 1, NULL, NULL #define ORDATA(nm,loc,wd) "nm", &(loc), 8, (wd), 0, 1, NULL, NULL, 0
#define DRDATA(nm,loc,wd) "nm", &(loc), 10, (wd), 0, 1, NULL, NULL #define DRDATA(nm,loc,wd) "nm", &(loc), 10, (wd), 0, 1, NULL, NULL, 0
#define HRDATA(nm,loc,wd) "nm", &(loc), 16, (wd), 0, 1, NULL, NULL #define HRDATA(nm,loc,wd) "nm", &(loc), 16, (wd), 0, 1, NULL, NULL, 0
#define FLDATA(nm,loc,pos) "nm", &(loc), 2, 1, (pos), 1, NULL, NULL #define FLDATA(nm,loc,pos) "nm", &(loc), 2, 1, (pos), 1, NULL, NULL, 0
#define GRDATA(nm,loc,rdx,wd,pos) "nm", &(loc), (rdx), (wd), (pos), 1, NULL, NULL #define GRDATA(nm,loc,rdx,wd,pos) "nm", &(loc), (rdx), (wd), (pos), 1, NULL, NULL, 0
#define BRDATA(nm,loc,rdx,wd,dep) "nm", (loc), (rdx), (wd), 0, (dep), NULL, NULL #define BRDATA(nm,loc,rdx,wd,dep) "nm", (loc), (rdx), (wd), 0, (dep), NULL, NULL, 0
#define URDATA(nm,loc,rdx,wd,off,dep,fl) \ #define URDATA(nm,loc,rdx,wd,off,dep,fl) \
"nm", &(loc), (rdx), (wd), (off), (dep), NULL, NULL, ((fl) | REG_UNIT) "nm", &(loc), (rdx), (wd), (off), (dep), NULL, NULL, 0, ((fl) | REG_UNIT)
#define ORDATAD(nm,loc,wd,desc) "nm", &(loc), 8, (wd), 0, 1, (desc), NULL #define SRDATA(nm,loc,rdx,wd,off,dep,siz,fl) \
#define DRDATAD(nm,loc,wd,desc) "nm", &(loc), 10, (wd), 0, 1, (desc), NULL "nm", &(loc), (rdx), (wd), (off), (dep), NULL, NULL, (siz), ((fl) | REG_STRUCT)
#define HRDATAD(nm,loc,wd,desc) "nm", &(loc), 16, (wd), 0, 1, (desc), NULL #define ORDATAD(nm,loc,wd,desc) "nm", &(loc), 8, (wd), 0, 1, (desc), NULL, 0
#define FLDATAD(nm,loc,pos,desc) "nm", &(loc), 2, 1, (pos), 1, (desc), NULL #define DRDATAD(nm,loc,wd,desc) "nm", &(loc), 10, (wd), 0, 1, (desc), NULL, 0
#define GRDATAD(nm,loc,rdx,wd,pos,desc) "nm", &(loc), (rdx), (wd), (pos), 1, (desc), NULL #define HRDATAD(nm,loc,wd,desc) "nm", &(loc), 16, (wd), 0, 1, (desc), NULL, 0
#define BRDATAD(nm,loc,rdx,wd,dep,desc) "nm", (loc), (rdx), (wd), 0, (dep), (desc), NULL #define FLDATAD(nm,loc,pos,desc) "nm", &(loc), 2, 1, (pos), 1, (desc), NULL, 0
#define GRDATAD(nm,loc,rdx,wd,pos,desc) "nm", &(loc), (rdx), (wd), (pos), 1, (desc), NULL, 0
#define BRDATAD(nm,loc,rdx,wd,dep,desc) "nm", (loc), (rdx), (wd), 0, (dep), (desc), NULL, 0
#define URDATAD(nm,loc,rdx,wd,off,dep,fl,desc) \ #define URDATAD(nm,loc,rdx,wd,off,dep,fl,desc) \
"nm", &(loc), (rdx), (wd), (off), (dep), (desc), NULL, ((fl) | REG_UNIT) "nm", &(loc), (rdx), (wd), (off), (dep), (desc), NULL, 0, ((fl) | REG_UNIT)
#define ORDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 8, (wd), 0, 1, (desc), (flds) #define SRDATAD(nm,loc,rdx,wd,off,dep,fl,siz,desc) \
#define DRDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 10, (wd), 0, 1, (desc), (flds) "nm", &(loc), (rdx), (wd), (off), (dep), (desc), NULL, (siz), ((fl) | REG_STRUCT)
#define HRDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 16, (wd), 0, 1, (desc), (flds) #define ORDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 8, (wd), 0, 1, (desc), (flds), 0
#define FLDATADF(nm,loc,pos,desc,flds) "nm", &(loc), 2, 1, (pos), 1, (desc), (flds) #define DRDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 10, (wd), 0, 1, (desc), (flds), 0
#define GRDATADF(nm,loc,rdx,wd,pos,desc,flds) "nm", &(loc), (rdx), (wd), (pos), 1, (desc), (flds) #define HRDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 16, (wd), 0, 1, (desc), (flds), 0
#define BRDATADF(nm,loc,rdx,wd,dep,desc,flds) "nm", (loc), (rdx), (wd), 0, (dep), (desc), (flds) #define FLDATADF(nm,loc,pos,desc,flds) "nm", &(loc), 2, 1, (pos), 1, (desc), (flds), 0
#define GRDATADF(nm,loc,rdx,wd,pos,desc,flds) "nm", &(loc), (rdx), (wd), (pos), 1, (desc), (flds), 0
#define BRDATADF(nm,loc,rdx,wd,dep,desc,flds) "nm", (loc), (rdx), (wd), 0, (dep), (desc), (flds), 0
#define URDATADF(nm,loc,rdx,wd,off,dep,fl,desc,flds) \ #define URDATADF(nm,loc,rdx,wd,off,dep,fl,desc,flds) \
"nm", &(loc), (rdx), (wd), (off), (dep), (desc), (flds), ((fl) | REG_UNIT) "nm", &(loc), (rdx), (wd), (off), (dep), (desc), (flds), 0, ((fl) | REG_UNIT)
#define SRDATADF(nm,loc,rdx,wd,off,dep,fl,siz,desc,flds) \
"nm", &(loc), (rdx), (wd), (off), (dep), (desc), (flds), (siz), ((fl) | REG_STRUCT)
#define BIT(nm) {"nm", 0xffffffff, 1} /* Single Bit definition */ #define BIT(nm) {"nm", 0xffffffff, 1} /* Single Bit definition */
#define BITNC {"", 0xffffffff, 1} /* Don't care Bit definition */ #define BITNC {"", 0xffffffff, 1} /* Don't care Bit definition */
#define BITF(nm,sz) {"nm", 0xffffffff, sz} /* Bit Field definition */ #define BITF(nm,sz) {"nm", 0xffffffff, sz} /* Bit Field definition */