commit 592cb48e76c4d2b35597dbb9074260c33c87cfac
parent 3d39ba576c033fe8c07954abcc5d9d7e2ef9a513
Author: Roberto Vargas <roberto.vargas@arm.com>
Date: Tue, 19 Feb 2019 10:46:20 +0000
[libtypes] Remove libtypes
Change-Id: Iac45599369a4215271d1bf4f0eff2141df75fce4
Diffstat:
34 files changed, 1 insertion(+), 1283 deletions(-)
diff --git a/scripts/gencode.sh b/scripts/gencode.sh
@@ -1,117 +0,0 @@
-#/bin/sh
-
-sed '/prototypes/q' "$@" |
-awk '
-BEGIN {RS=""; FS="\n"}
-/^struct/ {split($1, w, " "); parse(w[2])}
-END {for (tag in structs) {
- gen("pack", tag)
- gen("unpack", tag)}}
-
-function parse(tag, fldnam,nfields,i,j,v,typ)
-{
- nfields = 0
- for (i = 2; i < NF; i++) {
- split($i, v, "#")
- nbits = int(v[2])
-
- sub(/^[ \t]*/, "", $i)
- sub(/;.*/, "", $i)
- n = split($i, v, /[ \t]*/)
-
- fldnam = v[n]
- typ = ""
- for (j = 1; j < n; j++) {
- if (typ != "")
- typ = typ " "
- typ = typ v[j]
- }
- fields[tag, nfields++] = typ SUBSEP fldnam SUBSEP nbits
- }
- structs[tag] = nfields
-}
-
-function buildfmt(tag, i,v,typ,nbits,fmt)
-{
- for (i = 0; i < structs[tag]; i++) {
- split(fields[tag, i], v, SUBSEP)
- typ = v[1]
- nbits = v[3]
- if (typ ~ "struct")
- fmt = fmt buildfmt(substr(typ, 8))
- else if (typ ~ /unsigned char/)
- fmt = fmt "%" nbits "c "
- else if (typ ~ /unsigned short/)
- fmt = fmt "%" nbits "hu "
- else if (typ ~ /unsigned long long/)
- fmt = fmt "%" nbits "llu "
- else if (typ ~ /unsigned long/)
- fmt = fmt "%" nbits "lu "
- }
- return fmt
-}
-
-function printfmt(tag,file, fmt,n,i,j,v)
-{
- fmt = buildfmt(tag)
- sub(/ *$/, "", fmt)
- n = split(fmt, v, / /)
-
- for (i = 1; i <= n; i += 7) {
- fmt = ""
- for (j = 0; j < 7 && i + j <= n; j++) {
- if (fmt != "")
- fmt = fmt " "
- fmt = fmt v[i+j]
- }
- printf("\t \"%s\"%s",
- fmt, (i+7 < n) ? "\n" : ",\n") >> file
- }
-}
-
-function gen(fun, tag, file,v,nbits)
-{
- file = fun "_" tag ".c"
-
- printf("#include <assert.h>\n"\
- "#include <stdint.h>\n\n"\
- "#include <types.h>\n\n"\
- "int\n"\
- "%s_%s(uint64_t buf[], struct %s *sp)\n"\
- "{\n"\
- "\tint n;\n\n"\
- "\tn = %s(buf,\n", fun, tag, tag, fun) > file
-
- printfmt(tag, file)
- printargs(fun, tag, "", file)
-
- for (i = 0; i < structs[tag]; i++) {
- split(fields[tag, i], v, SUBSEP)
- nbits += v[3]
- }
-
- print ");\n\n\tassert(n == " nbits ");\n\n"\
- "\treturn n;\n"\
- "}" >> file
-
- close(file)
-}
-
-function printargs(fun,tag,prefix,file, i,v,typ,fldnam)
-{
- for (i = 0; i < structs[tag]; i++) {
- split(fields[tag, i], v, SUBSEP)
- fldnam = v[2]
- typ = v[1]
- if (typ ~ "struct") {
- printargs(fun, substr(typ, 8), prefix fldnam ".", file)
- } else {
- printf("\t %ssp->%s%s",
- (fun == "unpack") ? "&" : "",
- prefix, fldnam) >> file
- }
- if (i != structs[tag]-1)
- print "," >> file
- }
-}
-'
diff --git a/scripts/genheaders.sh b/scripts/genheaders.sh
@@ -1,92 +0,0 @@
-#!/bin/sh
-
-awk '
-/^[^\t]/ {struct = $1; nbits = 1}
-
-/^\t[^\t]/ {if (fldname != "")
- fldname = fldname "#"
- fldname = fldname $1
- fldsize[$1] = $2
- fldbegin[$1] = nbits
- last = $1
- next}
-
-/^\t\t/ {bitnam[nbits] = $1
- bitset[nbits] = $2
- fldcnt[last]++
- nbits++}
-
-END {split(fldname, names, "#")
- gentypes()
- genstruct()
- genprotos()}
-
-function genprotos( t)
-{
- print "/* prototypes */"
- for (t in list) {
- printf("extern int pack_%s(uint64_t buf[], struct %s *sp);\n"\
- "extern int unpack_%s(uint64_t buf[], struct %s *sp);\n\n",
- t, t, t, t);
- }
-}
-
-function gentypes( f,bs,n,fld,off,res,i,name)
-{
- for (f in names) {
- fld = names[f]
- if (fldcnt[fld] == 1)
- continue
- off = fldbegin[fld]
- res = 0
-
- print "struct " struct "_" fld " {"
- for (i = 0; i < fldcnt[fld]; i++) {
- n = off + i
- name = bitnam[n]
- if (name == "res0")
- name = "res0_" res++
- bs = bitset[n]
- printf("\t%s %s;\t\t//#%d\n", type(bs), name, getbits(bs))
- }
- print "};\n"
- list[struct "_" fld] = 1
- }
-}
-
-function genstruct( f,fld,t,s,bs)
-{
- printf("struct %s {\n", struct)
- for (f in names) {
- fld = names[f]
- s = fldsize[fld]
- t = (fldcnt[fld] == 1) ? type(s) : "struct rscb_" fld
- printf("\t%s %s;\t\t//#%d\n", t, fld, s)
- }
- print "};\n"
-}
-
-
-function getbits(desc, arr,n)
-{
- n = split(desc, arr, ":")
- if (n == 1)
- return 1
- return arr[1] - arr[2]
-}
-
-function type(desc, siz)
-{
- siz = getbits(desc)
-
- if (siz <= 8)
- return "unsigned char"
- if (siz <= 16)
- return "unsigned short"
- if (siz <= 32)
- return "unsigned long"
- if (siz <= 64)
- return "unsigned long long"
- print "error"
-}
-' "$@"
diff --git a/scripts/genrscb.sh b/scripts/genrscb.sh
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-for i
-do
- case $i in
- -j)
- jsondir="-I $2"
- shift 2
- ;;
- --)
- shift
- ;;
- -*)
- echo usage: genrscb.sh [-j jsondir] [file] >&2
- exit 1
- ;;
- esac
-done
-
-jinc.sh $jsondir "$@" |
-rscb.sh |
-tr 'A-Z' 'a-z' |
-genheaders.sh |
-tee rscb.h |
-gencode.sh
diff --git a/scripts/jinc.sh b/scripts/jinc.sh
@@ -1,46 +0,0 @@
-#!/bin/sh
-
-
-include="."
-
-for i
-do
- case $i in
- -I)
- include=$2
- shift 2
- ;;
- --)
- shift
- ;;
- -*)
- echo usage: jinc.sh [-I dir] [file] >&2
- exit 1
- ;;
- esac
-done
-
-awk -v inc=$include '
-match($0, /"_include" *: *"[^"]*"/) {
- pre = substr($0, 1, RSTART-1)
- post = substr($0, RSTART+RLENGTH)
- incl = substr($0, RSTART, RLENGTH)
-
-
- split(incl, v, /:/)
- incl = v[2]
- gsub(/ *" */, "", incl)
- nf = split(incl, v, /\//)
-
- file = v[nf]
- dir = inc
- for (i = 1; i < nf; i++)
- dir = dir "/" v[i]
-
- print pre, "\"_include\":"
- system("cd " dir " && jinc.sh " file)
- print post
-
- next
-}
- {print}' "$@"
diff --git a/scripts/rscb.sh b/scripts/rscb.sh
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-jq -r '
-.register_blocks[0]._include |
-{name,
- registers: .registers |
- map(._include) |
- map({name, fieldsets: .fieldsets |
- map({width,
- values: .values |
- map({name, value, rangeset})})})} |
-.name,
-(.registers |
- map("\t" +
- (.name | ltrimstr("RSCB_")) +
- "\t" + (.fieldsets[0].width | tostring),
- (.fieldsets |
- map(.values |
- map("\t\t\t" +
- .name +
- .value +
- "\t" +
- .rangeset)[])[])))[]'
diff --git a/src/Makefile b/src/Makefile
@@ -2,7 +2,7 @@
PROJECTDIR=..
include $(PROJECTDIR)/scripts/rules.mk
-LIBS = lib9p libk libc librmu libtypes libhdl
+LIBS = lib9p libk libc librmu libhdl
IMGS = ramfw romfw
DIRS = $(LIBS) $(IMGS)
diff --git a/src/libtypes/.gitignore b/src/libtypes/.gitignore
@@ -1 +0,0 @@
-rscb.h
diff --git a/src/libtypes/Makefile b/src/libtypes/Makefile
@@ -1,45 +0,0 @@
-.POSIX:
-PROJECTDIR=../..
-include $(PROJECTDIR)/scripts/rules.mk
-
-OBJS = pack.o unpack.o \
- pack_rscb_state.o \
- unpack_rscb_state.o \
- pack_rscb_event_ctx.o \
- unpack_rscb_event_ctx.o \
- pack_rscb_sys_props.o \
- unpack_rscb_sys_props.o \
- pack_rscb_event_vec.o \
- unpack_rscb_event_vec.o \
- pack_rscb_l0rgt_hdr.o \
- unpack_rscb_l0rgt_hdr.o \
- pack_rscb_rpu_cfg.o \
- unpack_rscb_rpu_cfg.o \
- pack_rscb_ctrl.o \
- unpack_rscb_ctrl.o \
- pack_crgte.o \
- unpack_crgte.o \
- pack_l0rgte.o \
- unpack_l0rgte.o \
- pack_rgte.o \
- unpack_rgte.o \
-
-RMSA = $(JSONDIR)/RMSA.json # gendep.sh expects this var after OBJS
-TARGET = $(LIBDIR)/libtypes.a
-
-$(TARGET): $(OBJS)
-
-all: $(TARGET)
-
-gen: rscb.h FORCE
- gendep.sh -I $(INCDIR) rscb.h
-
-rscb.h: $(JSONDIR)/version
- genrscb.sh -j $(JSONDIR) $(RMSA)
- git log -n1 | awk '/commit/ {print $2}' > json-version
-
-$(TARGET): $(OBJS)
- mklib -o $@ $?
-
-clean:
- rm -f rscb.h
diff --git a/src/libtypes/gendep.sh b/src/libtypes/gendep.sh
@@ -1,52 +0,0 @@
-#!/bin/sh
-
-set -e
-
-for i
-do
- case $i in
- -I)
- inc=$2/
- shift 2
- ;;
- --)
- shift
- ;;
- -*)
- echo usage: gendep.sh [-I dir] files ... >&2
- exit 1
- esac
-done
-
-tmp=tmp1.$$
-trap 'rm -f $tmp1 $tmp2;exit $?' EXIT HUP INT QUIT TERM
-
-
-(cat <<'EOF'
-#if __GNUC__ || __clang__
-#define UNPACKFMT __attribute__ ((format (scanf, 2, 3)))
-#define PACKFMT __attribute__ ((format (printf, 2, 3)))
-#else
-#define UNPACKFMT
-#define PACKFMT
-#endif
-
-extern int unpack(uint64_t buf[], const char *fmt, ...) UNPACKFMT;
-extern int pack(uint64_t buf[], const char *fmt, ...) PACKFMT;
-EOF
-
-cat "$@") > $tmp && mv $tmp ${inc}types.h
-
-(echo H
-echo '/^OBJS/;/^RMSA/-c'
-printf 'OBJS = pack.o unpack.o \\\n'
-for i
-do
- sed -n '/prototypes/,$ {
- /prototypes/d
- /^$/d
- s/extern int \(.*\)(.*/ \1.o \\/p
- }' $i
-done
-printf "\n.\nw\n"
-) | ed -s Makefile
diff --git a/src/libtypes/json-version b/src/libtypes/json-version
@@ -1 +0,0 @@
-15f36f5980bcccf456d4abe53efec532b2b432b9
diff --git a/src/libtypes/pack.c b/src/libtypes/pack.c
@@ -1,123 +0,0 @@
-#include <stdarg.h>
-#include <stdint.h>
-
-#include <types.h>
-
-static uint64_t
-setbits(uint64_t dst, uint64_t src, int pos, int num)
-{
- uint64_t mask;
-
- if (num == 64) {
- mask = 0;
- } else {
- mask = ~(~0ull << num);
- mask = ~(mask << pos);
- }
-
- dst &= mask;
- dst |= src << pos;
- return dst;
-}
-
-/*
- * This function stores a field of length `num` in the logical bitstream
- * represented by `buf[]` with the value from `v` starting at
- * position `pos`. Each word in `buf[]` is 64 bits. If the field
- * spans 2 words in `buf[]` then the required bits of both words are stored.
- */
-static void
-setfield(uint64_t buf[], uint64_t v, int pos, int num)
-{
- int n, word, bit, rem;
-
- word = pos / 64; /* 1st word of the field */
- bit = pos % 64; /* offset in the 1st word */
-
- n = (bit + num < 64) ? num : 64 - bit;
- buf[word] = setbits(buf[word], v, bit, n);
- rem = num - n;
- if (rem != 0)
- buf[word+1] = setbits(buf[word+1], v >> n, 0, rem);
-}
-
-int
-pack(uint64_t buf[], const char *fmt, ...)
-{
- va_list va;
- int pos, nbits, ret = -1;
-
- va_start(va, fmt);
- for (pos = 0; *fmt; pos += nbits) {
- int d, size;
- unsigned long long v;
-
- nbits = 0;
- if (*fmt == ' ') {
- fmt++;
- continue;
- }
-
- if (*fmt++ != '%')
- goto err;
-
- while (*fmt >= '0' && *fmt <= '9') {
- d = *fmt++ - '0';
- nbits = nbits * 10 + d;
- }
- if (nbits == 0)
- goto err;
-
- size = 0;
-flags:
- switch (*fmt++) {
- case 'c':
- if (nbits > 8)
- goto err;
- v = va_arg(va, unsigned);
- setfield(buf, v, pos, nbits);
- break;
- case 'h':
- size = 1;
- goto flags;
- case 'l':
- size += 2;
- goto flags;
- case 'u':
- switch (size) {
- case 0:
- if (nbits > 16)
- goto err;
- v = va_arg(va, unsigned);
- setfield(buf, v, pos, nbits);
- break;
- case 1:
- if (nbits > 16)
- goto err;
- v = va_arg(va, unsigned);
- setfield(buf, v, pos, nbits);
- break;
- case 2:
- if (nbits > 32)
- goto err;
- v = va_arg(va, unsigned long);
- setfield(buf, v, pos, nbits);
- break;
- case 4:
- if (nbits > 64)
- goto err;
- v = va_arg(va, unsigned long long);
- setfield(buf, v, pos, nbits);
- break;
- default:
- goto err;
- }
- break;
- }
- }
- va_end(va);
-
- ret = pos;
-err:
- return ret;
-}
diff --git a/src/libtypes/pack_crgte.c b/src/libtypes/pack_crgte.c
@@ -1,18 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_crgte(uint64_t buf[], struct crgte *sp)
-{
- int n;
-
- n = pack(buf,
- "%2c",
- sp->props);
-
- assert(n == 2);
-
- return n;
-}
diff --git a/src/libtypes/pack_l0rgte.c b/src/libtypes/pack_l0rgte.c
@@ -1,28 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_l0rgte(uint64_t buf[], struct l0rgte *sp)
-{
- int n;
-
- n = pack(buf,
- "%1c %1c %1c %5c %4c %40llu"
- "%12u %12u %40llu %12u",
- sp->valid,
- sp->l1rgt_en,
- sp->crgt_en,
- sp->type,
- sp->res0_0,
- sp->baddr,
- sp->res0_1,
- sp->start,
- sp->cbaddr,
- sp->end);
-
- assert(n == 128);
-
- return n;
-}
diff --git a/src/libtypes/pack_rgte.c b/src/libtypes/pack_rgte.c
@@ -1,36 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rgte(uint64_t buf[], struct rgte *sp)
-{
- int n;
-
- n = pack(buf,
- "%4c %3c %1c %2c %2c %40llu"
- "%8c %4c %1c %3c %1c %1c %1c"
- "%2c %3c %44llu %8c",
- sp->state,
- sp->owner_perms,
- sp->visibility,
- sp->global_perms,
- sp->secure_access,
- sp->owner,
- sp->res0_0,
- sp->fuse_level,
- sp->lock,
- sp->lock_ext,
- sp->pin,
- sp->integ,
- sp->res0_1,
- sp->export_depth,
- sp->res0_2,
- sp->mapped_addr,
- sp->res0_3);
-
- assert(n == 128);
-
- return n;
-}
diff --git a/src/libtypes/pack_rscb.c b/src/libtypes/pack_rscb.c
@@ -1,76 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rscb(uint64_t buf[], struct rscb *sp)
-{
- int n;
-
- n = pack(buf,
- "%1c %1c %1c %1c %1c %1c %1c"
- "%1c %55llu %1c %5c %1c %5c %7c"
- "%7c %1c %4c %5c %39llu %3c %1c"
- "%1c %1c %1c %64c %32c %32c %32c"
- "%1c %2c %1c %1c %1c %1c %22lu"
- "%32c %32c %32c %32c %64c %7c %23lu"
- "%1c %1c %1c %1c %1c %26lu %5c"
- "%5c %39llu %3c",
- sp->ctrl.en,
- sp->ctrl.preg_lock,
- sp->ctrl.dbg,
- sp->ctrl.res0_0,
- sp->ctrl.rmu_wlock,
- sp->ctrl.rot_wlock,
- sp->ctrl.rscb_lock,
- sp->ctrl.alive,
- sp->ctrl.res0_1,
- sp->rpu_cfg.rpgsize,
- sp->rpu_cfg.res0_0,
- sp->rpu_cfg.spec,
- sp->rpu_cfg.res0_1,
- sp->rpu_cfg.srpupriv,
- sp->rpu_cfg.pepriv,
- sp->l0rgt_hdr.valid,
- sp->l0rgt_hdr.entries,
- sp->l0rgt_hdr.segsize,
- sp->l0rgt_hdr.baddr,
- sp->l0rgt_hdr.res0_0,
- sp->l0rgt_hdr.irgn,
- sp->l0rgt_hdr.orgn,
- sp->l0rgt_hdr.sh,
- sp->l0rgt_hdr.res0_1,
- sp->global_lock,
- sp->hw_ver,
- sp->rom_ver,
- sp->ram_ver,
- sp->sys_props.rpu,
- sp->sys_props.enc,
- sp->sys_props.res0_0,
- sp->sys_props.integ,
- sp->sys_props.zero,
- sp->sys_props.dram_pkg,
- sp->sys_props.res0_1,
- sp->gp0,
- sp->gp1,
- sp->gp2,
- sp->gp3,
- sp->nonce,
- sp->state.extdbg,
- sp->state.res0_0,
- sp->event_vec.fatal,
- sp->event_vec.sram_ras,
- sp->event_vec.preg_wb,
- sp->event_vec.rpu_err,
- sp->event_vec.mpe_err,
- sp->event_vec.res0_0,
- sp->event_ctx.index,
- sp->event_ctx.client,
- sp->event_ctx.addr,
- sp->event_ctx.subtype);
-
- assert(n == 672);
-
- return n;
-}
diff --git a/src/libtypes/pack_rscb_ctrl.c b/src/libtypes/pack_rscb_ctrl.c
@@ -1,27 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rscb_ctrl(uint64_t buf[], struct rscb_ctrl *sp)
-{
- int n;
-
- n = pack(buf,
- "%1c %1c %1c %1c %1c %1c %1c"
- "%1c %55llu",
- sp->en,
- sp->preg_lock,
- sp->dbg,
- sp->res0_0,
- sp->rmu_wlock,
- sp->rot_wlock,
- sp->rscb_lock,
- sp->alive,
- sp->res0_1);
-
- assert(n == 63);
-
- return n;
-}
diff --git a/src/libtypes/pack_rscb_event_ctx.c b/src/libtypes/pack_rscb_event_ctx.c
@@ -1,21 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rscb_event_ctx(uint64_t buf[], struct rscb_event_ctx *sp)
-{
- int n;
-
- n = pack(buf,
- "%5c %5c %39llu %3c",
- sp->index,
- sp->client,
- sp->addr,
- sp->subtype);
-
- assert(n == 52);
-
- return n;
-}
diff --git a/src/libtypes/pack_rscb_event_vec.c b/src/libtypes/pack_rscb_event_vec.c
@@ -1,23 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rscb_event_vec(uint64_t buf[], struct rscb_event_vec *sp)
-{
- int n;
-
- n = pack(buf,
- "%1c %1c %1c %1c %1c %26lu",
- sp->fatal,
- sp->sram_ras,
- sp->preg_wb,
- sp->rpu_err,
- sp->mpe_err,
- sp->res0_0);
-
- assert(n == 31);
-
- return n;
-}
diff --git a/src/libtypes/pack_rscb_l0rgt_hdr.c b/src/libtypes/pack_rscb_l0rgt_hdr.c
@@ -1,27 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rscb_l0rgt_hdr(uint64_t buf[], struct rscb_l0rgt_hdr *sp)
-{
- int n;
-
- n = pack(buf,
- "%1c %4c %5c %39llu %3c %1c %1c"
- "%1c %1c",
- sp->valid,
- sp->entries,
- sp->segsize,
- sp->baddr,
- sp->res0_0,
- sp->irgn,
- sp->orgn,
- sp->sh,
- sp->res0_1);
-
- assert(n == 56);
-
- return n;
-}
diff --git a/src/libtypes/pack_rscb_rpu_cfg.c b/src/libtypes/pack_rscb_rpu_cfg.c
@@ -1,23 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rscb_rpu_cfg(uint64_t buf[], struct rscb_rpu_cfg *sp)
-{
- int n;
-
- n = pack(buf,
- "%1c %5c %1c %5c %7c %7c",
- sp->rpgsize,
- sp->res0_0,
- sp->spec,
- sp->res0_1,
- sp->srpupriv,
- sp->pepriv);
-
- assert(n == 26);
-
- return n;
-}
diff --git a/src/libtypes/pack_rscb_state.c b/src/libtypes/pack_rscb_state.c
@@ -1,19 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rscb_state(uint64_t buf[], struct rscb_state *sp)
-{
- int n;
-
- n = pack(buf,
- "%7c %23lu",
- sp->extdbg,
- sp->res0_0);
-
- assert(n == 30);
-
- return n;
-}
diff --git a/src/libtypes/pack_rscb_sys_props.c b/src/libtypes/pack_rscb_sys_props.c
@@ -1,24 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-pack_rscb_sys_props(uint64_t buf[], struct rscb_sys_props *sp)
-{
- int n;
-
- n = pack(buf,
- "%1c %2c %1c %1c %1c %1c %22lu",
- sp->rpu,
- sp->enc,
- sp->res0_0,
- sp->integ,
- sp->zero,
- sp->dram_pkg,
- sp->res0_1);
-
- assert(n == 29);
-
- return n;
-}
diff --git a/src/libtypes/unpack.c b/src/libtypes/unpack.c
@@ -1,113 +0,0 @@
-#include <stdarg.h>
-#include <stdint.h>
-
-#include <types.h>
-
-static uint64_t
-getbits(uint64_t v, int pos, int num)
-{
- uint64_t mask = (num == 64) ? ~0ull : ~(~0ull << num);
-
- return (v >> pos) & mask;
-}
-
-/*
- * This function extracts a field of length `num` in the
- * logical bitstream represented by `buf[]` starting at position `pos`.
- * Each word in `buf[]` is 64 bits. If the field spans 2 words
- * then it extracts the bits from the two words and returns the composed result.
- */
-static uint64_t
-getfield(uint64_t buf[], int pos, int num)
-{
- int n, word, bit, rem;
- unsigned long long v;
-
- word = pos / 64; /* 1st word of the field */
- bit = pos % 64; /* offset in the 1st word */
-
- n = (bit + num < 64) ? num : 64 - bit;
- v = getbits(buf[word], bit, n);
- rem = num - n;
- if (rem != 0)
- v |= getbits(buf[word+1], 0, rem) << n;
-
- return v;
-}
-
-int
-unpack(uint64_t buf[], const char *fmt, ...)
-{
- va_list va;
- int pos, nbits, ret = -1;
-
- va_start(va, fmt);
- for (pos = 0; *fmt; pos += nbits) {
- int d, size;
- unsigned long long v;
-
- nbits = 0;
- if (*fmt == ' ') {
- fmt++;
- continue;
- }
-
- if (*fmt++ != '%')
- goto err;
-
- while (*fmt >= '0' && *fmt <= '9') {
- d = *fmt++ - '0';
- nbits = nbits * 10 + d;
- }
- if (nbits == 0)
- goto err;
-
- size = 0;
- v = getfield(buf, pos, nbits);
-flags:
- switch (*fmt++) {
- case 'c':
- if (nbits > 8)
- goto err;
- *va_arg(va, unsigned char *) = v;
- break;
- case 'h':
- size = 1;
- goto flags;
- case 'l':
- size += 2;
- goto flags;
- case 'u':
- switch (size) {
- case 0:
- if (nbits > 16)
- goto err;
- *va_arg(va, unsigned *) = v;
- break;
- case 1:
- if (nbits > 16)
- goto err;
- *va_arg(va, unsigned short *) = v;
- break;
- case 2:
- if (nbits > 32)
- goto err;
- *va_arg(va, unsigned long *) = v;
- break;
- case 4:
- if (nbits > 64)
- goto err;
- *va_arg(va, unsigned long long *) = v;
- break;
- default:
- goto err;
- }
- break;
- }
- }
- va_end(va);
-
- ret = pos;
-err:
- return ret;
-}
diff --git a/src/libtypes/unpack_crgte.c b/src/libtypes/unpack_crgte.c
@@ -1,18 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_crgte(uint64_t buf[], struct crgte *sp)
-{
- int n;
-
- n = unpack(buf,
- "%2c",
- &sp->props);
-
- assert(n == 2);
-
- return n;
-}
diff --git a/src/libtypes/unpack_l0rgte.c b/src/libtypes/unpack_l0rgte.c
@@ -1,28 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_l0rgte(uint64_t buf[], struct l0rgte *sp)
-{
- int n;
-
- n = unpack(buf,
- "%1c %1c %1c %5c %4c %40llu"
- "%12u %12u %40llu %12u",
- &sp->valid,
- &sp->l1rgt_en,
- &sp->crgt_en,
- &sp->type,
- &sp->res0_0,
- &sp->baddr,
- &sp->res0_1,
- &sp->start,
- &sp->cbaddr,
- &sp->end);
-
- assert(n == 128);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rgte.c b/src/libtypes/unpack_rgte.c
@@ -1,36 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rgte(uint64_t buf[], struct rgte *sp)
-{
- int n;
-
- n = unpack(buf,
- "%4c %3c %1c %2c %2c %40llu"
- "%8c %4c %1c %3c %1c %1c %1c"
- "%2c %3c %44llu %8c",
- &sp->state,
- &sp->owner_perms,
- &sp->visibility,
- &sp->global_perms,
- &sp->secure_access,
- &sp->owner,
- &sp->res0_0,
- &sp->fuse_level,
- &sp->lock,
- &sp->lock_ext,
- &sp->pin,
- &sp->integ,
- &sp->res0_1,
- &sp->export_depth,
- &sp->res0_2,
- &sp->mapped_addr,
- &sp->res0_3);
-
- assert(n == 128);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rscb.c b/src/libtypes/unpack_rscb.c
@@ -1,76 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rscb(uint64_t buf[], struct rscb *sp)
-{
- int n;
-
- n = unpack(buf,
- "%1c %1c %1c %1c %1c %1c %1c"
- "%1c %55llu %1c %5c %1c %5c %7c"
- "%7c %1c %4c %5c %39llu %3c %1c"
- "%1c %1c %1c %64c %32c %32c %32c"
- "%1c %2c %1c %1c %1c %1c %22lu"
- "%32c %32c %32c %32c %64c %7c %23lu"
- "%1c %1c %1c %1c %1c %26lu %5c"
- "%5c %39llu %3c",
- &sp->ctrl.en,
- &sp->ctrl.preg_lock,
- &sp->ctrl.dbg,
- &sp->ctrl.res0_0,
- &sp->ctrl.rmu_wlock,
- &sp->ctrl.rot_wlock,
- &sp->ctrl.rscb_lock,
- &sp->ctrl.alive,
- &sp->ctrl.res0_1,
- &sp->rpu_cfg.rpgsize,
- &sp->rpu_cfg.res0_0,
- &sp->rpu_cfg.spec,
- &sp->rpu_cfg.res0_1,
- &sp->rpu_cfg.srpupriv,
- &sp->rpu_cfg.pepriv,
- &sp->l0rgt_hdr.valid,
- &sp->l0rgt_hdr.entries,
- &sp->l0rgt_hdr.segsize,
- &sp->l0rgt_hdr.baddr,
- &sp->l0rgt_hdr.res0_0,
- &sp->l0rgt_hdr.irgn,
- &sp->l0rgt_hdr.orgn,
- &sp->l0rgt_hdr.sh,
- &sp->l0rgt_hdr.res0_1,
- &sp->global_lock,
- &sp->hw_ver,
- &sp->rom_ver,
- &sp->ram_ver,
- &sp->sys_props.rpu,
- &sp->sys_props.enc,
- &sp->sys_props.res0_0,
- &sp->sys_props.integ,
- &sp->sys_props.zero,
- &sp->sys_props.dram_pkg,
- &sp->sys_props.res0_1,
- &sp->gp0,
- &sp->gp1,
- &sp->gp2,
- &sp->gp3,
- &sp->nonce,
- &sp->state.extdbg,
- &sp->state.res0_0,
- &sp->event_vec.fatal,
- &sp->event_vec.sram_ras,
- &sp->event_vec.preg_wb,
- &sp->event_vec.rpu_err,
- &sp->event_vec.mpe_err,
- &sp->event_vec.res0_0,
- &sp->event_ctx.index,
- &sp->event_ctx.client,
- &sp->event_ctx.addr,
- &sp->event_ctx.subtype);
-
- assert(n == 672);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rscb_ctrl.c b/src/libtypes/unpack_rscb_ctrl.c
@@ -1,27 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rscb_ctrl(uint64_t buf[], struct rscb_ctrl *sp)
-{
- int n;
-
- n = unpack(buf,
- "%1c %1c %1c %1c %1c %1c %1c"
- "%1c %55llu",
- &sp->en,
- &sp->preg_lock,
- &sp->dbg,
- &sp->res0_0,
- &sp->rmu_wlock,
- &sp->rot_wlock,
- &sp->rscb_lock,
- &sp->alive,
- &sp->res0_1);
-
- assert(n == 63);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rscb_event_ctx.c b/src/libtypes/unpack_rscb_event_ctx.c
@@ -1,21 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rscb_event_ctx(uint64_t buf[], struct rscb_event_ctx *sp)
-{
- int n;
-
- n = unpack(buf,
- "%5c %5c %39llu %3c",
- &sp->index,
- &sp->client,
- &sp->addr,
- &sp->subtype);
-
- assert(n == 52);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rscb_event_vec.c b/src/libtypes/unpack_rscb_event_vec.c
@@ -1,23 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rscb_event_vec(uint64_t buf[], struct rscb_event_vec *sp)
-{
- int n;
-
- n = unpack(buf,
- "%1c %1c %1c %1c %1c %26lu",
- &sp->fatal,
- &sp->sram_ras,
- &sp->preg_wb,
- &sp->rpu_err,
- &sp->mpe_err,
- &sp->res0_0);
-
- assert(n == 31);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rscb_l0rgt_hdr.c b/src/libtypes/unpack_rscb_l0rgt_hdr.c
@@ -1,27 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rscb_l0rgt_hdr(uint64_t buf[], struct rscb_l0rgt_hdr *sp)
-{
- int n;
-
- n = unpack(buf,
- "%1c %4c %5c %39llu %3c %1c %1c"
- "%1c %1c",
- &sp->valid,
- &sp->entries,
- &sp->segsize,
- &sp->baddr,
- &sp->res0_0,
- &sp->irgn,
- &sp->orgn,
- &sp->sh,
- &sp->res0_1);
-
- assert(n == 56);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rscb_rpu_cfg.c b/src/libtypes/unpack_rscb_rpu_cfg.c
@@ -1,23 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rscb_rpu_cfg(uint64_t buf[], struct rscb_rpu_cfg *sp)
-{
- int n;
-
- n = unpack(buf,
- "%1c %5c %1c %5c %7c %7c",
- &sp->rpgsize,
- &sp->res0_0,
- &sp->spec,
- &sp->res0_1,
- &sp->srpupriv,
- &sp->pepriv);
-
- assert(n == 26);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rscb_state.c b/src/libtypes/unpack_rscb_state.c
@@ -1,19 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rscb_state(uint64_t buf[], struct rscb_state *sp)
-{
- int n;
-
- n = unpack(buf,
- "%7c %23lu",
- &sp->extdbg,
- &sp->res0_0);
-
- assert(n == 30);
-
- return n;
-}
diff --git a/src/libtypes/unpack_rscb_sys_props.c b/src/libtypes/unpack_rscb_sys_props.c
@@ -1,24 +0,0 @@
-#include <assert.h>
-#include <stdint.h>
-
-#include <types.h>
-
-int
-unpack_rscb_sys_props(uint64_t buf[], struct rscb_sys_props *sp)
-{
- int n;
-
- n = unpack(buf,
- "%1c %2c %1c %1c %1c %1c %22lu",
- &sp->rpu,
- &sp->enc,
- &sp->res0_0,
- &sp->integ,
- &sp->zero,
- &sp->dram_pkg,
- &sp->res0_1);
-
- assert(n == 29);
-
- return n;
-}