forked from Imagelibrary/littlefs
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:
@@ -35,8 +35,9 @@ TAG_MDIR = 0x0315 # 0x0314 v--- --11 ---1 -1rr
|
||||
TAG_MTREE = 0x031c # 0x031c v--- --11 ---1 11rr
|
||||
TAG_DID = 0x0320 # 0x0320 v--- --11 --1- ----
|
||||
TAG_BRANCH = 0x032c # 0x032c v--- --11 --1- 11rr
|
||||
TAG_UATTR = 0x0400 # 0x04aa v--- -1-a -aaa aaaa
|
||||
TAG_SATTR = 0x0600 # 0x06aa v--- -11a -aaa aaaa
|
||||
TAG_ATTR = 0x0400 ## 0x04aa v--- -1-a -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_ALT = 0x4000 ## 0x4kkk v1cd kkkk -kkk kkkk
|
||||
TAG_B = 0x0000
|
||||
@@ -213,16 +214,11 @@ def tagrepr(tag, w=None, size=None, off=None):
|
||||
else 'struct 0x%02x' % (tag & 0xff),
|
||||
' w%d' % w if w else '',
|
||||
' %s' % size if size is not None else '')
|
||||
elif (tag & 0x6e00) == TAG_UATTR:
|
||||
return '%suattr 0x%02x%s%s' % (
|
||||
elif (tag & 0x6e00) == TAG_ATTR:
|
||||
return '%s%sattr 0x%02x%s%s' % (
|
||||
'shrub' if tag & TAG_SHRUB else '',
|
||||
((tag & 0x100) >> 1) | (tag & 0xff),
|
||||
' w%d' % w if w else '',
|
||||
' %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),
|
||||
's' if tag & 0x100 else 'u',
|
||||
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||
' w%d' % w if w else '',
|
||||
' %s' % size if size is not None else '')
|
||||
elif tag & TAG_ALT:
|
||||
|
||||
Reference in New Issue
Block a user