plan9fox/sys/src
cinap_lenrek e77fa31516 libaml: fix IndexField and BankField implementations (thanks Michael Forney)
IndexField is supposed to increment the index value when an
access is done with a bigger size than the data field.
The index value is always a byte offset.

Now that we always calculate the offset for each field unit
access for IndexField, rename the indexv to bank (the bank
value), as it is only used for that. Also, do not compare
it with nil, as it is a integer constant which can be
encoded as nil to mean zero.

For BankField, the banking field was written using store(),
which does nothing when the destination is a Field*.
Use rwfield() to fix it in the new rwfieldunit().

Resolve all the Name*'s when IndexField, BankField and
Field are created. Now, Field.reg points to eigther
Buffer object, Region or Field (data Field of an IndexField).

PS: initial bug report by Michael Forney follows below:

In /dev/kmesg on my T14, I saw a message

	amlmapio: [0xffffff18-0x100000018] overlaps usable memory
	amlmapio: mapping \_SB.FRTP failed

Here is the relevant snippet from my DSDT:

    Scope (_SB)
    {
        ...

        OperationRegion (ECMC, SystemIO, 0x72, 0x02)
        Field (ECMC, AnyAcc, NoLock, Preserve)
        {
            ECMI,   8,
            ECMD,   8
        }

        IndexField (ECMI, ECMD, ByteAcc, NoLock, Preserve)
        {
            Offset (0x08),
            FRTB,   32
        }

        OperationRegion (FRTP, SystemMemory, FRTB, 0x0100)
        Field (FRTP, AnyAcc, NoLock, Preserve)
        {
		...
        }
    }

With some debugging output:

	amlmapio(\_SB.ECMC): Io       72 - 74
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 8
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 18
	amlmapio(\_SB.FRTP): Mem      ffffff18 - 100000018
	amlmapio: [0xffffff18-0x100000018) overlaps usable memory
	amlmapio: mapping \_SB.FRTP failed

It seems that libaml does not handle IndexField correctly and just did
a single read from ECMD after setting ECMI to 8, causing the FRTP
region to be evaluated as 0xffffff18-0x100000018. Instead, it should
be reading 4 bytes [18 c0 22 cc], evaluating it as
0xcc22c018-0xcc22118:

	amlmapio(\_SB.ECMC): Io       72 - 74
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 8
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 18
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 9
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> c0
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- a
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 22
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- b
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> cc
	amlmapio(\_SB.FRTP): Mem      cc22c018 - cc22c118

I wrote a patch (attached) to fix this, and it seems to work. Though,
it's not clear to me when things should be dereferenced. Previously,
the data field was dereferenced at evalfield, but the region and index
field were not until rwfield. After the patch, the index field is
also dereferenced in evalfield.

For BankField, the index *is* dereferenced in evalfield. I'm pretty
sure that this means that BankField does not work currently, since
store() just returns nil for 'f' objects. The bank selector will
never get set.

