attrs: Reduced UATTR/SATTR range down to 7-bits
It would be nice to have a full 8-bit range for both user attrs and system attrs, for both backwards compatibility and maximizing the available attr space, but I think it just doesn't make sense from an API perspective. Sure we could finagle the user/sys bit into a flags argument, or provide separate lfsr_getuattr/getsattr functions, but asking users to use a 9-bit int for higher-level operations (dynamic attrs, iteration, etc) is a bit much... So this reduces the two attr ranges down to 7-bits, requiring 8-bits total to store all possible attr types in the current system: TAG_ATTR 0x0400 v--- -1-a -aaa aaaa TAG_UATTR 0x04aa v--- -1-- -aaa aaaa TAG_SATTR 0x05aa v--- -1-1 -aaa aaaa This really just affects scripts, since we haven't actually implemented attributes yet. Worst case we still have the 9-bit encoding space carved out, so we can always add an additional set of attrs in the future if we start running into attr pressure. Or, you know, just turn on the subtype leb128 encoding the 8th subtype bit is reserved for. Then you'd only be limited by internal driver details, probably 24-bits per attr range if we make tags 32-bits internally. Though this would probably come with quite a code cost...
This commit is contained in:
@@ -1392,8 +1392,9 @@ enum lfsr_tag {
|
|||||||
LFSR_TAG_BRANCH = 0x032c,
|
LFSR_TAG_BRANCH = 0x032c,
|
||||||
|
|
||||||
// user/sys attributes
|
// user/sys attributes
|
||||||
|
LFSR_TAG_ATTR = 0x0400,
|
||||||
LFSR_TAG_UATTR = 0x0400,
|
LFSR_TAG_UATTR = 0x0400,
|
||||||
LFSR_TAG_SATTR = 0x0600,
|
LFSR_TAG_SATTR = 0x0500,
|
||||||
|
|
||||||
// shrub tags belong to secondary trees
|
// shrub tags belong to secondary trees
|
||||||
LFSR_TAG_SHRUB = 0x1000,
|
LFSR_TAG_SHRUB = 0x1000,
|
||||||
@@ -1433,13 +1434,8 @@ enum lfsr_tag {
|
|||||||
| (0x1000 & (d)) \
|
| (0x1000 & (d)) \
|
||||||
| (0x0fff & (lfsr_tag_t)(key)))
|
| (0x0fff & (lfsr_tag_t)(key)))
|
||||||
|
|
||||||
#define LFSR_TAG_UATTR(attr) \
|
#define LFSR_TAG_ATTR(attr) \
|
||||||
(LFSR_TAG_UATTR \
|
(LFSR_TAG_ATTR \
|
||||||
| ((0x80 & (lfsr_tag_t)(attr)) << 1) \
|
|
||||||
| (0x7f & (lfsr_tag_t)(attr)))
|
|
||||||
|
|
||||||
#define LFSR_TAG_SATTR(attr) \
|
|
||||||
(LFSR_TAG_SATTR \
|
|
||||||
| ((0x80 & (lfsr_tag_t)(attr)) << 1) \
|
| ((0x80 & (lfsr_tag_t)(attr)) << 1) \
|
||||||
| (0x7f & (lfsr_tag_t)(attr)))
|
| (0x7f & (lfsr_tag_t)(attr)))
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -37,8 +37,9 @@ TAG_MDIR = 0x0315 # 0x0314 v--- --11 ---1 -1rr
|
|||||||
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
||||||
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
||||||
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
||||||
TAG_UATTR = 0x0400 # 0x04aa v--- -1-a -aaa aaaa
|
TAG_ATTR = 0x0400 ## 0x04aa v--- -1-a -aaa aaaa
|
||||||
TAG_SATTR = 0x0600 # 0x06aa v--- -11a -aaa aaaa
|
TAG_UATTR = 0x0400 # 0x04aa v--- -1-- -aaa aaaa
|
||||||
|
TAG_SATTR = 0x0500 # 0x05aa v--- -1-1 -aaa aaaa
|
||||||
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
||||||
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
||||||
TAG_B = 0x0000
|
TAG_B = 0x0000
|
||||||
|
|||||||
+7
-11
@@ -35,8 +35,9 @@ TAG_MDIR = 0x0315 # 0x0314 v--- --11 ---1 -1rr
|
|||||||
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
||||||
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
||||||
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
||||||
TAG_UATTR = 0x0400 # 0x04aa v--- -1-a -aaa aaaa
|
TAG_ATTR = 0x0400 ## 0x04aa v--- -1-a -aaa aaaa
|
||||||
TAG_SATTR = 0x0600 # 0x06aa v--- -11a -aaa aaaa
|
TAG_UATTR = 0x0400 # 0x04aa v--- -1-- -aaa aaaa
|
||||||
|
TAG_SATTR = 0x0500 # 0x05aa v--- -1-1 -aaa aaaa
|
||||||
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
||||||
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
||||||
TAG_B = 0x0000
|
TAG_B = 0x0000
|
||||||
@@ -213,16 +214,11 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_UATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%suattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
's' if tag & 0x100 else 'u',
|
||||||
' w%d' % w if w else '',
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' %s' % size if size is not None else '')
|
|
||||||
elif (tag & 0x6e00) == TAG_SATTR:
|
|
||||||
return '%ssattr 0x%02x%s%s' % (
|
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
|
|||||||
+7
-11
@@ -36,8 +36,9 @@ TAG_MDIR = 0x0315 # 0x0314 v--- --11 ---1 -1rr
|
|||||||
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
||||||
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
||||||
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
||||||
TAG_UATTR = 0x0400 # 0x04aa v--- -1-a -aaa aaaa
|
TAG_ATTR = 0x0400 ## 0x04aa v--- -1-a -aaa aaaa
|
||||||
TAG_SATTR = 0x0600 # 0x06aa v--- -11a -aaa aaaa
|
TAG_UATTR = 0x0400 # 0x04aa v--- -1-- -aaa aaaa
|
||||||
|
TAG_SATTR = 0x0500 # 0x05aa v--- -1-1 -aaa aaaa
|
||||||
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
||||||
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
||||||
TAG_B = 0x0000
|
TAG_B = 0x0000
|
||||||
@@ -244,16 +245,11 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_UATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%suattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
's' if tag & 0x100 else 'u',
|
||||||
' w%d' % w if w else '',
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' %s' % size if size is not None else '')
|
|
||||||
elif (tag & 0x6e00) == TAG_SATTR:
|
|
||||||
return '%ssattr 0x%02x%s%s' % (
|
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
|
|||||||
+7
-11
@@ -35,8 +35,9 @@ TAG_MDIR = 0x0315 # 0x0314 v--- --11 ---1 -1rr
|
|||||||
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
||||||
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
||||||
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
||||||
TAG_UATTR = 0x0400 # 0x04aa v--- -1-a -aaa aaaa
|
TAG_ATTR = 0x0400 ## 0x04aa v--- -1-a -aaa aaaa
|
||||||
TAG_SATTR = 0x0600 # 0x06aa v--- -11a -aaa aaaa
|
TAG_UATTR = 0x0400 # 0x04aa v--- -1-- -aaa aaaa
|
||||||
|
TAG_SATTR = 0x0500 # 0x05aa v--- -1-1 -aaa aaaa
|
||||||
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
||||||
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
||||||
TAG_B = 0x0000
|
TAG_B = 0x0000
|
||||||
@@ -228,16 +229,11 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_UATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%suattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
's' if tag & 0x100 else 'u',
|
||||||
' w%d' % w if w else '',
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' %s' % size if size is not None else '')
|
|
||||||
elif (tag & 0x6e00) == TAG_SATTR:
|
|
||||||
return '%ssattr 0x%02x%s%s' % (
|
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
|
|||||||
+7
-11
@@ -44,8 +44,9 @@ TAG_MDIR = 0x0315 # 0x0314 v--- --11 ---1 -1rr
|
|||||||
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
||||||
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
||||||
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
||||||
TAG_UATTR = 0x0400 # 0x04aa v--- -1-a -aaa aaaa
|
TAG_ATTR = 0x0400 ## 0x04aa v--- -1-a -aaa aaaa
|
||||||
TAG_SATTR = 0x0600 # 0x06aa v--- -11a -aaa aaaa
|
TAG_UATTR = 0x0400 # 0x04aa v--- -1-- -aaa aaaa
|
||||||
|
TAG_SATTR = 0x0500 # 0x05aa v--- -1-1 -aaa aaaa
|
||||||
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
||||||
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
||||||
TAG_B = 0x0000
|
TAG_B = 0x0000
|
||||||
@@ -215,16 +216,11 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_UATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%suattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
's' if tag & 0x100 else 'u',
|
||||||
' w%d' % w if w else '',
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' %s' % size if size is not None else '')
|
|
||||||
elif (tag & 0x6e00) == TAG_SATTR:
|
|
||||||
return '%ssattr 0x%02x%s%s' % (
|
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
|
|||||||
+7
-11
@@ -33,8 +33,9 @@ TAG_MDIR = 0x0315 # 0x0314 v--- --11 ---1 -1rr
|
|||||||
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
||||||
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
||||||
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
||||||
TAG_UATTR = 0x0400 # 0x04aa v--- -1-a -aaa aaaa
|
TAG_ATTR = 0x0400 ## 0x04aa v--- -1-a -aaa aaaa
|
||||||
TAG_SATTR = 0x0600 # 0x06aa v--- -11a -aaa aaaa
|
TAG_UATTR = 0x0400 # 0x04aa v--- -1-- -aaa aaaa
|
||||||
|
TAG_SATTR = 0x0500 # 0x05aa v--- -1-1 -aaa aaaa
|
||||||
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
TAG_SHRUB = 0x1000 ## 0x1kkk v--1 kkkk -kkk kkkk
|
||||||
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
TAG_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
||||||
TAG_B = 0x0000
|
TAG_B = 0x0000
|
||||||
@@ -170,16 +171,11 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_UATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%suattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
's' if tag & 0x100 else 'u',
|
||||||
' w%d' % w if w else '',
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' %s' % size if size is not None else '')
|
|
||||||
elif (tag & 0x6e00) == TAG_SATTR:
|
|
||||||
return '%ssattr 0x%02x%s%s' % (
|
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
|
||||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
|
||||||
' w%d' % w if w else '',
|
' w%d' % w if w else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
|
|||||||
+149
-149
File diff suppressed because it is too large
Load Diff
+2009
-2009
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user