Anyway, I don't know if this solves any real problems; it's just
something I noticed and thought I'd try to fix.
2021-02-22 19:27:49 +01:00
..
9 ether82563: add pci id for i219-LM on thinkcenter (easypeasy, thanks hiro) 2021-02-20 19:06:59 +01:00
ape ape/lib9: expose fd2path (thanks phil9) 2021-02-20 21:02:07 -08:00
boot 9boot: handle automatic length for 64-bit values in hexfmt() for framebuffer address (thanks Michael Forney) 2021-02-20 12:55:42 +01:00
cmd upas/send: add \n to error in refuse() (thanks josuah) 2021-02-20 15:25:25 -08:00
games games/snes: use 4-point hermite interpolation to resample 2021-02-22 16:12:24 +01:00
lib9p lib9p: open internal file-descriptor with OCEXEC flag in getremotesys() 2020-12-07 14:54:27 +01:00
libaml libaml: fix IndexField and BankField implementations (thanks Michael Forney) 2021-02-22 19:27:49 +01:00
libauth libauth: re-implement procsetuser() to use /proc instead of #c/user 2020-12-23 13:10:30 +01:00
libauthsrv libauthsrv: open internal file-descriptors with OCEXEC flag 2020-12-07 16:47:06 +01:00
libavl replica: use libavl for avl tree implementation 2017-04-22 14:28:02 -05:00
libbin Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
libbio bio: add support for custom I/O handler via Biofn 2017-05-04 17:42:12 +00:00
libc libc/arm: open #c/sysstat file with OCEXEC (internal file descriptor) 2020-12-29 19:08:08 +01:00
libcomplete libcomplete: open internal file-descriptor with OCEXEC flag 2020-12-07 17:18:33 +01:00
libcontrol /sys/src/lib*: clean up 2016-11-17 22:58:16 +01:00
libdisk libdisk: catch null bytes in proto file, fix memory leaks 2018-10-20 20:32:22 +02:00
libdraw libdraw: enter/eenter: fix ^W removing the text on the right side of the tick 2021-02-04 10:57:37 +01:00
libdtracy dtracy: avoid dmachlock() race 2019-03-30 09:17:46 +01:00
libfis libfis: fix inverted CHS bit 2017-06-25 23:23:56 +00:00
libflate libflate: force non-empty huffman table in mkzprecode() for deflate 2017-12-09 18:20:29 +01:00
libframe /sys/src/lib*: clean up 2016-11-17 22:58:16 +01:00
libgeometry qball: remove unused #include <stdio.h> 2020-08-04 16:27:27 +02:00
libhtml libhtml: increase Nestmax to render some convoluted pages (thanks fernan) 2018-09-23 23:35:41 +02:00
libhttpd always zero initialize Tm structure for tm2sec() 2019-12-03 08:22:02 +01:00
libip libip: move optimized 386 assembly version of ptclbsum() from kernel to libip 2019-02-27 18:29:08 +01:00
libjson libjson: add slack space to literal string buffer to handle bad runes (thanks mischief) 2016-04-27 12:59:06 +02:00
liblex liblex: fix allprint() definition (from sources) 2012-10-03 18:18:01 +02:00
libmach libmach: remove newline 2019-05-09 10:27:17 +02:00
libmemdraw libmemdraw: remove inexistent build targets 2020-04-19 15:30:58 +02:00
libmemlayer libmemdraw/libmemlayer: get rid of drawdebug prints 2017-04-29 21:10:28 +02:00
libmp libmp: add dummy mkfile for arm64 2019-05-03 21:02:13 +02:00
libndb libndb: open internal file-descriptors with OCEXEC flag 2020-12-07 15:15:02 +01:00
libplumb libplumb: fix plumbunpackpartial() 2018-05-10 19:46:38 +02:00
libregexp libregexp: fix lexer so it doesnt move past the string when it gets a \ escape 2017-07-31 06:56:22 +02:00
libsat libsat, forp: fix va_list hack on amd64 2018-04-24 12:20:07 +01:00
libscribble /sys/src/lib*: clean up 2016-11-17 22:58:16 +01:00
libsec libsec: open internal file-descriptors with OCEXEC flag 2020-12-07 17:14:34 +01:00
libstdio libstdio: sync bits of vfprintf from APE 2021-02-19 23:04:09 +01:00
libString Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
libsunrpc Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
libthread libthread: remove unused _times() function 2020-12-19 18:47:17 +01:00
libttf libttf: fix cmap subtable offset type and rank UCS-4 higher (more codepoints). fixes runes > 0xffff 2020-08-05 14:25:21 +02:00
libventi sys/src/libventi: implement vtsha1 and vtsha1check functions 2019-09-06 11:55:18 -07:00
mkfile add dtracy to mkfile 2018-11-11 10:10:30 +00:00
mkfile.proto arm64: add mkfile 2019-05-03 21:12:31 +02:00