diff options
author | Renato Botelho <renato@netgate.com> | 2016-10-06 07:48:56 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-10-06 07:48:56 -0300 |
commit | fa098ef31c4cf4ddab63aced6553fef24c185eea (patch) | |
tree | 889bed18c879ec9a159ac7ceca8c175fe3dbffa8 | |
parent | 4548300e7a07c11f157a8ca76565517d2483df36 (diff) | |
parent | ad44cbcf96571d28c76d58c4beff77c8f2af28cb (diff) | |
download | FreeBSD-src-fa098ef31c4cf4ddab63aced6553fef24c185eea.zip FreeBSD-src-fa098ef31c4cf4ddab63aced6553fef24c185eea.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
397 files changed, 24864 insertions, 14777 deletions
diff --git a/etc/periodic/security/100.chksetuid b/etc/periodic/security/100.chksetuid index 95920a6..da8d29d 100755 --- a/etc/periodic/security/100.chksetuid +++ b/etc/periodic/security/100.chksetuid @@ -46,7 +46,7 @@ then echo "" echo 'Checking setuid files and devices:' MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'` - find -sx $MP /dev/null -type f \ + find -sx $MP /dev/null \( ! -fstype local \) -prune -o -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ \( -perm -u+s -or -perm -g+s \) -exec ls -liTd \{\} \+ | check_diff setuid - "${host} setuid diffs:" diff --git a/etc/periodic/security/110.neggrpperm b/etc/periodic/security/110.neggrpperm index 1d545ac..bd94015 100755 --- a/etc/periodic/security/110.neggrpperm +++ b/etc/periodic/security/110.neggrpperm @@ -44,7 +44,7 @@ then echo "" echo 'Checking negative group permissions:' MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'` - n=$(find -sx $MP /dev/null -type f \ + n=$(find -sx $MP /dev/null \( ! -fstype local \) -prune -o -type f \ \( \( ! -perm +010 -and -perm +001 \) -or \ \( ! -perm +020 -and -perm +002 \) -or \ \( ! -perm +040 -and -perm +004 \) \) \ diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index 2be6358..89703ec 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -301,10 +301,11 @@ label: * XXX This is bogus if parsed before hour-related * specifiers. */ + if (tm->tm_hour > 12) + return (NULL); + len = strlen(tptr->am); if (strncasecmp_l(buf, tptr->am, len, locale) == 0) { - if (tm->tm_hour > 12) - return (NULL); if (tm->tm_hour == 12) tm->tm_hour = 0; buf += len; @@ -313,8 +314,6 @@ label: len = strlen(tptr->pm); if (strncasecmp_l(buf, tptr->pm, len, locale) == 0) { - if (tm->tm_hour > 12) - return (NULL); if (tm->tm_hour != 12) tm->tm_hour += 12; buf += len; @@ -374,15 +373,17 @@ label: break; + case 'u': case 'w': if (!isdigit_l((unsigned char)*buf, locale)) return (NULL); - i = *buf - '0'; - if (i > 6) + i = *buf++ - '0'; + if (i < 0 || i > 7 || (c == 'u' && i < 1) || + (c == 'w' && i > 6)) return (NULL); - tm->tm_wday = i; + tm->tm_wday = i % 7; flags |= FLAG_WDAY; break; @@ -581,10 +582,16 @@ label: i *= 10; i += *buf - '0'; buf++; + } else if (len == 2) { + i *= 100; + break; } else return (NULL); } + if (i > 1400 || (sign == -1 && i > 1200) || + (i % 100) >= 60) + return (NULL); tm->tm_hour -= sign * (i / 100); tm->tm_min -= sign * (i % 100); *GMTp = 1; @@ -609,17 +616,28 @@ label: TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1); flags |= FLAG_YDAY; } else if (day_offset != -1) { + int tmpwday, tmpyday, fwo; + + fwo = first_wday_of(tm->tm_year + TM_YEAR_BASE); + /* No incomplete week (week 0). */ + if (week_offset == 0 && fwo == day_offset) + return (NULL); + /* Set the date to the first Sunday (or Monday) * of the specified week of the year. */ - if (!(flags & FLAG_WDAY)) { - tm->tm_wday = day_offset; - flags |= FLAG_WDAY; + tmpwday = (flags & FLAG_WDAY) ? tm->tm_wday : + day_offset; + tmpyday = (7 - fwo + day_offset) % 7 + + (week_offset - 1) * 7 + + (tmpwday - day_offset + 7) % 7; + /* Impossible yday for incomplete week (week 0). */ + if (tmpyday < 0) { + if (flags & FLAG_WDAY) + return (NULL); + tmpyday = 0; } - tm->tm_yday = (7 - - first_wday_of(tm->tm_year + TM_YEAR_BASE) + - day_offset) % 7 + (week_offset - 1) * 7 + - tm->tm_wday - day_offset; + tm->tm_yday = tmpyday; flags |= FLAG_YDAY; } } diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index cb5575c..e4c89d0 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -316,6 +316,8 @@ MAN+= sctp_generic_recvmsg.2 \ sync.2 \ sysarch.2 \ syscall.2 \ + thr_suspend.2 \ + thr_wake.2 \ timer_create.2 \ timer_delete.2 \ timer_settime.2 \ diff --git a/lib/libc/sys/poll.2 b/lib/libc/sys/poll.2 index a1c7ada..466523b 100644 --- a/lib/libc/sys/poll.2 +++ b/lib/libc/sys/poll.2 @@ -180,7 +180,6 @@ specifies a signal mask which is set while waiting for input. When .Fn ppoll returns, the original signal mask is restored. -.Pp .Bd -literal struct timespec { time_t tv_sec; /* seconds */ diff --git a/lib/libc/sys/thr_suspend.2 b/lib/libc/sys/thr_suspend.2 new file mode 100644 index 0000000..b470d18 --- /dev/null +++ b/lib/libc/sys/thr_suspend.2 @@ -0,0 +1,130 @@ +.\" Copyright (c) 2016 The FreeBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This documentation was written by +.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship +.\" from the FreeBSD Foundation. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd September 23, 2016 +.Dt THR_SUSPEND 2 +.Os +.Sh NAME +.Nm thr_suspend +.Nd suspend the calling thread +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/thr.h +.Ft int +.Fn thr_suspend "struct timespec *timeout" +.Sh DESCRIPTION +.Bf -symbolic +This function is intended for implementing threading. +Normal applications should use +.Xr pthread_cond_timedwait 3 +together with +.Xr pthread_cond_broadcast 3 +for typical safe suspension with cooperation of the thread +being suspended, or +.Xr pthread_suspend_np 3 +and +.Xr pthread_resume_np 3 +in some specific situations, instead. +.Ef +.Pp +The +.Fn thr_suspend +system call puts the calling thread in a suspended state, where it is +not eligible for CPU time. +This state is exited by another thread calling +.Xr thr_wake 2 , +when the time interval specified by +.Fa timeout +has elapsed, +or by the delivery of a signal to the suspended thread. +.Pp +If the +.Fa timeout +argument is +.Dv NULL , +the suspended state can be only terminated by explicit +.Fn thr_wake +or signal. +.Pp +If a wake from +.Xr thr_wake 2 +was delivered before the +.Nm +call, the thread is not put into a suspended state. +Instead, the call +returns immediately without an error. +.Pp +If a thread previously called +.Xr thr_wake 2 +with its own thread identifier, which resulted in setting the internal kernel +flag to immediately abort interruptible sleeps with an +.Er EINTR +error +.Po +see +.Xr thr_wake 2 +.Pc , +the flag is cleared. +As with +.Xr thr_wake 2 +called from another thread, the next +.Nm +call does not result in suspension. +.Pp +.Sh RETURN VALUES +.Rv -std thr_suspend +.Sh ERRORS +The +.Fn thr_suspend +operation returns the following errors: +.Bl -tag -width Er +.It Bq Er EFAULT +The memory pointed to by the +.Fa timeout +argument is not valid. +.It Bq Er ETIMEDOUT +The specified timeout expired. +.It Bq Er ETIMEDOUT +The +.Fa timeout +argument specified a zero time interval. +.It Bq Er EINTR +The sleep was interrupted by a signal. +.El +.Sh SEE ALSO +.Xr ps 1 , +.Xr thr_wake 2 , +.Xr pthread_resume_np 3 , +.Xr pthread_suspend_np 3 +.Sh STANDARDS +The +.Fn thr_suspend +system call is non-standard. diff --git a/lib/libc/sys/thr_wake.2 b/lib/libc/sys/thr_wake.2 new file mode 100644 index 0000000..59df7d2 --- /dev/null +++ b/lib/libc/sys/thr_wake.2 @@ -0,0 +1,112 @@ +.\" Copyright (c) 2016 The FreeBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This documentation was written by +.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship +.\" from the FreeBSD Foundation. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd September 23, 2016 +.Dt THR_WAKE 2 +.Os +.Sh NAME +.Nm thr_wake +.Nd wake up the suspended thread +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/thr.h +.Ft int +.Fn thr_wake "long id" +.Sh DESCRIPTION +.Bf -symbolic +This function is intended for implementing threading. +Normal applications should use +.Xr pthread_cond_timedwait 3 +together with +.Xr pthread_cond_broadcast 3 +for typical safe suspension with cooperation of the thread +being suspended, or +.Xr pthread_suspend_np 3 +and +.Xr pthread_resume_np 3 +in some specific situations, instead. +.Ef +.Pp +Passing the thread identifier of the calling thread +.Po +see +.Xr thr_self 2 +.Pc +to +.Fn thr_wake +sets a thread's flag to cause the next signal-interruptible sleep +of that thread in the kernel to fail immediately with the +.Er EINTR +error. +The flag is cleared by an interruptible sleep attempt or by a call to +.Xr thr_suspend 2. +This is used by the system threading library to implement cancellation. +.Pp +If +.Fa id +is not equal to the current thread identifier, the specified thread is +woken up if suspended by the +.Xr thr_suspend +system call. +If the thread is not suspended at the time of the +.Nm +call, the wake is remembered and the next attempt of the thread to +suspend itself with the +.Xr thr_suspend 2 +results in immediate return with success. +Only one wake is remembered. +.Sh RETURN VALUES +.Rv -std thr_wake +.Sh ERRORS +The +.Fn thr_wake +operation returns these errors: +.Bl -tag -width Er +.It Bq Er ESRCH +The specified thread was not found or does not belong to the process +of the calling thread. +.El +.Sh SEE ALSO +.Xr ps 1 , +.Xr thr_self 2 +.Xr thr_suspend 2 , +.Xr pthread_cancel 3 , +.Xr pthread_resume_np 3 , +.Xr pthread_suspend_np 3 +.Sh STANDARDS +The +.Fn thr_suspend +system call is non-standard and is used by +.Lb libthr +to implement +.St -p1003.1-2001 +.Xr pthread 3 +functionality. diff --git a/lib/libdevctl/devctl.3 b/lib/libdevctl/devctl.3 index 7c4c74b..de4a9b6 100644 --- a/lib/libdevctl/devctl.3 +++ b/lib/libdevctl/devctl.3 @@ -25,12 +25,13 @@ .\" .\" $FreeBSD$ .\" -.Dd February 2, 2016 +.Dd August 29, 2016 .Dt DEVCTL 3 .Os .Sh NAME .Nm devctl , .Nm devctl_attach , +.Nm devctl_clear_driver , .Nm devctl_detach , .Nm devctl_disable , .Nm devctl_enable , @@ -43,6 +44,8 @@ .Ft int .Fn devctl_attach "const char *device" .Ft int +.Fn devctl_clear_driver "const char *device" "bool force" +.Ft int .Fn devctl_detach "const char *device" "bool force" .Ft int .Fn devctl_disable "const char *device" "bool force_detach" @@ -133,9 +136,26 @@ If the device is already attached and is true, the device will be detached from its current device driver before it is attached to the new device driver. +.Pp +The +.Fn devctl_clear_driver +function resets a device so that it can be attached to any valid device +driver rather than only drivers with a previously specified name. +This function is used to undo a previous call to +.Fn devctl_set_driver . +If the device is already attached and +.Fa force +is false, +the request will fail. +If the device is already attached and +.Fa force +is true, +the device will be detached from its current device driver. +After the device's name is reset, +it is reprobed and attached to a suitable device driver if one is found. .Sh RETURN VALUES -.Rv -std devctl_attach devctl_detach devctl_disable devctl_enable \ -devctl_set_driver +.Rv -std devctl_attach devctl_clear_driver devctl_detach \ +devctl_disable devctl_enable devctl_set_driver .Sh ERRORS In addition to specific errors noted below, all of the @@ -244,6 +264,24 @@ The device is disabled. .It Bq Er ENXIO The new device driver failed to attach. .El +.Pp +The +.Fn devctl_clear_driver +function may fail if: +.Bl -tag -width Er +.It Bq Er EBUSY +The device is currently attached to a device driver and +.Fa force +is false. +.It Bq Er EBUSY +The current device driver for +.Fa device +is busy and cannot detach at this time. +.It Bq Er EINVAL +The device is not configured for a specific device driver name. +.It Bq Er ENXIO +The device driver chosen after reprobing failed to attach. +.El .Sh SEE ALSO .Xr devinfo 3 , .Xr devstat 3 , diff --git a/lib/libdevctl/devctl.c b/lib/libdevctl/devctl.c index fa0e6a5..9e3b908 100644 --- a/lib/libdevctl/devctl.c +++ b/lib/libdevctl/devctl.c @@ -108,3 +108,11 @@ devctl_set_driver(const char *device, const char *driver, bool force) req.dr_flags |= DEVF_SET_DRIVER_DETACH; return (devctl_request(DEV_SET_DRIVER, &req)); } + +int +devctl_clear_driver(const char *device, bool force) +{ + + return (devctl_simple_request(DEV_CLEAR_DRIVER, device, force ? + DEVF_CLEAR_DRIVER_DETACH : 0)); +} diff --git a/lib/libdevctl/devctl.h b/lib/libdevctl/devctl.h index 3426cce..d65ea13 100644 --- a/lib/libdevctl/devctl.h +++ b/lib/libdevctl/devctl.h @@ -36,5 +36,6 @@ int devctl_detach(const char *device, bool force); int devctl_enable(const char *device); int devctl_disable(const char *device, bool force_detach); int devctl_set_driver(const char *device, const char *driver, bool force); +int devctl_clear_driver(const char *device, bool force); #endif /* !__DEVCTL_H__ */ diff --git a/lib/libdpv/dpv.3 b/lib/libdpv/dpv.3 index 97461eb..54f9dc7 100644 --- a/lib/libdpv/dpv.3 +++ b/lib/libdpv/dpv.3 @@ -503,7 +503,7 @@ This does not effect .Xr Xdialog 1 , which renders the color escape sequences as plain text. See -.Do Li +.Do embedded "\\Z" sequences .Dc in diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8 index 7e6c196..9ebd5d9 100644 --- a/sbin/ipfw/ipfw.8 +++ b/sbin/ipfw/ipfw.8 @@ -1597,7 +1597,6 @@ be specified as: .Pp Note that the ampersand character has a special meaning in many shells and should generally be escaped. -.Pp .El Note that the order of MAC addresses (destination first, source second) is diff --git a/share/man/man4/gre.4 b/share/man/man4/gre.4 index 15ef0ec..1efb0f5 100644 --- a/share/man/man4/gre.4 +++ b/share/man/man4/gre.4 @@ -91,7 +91,6 @@ Enables checksum calculation for outgoing packets. Enables use of sequence number field in the GRE header for outgoing packets. .El .Sh EXAMPLES -.Pp .Bd -literal 192.168.1.* --- Router A -------tunnel-------- Router B --- 192.168.2.* \\ / @@ -190,7 +189,6 @@ A description of GRE encapsulation can be found in RFC 2784 and RFC 2890. .An Andrey V. Elsukov Aq Mt ae@FreeBSD.org .An Heiko W.Rupp Aq Mt hwr@pilhuhn.de .Sh BUGS -.Pp The current implementation uses the key only for outgoing packets. Incoming packets with a different key or without a key will be treated as if they would belong to this interface. diff --git a/share/man/man4/man4.arm/cgem.4 b/share/man/man4/man4.arm/cgem.4 index 8af1b2a..01e2921 100644 --- a/share/man/man4/man4.arm/cgem.4 +++ b/share/man/man4/man4.arm/cgem.4 @@ -248,6 +248,23 @@ checksum offloading is enabled. Counter of frames discarded due to an incorrect UDP checksum when checksum offloading is enabled. .El +.Sh SEE ALSO +.Xr miibus 4 , +.Xr ifconfig 8 +.Rs +.%T "Zynq-7000 SoC Technical Reference Manual (Xilinx doc UG585)" +.%U http://www.xilinx.com/support/documentation/user_guides/\:ug585-Zynq-7000-TRM.pdf +.Re +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 10.0 . +.Sh AUTHORS +The +.Nm +driver and this manual page was written by +.An Thomas Skibo Aq Mt thomasskibo@yahoo.com . .Sh BUGS The GEM can perform TCP/UDP/IP checksum offloading. However, when transmit checksum offloading is enabled, the GEM generates and @@ -277,21 +294,3 @@ If the bug does not exist in other versions of this device, the work-around can be disabled by setting the dev.cgem.%d.rxhangwar .Xr sysctl 8 variable to 0. -.Pp -.Sh SEE ALSO -.Xr miibus 4 , -.Xr ifconfig 8 -.Rs -.%T "Zynq-7000 SoC Technical Reference Manual (Xilinx doc UG585)" -.%U http://www.xilinx.com/support/documentation/user_guides/\:ug585-Zynq-7000-TRM.pdf -.Re -.Sh HISTORY -The -.Nm -device driver first appeared in -.Fx 10.0 . -.Sh AUTHORS -The -.Nm -driver and this manual page was written by -.An Thomas Skibo Aq Mt thomasskibo@yahoo.com . diff --git a/share/man/man4/me.4 b/share/man/man4/me.4 index e1be5c8..668d346 100644 --- a/share/man/man4/me.4 +++ b/share/man/man4/me.4 @@ -67,7 +67,6 @@ IP header is modified and the modifications are inserted between the so modified header and the original payload. The protocol number 55 is used for outer header. .Sh NOTES -.Pp For correct operation, the .Nm device needs a route to the decapsulating host that does not run over the tunnel, diff --git a/share/man/man4/netmap.4 b/share/man/man4/netmap.4 index 1b2dc7a..08349bd 100644 --- a/share/man/man4/netmap.4 +++ b/share/man/man4/netmap.4 @@ -614,7 +614,7 @@ In the example below, "netmap:foo" is any valid netmap port name. (default) all hardware ring pairs .It NR_REG_SW_NIC "netmap:foo^" the ``host rings'', connecting to the host stack. -.It NR_RING_NIC_SW "netmap:foo+ +.It NR_RING_NIC_SW "netmap:foo+" all hardware rings and the host rings .It NR_REG_ONE_NIC "netmap:foo-i" only the i-th hardware ring pair, where the number is in diff --git a/share/man/man4/pci.4 b/share/man/man4/pci.4 index c79626f..578c365 100644 --- a/share/man/man4/pci.4 +++ b/share/man/man4/pci.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 3, 2008 +.Dd August 9, 2016 .Dt PCI 4 .Os .Sh NAME @@ -229,7 +229,8 @@ The status tells the user the disposition of his request for a device list. The possible status values are: .Bl -ohang .It PCI_GETCONF_LAST_DEVICE -This means that there are no more devices in the PCI device list after the +This means that there are no more devices in the PCI device list matching +the specified criteria after the ones returned in the .Va matches buffer. @@ -245,9 +246,7 @@ and to zero to start over at the beginning of the list. .It PCI_GETCONF_MORE_DEVS This tells the user that his buffer was not large enough to hold all of the -remaining devices in the device list that possibly match his criteria. -It is possible for this status to be returned, even when none of the remaining -devices in the list would match the user's criteria. +remaining devices in the device list that match his criteria. .It PCI_GETCONF_ERROR This indicates a general error while servicing the user's request. If the diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 6b368bf..3a3508a 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1037,7 +1037,10 @@ MLINKS+=pci.9 pci_alloc_msi.9 \ pci.9 pci_set_max_read_req.9 \ pci.9 pci_write_config.9 \ pci.9 pcie_adjust_config.9 \ + pci.9 pcie_flr.9 \ + pci.9 pcie_max_completion_timeout.9 \ pci.9 pcie_read_config.9 \ + pci.9 pcie_wait_for_pending_transactions.9 \ pci.9 pcie_write_config.9 MLINKS+=pfil.9 pfil_add_hook.9 \ pfil.9 pfil_hook_get.9 \ diff --git a/share/man/man9/get_cyclecount.9 b/share/man/man9/get_cyclecount.9 index eabaeb1..04efdd5 100644 --- a/share/man/man9/get_cyclecount.9 +++ b/share/man/man9/get_cyclecount.9 @@ -77,7 +77,6 @@ and processors use the .Li TSC register. -.Pp The .Tn IA64 processors use the diff --git a/share/man/man9/malloc.9 b/share/man/man9/malloc.9 index 9653b58..45a52d1 100644 --- a/share/man/man9/malloc.9 +++ b/share/man/man9/malloc.9 @@ -208,12 +208,6 @@ one must include .In sys/types.h ) and .In sys/kernel.h . -.Sh IMPLEMENTATION NOTES -The memory allocator allocates memory in chunks that have size a power -of two for requests up to the size of a page of memory. -For larger requests, one or more pages is allocated. -While it should not be relied upon, this information may be useful for -optimizing the efficiency of memory use. .Pp Programmers should be careful not to confuse the malloc flags .Dv M_NOWAIT @@ -255,6 +249,12 @@ when holding a .Xr vnode 9 interlock, will cause a LOR (Lock Order Reversal) due to the intertwining of VM Objects and Vnodes. +.Sh IMPLEMENTATION NOTES +The memory allocator allocates memory in chunks that have size a power +of two for requests up to the size of a page of memory. +For larger requests, one or more pages is allocated. +While it should not be relied upon, this information may be useful for +optimizing the efficiency of memory use. .Sh RETURN VALUES The .Fn malloc , diff --git a/share/man/man9/pci.9 b/share/man/man9/pci.9 index cddefb1..1a9be2d 100644 --- a/share/man/man9/pci.9 +++ b/share/man/man9/pci.9 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 24, 2016 +.Dd September 1, 2016 .Dt PCI 9 .Os .Sh NAME @@ -62,7 +62,10 @@ .Nm pci_set_powerstate , .Nm pci_write_config , .Nm pcie_adjust_config , +.Nm pcie_flr , +.Nm pcie_get_max_completion_timeout , .Nm pcie_read_config , +.Nm pcie_wait_for_pending_transactions , .Nm pcie_write_config .Nd PCI bus interface .Sh SYNOPSIS @@ -139,8 +142,14 @@ .Fa "uint32_t val" .Fa "int width" .Fc +.Ft bool +.Fn pcie_flr "device_t dev" "u_int max_delay" "bool force" +.Ft int +.Fn pcie_get_max_completion_timeout "device_t dev" .Ft uint32_t .Fn pcie_read_config "device_t dev" "int reg" "int width" +.Ft bool +.Fn pcie_wait_for_pending_transactions "device_t dev" "u_int max_delay" .Ft void .Fn pcie_write_config "device_t dev" "int reg" "uint32_t val" "int width" .Sh DESCRIPTION @@ -393,6 +402,51 @@ keyword, then .Fn pci_get_vpd_readonly returns an error. +.Pp +The +.Fn pcie_get_max_completion_timeout +function returns the maximum completion timeout configured for the device +.Fa dev +in microseconds. +If the +.Fa dev +device is not a PCI-express device, +.Fn pcie_get_max_completion_timeout +returns zero. +When completion timeouts are disabled for +.Fa dev , +this function returns the maxmimum timeout that would be used if timeouts +were enabled. +.Pp +The +.Fn pcie_wait_for_pending_transactions +function waits for any pending transactions initiated by the +.Fa dev +device to complete. +The function checks for pending transactions by polling the transactions +pending flag in the PCI-express device status register. +It returns +.Dv true +once the transaction pending flag is clear. +If transactions are still pending after +.Fa max_delay +milliseconds, +.Fn pcie_wait_for_pending_transactions +returns +.Dv false . +If +.Fa max_delay +is set to zero, +.Fn pcie_wait_for_pending_transactions +performs a single check; +otherwise, +this function may sleep while polling the transactions pending flag. +.Nm pcie_wait_for_pending_transactions +returns +.Dv true +if +.Fa dev +is not a PCI-express device. .Ss Device Configuration The .Fn pci_enable_busmaster @@ -541,6 +595,51 @@ is invoked, then the device will be transitioned to .Dv PCI_POWERSTATE_D0 before any config registers are restored. +.Pp +The +.Fn pcie_flr +function requests a Function Level Reset +.Pq FLR +of +.Fa dev . +If +.Fa dev +is not a PCI-express device or does not support Function Level Resets via +the PCI-express device control register, +.Dv false +is returned. +Pending transactions are drained by disabling busmastering and calling +.Fn pcie_wait_for_pending_transactions +before resetting the device. +The +.Fa max_delay +argument specifies the maximum timeout to wait for pending transactions as +described for +.Fn pcie_wait_for_pending_transactions . +If +.Fn pcie_wait_for_pending_transactions +fails with a timeout and +.Fa force +is +.Dv false , +busmastering is re-enabled and +.Dv false +is returned. +If +.Fn pcie_wait_for_pending_transactions +fails with a timeout and +.Fa force +is +.Dv true , +the device is reset despite the timeout. +After the reset has been requested, +.Nm pcie_flr +sleeps for at least 100 milliseconds before returning +.Dv true . +Note that +.Nm pcie_flr +does not save and restore any state around the reset. +The caller should save and restore state as needed. .Ss Message Signaled Interrupts Message Signaled Interrupts .Pq MSI @@ -793,11 +892,6 @@ with one in the new distribution. The .Fn pci_remap_msix function will fail if this condition is not met. -.Sh IMPLEMENTATION NOTES -The -.Vt pci_addr_t -type varies according to the size of the PCI bus address -space on the target architecture. .Sh SEE ALSO .Xr pci 4 , .Xr pciconf 8 , diff --git a/share/man/man9/sleepqueue.9 b/share/man/man9/sleepqueue.9 index 7f6269b..46f6539 100644 --- a/share/man/man9/sleepqueue.9 +++ b/share/man/man9/sleepqueue.9 @@ -246,7 +246,6 @@ allows to pass additional .Fn callout_reset_sbt flags. .Pp -.Pp Once the thread is ready to suspend, one of the wait functions is called to put the current thread to sleep until it is awakened and to context switch to another thread. diff --git a/sys/amd64/vmm/io/iommu.c b/sys/amd64/vmm/io/iommu.c index 9cfc4c2..b179535 100644 --- a/sys/amd64/vmm/io/iommu.c +++ b/sys/amd64/vmm/io/iommu.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> +#include <machine/cpu.h> #include <machine/md_var.h> #include "vmm_util.h" @@ -51,6 +52,10 @@ static int iommu_avail; SYSCTL_INT(_hw_vmm_iommu, OID_AUTO, initialized, CTLFLAG_RD, &iommu_avail, 0, "bhyve iommu initialized?"); +static int iommu_enable = 1; +SYSCTL_INT(_hw_vmm_iommu, OID_AUTO, enable, CTLFLAG_RDTUN, &iommu_enable, 0, + "Enable use of I/O MMU (required for PCI passthrough)."); + static struct iommu_ops *ops; static void *host_domain; @@ -148,14 +153,16 @@ IOMMU_DISABLE(void) (*ops->disable)(); } -void +static void iommu_init(void) { int error, bus, slot, func; vm_paddr_t maxaddr; - const char *name; device_t dev; + if (!iommu_enable) + return; + if (vmm_is_intel()) ops = &iommu_ops_intel; else if (vmm_is_amd()) @@ -174,8 +181,13 @@ iommu_init(void) */ maxaddr = vmm_mem_maxaddr(); host_domain = IOMMU_CREATE_DOMAIN(maxaddr); - if (host_domain == NULL) - panic("iommu_init: unable to create a host domain"); + if (host_domain == NULL) { + printf("iommu_init: unable to create a host domain"); + IOMMU_CLEANUP(); + ops = NULL; + iommu_avail = 0; + return; + } /* * Create 1:1 mappings from '0' to 'maxaddr' for devices assigned to @@ -190,12 +202,7 @@ iommu_init(void) if (dev == NULL) continue; - /* skip passthrough devices */ - name = device_get_name(dev); - if (name != NULL && strcmp(name, "ppt") == 0) - continue; - - /* everything else belongs to the host domain */ + /* Everything belongs to the host domain. */ iommu_add_device(host_domain, pci_get_rid(dev)); } @@ -216,7 +223,16 @@ iommu_cleanup(void) void * iommu_create_domain(vm_paddr_t maxaddr) { - + static volatile int iommu_initted; + + if (iommu_initted < 2) { + if (atomic_cmpset_int(&iommu_initted, 0, 1)) { + iommu_init(); + atomic_store_rel_int(&iommu_initted, 2); + } else + while (iommu_initted == 1) + cpu_spinwait(); + } return (IOMMU_CREATE_DOMAIN(maxaddr)); } diff --git a/sys/amd64/vmm/io/iommu.h b/sys/amd64/vmm/io/iommu.h index 36b44fa..a941c77 100644 --- a/sys/amd64/vmm/io/iommu.h +++ b/sys/amd64/vmm/io/iommu.h @@ -61,7 +61,6 @@ struct iommu_ops { extern struct iommu_ops iommu_ops_intel; extern struct iommu_ops iommu_ops_amd; -void iommu_init(void); void iommu_cleanup(void); void *iommu_host_domain(void); void *iommu_create_domain(vm_paddr_t maxaddr); diff --git a/sys/amd64/vmm/io/ppt.c b/sys/amd64/vmm/io/ppt.c index 692190a..4c9ff47 100644 --- a/sys/amd64/vmm/io/ppt.c +++ b/sys/amd64/vmm/io/ppt.c @@ -362,7 +362,13 @@ ppt_assign_device(struct vm *vm, int bus, int slot, int func) if (ppt->vm != NULL && ppt->vm != vm) return (EBUSY); + pci_save_state(ppt->dev); + pcie_flr(ppt->dev, + max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10), + true); + pci_restore_state(ppt->dev); ppt->vm = vm; + iommu_remove_device(iommu_host_domain(), pci_get_rid(ppt->dev)); iommu_add_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev)); return (0); } @@ -381,10 +387,17 @@ ppt_unassign_device(struct vm *vm, int bus, int slot, int func) */ if (ppt->vm != vm) return (EBUSY); + + pci_save_state(ppt->dev); + pcie_flr(ppt->dev, + max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10), + true); + pci_restore_state(ppt->dev); ppt_unmap_mmio(vm, ppt); ppt_teardown_msi(ppt); ppt_teardown_msix(ppt); iommu_remove_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev)); + iommu_add_device(iommu_host_domain(), pci_get_rid(ppt->dev)); ppt->vm = NULL; return (0); } diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index cabc271..c2b5f61 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -228,11 +228,6 @@ SYSCTL_INT(_hw_vmm, OID_AUTO, trace_guest_exceptions, CTLFLAG_RDTUN, &trace_guest_exceptions, 0, "Trap into hypervisor on all guest exceptions and reflect them back"); -static int vmm_force_iommu = 0; -TUNABLE_INT("hw.vmm.force_iommu", &vmm_force_iommu); -SYSCTL_INT(_hw_vmm, OID_AUTO, force_iommu, CTLFLAG_RDTUN, &vmm_force_iommu, 0, - "Force use of I/O MMU even if no passthrough devices were found."); - static void vm_free_memmap(struct vm *vm, int ident); static bool sysmem_mapping(struct vm *vm, struct mem_map *mm); static void vcpu_notify_event_locked(struct vcpu *vcpu, bool lapic_intr); @@ -362,8 +357,6 @@ vmm_handler(module_t mod, int what, void *arg) switch (what) { case MOD_LOAD: vmmdev_init(); - if (vmm_force_iommu || ppt_avail_devices() > 0) - iommu_init(); error = vmm_init(); if (error == 0) vmm_initialized = 1; @@ -400,9 +393,6 @@ static moduledata_t vmm_kmod = { /* * vmm initialization has the following dependencies: * - * - iommu initialization must happen after the pci passthru driver has had - * a chance to attach to any passthru devices (after SI_SUB_CONFIGURE). - * * - VT-x initialization requires smp_rendezvous() and therefore must happen * after SMP is fully functional (after SI_SUB_SMP). */ @@ -897,6 +887,8 @@ vm_assign_pptdev(struct vm *vm, int bus, int slot, int func) ("vm_assign_pptdev: iommu must be NULL")); maxaddr = sysmem_maxaddr(vm); vm->iommu = iommu_create_domain(maxaddr); + if (vm->iommu == NULL) + return (ENXIO); vm_iommu_map(vm); } diff --git a/sys/boot/common/zfsloader.8 b/sys/boot/common/zfsloader.8 index 9bb74a4..fd437d9 100644 --- a/sys/boot/common/zfsloader.8 +++ b/sys/boot/common/zfsloader.8 @@ -62,7 +62,6 @@ refers to a ZFS filesystem, then will instruct kernel to use that filesystem as the root filesystem. .Sh ZFS COMMAND EXTENSIONS .Bl -tag -width Ds -compact -.Pp .It Ic lsdev Op Fl v Lists ZFS pools in addition to disks and partitions. Adding @@ -87,11 +86,9 @@ itself. .El .Sh EXAMPLES Set the default device used for loading a kernel from a ZFS filesystem: -.Pp .Bd -literal -offset indent set currdev=zfs:tank/ROOT/knowngood: .Ed -.Pp .Sh SEE ALSO .Xr gptzfsboot 8 , .Xr loader 8 , diff --git a/sys/boot/i386/gptzfsboot/gptzfsboot.8 b/sys/boot/i386/gptzfsboot/gptzfsboot.8 index 400c8c6..ffb055d 100644 --- a/sys/boot/i386/gptzfsboot/gptzfsboot.8 +++ b/sys/boot/i386/gptzfsboot/gptzfsboot.8 @@ -176,6 +176,9 @@ gpart bootcode -p /boot/gptzfsboot -i 1 ada0 .Sh HISTORY .Nm appeared in FreeBSD 7.3. +.Sh AUTHORS +This manual page was written by +.An Andriy Gapon Aq avg@FreeBSD.org . .Sh BUGS .Nm looks for ZFS meta-data only in MBR partitions @@ -188,6 +191,3 @@ found at the fixed offsets relative to a slice, then .Nm will recognize the partition as a part of a ZFS pool, but this is not guaranteed to happen. -.Sh AUTHORS -This manual page was written by -.An Andriy Gapon Aq avg@FreeBSD.org . diff --git a/sys/cam/cam_compat.c b/sys/cam/cam_compat.c index f291479..68193fc 100644 --- a/sys/cam/cam_compat.c +++ b/sys/cam/cam_compat.c @@ -63,28 +63,28 @@ cam_compat_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, switch (cmd) { case CAMIOCOMMAND_0x16: { - union ccb *ccb; + struct ccb_hdr_0x17 *hdr17; - ccb = (union ccb *)addr; - if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS_0x16) { - ccb->ccb_h.flags &= ~CAM_SG_LIST_PHYS_0x16; - ccb->ccb_h.flags |= CAM_DATA_SG_PADDR; + hdr17 = (struct ccb_hdr_0x17 *)addr; + if (hdr17->flags & CAM_SG_LIST_PHYS_0x16) { + hdr17->flags &= ~CAM_SG_LIST_PHYS_0x16; + hdr17->flags |= CAM_DATA_SG_PADDR; } - if (ccb->ccb_h.flags & CAM_DATA_PHYS_0x16) { - ccb->ccb_h.flags &= ~CAM_DATA_PHYS_0x16; - ccb->ccb_h.flags |= CAM_DATA_PADDR; + if (hdr17->flags & CAM_DATA_PHYS_0x16) { + hdr17->flags &= ~CAM_DATA_PHYS_0x16; + hdr17->flags |= CAM_DATA_PADDR; } - if (ccb->ccb_h.flags & CAM_SCATTER_VALID_0x16) { - ccb->ccb_h.flags &= CAM_SCATTER_VALID_0x16; - ccb->ccb_h.flags |= CAM_DATA_SG; + if (hdr17->flags & CAM_SCATTER_VALID_0x16) { + hdr17->flags &= CAM_SCATTER_VALID_0x16; + hdr17->flags |= CAM_DATA_SG; } cmd = CAMIOCOMMAND; - error = (cbfnp)(dev, cmd, addr, flag, td); + error = cam_compat_handle_0x17(dev, cmd, addr, flag, td, cbfnp); break; } case CAMGETPASSTHRU_0x16: cmd = CAMGETPASSTHRU; - error = (cbfnp)(dev, cmd, addr, flag, td); + error = cam_compat_handle_0x17(dev, cmd, addr, flag, td, cbfnp); break; case CAMIOCOMMAND_0x17: cmd = CAMIOCOMMAND; diff --git a/sys/cam/cam_compat.h b/sys/cam/cam_compat.h index d5bde1a..ffcf99f 100644 --- a/sys/cam/cam_compat.h +++ b/sys/cam/cam_compat.h @@ -43,8 +43,8 @@ int cam_compat_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, #define CAM_VERSION_0x16 0x16 /* The size of the union ccb didn't change when going to 0x17 */ -#define CAMIOCOMMAND_0x16 _IOWR(CAM_VERSION_0x16, 2, union ccb) -#define CAMGETPASSTHRU_0x16 _IOWR(CAM_VERSION_0x16, 3, union ccb) +#define CAMIOCOMMAND_0x16 _IOC(IOC_INOUT, CAM_VERSION_0x16, 2, CAM_0X17_LEN) +#define CAMGETPASSTHRU_0x16 _IOC(IOC_INOUT, CAM_VERSION_0x16, 3, CAM_0X17_LEN) #define CAM_SCATTER_VALID_0x16 0x00000010 #define CAM_SG_LIST_PHYS_0x16 0x00040000 @@ -110,8 +110,8 @@ struct ccb_pathinq_0x17 { u_int16_t hba_subdevice; /* HBA subdevice ID */ }; -#define CAM_0X17_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr) + sizeof(struct ccb_hdr_0x17)) -#define CAM_0X17_DATA_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr_0x17)) +#define CAM_0X17_DATA_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr)) +#define CAM_0X17_LEN (sizeof(struct ccb_hdr_0x17) + CAM_0X17_DATA_LEN) #define CAMIOCOMMAND_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 2, CAM_0X17_LEN) #define CAMGETPASSTHRU_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 3, CAM_0X17_LEN) diff --git a/sys/conf/files b/sys/conf/files index 8add482..825cc4d 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -270,11 +270,11 @@ contrib/dev/acpica/components/debugger/dbcmds.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbconvert.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbdisply.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbexec.c optional acpi acpi_debug -contrib/dev/acpica/components/debugger/dbfileio.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbhistry.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbinput.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbmethod.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbnames.c optional acpi acpi_debug +contrib/dev/acpica/components/debugger/dbobject.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbstats.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbtest.c optional acpi acpi_debug contrib/dev/acpica/components/debugger/dbutils.c optional acpi acpi_debug @@ -284,7 +284,6 @@ contrib/dev/acpica/components/disassembler/dmcstyle.c optional acpi acpi_debug contrib/dev/acpica/components/disassembler/dmdeferred.c optional acpi acpi_debug contrib/dev/acpica/components/disassembler/dmnames.c optional acpi acpi_debug contrib/dev/acpica/components/disassembler/dmopcode.c optional acpi acpi_debug -contrib/dev/acpica/components/disassembler/dmobject.c optional acpi acpi_debug contrib/dev/acpica/components/disassembler/dmresrc.c optional acpi acpi_debug contrib/dev/acpica/components/disassembler/dmresrcl.c optional acpi acpi_debug contrib/dev/acpica/components/disassembler/dmresrcl2.c optional acpi acpi_debug @@ -293,6 +292,7 @@ contrib/dev/acpica/components/disassembler/dmutils.c optional acpi acpi_debug contrib/dev/acpica/components/disassembler/dmwalk.c optional acpi acpi_debug contrib/dev/acpica/components/dispatcher/dsargs.c optional acpi contrib/dev/acpica/components/dispatcher/dscontrol.c optional acpi +contrib/dev/acpica/components/dispatcher/dsdebug.c optional acpi contrib/dev/acpica/components/dispatcher/dsfield.c optional acpi contrib/dev/acpica/components/dispatcher/dsinit.c optional acpi contrib/dev/acpica/components/dispatcher/dsmethod.c optional acpi @@ -320,6 +320,7 @@ contrib/dev/acpica/components/events/evxface.c optional acpi contrib/dev/acpica/components/events/evxfevnt.c optional acpi contrib/dev/acpica/components/events/evxfgpe.c optional acpi contrib/dev/acpica/components/events/evxfregn.c optional acpi +contrib/dev/acpica/components/executer/exconcat.c optional acpi contrib/dev/acpica/components/executer/exconfig.c optional acpi contrib/dev/acpica/components/executer/exconvrt.c optional acpi contrib/dev/acpica/components/executer/excreate.c optional acpi @@ -343,6 +344,7 @@ contrib/dev/acpica/components/executer/exstore.c optional acpi contrib/dev/acpica/components/executer/exstoren.c optional acpi contrib/dev/acpica/components/executer/exstorob.c optional acpi contrib/dev/acpica/components/executer/exsystem.c optional acpi +contrib/dev/acpica/components/executer/extrace.c optional acpi contrib/dev/acpica/components/executer/exutils.c optional acpi contrib/dev/acpica/components/hardware/hwacpi.c optional acpi contrib/dev/acpica/components/hardware/hwesleep.c optional acpi @@ -389,7 +391,7 @@ contrib/dev/acpica/components/parser/psxface.c optional acpi contrib/dev/acpica/components/resources/rsaddr.c optional acpi contrib/dev/acpica/components/resources/rscalc.c optional acpi contrib/dev/acpica/components/resources/rscreate.c optional acpi -contrib/dev/acpica/components/resources/rsdump.c optional acpi +contrib/dev/acpica/components/resources/rsdump.c optional acpi acpi_debug contrib/dev/acpica/components/resources/rsdumpinfo.c optional acpi contrib/dev/acpica/components/resources/rsinfo.c optional acpi contrib/dev/acpica/components/resources/rsio.c optional acpi @@ -411,6 +413,7 @@ contrib/dev/acpica/components/tables/tbxfload.c optional acpi contrib/dev/acpica/components/tables/tbxfroot.c optional acpi contrib/dev/acpica/components/utilities/utaddress.c optional acpi contrib/dev/acpica/components/utilities/utalloc.c optional acpi +contrib/dev/acpica/components/utilities/utascii.c optional acpi contrib/dev/acpica/components/utilities/utbuffer.c optional acpi contrib/dev/acpica/components/utilities/utcache.c optional acpi contrib/dev/acpica/components/utilities/utcopy.c optional acpi @@ -428,6 +431,7 @@ contrib/dev/acpica/components/utilities/utlock.c optional acpi contrib/dev/acpica/components/utilities/utmath.c optional acpi contrib/dev/acpica/components/utilities/utmisc.c optional acpi contrib/dev/acpica/components/utilities/utmutex.c optional acpi +contrib/dev/acpica/components/utilities/utnonansi.c optional acpi contrib/dev/acpica/components/utilities/utobject.c optional acpi contrib/dev/acpica/components/utilities/utosi.c optional acpi contrib/dev/acpica/components/utilities/utownerid.c optional acpi @@ -3273,6 +3277,7 @@ libkern/strndup.c standard libkern/strlcat.c standard libkern/strlcpy.c standard libkern/strlen.c standard +libkern/strncat.c standard libkern/strncmp.c standard libkern/strncpy.c standard libkern/strnlen.c standard diff --git a/sys/contrib/dev/acpica/acpica_prep.sh b/sys/contrib/dev/acpica/acpica_prep.sh index efb75b2..5a1704f 100755 --- a/sys/contrib/dev/acpica/acpica_prep.sh +++ b/sys/contrib/dev/acpica/acpica_prep.sh @@ -19,20 +19,20 @@ fulldirs="common compiler components include os_specific" # files to remove stripdirs="generate libraries tests tools" stripfiles="Makefile README accygwin.h acdragonfly.h acdragonflyex.h \ - acefi.h achaiku.h acintel.h aclinux.h aclinuxex.h acmacosx.h \ - acmsvc.h acnetbsd.h acos2.h acwin.h acwin64.h new_table.txt \ - osbsdtbl.c osefitbl.c osefixf.c osfreebsdtbl.c oslinuxtbl.c \ - osunixdir.c osunixmap.c oswindir.c oswintbl.c oswinxf.c \ - readme.txt utclib.c" + acefi.h acefiex.h achaiku.h acintel.h aclinux.h aclinuxex.h \ + acmacosx.h acmsvc.h acmsvcex.h acnetbsd.h acos2.h acqnx.h \ + acwin.h acwin64.h acwinex.h new_table.txt osbsdtbl.c osefitbl.c \ + osefixf.c osfreebsdtbl.c oslinuxtbl.c osunixdir.c osunixmap.c \ + oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c" # include files to canonify -src_headers="acapps.h acbuffer.h accommon.h acconfig.h acdebug.h \ - acdisasm.h acdispat.h acevents.h acexcep.h acglobal.h achware.h \ - acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h acobject.h \ - acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h \ - acpredef.h acresrc.h acrestyp.h acstruct.h actables.h actbl.h \ - actbl1.h actbl2.h actbl3.h actypes.h acutils.h amlcode.h \ - amlresrc.h platform/acenv.h platform/acenvex.h \ +src_headers="acapps.h acbuffer.h acclib.h accommon.h acconfig.h \ + acdebug.h acdisasm.h acdispat.h acevents.h acexcep.h acglobal.h \ + achware.h acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h \ + acobject.h acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h \ + acpixf.h acpredef.h acresrc.h acrestyp.h acstruct.h actables.h \ + actbl.h actbl1.h actbl2.h actbl3.h actypes.h acutils.h acuuid.h \ + amlcode.h amlresrc.h platform/acenv.h platform/acenvex.h \ platform/acfreebsd.h platform/acgcc.h" comp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h \ aslsupport.l asltypes.h dtcompiler.h dttemplate.h preprocess.h" diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt index 511652f..ff863a7 100644 --- a/sys/contrib/dev/acpica/changes.txt +++ b/sys/contrib/dev/acpica/changes.txt @@ -1,5 +1,930 @@ ---------------------------------------- -08 April 2015. Summary of changes for version 20150515: +27 May 2016. Summary of changes for version 20160527: + +This release is available at https://acpica.org/downloads + + +1) ACPICA kernel-resident subsystem: + +Temporarily reverted the new arbitrary bit length/alignment support in +AcpiHwRead/AcpiHwWrite for the Generic Address Structure. There have been +a number of regressions with the new code that need to be fully resolved +and tested before this support can be finally integrated into ACPICA. +Apologies for any inconveniences these issues may have caused. + +The ACPI message macros are not configurable (ACPI_MSG_ERROR, +ACPI_MSG_EXCEPTION, ACPI_MSG_WARNING, ACPI_MSG_INFO, ACPI_MSG_BIOS_ERROR, +and ACPI_MSG_BIOS_WARNING). Lv Zheng. + +Fixed a couple of GCC warnings associated with the use of the -Wcast-qual +option. Adds a new return macro, return_STR. Junk-uk Kim. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 136.8K Code, 51.6K Data, 188.4K Total + Debug Version: 201.5K Code, 82.2K Data, 283.7K Total + Previous Release: + Non-Debug Version: 137.4K Code, 52.6K Data, 190.0K Total + Debug Version: 200.9K Code, 82.2K Data, 283.1K Total + +---------------------------------------- +22 April 2016. Summary of changes for version 20160422: + +1) ACPICA kernel-resident subsystem: + +Fixed a regression in the GAS (generic address structure) arbitrary bit +support in AcpiHwRead/AcpiHwWrite. Problem could cause incorrect behavior +and incorrect return values. Lv Zheng. ACPICA BZ 1270. + +ACPI 6.0: Added support for new/renamed resource macros. One new argument +was added to each of these macros, and the original name has been +deprecated. The AML disassembler will always disassemble to the new +names. Support for the new macros was added to iASL, disassembler, +resource manager, and the acpihelp utility. ACPICA BZ 1274. + + I2cSerialBus -> I2cSerialBusV2 + SpiSerialBus -> SpiSerialBusV2 + UartSerialBus -> UartSerialBusV2 + +ACPI 6.0: Added support for a new integer field that was appended to the +package object returned by the _BIX method. This adds iASL compile-time +and AML runtime error checking. ACPICA BZ 1273. + +ACPI 6.1: Added support for a new PCCT subtable, "HW-Reduced Comm +Subspace Type2" (Headers, Disassembler, and data table compiler). + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 137.4K Code, 52.6K Data, 190.0K Total + Debug Version: 201.5K Code, 82.2K Data, 283.7K Total + Previous Release: + Non-Debug Version: 137.1K Code, 51.5K Data, 188.6K Total + Debug Version: 201.0K Code, 82.0K Data, 283.0K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented an ASL grammar extension to allow/enable executable +"module-level code" to be created and executed under the various +operators that create new scopes. This type of AML code is already +supported in all known AML interpreters, and the grammar change will +appear in the next version of the ACPI specification. Simplifies the +conditional runtime creation of named objects under these object types: + + Device + PowerResource + Processor + Scope + ThermalZone + +iASL: Implemented a new ASL extension, a "For" loop macro to add greater +ease-of-use to the ASL language. The syntax is similar to the +corresponding C operator, and is implemented with the existing AML While +opcode -- thus requiring no changes to existing AML interpreters. + + For (Initialize, Predicate, Update) {TermList} + +Grammar: + ForTerm := + For ( + Initializer // Nothing | TermArg => ComputationalData + Predicate // Nothing | TermArg => ComputationalData + Update // Nothing | TermArg => ComputationalData + ) {TermList} + + +iASL: The _HID/_ADR detection and validation has been enhanced to search +under conditionals in order to allow these objects to be conditionally +created at runtime. + +iASL: Fixed several issues with the constant folding feature. The +improvement allows better detection and resolution of statements that can +be folded at compile time. ACPICA BZ 1266. + +iASL/Disassembler: Fixed a couple issues with the Else{If{}...} +conversion to the ASL ElseIf operator where incorrect ASL code could be +generated. + +iASL/Disassembler: Fixed a problem with the ASL+ code disassembly where +sometimes an extra (and extraneous) set of parentheses were emitted for +some combinations of operators. Although this did not cause any problems +with recompilation of the disassembled code, it made the code more +difficult to read. David Box. ACPICA BZ 1231. + +iASL: Changed to ignore the unreferenced detection for predefined names +of resource descriptor elements, when the resource descriptor is +created/defined within a control method. + +iASL: Disassembler: Fix a possible fault with externally declared Buffer +objects. + +---------------------------------------- +18 March 2016. Summary of changes for version 20160318: + +1) ACPICA kernel-resident subsystem: + +Added support for arbitrary bit lengths and bit offsets for registers +defined by the Generic Address Structure. Previously, only aligned bit +lengths of 8/16/32/64 were supported. This was sufficient for many years, +but recently some machines have been seen that require arbitrary bit- +level support. ACPICA BZ 1240. Lv Zheng. + +Fixed an issue where the \_SB._INI method sometimes must be evaluated +before any _REG methods are evaluated. Lv Zheng. + +Implemented several changes related to ACPI table support +(Headers/Disassembler/TableCompiler): +NFIT: For ACPI 6.1, updated to add some additional new fields and +constants. +FADT: Updated a warning message and set compliance to ACPI 6.1 (Version +6). +DMAR: Added new constants per the 10/2014 DMAR spec. +IORT: Added new subtable per the 10/2015 IORT spec. +HEST: For ACPI 6.1, added new constants and new subtable. +DBG2: Added new constants per the 12/2015 DBG2 spec. +FPDT: Fixed several incorrect fields, add the FPDT boot record structure. +ACPICA BZ 1249. +ERST/EINJ: Updated disassembler with new "Execute Timings" actions. + +Updated header support for the DMAR table to match the current version of +the related spec. + +Added extensions to the ASL Concatenate operator to allow any ACPI object +to be passed as an operand. Any object other than Integer/String/Buffer +simply returns a string containing the object type. This extends the +usefulness of the Printf macros. Previously, Concatenate would abort the +control method if a non-data object was encountered. + +ACPICA source code: Deployed the C "const" keyword across the source code +where appropriate. ACPICA BZ 732. Joerg Sonnenberger (NetBSD). + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 137.1K Code, 51.5K Data, 188.6K Total + Debug Version: 201.0K Code, 82.0K Data, 283.0K Total + Previous Release: + Non-Debug Version: 136.2K Code, 51.5K Data, 187.7K Total + Debug Version: 200.4K Code, 82.0K Data, 282.4K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL/Disassembler: Improved the heuristic used to determine the number of +arguments for an externally defined control method (a method in another +table). Although this is an improvement, there is no deterministic way to +"guess" the number of method arguments. Only the ACPI 6.0 External opcode +will completely solve this problem as it is deployed (automatically) in +newer BIOS code. + +iASL/Disassembler: Fixed an ordering issue for emitted External() ASL +statements that could cause errors when the disassembled file is +compiled. ACPICA BZ 1243. David Box. + +iASL: Fixed a regression caused by the merger of the two versions of the +local strtoul64. Because of a dependency on a global variable, strtoul64 +could return an error for integers greater than a 32-bit value. ACPICA BZ +1260. + +iASL: Fixed a regression where a fault could occur for an ASL Return +statement if it invokes a control method that is not resolved. ACPICA BZ +1264. + +AcpiXtract: Improved input file validation: detection of binary files and +non-acpidump text files. + +---------------------------------------- +12 February 2016. Summary of changes for version 20160212: + +1) ACPICA kernel-resident subsystem: + +Implemented full support for the ACPI 6.1 specification (released in +January). This version of the specification is available at: +http://www.uefi.org/specifications + +Only a relatively small number of changes were required in ACPICA to +support ACPI 6.1, in these areas: +- New predefined names +- New _HID values +- A new subtable for HEST +- A few other header changes for new values + +Ensure \_SB_._INI is executed before any _REG methods are executed. There +appears to be existing BIOS code that relies on this behavior. Lv Zheng. + +Reverted a change made in version 20151218 which enabled method +invocations to be targets of various ASL operators (SuperName and Target +grammar elements). While the new behavior is supported by the ACPI +specification, other AML interpreters do not support this behavior and +never will. The ACPI specification will be updated for ACPI 6.2 to remove +this support. Therefore, the change was reverted to the original ACPICA +behavior. + +ACPICA now supports the GCC 6 compiler. + +Current Release: (Note: build changes increased sizes) + Non-Debug Version: 136.2K Code, 51.5K Data, 187.7K Total + Debug Version: 200.4K Code, 82.0K Data, 282.4K Total +Previous Release: + Non-Debug Version: 102.7K Code, 28.4K Data, 131.1K Total + Debug Version: 200.4K Code, 81.9K Data, 282.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +Completed full support for the ACPI 6.0 External() AML opcode. The +compiler emits an external AML opcode for each ASL External statement. +This opcode is used by the disassembler to assist with the disassembly of +external control methods by specifying the required number of arguments +for the method. AML interpreters do not use this opcode. To ensure that +interpreters do not even see the opcode, a block of one or more external +opcodes is surrounded by an "If(0)" construct. As this feature becomes +commonly deployed in BIOS code, the ability of disassemblers to correctly +disassemble AML code will be greatly improved. David Box. + +iASL: Implemented support for an optional cross-reference output file. +The -lx option will create a the cross-reference file with the suffix +"xrf". Three different types of cross-reference are created in this file: +- List of object references made from within each control method +- Invocation (caller) list for each user-defined control method +- List of references to each non-method object in the namespace + +iASL: Method invocations as ASL Target operands are now disallowed and +flagged as errors in preparation for ACPI 6.2 (see the description of the +problem above). + +---------------------------------------- +8 January 2016. Summary of changes for version 20160108: + +1) ACPICA kernel-resident subsystem: + +Updated all ACPICA copyrights and signons to 2016: Added the 2016 +copyright to all source code module headers and utility/tool signons. +This includes the standard Linux dual-license header. This affects +virtually every file in the ACPICA core subsystem, iASL compiler, all +ACPICA utilities, and the ACPICA test suite. + +Fixed a regression introduced in version 20151218 concerning the +execution of so-called module-level ASL/AML code. Namespace objects +created under a module-level If() construct were not properly/fully +entered into the namespace and could cause an interpreter fault when +accessed. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + +Current Release: + Non-Debug Version: 102.7K Code, 28.4K Data, 131.1K Total + Debug Version: 200.4K Code, 81.9K Data, 282.4K Total + Previous Release: + Non-Debug Version: 102.6K Code, 28.4K Data, 131.0K Total + Debug Version: 200.3K Code, 81.9K Data, 282.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed a problem with the compilation of the GpioIo and GpioInt resource +descriptors. The _PIN field name was incorrectly defined to be an array +of 32-bit values, but the _PIN values are in fact 16 bits each. This +would cause incorrect bit width warnings when using Word (16-bit) fields +to access the descriptors. + + +---------------------------------------- +18 December 2015. Summary of changes for version 20151218: + +1) ACPICA kernel-resident subsystem: + +Implemented per-AML-table execution of "module-level code" as individual +ACPI tables are loaded into the namespace during ACPICA initialization. +In other words, any module-level code within an AML table is executed +immediately after the table is loaded, instead of batched and executed +after all of the tables have been loaded. This provides compatibility +with other ACPI implementations. ACPICA BZ 1219. Bob Moore, Lv Zheng, +David Box. + +To fully support the feature above, the default operation region handlers +for the SystemMemory, SystemIO, and PCI_Config address spaces are now +installed before any ACPI tables are loaded. This enables module-level +code to access these address spaces during the table load and module- +level code execution phase. ACPICA BZ 1220. Bob Moore, Lv Zheng, David +Box. + +Implemented several changes to the internal _REG support in conjunction +with the changes above. Also, changes to the AcpiExec/AcpiNames/Examples +utilities for the changes above. Although these tools were changed, host +operating systems that simply use the default handlers for SystemMemory, +SystemIO, and PCI_Config spaces should not require any update. Lv Zheng. + +For example, in the code below, DEV1 is conditionally added to the +namespace by the DSDT via module-level code that accesses an operation +region. The SSDT references DEV1 via the Scope operator. DEV1 must be +created immediately after the DSDT is loaded in order for the SSDT to +successfully reference DEV1. Previously, this code would cause an +AE_NOT_EXIST exception during the load of the SSDT. Now, this code is +fully supported by ACPICA. + + DefinitionBlock ("", "DSDT", 2, "Intel", "DSDT1", 1) + { + OperationRegion (OPR1, SystemMemory, 0x400, 32) + Field (OPR1, AnyAcc, NoLock, Preserve) + { + FLD1, 1 + } + If (FLD1) + { + Device (\DEV1) + { + } + } + } + DefinitionBlock ("", "SSDT", 2, "Intel", "SSDT1", 1) + { + External (\DEV1, DeviceObj) + Scope (\DEV1) + { + } + } + +Fixed an AML interpreter problem where control method invocations were +not handled correctly when the invocation was itself a SuperName argument +to another ASL operator. In these cases, the method was not invoked. +ACPICA BZ 1002. Affects the following ASL operators that have a SuperName +argument: + Store + Acquire, Wait + CondRefOf, RefOf + Decrement, Increment + Load, Unload + Notify + Signal, Release, Reset + SizeOf + +Implemented automatic String-to-ObjectReference conversion support for +packages returned by predefined names (such as _DEP). A common BIOS error +is to add double quotes around an ObjectReference namepath, which turns +the reference into an unexpected string object. This support detects the +problem and corrects it before the package is returned to the caller that +invoked the method. Lv Zheng. + +Implemented extensions to the Concatenate operator. Concatenate now +accepts any type of object, it is not restricted to simply +Integer/String/Buffer. For objects other than these 3 basic data types, +the argument is treated as a string containing the name of the object +type. This expands the utility of Concatenate and the Printf/Fprintf +macros. ACPICA BZ 1222. + +Cleaned up the output of the ASL Debug object. The timer() value is now +optional and no longer emitted by default. Also, the basic data types of +Integer/String/Buffer are simply emitted as their values, without a data +type string -- since the data type is obvious from the output. ACPICA BZ +1221. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 102.6K Code, 28.4K Data, 131.0K Total + Debug Version: 200.3K Code, 81.9K Data, 282.3K Total + Previous Release: + Non-Debug Version: 102.0K Code, 28.3K Data, 130.3K Total + Debug Version: 199.6K Code, 81.8K Data, 281.4K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Fixed some issues with the ASL Include() operator. This operator +was incorrectly defined in the iASL parser rules, causing a new scope to +be opened for the code within the include file. This could lead to +several issues, including allowing ASL code that is technically illegal +and not supported by AML interpreters. Note, this does not affect the +related #include preprocessor operator. ACPICA BZ 1212. + +iASL/Disassembler: Implemented support for the ASL ElseIf operator. This +operator is essentially an ASL macro since there is no AML opcode +associated with it. The code emitted by the iASL compiler for ElseIf is +an Else opcode followed immediately by an If opcode. The disassembler +will now emit an ElseIf if it finds an Else immediately followed by an +If. This simplifies the decoded ASL, especially for deeply nested +If..Else and large Switch constructs. Thus, the disassembled code more +closely follows the original source ASL. ACPICA BZ 1211. Example: + + Old disassembly: + Else + { + If (Arg0 == 0x02) + { + Local0 = 0x05 + } + } + + New disassembly: + ElseIf (Arg0 == 0x02) + { + Local0 = 0x05 + } + +AcpiExec: Added support for the new module level code behavior and the +early region installation. This required a small change to the +initialization, since AcpiExec must install its own operation region +handlers. + +AcpiExec: Added support to make the debug object timer optional. Default +is timer disabled. This cleans up the debug object output -- the timer +data is rarely used. + +AcpiExec: Multiple ACPI tables are now loaded in the order that they +appear on the command line. This can be important when there are +interdependencies/references between the tables. + +iASL/Templates. Add support to generate template files with multiple +SSDTs within a single output file. Also added ommand line support to +specify the number of SSDTs (in addition to a single DSDT). ACPICA BZ +1223, 1225. + + +---------------------------------------- +24 November 2015. Summary of changes for version 20151124: + +1) ACPICA kernel-resident subsystem: + +Fixed a possible regression for a previous update to FADT handling. The +FADT no longer has a fixed table ID, causing some issues with code that +was hardwired to a specific ID. Lv Zheng. + +Fixed a problem where the method auto-serialization could interfere with +the current SyncLevel. This change makes the auto-serialization support +transparent to the SyncLevel support and management. + +Removed support for the _SUB predefined name in AcpiGetObjectInfo. This +interface is intended for early access to the namespace during the +initial namespace device discovery walk. The _SUB method has been seen to +access operation regions in some cases, causing errors because the +operation regions are not fully initialized. + +AML Debugger: Fixed some issues with the terminate/quit/exit commands +that can cause faults. Lv Zheng. + +AML Debugger: Add thread ID support so that single-step mode only applies +to the AML Debugger thread. This prevents runtime errors within some +kernels. Lv Zheng. + +Eliminated extraneous warnings from AcpiGetSleepTypeData. Since the _Sx +methods that are invoked by this interface are optional, removed warnings +emitted for the case where one or more of these methods do not exist. +ACPICA BZ 1208, original change by Prarit Bhargava. + +Made a major pass through the entire ACPICA source code base to +standardize formatting that has diverged a bit over time. There are no +functional changes, but this will of course cause quite a few code +differences from the previous ACPICA release. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 102.0K Code, 28.3K Data, 130.3K Total + Debug Version: 199.6K Code, 81.8K Data, 281.4K Total + Previous Release: + Non-Debug Version: 101.7K Code, 27.9K Data, 129.6K Total + Debug Version: 199.3K Code, 81.4K Data, 280.7K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL/acpiexec/acpixtract/disassembler: Added support to allow multiple +definition blocks within a single ASL file and the resulting AML file. +Support for this type of file was also added to the various tools that +use binary AML files: acpiexec, acpixtract, and the AML disassembler. The +example code below shows two definition blocks within the same file: + + DefinitionBlock ("dsdt.aml", "DSDT", 2, "Intel", "Template", +0x12345678) + { + } + DefinitionBlock ("", "SSDT", 2, "Intel", "Template", 0xABCDEF01) + { + } + +iASL: Enhanced typechecking for the Name() operator. All expressions for +the value of the named object must be reduced/folded to a single constant +at compile time, as per the ACPI specification (the AML definition of +Name()). + +iASL: Fixed some code indentation issues for the -ic and -ia options (C +and assembly headers). Now all emitted code correctly begins in column 1. + +iASL: Added an error message for an attempt to open a Scope() on an +object defined in an SSDT. The DSDT is always loaded into the namespace +first, so any attempt to open a Scope on an SSDT object will fail at +runtime. + + +---------------------------------------- +30 September 2015. Summary of changes for version 20150930: + +1) ACPICA kernel-resident subsystem: + +Debugger: Implemented several changes and bug fixes to assist support for +the in-kernel version of the AML debugger. Lv Zheng. +- Fix the "predefined" command for in-kernel debugger. +- Do not enter debug command loop for the help and version commands. +- Disallow "execute" command during execution/single-step of a method. + +Interpreter: Updated runtime typechecking for all operators that have +target operands. The operand is resolved and validated that it is legal. +For example, the target cannot be a non-data object such as a Device, +Mutex, ThermalZone, etc., as per the ACPI specification. + +Debugger: Fixed the double-mutex user I/O handshake to work when local +deadlock detection is enabled. + +Debugger: limited display of method locals and arguments (LocalX and +ArgX) to only those that have actually been initialized. This prevents +lines of extraneous output. + +Updated the definition of the NFIT table to correct the bit polarity of +one flag: ACPI_NFIT_MEM_ARMED --> ACPI_NFIT_MEM_NOT_ARMED + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 101.7K Code, 27.9K Data, 129.6K Total + Debug Version: 199.3K Code, 81.4K Data, 280.7K Total + Previous Release: + Non-Debug Version: 101.3K Code, 27.7K Data, 129.0K Total + Debug Version: 198.6K Code, 80.9K Data, 279.5K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Improved the compile-time typechecking for operands of many of the +ASL operators: + +-- Added an option to disable compiler operand/operator typechecking (- +ot). + +-- For the following operators, the TermArg operands are now validated +when possible to be Integer data objects: BankField, OperationRegion, +DataTableRegion, Buffer, and Package. + +-- Store (Source, Target): Both the source and target operands are +resolved and checked that the operands are both legal. For example, +neither operand can be a non-data object such as a Device, Mutex, +ThermalZone, etc. Note, as per the ACPI specification, the CopyObject +operator can be used to store an object to any type of target object. + +-- Store (Source, Target): If the source is a Package object, the target +must be a Package object, LocalX, ArgX, or Debug. Likewise, if the target +is a Package, the source must also be a Package. + +-- Store (Source, Target): A warning is issued if the source and target +resolve to the identical named object. + +-- Store (Source, <method invocation>): An error is generated for the +target method invocation, as this construct is not supported by the AML +interpreter. + +-- For all ASL math and logic operators, the target operand must be a +data object (Integer, String, Buffer, LocalX, ArgX, or Debug). This +includes the function return value also. + +-- External declarations are also included in the typechecking where +possible. External objects defined using the UnknownObj keyword cannot be +typechecked, however. + +iASL and Disassembler: Added symbolic (ASL+) support for the ASL Index +operator: +- Legacy code: Index(PKG1, 3) +- New ASL+ code: PKG1[3] +This completes the ACPI 6.0 ASL+ support as it was the only operator not +supported. + +iASL: Fixed the file suffix for the preprocessor output file (.i). Two +spaces were inadvertently appended to the filename, causing file access +and deletion problems on some systems. + +ASL Test Suite (ASLTS): Updated the master makefile to generate all +possible compiler output files when building the test suite -- thus +exercising these features of the compiler. These files are automatically +deleted when the test suite exits. + + +---------------------------------------- +18 August 2015. Summary of changes for version 20150818: + +1) ACPICA kernel-resident subsystem: + +Fix a regression for AcpiGetTableByIndex interface causing it to fail. Lv +Zheng. ACPICA BZ 1186. + +Completed development to ensure that the ACPICA Disassembler and Debugger +are fully standalone components of ACPICA. Removed cross-component +dependences. Lv Zheng. + +The max-number-of-AML-loops is now runtime configurable (previously was +compile-time only). This is essentially a loop timeout to force-abort +infinite AML loops. ACPCIA BZ 1192. + +Debugger: Cleanup output to dump ACPI names and namepaths without any +trailing underscores. Lv Zheng. ACPICA BZ 1135. + +Removed unnecessary conditional compilations across the Debugger and +Disassembler components where entire modules could be left uncompiled. + +The aapits test is deprecated and has been removed from the ACPICA git +tree. The test has never been completed and has not been maintained, thus +becoming rather useless. ACPICA BZ 1015, 794. + +A batch of small changes to close bugzilla and other reports: +- Remove duplicate code for _PLD processing. ACPICA BZ 1176. +- Correctly cleanup after a ACPI table load failure. ACPICA BZ 1185. +- iASL: Support POSIX yacc again in makefile. Jung-uk Kim. +- ACPI table support: general cleanup and simplification. Lv Zheng, Bob +Moore. +- ACPI table support: fix for a buffer read overrun in AcpiTbFindTable. +ACPICA BZ 1184. +- Enhance parameter validation for DataTableRegion and LoadTable ASL/AML +operators. +- Debugger: Split debugger initialization/termination interfaces. Lv +Zheng. +- AcpiExec: Emit OemTableId for SSDTs during the load phase for table +identification. +- AcpiExec: Add debug message during _REG method phase during table +load/init. +- AcpiNames: Fix a regression where some output was missing and no longer +emitted. +- Debugger: General cleanup and simplification. Lv Zheng. +- Disassembler: Cleanup use of several global option variables. Lv Zheng. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 101.3K Code, 27.7K Data, 129.0K Total + Debug Version: 198.6K Code, 80.9K Data, 279.5K Total + Previous Release: + Non-Debug Version: 100.9K Code, 24.5K Data, 125.4K Total + Debug Version: 197.8K Code, 81.5K Data, 279.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +AcpiExec: Fixed a problem where any more than 32 ACPI tables in the XSDT +were not handled properly and caused load errors. Now, properly invoke +and use the ACPICA auto-reallocate mechanism for ACPI table data +structures. ACPICA BZ 1188 + +AcpiNames: Add command-line wildcard support for ACPI table files. ACPICA +BZ 1190. + +AcpiExec and AcpiNames: Add -l option to load ACPI tables only. For +AcpiExec, this means that no control methods (like _REG/_INI/_STA) are +executed during initialization. ACPICA BZ 1187, 1189. + +iASL/Disassembler: Implemented a prototype "listing" mode that emits AML +that corresponds to each disassembled ASL statement, to simplify +debugging. ACPICA BZ 1191. + +Debugger: Add option to the "objects" command to display a summary of the +current namespace objects (Object type and count). This is displayed if +the command is entered with no arguments. + +AcpiNames: Add -x option to specify debug level, similar to AcpiExec. + + +---------------------------------------- +17 July 2015. Summary of changes for version 20150717: + +1) ACPICA kernel-resident subsystem: + +Improved the partitioning between the Debugger and Disassembler +components. This allows the Debugger to be used standalone within kernel +code without the Disassembler (which is used for single stepping also). +This renames and moves one file, dmobject.c to dbobject.c. Lv Zheng. + +Debugger: Implemented a new command to trace the execution of control +methods (Trace). This is especially useful for the in-kernel version of +the debugger when file I/O may not be available for method trace output. +See the ACPICA reference for more information. Lv Zheng. + +Moved all C library prototypes (used for the local versions of these +functions when requested) to a new header, acclib.h +Cleaned up the use of non-ANSI C library functions. These functions are +implemented locally in ACPICA. Moved all such functions to a common +source file, utnonansi.c + +Debugger: Fixed a problem with the "!!" command (get last command +executed) where the debugger could enter an infinite loop and eventually +crash. + +Removed the use of local macros that were used for some of the standard C +library functions to automatically cast input parameters. This mostly +affected the is* functions where the input parameter is defined to be an +int. This required a few modifications to the main ACPICA source code to +provide casting for these functions and eliminate possible compiler +warnings for these parameters. + +Across the source code, added additional status/error checking to resolve +issues discovered by static source code analysis tools such as Coverity. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 100.9K Code, 24.5K Data, 125.4K Total + Debug Version: 197.8K Code, 81.5K Data, 279.3K Total + Previous Release: + Non-Debug Version: 100.6K Code, 27.6K Data, 128.2K Total + Debug Version: 196.2K Code, 81.0K Data, 277.2K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Fixed a regression where the device map file feature no longer +worked properly when used in conjunction with the disassembler. It only +worked properly with the compiler itself. + +iASL: Implemented a new warning for method LocalX variables that are set +but never used (similar to a C compiler such as gcc). This also applies +to ArgX variables that are not defined by the parent method, and are +instead (legally) used as local variables. + +iASL/Preprocessor: Finished the pass-through of line numbers from the +preprocessor to the compiler. This ensures that compiler errors/warnings +have the correct original line numbers and filenames, regardless of any +#include files. + +iASL/Preprocessor: Fixed a couple of issues with comment handling and the +pass-through of comments to the preprocessor output file (which becomes +the compiler input file). Also fixed a problem with // comments that +appear after a math expression. + +iASL: Added support for the TCPA server table to the table compiler and +template generator. (The client table was already previously supported) + +iASL/Preprocessor: Added a permanent #define of the symbol "__IASL__" to +identify the iASL compiler. + +Cleaned up the use of the macros NEGATIVE and POSITIVE which were defined +multiple times. The new names are ACPI_SIGN_NEGATIVE and +ACPI_SIGN_POSITIVE. + +AcpiHelp: Update to expand help messages for the iASL preprocessor +directives. + + +---------------------------------------- +19 June 2015. Summary of changes for version 20150619: + +Two regressions in version 20150616 have been addressed: + +Fixes some problems/issues with the C library macro removal (ACPI_STRLEN, +etc.) This update changes ACPICA to only use the standard headers for +functions, or the prototypes for the local versions of the C library +functions. Across the source code, this required some additional casts +for some Clib invocations for portability. Moved all local prototypes to +a new file, acclib.h + +Fixes several problems with recent changes to the handling of the FACS +table that could cause some systems not to boot. + + +---------------------------------------- +16 June 2015. Summary of changes for version 20150616: + + +1) ACPICA kernel-resident subsystem: + +Across the entire ACPICA source code base, the various macros for the C +library functions (such as ACPI_STRLEN, etc.) have been removed and +replaced by the standard C library names (strlen, etc.) The original +purpose for these macros is no longer applicable. This simplification +reduces the number of macros used in the ACPICA source code +significantly, improving readability and maintainability. + +Implemented support for a new ACPI table, the OSDT. This table, the +"override" SDT, can be loaded directly by the host OS at boot time. It +enables the replacement of existing namespace objects that were installed +via the DSDT and/or SSDTs. The primary purpose for this is to replace +buggy or incorrect ASL/AML code obtained via the BIOS. The OSDT is slated +for inclusion in a future version of the ACPI Specification. Lv Zheng/Bob +Moore. + +Added support for systems with (improperly) two FACS tables -- a "32-bit" +table (via FADT 32-bit legacy field) and a "64-bit" table (via the 64-bit +X field). This change will support both automatically. There continues to +be systems found with this issue. This support requires a change to the +AcpiSetFirmwareWakingVector interface. Also, a public global variable has +been added to allow the host to select which FACS is desired +(AcpiGbl_Use32BitFacsAddresses). See the ACPICA reference for more +details Lv Zheng. + +Added a new feature to allow for systems that do not contain an FACS. +Although this is already supported on hardware-reduced platforms, the +feature has been extended for all platforms. The reasoning is that we do +not want to abort the entire ACPICA initialization just because the +system is seriously buggy and has no FACS. + +Fixed a problem where the GUID strings for NFIT tables (in acuuid.h) were +not correctly transcribed from the ACPI specification in ACPICA version +20150515. + +Implemented support for the _CLS object in the AcpiGetObjectInfo external +interface. + +Updated the definitions of the TCPA and TPM2 ACPI tables to the more +recent TCG ACPI Specification, December 14, 2014. Table disassembler and +compiler also updated. Note: The TCPA "server" table is not supported by +the disassembler/table-compiler at this time. + +ACPI 6.0: Added definitions for the new GIC version field in the MADT. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 100.6K Code, 27.6K Data, 128.2K Total + Debug Version: 196.2K Code, 81.0K Data, 277.2K Total + Previous Release: + Non-Debug Version: 99.9K Code, 27.5K Data, 127.4K Total + Debug Version: 195.2K Code, 80.8K Data, 276.0K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Fixed a problem with the new symbolic operator disassembler +where incorrect ASL code could be emitted in some cases for the "non- +commutative" operators -- Subtract, Divide, Modulo, ShiftLeft, and +ShiftRight. The actual problem cases seem to be rather unusual in common +ASL code, however. David Box. + +Modified the linux version of acpidump to obtain ACPI tables from not +just /dev/mem (which may not exist) and /sys/firmware/acpi/tables. Lv +Zheng. + +iASL: Fixed a problem where the user preprocessor output file (.i) +contained extra data that was not expected. The compiler was using this +file as a temporary file and passed through #line directives in order to +keep compiler error messages in sync with the input file and line number +across multiple include files. The (.i) is no longer a temporary file as +the compiler uses a new, different file for the original purpose. + +iASL: Fixed a problem where comments within the original ASL source code +file were not passed through to the preprocessor output file, nor any +listing files. + +iASL: Fixed some issues for the handling of the "#include" preprocessor +directive and the similar (but not the same) "Include" ASL operator. + +iASL: Add support for the new OSDT in both the disassembler and compiler. + +iASL: Fixed a problem with the constant folding support where a Buffer +object could be incorrectly generated (incorrectly formed) during a +conversion to a Store() operator. + +AcpiHelp: Updated for new NFIT GUIDs, "External" AML opcode, and new +description text for the _REV predefined name. _REV now permanently +returns 2, as per the ACPI 6.0 specification. + +Debugger: Enhanced the output of the Debug ASL object for references +produced by the Index operator. For Buffers and strings, only output the +actual byte pointed to by the index. For packages, only print the single +package element decoded by the index. Previously, the entire +buffer/string/package was emitted. + +iASL/Table-compiler: Fixed a regression where the "generic" data types +were no longer recognized, causing errors. + + +---------------------------------------- +15 May 2015. Summary of changes for version 20150515: This release implements most of ACPI 6.0 as described below. @@ -34,7 +959,7 @@ iASL disassembler and table compiler: Added ACPI 6.0 changes to existing tables: FADT, MADT. iASL preprocessor: Added a new directive to enable inclusion of binary -blobs into ASL code. The new directive is #includebinary. It takes a +blobs into ASL code. The new directive is #includebuffer. It takes a binary file as input and emits a named ascii buffer object into the ASL code. @@ -46,6 +971,7 @@ directives. AcpiHelp: Added a new option, -t, to display all known/supported ACPI tables. + ---------------------------------------- 10 April 2015. Summary of changes for version 20150410: @@ -53,6 +979,7 @@ Reverted a change introduced in version 20150408 that caused a regression in the disassembler where incorrect operator symbols could be emitted. + ---------------------------------------- 08 April 2015. Summary of changes for version 20150408: @@ -125,6 +1052,7 @@ Debugger: Removed some unused global variables. Tests: Updated the makefile for proper generation of the AAPITS suite. + ---------------------------------------- 04 February 2015. Summary of changes for version 20150204: @@ -165,7 +1093,8 @@ David Box Non-Debug Version: 101.7K Code, 27.9K Data, 129.6K Total Debug Version: 199.2K Code, 82.4K Data, 281.6K Total ----------------------------------------- +-- +-------------------------------------- 07 November 2014. Summary of changes for version 20141107: This release is available at https://acpica.org/downloads @@ -669,6 +1598,7 @@ Disassembler: Cleaned up a block of code that extracts a parent Op object. Added a comment that explains that the parent is guaranteed to be valid in this case. ACPICA BZ 1069. + ---------------------------------------- 24 April 2014. Summary of changes for version 20140424: @@ -736,6 +1666,7 @@ checking and take care not to reset terminal attributes on exit if they were never set. This should help guarantee that the terminal is always left in the previous state on program exit. + ---------------------------------------- 25 March 2014. Summary of changes for version 20140325: @@ -836,6 +1767,7 @@ AcpiBin utility: is made obsolete by the AcpiXtract utility. 2) General cleanup of open files and allocated buffers. + ---------------------------------------- 14 February 2014. Summary of changes for version 20140214: @@ -901,6 +1833,7 @@ iASL: Removed the obsolete -g option to obtain ACPI tables from the Windows registry. This feature has been superseded by the acpidump utility. + ---------------------------------------- 14 January 2014. Summary of changes for version 20140114: @@ -977,6 +1910,7 @@ Debugger: Added the "test predefined" command. This change makes this test public and puts it under the new "test" command. The test executes each and every predefined name within the current namespace. + ---------------------------------------- 18 December 2013. Summary of changes for version 20131218: @@ -1079,6 +2013,7 @@ that it builds to an actual working program, not just example code. Added ACPI tables and execution of an example control method in the DSDT. Added makefile support for Unix generation. + ---------------------------------------- 15 November 2013. Summary of changes for version 20131115: diff --git a/sys/contrib/dev/acpica/common/acfileio.c b/sys/contrib/dev/acpica/common/acfileio.c new file mode 100644 index 0000000..da64d40 --- /dev/null +++ b/sys/contrib/dev/acpica/common/acfileio.c @@ -0,0 +1,538 @@ +/****************************************************************************** + * + * Module Name: acfileio - Get ACPI tables from file + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acapps.h> +#include <contrib/dev/acpica/include/actables.h> +#include <contrib/dev/acpica/include/acutils.h> +#include <errno.h> + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("acfileio") + + +/* Local prototypes */ + +static ACPI_STATUS +AcGetOneTableFromFile ( + char *Filename, + FILE *File, + UINT8 GetOnlyAmlTables, + ACPI_TABLE_HEADER **Table); + +static ACPI_STATUS +AcCheckTextModeCorruption ( + ACPI_TABLE_HEADER *Table); + + +/******************************************************************************* + * + * FUNCTION: AcGetAllTablesFromFile + * + * PARAMETERS: Filename - Table filename + * GetOnlyAmlTables - TRUE if the tables must be AML tables + * ReturnListHead - Where table list is returned + * + * RETURN: Status + * + * DESCRIPTION: Get all ACPI tables from within a single file. + * + ******************************************************************************/ + +ACPI_STATUS +AcGetAllTablesFromFile ( + char *Filename, + UINT8 GetOnlyAmlTables, + ACPI_NEW_TABLE_DESC **ReturnListHead) +{ + ACPI_NEW_TABLE_DESC *ListHead = NULL; + ACPI_NEW_TABLE_DESC *ListTail = NULL; + ACPI_NEW_TABLE_DESC *TableDesc; + FILE *File; + ACPI_TABLE_HEADER *Table = NULL; + UINT32 FileSize; + ACPI_STATUS Status = AE_OK; + + + File = fopen (Filename, "rb"); + if (!File) + { + perror ("Could not open input file"); + if (errno == ENOENT) + { + return (AE_NOT_EXIST); + } + + return (AE_ERROR); + } + + /* Get the file size */ + + FileSize = CmGetFileSize (File); + if (FileSize == ACPI_UINT32_MAX) + { + Status = AE_ERROR; + goto ErrorExit; + } + + fprintf (stderr, + "Input file %s, Length 0x%X (%u) bytes\n", + Filename, FileSize, FileSize); + + /* We must have at least one ACPI table header */ + + if (FileSize < sizeof (ACPI_TABLE_HEADER)) + { + Status = AE_BAD_HEADER; + goto ErrorExit; + } + + /* Check for an non-binary file */ + + if (!AcIsFileBinary (File)) + { + fprintf (stderr, + " %s: File does not appear to contain a valid AML table\n", + Filename); + return (AE_TYPE); + } + + /* Read all tables within the file */ + + while (ACPI_SUCCESS (Status)) + { + /* Get one entire ACPI table */ + + Status = AcGetOneTableFromFile ( + Filename, File, GetOnlyAmlTables, &Table); + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + break; + } + else if (Status == AE_TYPE) + { + return (AE_OK); + } + else if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Print table header for iASL/disassembler only */ + +#ifdef ACPI_ASL_COMPILER + + AcpiTbPrintTableHeader (0, Table); +#endif + + /* Allocate and link a table descriptor */ + + TableDesc = AcpiOsAllocate (sizeof (ACPI_NEW_TABLE_DESC)); + TableDesc->Table = Table; + TableDesc->Next = NULL; + + /* Link at the end of the local table list */ + + if (!ListHead) + { + ListHead = TableDesc; + ListTail = TableDesc; + } + else + { + ListTail->Next = TableDesc; + ListTail = TableDesc; + } + } + + /* Add the local table list to the end of the global list */ + + if (*ReturnListHead) + { + ListTail = *ReturnListHead; + while (ListTail->Next) + { + ListTail = ListTail->Next; + } + + ListTail->Next = ListHead; + } + else + { + *ReturnListHead = ListHead; + } + +ErrorExit: + fclose(File); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcGetOneTableFromFile + * + * PARAMETERS: Filename - File where table is located + * File - Open FILE pointer to Filename + * GetOnlyAmlTables - TRUE if the tables must be AML tables. + * ReturnTable - Where a pointer to the table is returned + * + * RETURN: Status + * + * DESCRIPTION: Read the next ACPI table from a file. Implements support + * for multiple tables within a single file. File must already + * be open. + * + * Note: Loading an RSDP is not supported. + * + ******************************************************************************/ + +static ACPI_STATUS +AcGetOneTableFromFile ( + char *Filename, + FILE *File, + UINT8 GetOnlyAmlTables, + ACPI_TABLE_HEADER **ReturnTable) +{ + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER TableHeader; + ACPI_TABLE_HEADER *Table; + INT32 Count; + long TableOffset; + + + *ReturnTable = NULL; + + /* Get the table header to examine signature and length */ + + TableOffset = ftell (File); + Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File); + if (Count != sizeof (ACPI_TABLE_HEADER)) + { + return (AE_CTRL_TERMINATE); + } + + /* Validate the table signature/header (limited ASCII chars) */ + + Status = AcValidateTableHeader (File, TableOffset); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (GetOnlyAmlTables) + { + /* Table must be an AML table (DSDT/SSDT) or FADT */ + + if (!ACPI_COMPARE_NAME (TableHeader.Signature, ACPI_SIG_FADT) && + !AcpiUtIsAmlTable (&TableHeader)) + { + fprintf (stderr, + " %s: Table [%4.4s] is not an AML table - ignoring\n", + Filename, TableHeader.Signature); + + return (AE_TYPE); + } + } + + /* Allocate a buffer for the entire table */ + + Table = AcpiOsAllocate ((size_t) TableHeader.Length); + if (!Table) + { + return (AE_NO_MEMORY); + } + + /* Read the entire ACPI table, including header */ + + fseek (File, TableOffset, SEEK_SET); + + Count = fread (Table, 1, TableHeader.Length, File); + if (Count != (INT32) TableHeader.Length) + { + Status = AE_ERROR; + goto ErrorExit; + } + + /* Validate the checksum (just issue a warning) */ + + Status = AcpiTbVerifyChecksum (Table, TableHeader.Length); + if (ACPI_FAILURE (Status)) + { + Status = AcCheckTextModeCorruption (Table); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + } + + *ReturnTable = Table; + return (AE_OK); + + +ErrorExit: + AcpiOsFree (Table); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcIsFileBinary + * + * PARAMETERS: File - Open input file + * + * RETURN: TRUE if file appears to be binary + * + * DESCRIPTION: Scan a file for any non-ASCII bytes. + * + * Note: Maintains current file position. + * + ******************************************************************************/ + +BOOLEAN +AcIsFileBinary ( + FILE *File) +{ + UINT8 Byte; + BOOLEAN IsBinary = FALSE; + long FileOffset; + + + /* Scan entire file for any non-ASCII bytes */ + + FileOffset = ftell (File); + while (fread (&Byte, 1, 1, File) == 1) + { + if (!isprint (Byte) && !isspace (Byte)) + { + IsBinary = TRUE; + goto Exit; + } + } + +Exit: + fseek (File, FileOffset, SEEK_SET); + return (IsBinary); +} + + +/******************************************************************************* + * + * FUNCTION: AcValidateTableHeader + * + * PARAMETERS: File - Open input file + * + * RETURN: Status + * + * DESCRIPTION: Determine if a file seems to contain one or more binary ACPI + * tables, via the + * following checks on what would be the table header: + * 1) File must be at least as long as an ACPI_TABLE_HEADER + * 2) There must be enough room in the file to hold entire table + * 3) Signature, OemId, OemTableId, AslCompilerId must be ASCII + * + * Note: There can be multiple definition blocks per file, so we cannot + * expect/compare the file size to be equal to the table length. 12/2015. + * + * Note: Maintains current file position. + * + ******************************************************************************/ + +ACPI_STATUS +AcValidateTableHeader ( + FILE *File, + long TableOffset) +{ + ACPI_TABLE_HEADER TableHeader; + size_t Actual; + long OriginalOffset; + UINT32 FileSize; + UINT32 i; + + + ACPI_FUNCTION_TRACE ("AcValidateTableHeader"); + + + /* Read a potential table header */ + + OriginalOffset = ftell (File); + fseek (File, TableOffset, SEEK_SET); + + Actual = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File); + fseek (File, OriginalOffset, SEEK_SET); + + if (Actual < sizeof (ACPI_TABLE_HEADER)) + { + return (AE_ERROR); + } + + /* Validate the signature (limited ASCII chars) */ + + if (!AcpiUtValidNameseg (TableHeader.Signature)) + { + fprintf (stderr, "Invalid table signature: 0x%8.8X\n", + *ACPI_CAST_PTR (UINT32, TableHeader.Signature)); + return (AE_BAD_SIGNATURE); + } + + /* Validate table length against bytes remaining in the file */ + + FileSize = CmGetFileSize (File); + if (TableHeader.Length > (UINT32) (FileSize - TableOffset)) + { + fprintf (stderr, "Table [%4.4s] is too long for file - " + "needs: 0x%.2X, remaining in file: 0x%.2X\n", + TableHeader.Signature, TableHeader.Length, + (UINT32) (FileSize - TableOffset)); + return (AE_BAD_HEADER); + } + + /* + * These fields must be ASCII: OemId, OemTableId, AslCompilerId. + * We allow a NULL terminator in OemId and OemTableId. + */ + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!ACPI_IS_ASCII ((UINT8) TableHeader.AslCompilerId[i])) + { + goto BadCharacters; + } + } + + for (i = 0; (i < ACPI_OEM_ID_SIZE) && (TableHeader.OemId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) TableHeader.OemId[i])) + { + goto BadCharacters; + } + } + + for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (TableHeader.OemTableId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) TableHeader.OemTableId[i])) + { + goto BadCharacters; + } + } + + return (AE_OK); + + +BadCharacters: + + ACPI_WARNING ((AE_INFO, + "Table header for [%4.4s] has invalid ASCII character(s)", + TableHeader.Signature)); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcCheckTextModeCorruption + * + * PARAMETERS: Table - Table buffer starting with table header + * + * RETURN: Status + * + * DESCRIPTION: Check table for text mode file corruption where all linefeed + * characters (LF) have been replaced by carriage return linefeed + * pairs (CR/LF). + * + ******************************************************************************/ + +static ACPI_STATUS +AcCheckTextModeCorruption ( + ACPI_TABLE_HEADER *Table) +{ + UINT32 i; + UINT32 Pairs = 0; + UINT8 *Buffer = ACPI_CAST_PTR (UINT8, Table); + + + /* Scan entire table to determine if each LF has been prefixed with a CR */ + + for (i = 1; i < Table->Length; i++) + { + if (Buffer[i] == 0x0A) + { + if (Buffer[i - 1] != 0x0D) + { + /* The LF does not have a preceding CR, table not corrupted */ + + return (AE_OK); + } + else + { + /* Found a CR/LF pair */ + + Pairs++; + } + + i++; + } + } + + if (!Pairs) + { + return (AE_OK); + } + + /* + * Entire table scanned, each CR is part of a CR/LF pair -- + * meaning that the table was treated as a text file somewhere. + * + * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the + * original table are left untouched by the text conversion process -- + * meaning that we cannot simply replace CR/LF pairs with LFs. + */ + AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); + AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs); + AcpiOsPrintf ("Table cannot be repaired!\n"); + + return (AE_BAD_VALUE); +} diff --git a/sys/contrib/dev/acpica/common/acgetline.c b/sys/contrib/dev/acpica/common/acgetline.c index 712b4a3..1f67ca3 100644 --- a/sys/contrib/dev/acpica/common/acgetline.c +++ b/sys/contrib/dev/acpica/common/acgetline.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -262,6 +262,7 @@ AcpiOsGetLine ( ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition + 1); EndOfLine--; + if (CursorPosition > 0) { CursorPosition--; diff --git a/sys/contrib/dev/acpica/common/adfile.c b/sys/contrib/dev/acpica/common/adfile.c index 2bfe7ed..8cd353f 100644 --- a/sys/contrib/dev/acpica/common/adfile.c +++ b/sys/contrib/dev/acpica/common/adfile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,7 @@ AdGenerateFilename ( } FilenameBuf[i] = 0; - strcat (FilenameBuf, ACPI_TABLE_FILE_SUFFIX); + strcat (FilenameBuf, FILE_SUFFIX_BINARY_TABLE); return (FilenameBuf); } diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c index 5d0cee2..73499ae 100644 --- a/sys/contrib/dev/acpica/common/adisasm.c +++ b/sys/contrib/dev/acpica/common/adisasm.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,16 +42,14 @@ */ #include <contrib/dev/acpica/compiler/aslcompiler.h> -#include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acdisasm.h> #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/acnamesp.h> -#include <contrib/dev/acpica/include/actables.h> +#include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/acapps.h> #include <stdio.h> -#include <time.h> #define _COMPONENT ACPI_TOOLS @@ -59,17 +57,29 @@ /* Local prototypes */ -static void -AdCreateTableHeader ( +static ACPI_STATUS +AdDoExternalFileList ( + char *Filename); + +static ACPI_STATUS +AdDisassembleOneTable ( + ACPI_TABLE_HEADER *Table, + FILE *File, char *Filename, - ACPI_TABLE_HEADER *Table); + char *DisasmFilename); static ACPI_STATUS -AdStoreTable ( +AdReparseOneTable ( ACPI_TABLE_HEADER *Table, - UINT32 *TableIndex); + FILE *File, + ACPI_OWNER_ID OwnerId); -/* Stubs for ASL compiler */ + +ACPI_TABLE_DESC LocalTables[1]; +ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; + + +/* Stubs for everything except ASL compiler */ #ifndef ACPI_ASL_COMPILER BOOLEAN @@ -77,7 +87,7 @@ AcpiDsIsResultUsed ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState) { - return TRUE; + return (TRUE); } ACPI_STATUS @@ -89,52 +99,6 @@ AcpiDsMethodError ( } #endif -ACPI_STATUS -AcpiNsLoadTable ( - UINT32 TableIndex, - ACPI_NAMESPACE_NODE *Node) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiDsRestartControlMethod ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT *ReturnDesc) -{ - return (AE_OK); -} - -void -AcpiDsTerminateControlMethod ( - ACPI_OPERAND_OBJECT *MethodDesc, - ACPI_WALK_STATE *WalkState) -{ - return; -} - -ACPI_STATUS -AcpiDsCallControlMethod ( - ACPI_THREAD_STATE *Thread, - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiDsMethodDataInitArgs ( - ACPI_OPERAND_OBJECT **Params, - UINT32 MaxParamCount, - ACPI_WALK_STATE *WalkState) -{ - return (AE_OK); -} - - -static ACPI_TABLE_DESC LocalTables[1]; -ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; - /******************************************************************************* * @@ -202,7 +166,7 @@ AdInitialize ( * * RETURN: Status * - * DESCRIPTION: Disassemble an entire ACPI table + * DESCRIPTION: Disassembler entry point. Disassemble an entire ACPI table. * *****************************************************************************/ @@ -214,14 +178,10 @@ AdAmlDisassemble ( char **OutFilename) { ACPI_STATUS Status; - ACPI_STATUS GlobalStatus = AE_OK; char *DisasmFilename = NULL; - char *ExternalFilename; - ACPI_EXTERNAL_FILE *ExternalFileList = AcpiGbl_ExternalFileList; FILE *File = NULL; ACPI_TABLE_HEADER *Table = NULL; - ACPI_TABLE_HEADER *ExternalTable; - ACPI_OWNER_ID OwnerId; + ACPI_NEW_TABLE_DESC *ListHead = NULL; /* @@ -230,81 +190,24 @@ AdAmlDisassemble ( */ if (Filename) { - Status = AcpiDbGetTableFromFile (Filename, &Table, FALSE); + /* Get the list of all AML tables in the file */ + + Status = AcGetAllTablesFromFile (Filename, + ACPI_GET_ALL_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { + AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n", + Filename, AcpiFormatException (Status)); return (Status); } - /* - * External filenames separated by commas - * Example: iasl -e file1,file2,file3 -d xxx.aml - */ - while (ExternalFileList) - { - ExternalFilename = ExternalFileList->Path; - if (!ACPI_STRCMP (ExternalFilename, Filename)) - { - /* Next external file */ - - ExternalFileList = ExternalFileList->Next; - continue; - } - - Status = AcpiDbGetTableFromFile (ExternalFilename, &ExternalTable, TRUE); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_TYPE) - { - ExternalFileList = ExternalFileList->Next; - GlobalStatus = AE_TYPE; - Status = AE_OK; - continue; - } - return (Status); - } - - /* Load external table for symbol resolution */ - - if (ExternalTable) - { - Status = AdParseTable (ExternalTable, &OwnerId, TRUE, TRUE); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not parse external ACPI tables, %s\n", - AcpiFormatException (Status)); - return (Status); - } - - /* - * Load namespace from names created within control methods - * Set owner id of nodes in external table - */ - AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, - AcpiGbl_RootNode, OwnerId); - AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); - } - - /* Next external file */ - - ExternalFileList = ExternalFileList->Next; - } - - if (ACPI_FAILURE (GlobalStatus)) - { - return (GlobalStatus); - } - - /* Clear external list generated by Scope in external tables */ + /* Process any user-specified files for external objects */ - if (AcpiGbl_ExternalFileList) + Status = AdDoExternalFileList (Filename); + if (ACPI_FAILURE (Status)) { - AcpiDmClearExternalList (); + return (Status); } - - /* Load any externals defined in the optional external ref file */ - - AcpiDmGetExternalsFromFile (); } else { @@ -316,7 +219,7 @@ AdAmlDisassemble ( return (Status); } - if (!AcpiGbl_DbOpt_Disasm) + if (!AcpiGbl_DmOpt_Disasm) { return (AE_OK); } @@ -353,7 +256,8 @@ AdAmlDisassemble ( File = fopen (DisasmFilename, "w+"); if (!File) { - fprintf (stderr, "Could not open output file %s\n", DisasmFilename); + fprintf (stderr, "Could not open output file %s\n", + DisasmFilename); Status = AE_ERROR; goto Cleanup; } @@ -363,190 +267,31 @@ AdAmlDisassemble ( *OutFilename = DisasmFilename; - /* ForceAmlDisassembly means to assume the table contains valid AML */ - - if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table)) - { - AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE); - AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n", - Table->Signature); - AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] " - "FieldName : FieldValue\n */\n\n"); - - AcpiDmDumpDataTable (Table); - fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n", - Table->Signature); + /* Disassemble all AML tables within the file */ - if (File) - { - fprintf (stderr, "Formatted output: %s - %u bytes\n", - DisasmFilename, CmGetFileSize (File)); - } - } - else + while (ListHead) { - /* Always parse the tables, only option is what to display */ - - Status = AdParseTable (Table, &OwnerId, TRUE, FALSE); + Status = AdDisassembleOneTable (ListHead->Table, + File, Filename, DisasmFilename); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not parse ACPI tables, %s\n", - AcpiFormatException (Status)); - goto Cleanup; - } - - if (AslCompilerdebug) - { - AcpiOsPrintf ("/**** Before second load\n"); - - if (File) - { - NsSetupNamespaceListing (File); - NsDisplayNamespace (); - } - AcpiOsPrintf ("*****/\n"); - } - - /* Load namespace from names created within control methods */ - - AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, - AcpiGbl_RootNode, OwnerId); - - /* - * Cross reference the namespace here, in order to - * generate External() statements - */ - AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, - AcpiGbl_RootNode, OwnerId); - - if (AslCompilerdebug) - { - AcpiDmDumpTree (AcpiGbl_ParseOpRoot); - } - - /* Find possible calls to external control methods */ - - AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot); - - /* - * If we found any external control methods, we must reparse - * the entire tree with the new information (namely, the - * number of arguments per method) - */ - if (AcpiDmGetExternalMethodCount ()) - { - fprintf (stderr, - "\nFound %u external control methods, " - "reparsing with new information\n", - AcpiDmGetExternalMethodCount ()); - - /* Reparse, rebuild namespace */ - - AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); - AcpiGbl_ParseOpRoot = NULL; - AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); - - AcpiGbl_RootNode = NULL; - AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; - AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; - AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; - AcpiGbl_RootNodeStruct.Parent = NULL; - AcpiGbl_RootNodeStruct.Child = NULL; - AcpiGbl_RootNodeStruct.Peer = NULL; - AcpiGbl_RootNodeStruct.Object = NULL; - AcpiGbl_RootNodeStruct.Flags = 0; - - Status = AcpiNsRootInitialize (); - - /* New namespace, add the external definitions first */ - - AcpiDmAddExternalsToNamespace (); - - /* Parse the table again. No need to reload it, however */ - - Status = AdParseTable (Table, NULL, FALSE, FALSE); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not parse ACPI tables, %s\n", - AcpiFormatException (Status)); - goto Cleanup; - } - - /* Cross reference the namespace again */ - - AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, - AcpiGbl_RootNode, OwnerId); - - AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, - AcpiGbl_RootNode, OwnerId); - - if (AslCompilerdebug) - { - AcpiOsPrintf ("/**** After second load and resource conversion\n"); - if (File) - { - NsSetupNamespaceListing (File); - NsDisplayNamespace (); - } - AcpiOsPrintf ("*****/\n"); - - AcpiDmDumpTree (AcpiGbl_ParseOpRoot); - } + break; } - /* - * Now that the namespace is finalized, we can perform namespace - * transforms. - * - * 1) Convert fixed-offset references to resource descriptors - * to symbolic references (Note: modifies namespace) - */ - AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); - - /* Optional displays */ - - if (AcpiGbl_DbOpt_Disasm) - { - /* This is the real disassembly */ - - AdDisplayTables (Filename, Table); - - /* Dump hex table if requested (-vt) */ - - AcpiDmDumpDataTable (Table); - - fprintf (stderr, "Disassembly completed\n"); - if (File) - { - fprintf (stderr, "ASL Output: %s - %u bytes\n", - DisasmFilename, CmGetFileSize (File)); - } - - if (Gbl_MapfileFlag) - { - fprintf (stderr, "%14s %s - %u bytes\n", - Gbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription, - Gbl_Files[ASL_FILE_MAP_OUTPUT].Filename, - FlGetFileSize (ASL_FILE_MAP_OUTPUT)); - } - } + ListHead = ListHead->Next; } Cleanup: - if (Table && !AcpiGbl_ForceAmlDisassembly &&!AcpiUtIsAmlTable (Table)) + if (Table && + !AcpiGbl_ForceAmlDisassembly && + !AcpiUtIsAmlTable (Table)) { ACPI_FREE (Table); } if (File) { - if (AslCompilerdebug) /* Display final namespace, with transforms */ - { - NsSetupNamespaceListing (File); - NsDisplayNamespace (); - } - fclose (File); AcpiOsRedirectOutput (stdout); } @@ -559,290 +304,243 @@ Cleanup: /****************************************************************************** * - * FUNCTION: AdDisassemblerHeader + * FUNCTION: AdDisassembleOneTable * - * PARAMETERS: Filename - Input file for the table - * TableType - Either AML or DataTable + * PARAMETERS: Table - Raw AML table + * File - Pointer for the input file + * Filename - AML input filename + * DisasmFilename - Output filename * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Create the disassembler header, including ACPICA signon with - * current time and date. + * DESCRIPTION: Disassemble a single ACPI table. AML or data table. * *****************************************************************************/ -void -AdDisassemblerHeader ( +static ACPI_STATUS +AdDisassembleOneTable ( + ACPI_TABLE_HEADER *Table, + FILE *File, char *Filename, - UINT8 TableType) + char *DisasmFilename) { - time_t Timer; - - - time (&Timer); + ACPI_STATUS Status; + ACPI_OWNER_ID OwnerId; - /* Header and input table info */ - AcpiOsPrintf ("/*\n"); - AcpiOsPrintf (ACPI_COMMON_HEADER (AML_DISASSEMBLER_NAME, " * ")); + /* ForceAmlDisassembly means to assume the table contains valid AML */ - if (TableType == ACPI_IS_AML_TABLE) + if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table)) { - if (AcpiGbl_CstyleDisassembly) - { - AcpiOsPrintf ( - " * Disassembling to symbolic ASL+ operators\n" - " *\n"); - } - else - { - AcpiOsPrintf ( - " * Disassembling to non-symbolic legacy ASL operators\n" - " *\n"); - } - } + AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE); - AcpiOsPrintf (" * Disassembly of %s, %s", Filename, ctime (&Timer)); - AcpiOsPrintf (" *\n"); -} + /* This is a "Data Table" (non-AML table) */ + AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n", + Table->Signature); + AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] " + "FieldName : FieldValue\n */\n\n"); -/****************************************************************************** - * - * FUNCTION: AdCreateTableHeader - * - * PARAMETERS: Filename - Input file for the table - * Table - Pointer to the raw table - * - * RETURN: None - * - * DESCRIPTION: Create the ASL table header, including ACPICA signon with - * current time and date. - * - *****************************************************************************/ + AcpiDmDumpDataTable (Table); + fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n", + Table->Signature); -static void -AdCreateTableHeader ( - char *Filename, - ACPI_TABLE_HEADER *Table) -{ - char *NewFilename; - UINT8 Checksum; + if (File) + { + fprintf (stderr, "Formatted output: %s - %u bytes\n", + DisasmFilename, CmGetFileSize (File)); + } + return (AE_OK); + } /* - * Print file header and dump original table header + * This is an AML table (DSDT or SSDT). + * Always parse the tables, only option is what to display */ - AdDisassemblerHeader (Filename, ACPI_IS_AML_TABLE); - - AcpiOsPrintf (" * Original Table Header:\n"); - AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature); - AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length); - - /* Print and validate the revision */ + Status = AdParseTable (Table, &OwnerId, TRUE, FALSE); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not parse ACPI tables, %s\n", + AcpiFormatException (Status)); + return (Status); + } - AcpiOsPrintf (" * Revision 0x%2.2X", Table->Revision); + /* Debug output, namespace and parse tree */ - switch (Table->Revision) + if (AslCompilerdebug && File) { - case 0: + AcpiOsPrintf ("/**** Before second load\n"); - AcpiOsPrintf (" **** Invalid Revision"); - break; + NsSetupNamespaceListing (File); + NsDisplayNamespace (); - case 1: + AcpiOsPrintf ("*****/\n"); + } - /* Revision of DSDT controls the ACPI integer width */ + /* Load namespace from names created within control methods */ - if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT)) - { - AcpiOsPrintf (" **** 32-bit table (V1), no 64-bit math support"); - } - break; + AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); - default: + /* + * Cross reference the namespace here, in order to + * generate External() statements + */ + AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); - break; + if (AslCompilerdebug) + { + AcpiDmDumpTree (AcpiGbl_ParseOpRoot); } - AcpiOsPrintf ("\n"); - /* Print and validate the table checksum */ + /* Find possible calls to external control methods */ - AcpiOsPrintf (" * Checksum 0x%2.2X", Table->Checksum); + AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot); - Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length); - if (Checksum) + /* + * If we found any external control methods, we must reparse + * the entire tree with the new information (namely, the + * number of arguments per method) + */ + if (AcpiDmGetExternalMethodCount ()) { - AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X", - (UINT8) (Table->Checksum - Checksum)); + Status = AdReparseOneTable (Table, File, OwnerId); + if (ACPI_FAILURE (Status)) + { + return (Status); + } } - AcpiOsPrintf ("\n"); - AcpiOsPrintf (" * OEM ID \"%.6s\"\n", Table->OemId); - AcpiOsPrintf (" * OEM Table ID \"%.8s\"\n", Table->OemTableId); - AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision); - AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId); - AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision); - AcpiOsPrintf (" */\n"); + /* + * Now that the namespace is finalized, we can perform namespace + * transforms. + * + * 1) Convert fixed-offset references to resource descriptors + * to symbolic references (Note: modifies namespace) + */ + AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); - /* Create AML output filename based on input filename */ + /* Optional displays */ - if (Filename) - { - NewFilename = FlGenerateFilename (Filename, "aml"); - } - else + if (AcpiGbl_DmOpt_Disasm) { - NewFilename = UtStringCacheCalloc (9); - if (NewFilename) + /* This is the real disassembly */ + + AdDisplayTables (Filename, Table); + + /* Dump hex table if requested (-vt) */ + + AcpiDmDumpDataTable (Table); + + fprintf (stderr, "Disassembly completed\n"); + if (File) { - strncat (NewFilename, Table->Signature, 4); - strcat (NewFilename, ".aml"); + fprintf (stderr, "ASL Output: %s - %u bytes\n", + DisasmFilename, CmGetFileSize (File)); } - } - if (!NewFilename) - { - AcpiOsPrintf (" **** Could not generate AML output filename\n"); - return; + if (Gbl_MapfileFlag) + { + fprintf (stderr, "%14s %s - %u bytes\n", + Gbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription, + Gbl_Files[ASL_FILE_MAP_OUTPUT].Filename, + FlGetFileSize (ASL_FILE_MAP_OUTPUT)); + } } - /* Open the ASL definition block */ - - AcpiOsPrintf ( - "DefinitionBlock (\"%s\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n", - NewFilename, Table->Signature, Table->Revision, - Table->OemId, Table->OemTableId, Table->OemRevision); + return (AE_OK); } /****************************************************************************** * - * FUNCTION: AdDisplayTables + * FUNCTION: AdReparseOneTable * - * PARAMETERS: Filename - Input file for the table - * Table - Pointer to the raw table + * PARAMETERS: Table - Raw AML table + * File - Pointer for the input file + * OwnerId - ID for this table * * RETURN: Status * - * DESCRIPTION: Display (disassemble) loaded tables and dump raw tables + * DESCRIPTION: Reparse a table that has already been loaded. Used to + * integrate information about external control methods. + * These methods may have been previously parsed incorrectly. * *****************************************************************************/ -ACPI_STATUS -AdDisplayTables ( - char *Filename, - ACPI_TABLE_HEADER *Table) +static ACPI_STATUS +AdReparseOneTable ( + ACPI_TABLE_HEADER *Table, + FILE *File, + ACPI_OWNER_ID OwnerId) { + ACPI_STATUS Status; - if (!AcpiGbl_ParseOpRoot) - { - return (AE_NOT_EXIST); - } + fprintf (stderr, + "\nFound %u external control methods, " + "reparsing with new information\n", + AcpiDmGetExternalMethodCount ()); - if (!AcpiGbl_DbOpt_Verbose) - { - AdCreateTableHeader (Filename, Table); - } + /* Reparse, rebuild namespace */ - AcpiDmDisassemble (NULL, AcpiGbl_ParseOpRoot, ACPI_UINT32_MAX); - MpEmitMappingInfo (); + AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); + AcpiGbl_ParseOpRoot = NULL; + AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); + + AcpiGbl_RootNode = NULL; + AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; + AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; + AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; + AcpiGbl_RootNodeStruct.Parent = NULL; + AcpiGbl_RootNodeStruct.Child = NULL; + AcpiGbl_RootNodeStruct.Peer = NULL; + AcpiGbl_RootNodeStruct.Object = NULL; + AcpiGbl_RootNodeStruct.Flags = 0; - if (AcpiGbl_DbOpt_Verbose) + Status = AcpiNsRootInitialize (); + if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("\n\nTable Header:\n"); - AcpiUtDebugDumpBuffer ((UINT8 *) Table, sizeof (ACPI_TABLE_HEADER), - DB_BYTE_DISPLAY, ACPI_UINT32_MAX); - - AcpiOsPrintf ("Table Body (Length 0x%X)\n", Table->Length); - AcpiUtDebugDumpBuffer (((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)), - Table->Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); + return (Status); } - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AdStoreTable - * - * PARAMETERS: Table - Table header - * TableIndex - Where the table index is returned - * - * RETURN: Status and table index. - * - * DESCRIPTION: Add an ACPI table to the global table list - * - ******************************************************************************/ + /* New namespace, add the external definitions first */ -static ACPI_STATUS -AdStoreTable ( - ACPI_TABLE_HEADER *Table, - UINT32 *TableIndex) -{ - ACPI_STATUS Status; - ACPI_TABLE_DESC *TableDesc; + AcpiDmAddExternalsToNamespace (); + /* Parse the table again. No need to reload it, however */ - Status = AcpiTbGetNextTableDescriptor (TableIndex, &TableDesc); + Status = AdParseTable (Table, NULL, FALSE, FALSE); if (ACPI_FAILURE (Status)) { + AcpiOsPrintf ("Could not parse ACPI tables, %s\n", + AcpiFormatException (Status)); return (Status); } - /* Initialize added table */ + /* Cross reference the namespace again */ - AcpiTbInitTableDescriptor (TableDesc, ACPI_PTR_TO_PHYSADDR (Table), - ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, Table); - AcpiTbValidateTable (TableDesc); - return (AE_OK); -} + AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); + AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); -/****************************************************************************** - * - * FUNCTION: AdGetLocalTables - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Get the ACPI tables from either memory or a file - * - *****************************************************************************/ - -ACPI_STATUS -AdGetLocalTables ( - void) -{ - ACPI_STATUS Status; - ACPI_TABLE_HEADER TableHeader; - ACPI_TABLE_HEADER *NewTable; - UINT32 TableIndex; - + /* Debug output - namespace and parse tree */ - /* Get the DSDT via table override */ - - ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_DSDT); - AcpiOsTableOverride (&TableHeader, &NewTable); - if (!NewTable) + if (AslCompilerdebug) { - fprintf (stderr, "Could not obtain DSDT\n"); - return (AE_NO_ACPI_TABLES); - } - - AdWriteTable (NewTable, NewTable->Length, - ACPI_SIG_DSDT, NewTable->OemTableId); - - /* Store DSDT in the Table Manager */ + AcpiOsPrintf ("/**** After second load and resource conversion\n"); + if (File) + { + NsSetupNamespaceListing (File); + NsDisplayNamespace (); + } - Status = AdStoreTable (NewTable, &TableIndex); - if (ACPI_FAILURE (Status)) - { - fprintf (stderr, "Could not store DSDT\n"); - return (AE_NO_ACPI_TABLES); + AcpiOsPrintf ("*****/\n"); + AcpiDmDumpTree (AcpiGbl_ParseOpRoot); } return (AE_OK); @@ -851,134 +549,108 @@ AdGetLocalTables ( /****************************************************************************** * - * FUNCTION: AdParseTable + * FUNCTION: AdDoExternalFileList * - * PARAMETERS: Table - Pointer to the raw table - * OwnerId - Returned OwnerId of the table - * LoadTable - If add table to the global table list - * External - If this is an external table + * PARAMETERS: Filename - Input file for the table * * RETURN: Status * - * DESCRIPTION: Parse the DSDT. + * DESCRIPTION: Process all tables found in the -e external files list * *****************************************************************************/ -ACPI_STATUS -AdParseTable ( - ACPI_TABLE_HEADER *Table, - ACPI_OWNER_ID *OwnerId, - BOOLEAN LoadTable, - BOOLEAN External) +static ACPI_STATUS +AdDoExternalFileList ( + char *Filename) { - ACPI_STATUS Status = AE_OK; - ACPI_WALK_STATE *WalkState; - UINT8 *AmlStart; - UINT32 AmlLength; - UINT32 TableIndex; - - - if (!Table) - { - return (AE_NOT_EXIST); - } - - /* Pass 1: Parse everything except control method bodies */ - - fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature); - - AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); - AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)); - - /* Create the root object */ - - AcpiGbl_ParseOpRoot = AcpiPsCreateScopeOp (); - if (!AcpiGbl_ParseOpRoot) - { - return (AE_NO_MEMORY); - } - - /* Create and initialize a new walk state */ + ACPI_EXTERNAL_FILE *ExternalFileList; + char *ExternalFilename; + ACPI_NEW_TABLE_DESC *ExternalListHead = NULL; + ACPI_STATUS Status; + ACPI_STATUS GlobalStatus = AE_OK; + ACPI_OWNER_ID OwnerId; - WalkState = AcpiDsCreateWalkState (0, - AcpiGbl_ParseOpRoot, NULL, NULL); - if (!WalkState) - { - return (AE_NO_MEMORY); - } - Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParseOpRoot, - NULL, AmlStart, AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + /* + * External filenames are specified on the command line like this: + * Example: iasl -e file1,file2,file3 -d xxx.aml + */ + ExternalFileList = AcpiGbl_ExternalFileList; - WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; - WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; + /* Process each external file */ - Status = AcpiPsParseAml (WalkState); - if (ACPI_FAILURE (Status)) + while (ExternalFileList) { - return (Status); - } - - /* If LoadTable is FALSE, we are parsing the last loaded table */ + ExternalFilename = ExternalFileList->Path; + if (!strcmp (ExternalFilename, Filename)) + { + /* Next external file */ - TableIndex = AcpiGbl_RootTableList.CurrentTableCount - 1; + ExternalFileList = ExternalFileList->Next; + continue; + } - /* Pass 2 */ + AcpiOsPrintf ("External object resolution file %16s\n", + ExternalFilename); - if (LoadTable) - { - Status = AdStoreTable (Table, &TableIndex); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - Status = AcpiTbAllocateOwnerId (TableIndex); + Status = AcGetAllTablesFromFile ( + ExternalFilename, ACPI_GET_ONLY_AML_TABLES, &ExternalListHead); if (ACPI_FAILURE (Status)) { + if (Status == AE_TYPE) + { + ExternalFileList = ExternalFileList->Next; + GlobalStatus = AE_TYPE; + Status = AE_OK; + continue; + } + return (Status); } - if (OwnerId) + + /* Load external tables for symbol resolution */ + + while (ExternalListHead) { - Status = AcpiTbGetOwnerId (TableIndex, OwnerId); + Status = AdParseTable ( + ExternalListHead->Table, &OwnerId, TRUE, TRUE); if (ACPI_FAILURE (Status)) { + AcpiOsPrintf ("Could not parse external ACPI tables, %s\n", + AcpiFormatException (Status)); return (Status); } + + /* + * Load namespace from names created within control methods + * Set owner id of nodes in external table + */ + AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); + AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); + + ExternalListHead = ExternalListHead->Next; } - } - fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature); + /* Next external file */ - Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex, NULL); - if (ACPI_FAILURE (Status)) - { - return (Status); + ExternalFileList = ExternalFileList->Next; } - /* No need to parse control methods of external table */ - - if (External) + if (ACPI_FAILURE (GlobalStatus)) { - return (AE_OK); + return (GlobalStatus); } - /* - * Pass 3: Parse control methods and link their parse trees - * into the main parse tree - */ - fprintf (stderr, - "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n"); - Status = AcpiDmParseDeferredOps (AcpiGbl_ParseOpRoot); - fprintf (stderr, "\n"); + /* Clear external list generated by Scope in external tables */ - /* Process Resource Templates */ + if (AcpiGbl_ExternalFileList) + { + AcpiDmClearExternalList (); + } - AcpiDmFindResources (AcpiGbl_ParseOpRoot); + /* Load any externals defined in the optional external ref file */ - fprintf (stderr, "Parsing completed\n"); + AcpiDmGetExternalsFromFile (); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/common/adwalk.c b/sys/contrib/dev/acpica/common/adwalk.c index b1dcf87..dcf3989 100644 --- a/sys/contrib/dev/acpica/common/adwalk.c +++ b/sys/contrib/dev/acpica/common/adwalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -135,6 +135,7 @@ AcpiDmDumpTree ( Info.Count = 0; Info.Level = 0; Info.WalkState = NULL; + AcpiDmWalkParseTree (Origin, AcpiDmDumpDescending, NULL, &Info); AcpiOsPrintf ("*/\n\n"); } @@ -168,6 +169,7 @@ AcpiDmFindOrphanMethods ( Info.Flags = 0; Info.Level = 0; Info.WalkState = NULL; + AcpiDmWalkParseTree (Origin, AcpiDmFindOrphanDescending, NULL, &Info); } @@ -211,7 +213,8 @@ AcpiDmFinishNamespaceLoad ( return; } - Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState); + Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, + WalkState); if (ACPI_FAILURE (Status)) { return; @@ -220,6 +223,7 @@ AcpiDmFinishNamespaceLoad ( Info.Flags = 0; Info.Level = 0; Info.WalkState = WalkState; + AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmLoadDescendingOp, AcpiDmCommonAscendingOp, &Info); ACPI_FREE (WalkState); @@ -264,7 +268,8 @@ AcpiDmCrossReferenceNamespace ( return; } - Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState); + Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, + WalkState); if (ACPI_FAILURE (Status)) { return; @@ -273,6 +278,7 @@ AcpiDmCrossReferenceNamespace ( Info.Flags = 0; Info.Level = 0; Info.WalkState = WalkState; + AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmXrefDescendingOp, AcpiDmCommonAscendingOp, &Info); ACPI_FREE (WalkState); @@ -317,15 +323,18 @@ AcpiDmConvertResourceIndexes ( return; } - Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState); + Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, + WalkState); if (ACPI_FAILURE (Status)) { + ACPI_FREE (WalkState); return; } Info.Flags = 0; Info.Level = 0; Info.WalkState = WalkState; + AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmResourceDescendingOp, AcpiDmCommonAscendingOp, &Info); ACPI_FREE (WalkState); @@ -396,7 +405,7 @@ AcpiDmDumpDescending ( if (Op->Common.Value.String) { AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Common.Value.String, - NULL, &Path); + NULL, &Path); AcpiOsPrintf ("%s %p", Path, Op->Common.Node); ACPI_FREE (Path); } @@ -434,7 +443,7 @@ AcpiDmDumpDescending ( * * DESCRIPTION: Check namepath Ops for orphaned method invocations * - * Note: Experimental. + * Note: Parts of this are experimental, under possible further development. * ******************************************************************************/ @@ -500,6 +509,7 @@ AcpiDmFindOrphanDescending ( ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); } break; + #endif case AML_STORE_OP: @@ -524,7 +534,7 @@ AcpiDmFindOrphanDescending ( /* One Arg means this is just a Store(Name,Target) */ AcpiDmAddOpToExternalList (ChildOp, - ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, ArgCount, 0); return (AE_OK); } @@ -546,7 +556,7 @@ AcpiDmFindOrphanDescending ( (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && !Op->Common.Node) { - ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op->Common.Next); + ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op); /* * Check if namepath is a predicate for if/while or lone parameter to @@ -655,6 +665,7 @@ AcpiDmLoadDescendingOp ( { NextOp = NextOp->Common.Next; } + Path = NextOp->Common.Value.String; } @@ -666,8 +677,8 @@ AcpiDmLoadDescendingOp ( /* Insert the name into the namespace */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &Node); + ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &Node); Op->Common.Node = Node; @@ -708,7 +719,8 @@ Exit: { if (Op->Common.Node) { - Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState); + Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, + WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -750,6 +762,7 @@ AcpiDmXrefDescendingOp ( ACPI_OPERAND_OBJECT *Object; UINT32 ParamCount = 0; char *Pathname; + UINT16 Flags = 0; WalkState = Info->WalkState; @@ -764,7 +777,25 @@ AcpiDmXrefDescendingOp ( { goto Exit; } + else if (Op->Common.Parent && + Op->Common.Parent->Common.AmlOpcode == AML_EXTERNAL_OP) + { + /* External() NamePath */ + Path = Op->Common.Value.String; + ObjectType = (ACPI_OBJECT_TYPE) Op->Common.Next->Common.Value.Integer; + if (ObjectType == ACPI_TYPE_METHOD) + { + ParamCount = (UINT32) + Op->Common.Next->Common.Next->Common.Value.Integer; + } + + Flags |= ACPI_EXT_RESOLVED_REFERENCE | ACPI_EXT_ORIGIN_FROM_OPCODE; + AcpiDmAddOpToExternalList (Op, Path, + (UINT8) ObjectType, ParamCount, Flags); + + goto Exit; + } /* Get the NamePath from the appropriate place */ @@ -825,8 +856,9 @@ AcpiDmXrefDescendingOp ( */ Node = NULL; Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &Node); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &Node); + if (ACPI_SUCCESS (Status) && (Node->Flags & ANOBJ_IS_EXTERNAL)) { /* Node was created by an External() statement */ @@ -851,12 +883,12 @@ AcpiDmXrefDescendingOp ( if (Node) { AcpiDmAddNodeToExternalList (Node, - (UINT8) ObjectType, 0, 0); + (UINT8) ObjectType, 7, Flags); } else { AcpiDmAddOpToExternalList (Op, Path, - (UINT8) ObjectType, 0, 0); + (UINT8) ObjectType, 7, Flags); } } } @@ -908,7 +940,8 @@ Exit: { if (Op->Common.Node) { - Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState); + Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, + WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -956,7 +989,8 @@ AcpiDmResourceDescendingOp ( if (Op->Common.Node) { - Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState); + Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, + WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -1036,40 +1070,69 @@ AcpiDmInspectPossibleArgs ( { const ACPI_OPCODE_INFO *OpInfo; UINT32 i; - UINT32 Last = 0; - UINT32 Lookahead; + UINT32 ArgumentCount = 0; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *ExecuteOp; - Lookahead = (ACPI_METHOD_NUM_ARGS + TargetCount) - CurrentOpArgCount; + if (!Op) + { + return (0); + } /* Lookahead for the maximum number of possible arguments */ - for (i = 0; i < Lookahead; i++) + NextOp = Op->Common.Next; + + for (i = 0; (i < ACPI_METHOD_NUM_ARGS) && NextOp; i++) { - if (!Op) - { - break; - } + OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode); - OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + /* Any one of these operators is "very probably" not a method arg */ - /* - * Any one of these operators is "very probably" not a method arg - */ - if ((Op->Common.AmlOpcode == AML_STORE_OP) || - (Op->Common.AmlOpcode == AML_NOTIFY_OP)) + if ((NextOp->Common.AmlOpcode == AML_STORE_OP) || + (NextOp->Common.AmlOpcode == AML_NOTIFY_OP) || + (OpInfo->Class == AML_CLASS_CONTROL) || + (OpInfo->Class == AML_CLASS_CREATE) || + (OpInfo->Class == AML_CLASS_NAMED_OBJECT)) { break; } - if ((OpInfo->Class != AML_CLASS_EXECUTE) && - (OpInfo->Class != AML_CLASS_CONTROL)) + if (OpInfo->Class == AML_CLASS_EXECUTE) { - Last = i+1; + /* Probable that this is method arg if there is no target */ + + ExecuteOp = NextOp->Common.Value.Arg; + while (ExecuteOp) + { + if ((ExecuteOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + (ExecuteOp->Common.Value.Arg == NULL)) + { + /* No target, could be a method arg */ + + break; + } + + if (NextOp->Common.AmlOpcode == AML_REF_OF_OP) + { + break; + } + + ExecuteOp = ExecuteOp->Common.Next; + } + + if (!ExecuteOp) + { + /* Has a target, not method arg */ + + return (ArgumentCount); + } } - Op = Op->Common.Next; + ArgumentCount++; + NextOp = NextOp->Common.Next; } - return (Last); + return (ArgumentCount); } diff --git a/sys/contrib/dev/acpica/common/ahids.c b/sys/contrib/dev/acpica/common/ahids.c index 038d9f6..aa12bc8 100644 --- a/sys/contrib/dev/acpica/common/ahids.c +++ b/sys/contrib/dev/acpica/common/ahids.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,6 +75,10 @@ const AH_DEVICE_ID AslDeviceIds[] = {"ACPI000D", "Power Meter Device"}, {"ACPI000E", "Time and Alarm Device"}, {"ACPI000F", "User Presence Detection Device"}, + {"ACPI0010", "Processor Container Device"}, + {"ACPI0011", "Generic Buttons Device"}, + {"ACPI0012", "NVDIMM Root Device"}, + {"ACPI0013", "Generic Event Device"}, {"ADMA0F28", "Intel Audio DMA"}, {"AMCR0F28", "Intel Audio Machine Driver"}, {"ATK4001", "Asus Radio Control Button"}, @@ -185,6 +189,7 @@ const AH_DEVICE_ID AslDeviceIds[] = {"PNP0C12", "Device Bay Controller"}, {"PNP0C14", "Windows Management Instrumentation Device"}, {"PNP0C15", "Docking Station"}, + {"PNP0C33", "Error Device"}, {"PNP0C40", "Standard Button Controller"}, {"PNP0C50", "HID Protocol Device (I2C bus)"}, {"PNP0C60", "Display Sensor Device"}, @@ -230,7 +235,7 @@ AcpiAhMatchHardwareId ( for (Info = AslDeviceIds; Info->Name; Info++) { - if (!ACPI_STRCMP (HardwareId, Info->Name)) + if (!strcmp (HardwareId, Info->Name)) { return (Info); } diff --git a/sys/contrib/dev/acpica/common/ahpredef.c b/sys/contrib/dev/acpica/common/ahpredef.c index 1454880..96bcbc8 100644 --- a/sys/contrib/dev/acpica/common/ahpredef.c +++ b/sys/contrib/dev/acpica/common/ahpredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -140,6 +140,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_FDI", "Floppy Drive Information", "Returns a floppy drive information block"), AH_PREDEF ("_FDM", "Floppy Drive Mode", "Sets a floppy drive speed"), AH_PREDEF ("_FIF", "Fan Information", "Returns fan device information"), + AH_PREDEF ("_FIT", "Firmware Interface Table", "Returns a list of NFIT structures"), AH_PREDEF ("_FIX", "Fixed Register Resource Provider", "Returns a list of devices that implement FADT register blocks"), AH_PREDEF ("_FLC", "Flow Control", "Flow control, Resource Descriptor field"), AH_PREDEF ("_FPS", "Fan Performance States", "Returns a list of supported fan performance states"), @@ -249,7 +250,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_RBW", "Register Bit Width", "Resource Descriptor field"), AH_PREDEF ("_RDI", "Resource Dependencies for Idle", "Returns a list of dependencies for idle states"), AH_PREDEF ("_REG", "Region Availability", "Inform AML code of an operation region availability change"), - AH_PREDEF ("_REV", "Supported ACPI Revision", "Returns the revision of the ACPI specification that is implemented"), + AH_PREDEF ("_REV", "Supported Integer Width", "Returns the supported integer width (<= 1: 32 bits only, >=2: both 32 and 64 bits"), AH_PREDEF ("_RMV", "Removal Status", "Returns a device's removal ability status (docking)"), AH_PREDEF ("_RNG", "Range", "Memory range type, Resource Descriptor field"), AH_PREDEF ("_RST", "Device Reset", "Executes a reset on a device"), @@ -332,8 +333,10 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_UPP", "User Presence Polling", "Returns the recommended user presence polling interval"), AH_PREDEF ("_VEN", "Vendor Data", "Resource Descriptor field"), AH_PREDEF ("_VPO", "Video Post Options", "Returns the implemented video post options"), - AH_PREDEF ("_WAK", "Wake", "Inform AML that the system has just awakened"), AH_PREDEF ("_Wxx", "Wake Event", "Method executed as a result of a wake event"), + AH_PREDEF ("_WAK", "Wake", "Inform AML that the system has just awakened"), + AH_PREDEF ("_WPC", "Wireless Power Calibration", "Calibrate power and notify wireless device"), + AH_PREDEF ("_WPP", "Wireless Power Polling", "Get recommended polling interval"), AH_PREDEF (NULL, NULL, NULL) }; diff --git a/sys/contrib/dev/acpica/common/ahtable.c b/sys/contrib/dev/acpica/common/ahtable.c index d4ce436..a3d18de 100644 --- a/sys/contrib/dev/acpica/common/ahtable.c +++ b/sys/contrib/dev/acpica/common/ahtable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/common/ahuuids.c b/sys/contrib/dev/acpica/common/ahuuids.c index eeec8b8..7828e9c 100644 --- a/sys/contrib/dev/acpica/common/ahuuids.c +++ b/sys/contrib/dev/acpica/common/ahuuids.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,7 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("ahuuids") + /* * Table of "known" (ACPI-related) UUIDs */ @@ -122,7 +123,7 @@ AcpiAhMatchUuid ( AcpiUtConvertStringToUuid (Info->String, UuidBuffer); - if (!ACPI_MEMCMP (Data, UuidBuffer, UUID_BUFFER_LENGTH)) + if (!memcmp (Data, UuidBuffer, UUID_BUFFER_LENGTH)) { return (Info->Description); } diff --git a/sys/contrib/dev/acpica/common/cmfsize.c b/sys/contrib/dev/acpica/common/cmfsize.c index 542b150..e27a8de 100644 --- a/sys/contrib/dev/acpica/common/cmfsize.c +++ b/sys/contrib/dev/acpica/common/cmfsize.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/common/dmextern.c b/sys/contrib/dev/acpica/common/dmextern.c index 2ea54ad..0b18058 100644 --- a/sys/contrib/dev/acpica/common/dmextern.c +++ b/sys/contrib/dev/acpica/common/dmextern.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -140,7 +140,6 @@ AcpiDmGetObjectTypeName ( { Type = ACPI_TYPE_DEVICE; } - else if (Type > ACPI_TYPE_LOCAL_INDEX_FIELD) { return (""); @@ -224,7 +223,7 @@ AcpiDmNormalizeParentPrefix ( return (NULL); } - Length = (ACPI_STRLEN (ParentPath) + ACPI_STRLEN (Path) + 1); + Length = (strlen (ParentPath) + strlen (Path) + 1); if (ParentPath[1]) { /* @@ -253,7 +252,7 @@ AcpiDmNormalizeParentPrefix ( * * Copy the parent path */ - ACPI_STRCPY (Fullpath, &ParentPath[Index]); + strcpy (Fullpath, &ParentPath[Index]); /* * Add dot separator @@ -261,12 +260,12 @@ AcpiDmNormalizeParentPrefix ( */ if (ParentPath[1]) { - ACPI_STRCAT (Fullpath, "."); + strcat (Fullpath, "."); } /* Copy child path (carat parent prefix(es) were skipped above) */ - ACPI_STRCAT (Fullpath, Path); + strcat (Fullpath, Path); Cleanup: ACPI_FREE (ParentPath); @@ -410,6 +409,7 @@ AcpiDmGetExternalsFromFile ( { continue; } + if (strcmp (Token, "External")) { continue; @@ -447,6 +447,7 @@ AcpiDmGetExternalsFromFile ( fprintf (stderr, "Invalid argument count (%s)\n", Token); continue; } + if (ArgCount > 7) { fprintf (stderr, "Invalid argument count (%u)\n", ArgCount); @@ -465,7 +466,8 @@ AcpiDmGetExternalsFromFile ( if (!ImportCount) { - fprintf (stderr, "Did not find any external methods in reference file \"%s\"\n", + fprintf (stderr, + "Did not find any external methods in reference file \"%s\"\n", Gbl_ExternalRefFilename); } else @@ -648,13 +650,13 @@ AcpiDmAddNodeToExternalList ( if ((*ExternalPath == AML_ROOT_PREFIX) && (ExternalPath[1])) { - Temp = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (ExternalPath) + 1); + Temp = ACPI_ALLOCATE_ZEROED (strlen (ExternalPath) + 1); if (!Temp) { return_VOID; } - ACPI_STRCPY (Temp, &ExternalPath[1]); + strcpy (Temp, &ExternalPath[1]); ACPI_FREE (ExternalPath); ExternalPath = Temp; } @@ -806,27 +808,39 @@ AcpiDmCreateNewExternal ( NextExternal = AcpiGbl_ExternalList; while (NextExternal) { - if (!ACPI_STRCMP (ExternalPath, NextExternal->Path)) - { - /* Duplicate method, check that the Value (ArgCount) is the same */ + /* Check for duplicates */ - if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (NextExternal->Value != Value) && - (Value > 0)) + if (!strcmp (ExternalPath, NextExternal->Path)) + { + /* + * If this external came from an External() opcode, we are + * finished with this one. (No need to check any further). + */ + if (NextExternal->Flags & ACPI_EXT_ORIGIN_FROM_OPCODE) { - ACPI_ERROR ((AE_INFO, - "External method arg count mismatch %s: Current %u, attempted %u", - NextExternal->Path, NextExternal->Value, Value)); + return_ACPI_STATUS (AE_ALREADY_EXISTS); } /* Allow upgrade of type from ANY */ - else if (NextExternal->Type == ACPI_TYPE_ANY) + else if ((NextExternal->Type == ACPI_TYPE_ANY) && + (Type != ACPI_TYPE_ANY)) { NextExternal->Type = Type; + } + + /* Update the argument count as necessary */ + + if (Value < NextExternal->Value) + { NextExternal->Value = Value; } + /* Update flags. */ + + NextExternal->Flags |= Flags; + NextExternal->Flags &= ~ACPI_EXT_INTERNAL_PATH_ALLOCATED; + return_ACPI_STATUS (AE_ALREADY_EXISTS); } @@ -849,7 +863,7 @@ AcpiDmCreateNewExternal ( NewExternal->Value = Value; NewExternal->Path = ExternalPath; NewExternal->Type = Type; - NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); + NewExternal->Length = (UINT16) strlen (ExternalPath); NewExternal->InternalPath = InternalPath; /* Link the new descriptor into the global list, alphabetically ordered */ @@ -917,9 +931,9 @@ AcpiDmAddExternalsToNamespace ( /* Add the external name (object) into the namespace */ Status = AcpiNsLookup (NULL, External->InternalPath, External->Type, - ACPI_IMODE_LOAD_PASS1, - ACPI_NS_ERROR_IF_FOUND | ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE, - NULL, &Node); + ACPI_IMODE_LOAD_PASS1, + ACPI_NS_ERROR_IF_FOUND | ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); if (ACPI_FAILURE (Status)) { @@ -1074,90 +1088,62 @@ AcpiDmEmitExternals ( AcpiDmUnresolvedWarning (1); - /* Emit any unresolved method externals in a single text block */ - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (!(NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE))) - { - AcpiOsPrintf (" External (%s%s", - NextExternal->Path, - AcpiDmGetObjectTypeName (NextExternal->Type)); - - AcpiOsPrintf (") // Warning: Unresolved method, " - "guessing %u arguments\n", - NextExternal->Value); - - NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; - } - - NextExternal = NextExternal->Next; - } - - AcpiOsPrintf ("\n"); - - - /* Emit externals that were imported from a file */ - if (Gbl_ExternalRefFilename) { AcpiOsPrintf ( - " /*\n * External declarations that were imported from\n" - " * the reference file [%s]\n */\n", + " /*\n * External declarations were imported from\n" + " * a reference file -- %s\n */\n\n", Gbl_ExternalRefFilename); - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if (!(NextExternal->Flags & ACPI_EXT_EXTERNAL_EMITTED) && - (NextExternal->Flags & ACPI_EXT_ORIGIN_FROM_FILE)) - { - AcpiOsPrintf (" External (%s%s", - NextExternal->Path, - AcpiDmGetObjectTypeName (NextExternal->Type)); - - if (NextExternal->Type == ACPI_TYPE_METHOD) - { - AcpiOsPrintf (") // %u Arguments\n", - NextExternal->Value); - } - else - { - AcpiOsPrintf (")\n"); - } - NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; - } - - NextExternal = NextExternal->Next; - } - - AcpiOsPrintf ("\n"); } /* - * Walk the list of externals found during the AML parsing + * Walk and emit the list of externals found during the AML parsing */ while (AcpiGbl_ExternalList) { if (!(AcpiGbl_ExternalList->Flags & ACPI_EXT_EXTERNAL_EMITTED)) { - AcpiOsPrintf (" External (%s%s", + AcpiOsPrintf (" External (%s%s)", AcpiGbl_ExternalList->Path, AcpiDmGetObjectTypeName (AcpiGbl_ExternalList->Type)); - /* For methods, add a comment with the number of arguments */ + /* Check for "unresolved" method reference */ - if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) + if ((AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) && + (!(AcpiGbl_ExternalList->Flags & ACPI_EXT_RESOLVED_REFERENCE))) { - AcpiOsPrintf (") // %u Arguments\n", + AcpiOsPrintf (" // Warning: Unknown method, " + "guessing %u arguments", AcpiGbl_ExternalList->Value); } + + /* Check for external from a external references file */ + + else if (AcpiGbl_ExternalList->Flags & ACPI_EXT_ORIGIN_FROM_FILE) + { + if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) + { + AcpiOsPrintf (" // %u Arguments", + AcpiGbl_ExternalList->Value); + } + + AcpiOsPrintf (" // From external reference file"); + } + + /* This is the normal external case */ + else { - AcpiOsPrintf (")\n"); + /* For methods, add a comment with the number of arguments */ + + if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) + { + AcpiOsPrintf (" // %u Arguments", + AcpiGbl_ExternalList->Value); + } } + + AcpiOsPrintf ("\n"); } /* Free this external info block and move on to next external */ @@ -1263,76 +1249,87 @@ appearing in an SSDT, the disassembler does not know what to do unless the owning SSDT has been loaded via the -e option. #endif +static char ExternalWarningPart1[600]; +static char ExternalWarningPart2[400]; +static char ExternalWarningPart3[400]; +static char ExternalWarningPart4[200]; + void AcpiDmUnresolvedWarning ( UINT8 Type) { + char *Format; + char Pad[] = " *"; + char NoPad[] = ""; + if (!AcpiGbl_NumExternalMethods) { return; } + if (AcpiGbl_NumExternalMethods == AcpiGbl_ResolvedExternalMethods) + { + return; + } + + Format = Type ? Pad : NoPad; + + sprintf (ExternalWarningPart1, + "%s iASL Warning: There %s %u external control method%s found during\n" + "%s disassembly, but only %u %s resolved (%u unresolved). Additional\n" + "%s ACPI tables may be required to properly disassemble the code. This\n" + "%s resulting disassembler output file may not compile because the\n" + "%s disassembler did not know how many arguments to assign to the\n" + "%s unresolved methods. Note: SSDTs can be dynamically loaded at\n" + "%s runtime and may or may not be available via the host OS.\n", + Format, (AcpiGbl_NumExternalMethods != 1 ? "were" : "was"), + AcpiGbl_NumExternalMethods, (AcpiGbl_NumExternalMethods != 1 ? "s" : ""), + Format, AcpiGbl_ResolvedExternalMethods, + (AcpiGbl_ResolvedExternalMethods != 1 ? "were" : "was"), + (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods), + Format, Format, Format, Format, Format); + + sprintf (ExternalWarningPart2, + "%s To specify the tables needed to resolve external control method\n" + "%s references, the -e option can be used to specify the filenames.\n" + "%s Example iASL invocations:\n" + "%s iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml\n" + "%s iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml\n" + "%s iasl -e ssdt*.aml -d dsdt.aml\n", + Format, Format, Format, Format, Format, Format); + + sprintf (ExternalWarningPart3, + "%s In addition, the -fe option can be used to specify a file containing\n" + "%s control method external declarations with the associated method\n" + "%s argument counts. Each line of the file must be of the form:\n" + "%s External (<method pathname>, MethodObj, <argument count>)\n" + "%s Invocation:\n" + "%s iasl -fe refs.txt -d dsdt.aml\n", + Format, Format, Format, Format, Format, Format); + + sprintf (ExternalWarningPart4, + "%s The following methods were unresolved and many not compile properly\n" + "%s because the disassembler had to guess at the number of arguments\n" + "%s required for each:\n", + Format, Format, Format); + if (Type) { if (!AcpiGbl_ExternalFileList) { /* The -e option was not specified */ - AcpiOsPrintf (" /*\n" - " * iASL Warning: There were %u external control methods found during\n" - " * disassembly, but additional ACPI tables to resolve these externals\n" - " * were not specified. This resulting disassembler output file may not\n" - " * compile because the disassembler did not know how many arguments\n" - " * to assign to these methods. To specify the tables needed to resolve\n" - " * external control method references, the -e option can be used to\n" - " * specify the filenames. Note: SSDTs can be dynamically loaded at\n" - " * runtime and may or may not be available via the host OS.\n" - " * Example iASL invocations:\n" - " * iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml\n" - " * iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml\n" - " * iasl -e ssdt*.aml -d dsdt.aml\n" - " *\n" - " * In addition, the -fe option can be used to specify a file containing\n" - " * control method external declarations with the associated method\n" - " * argument counts. Each line of the file must be of the form:\n" - " * External (<method pathname>, MethodObj, <argument count>)\n" - " * Invocation:\n" - " * iasl -fe refs.txt -d dsdt.aml\n" - " *\n" - " * The following methods were unresolved and many not compile properly\n" - " * because the disassembler had to guess at the number of arguments\n" - " * required for each:\n" - " */\n", - AcpiGbl_NumExternalMethods); + AcpiOsPrintf (" /*\n%s *\n%s *\n%s *\n%s */\n", + ExternalWarningPart1, ExternalWarningPart2, ExternalWarningPart3, + ExternalWarningPart4); } - else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods) + else { /* The -e option was specified, but there are still some unresolved externals */ - AcpiOsPrintf (" /*\n" - " * iASL Warning: There were %u external control methods found during\n" - " * disassembly, but only %u %s resolved (%u unresolved). Additional\n" - " * ACPI tables may be required to properly disassemble the code. This\n" - " * resulting disassembler output file may not compile because the\n" - " * disassembler did not know how many arguments to assign to the\n" - " * unresolved methods. Note: SSDTs can be dynamically loaded at\n" - " * runtime and may or may not be available via the host OS.\n" - " *\n" - " * If necessary, the -fe option can be used to specify a file containing\n" - " * control method external declarations with the associated method\n" - " * argument counts. Each line of the file must be of the form:\n" - " * External (<method pathname>, MethodObj, <argument count>)\n" - " * Invocation:\n" - " * iasl -fe refs.txt -d dsdt.aml\n" - " *\n" - " * The following methods were unresolved and many not compile properly\n" - " * because the disassembler had to guess at the number of arguments\n" - " * required for each:\n" - " */\n", - AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods, - (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), - (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods)); + AcpiOsPrintf (" /*\n%s *\n%s *\n%s */\n", + ExternalWarningPart1, ExternalWarningPart3, ExternalWarningPart4); } } else @@ -1341,50 +1338,15 @@ AcpiDmUnresolvedWarning ( { /* The -e option was not specified */ - fprintf (stderr, "\n" - "iASL Warning: There were %u external control methods found during\n" - "disassembly, but additional ACPI tables to resolve these externals\n" - "were not specified. The resulting disassembler output file may not\n" - "compile because the disassembler did not know how many arguments\n" - "to assign to these methods. To specify the tables needed to resolve\n" - "external control method references, the -e option can be used to\n" - "specify the filenames. Note: SSDTs can be dynamically loaded at\n" - "runtime and may or may not be available via the host OS.\n" - "Example iASL invocations:\n" - " iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml\n" - " iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml\n" - " iasl -e ssdt*.aml -d dsdt.aml\n" - "\n" - "In addition, the -fe option can be used to specify a file containing\n" - "control method external declarations with the associated method\n" - "argument counts. Each line of the file must be of the form:\n" - " External (<method pathname>, MethodObj, <argument count>)\n" - "Invocation:\n" - " iasl -fe refs.txt -d dsdt.aml\n", - AcpiGbl_NumExternalMethods); + fprintf (stderr, "\n%s\n%s\n%s\n", + ExternalWarningPart1, ExternalWarningPart2, ExternalWarningPart3); } - else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods) + else { /* The -e option was specified, but there are still some unresolved externals */ - fprintf (stderr, "\n" - "iASL Warning: There were %u external control methods found during\n" - "disassembly, but only %u %s resolved (%u unresolved). Additional\n" - "ACPI tables may be required to properly disassemble the code. The\n" - "resulting disassembler output file may not compile because the\n" - "disassembler did not know how many arguments to assign to the\n" - "unresolved methods. Note: SSDTs can be dynamically loaded at\n" - "runtime and may or may not be available via the host OS.\n" - "\n" - "If necessary, the -fe option can be used to specify a file containing\n" - "control method external declarations with the associated method\n" - "argument counts. Each line of the file must be of the form:\n" - " External (<method pathname>, MethodObj, <argument count>)\n" - "Invocation:\n" - " iasl -fe refs.txt -d dsdt.aml\n", - AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods, - (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), - (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods)); + fprintf (stderr, "\n%s\n%s\n", + ExternalWarningPart1, ExternalWarningPart3); } } } diff --git a/sys/contrib/dev/acpica/common/dmrestag.c b/sys/contrib/dev/acpica/common/dmrestag.c index c457658..337456e 100644 --- a/sys/contrib/dev/acpica/common/dmrestag.c +++ b/sys/contrib/dev/acpica/common/dmrestag.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -279,6 +279,7 @@ static const ACPI_RESOURCE_TAG AcpiDmGpioIoTags[] = static const ACPI_RESOURCE_TAG AcpiDmI2cSerialBusTags[] = { {( 6 * 8) + 0, ACPI_RESTAG_SLAVEMODE}, + {( 6 * 8) + 2, ACPI_RESTAG_INTERRUPTSHARE}, /* V2 - ACPI 6.0 */ {( 7 * 8) + 0, ACPI_RESTAG_MODE}, {(12 * 8), ACPI_RESTAG_SPEED}, {(16 * 8), ACPI_RESTAG_ADDRESS}, @@ -288,6 +289,7 @@ static const ACPI_RESOURCE_TAG AcpiDmI2cSerialBusTags[] = static const ACPI_RESOURCE_TAG AcpiDmSpiSerialBusTags[] = { {( 6 * 8) + 0, ACPI_RESTAG_SLAVEMODE}, + {( 6 * 8) + 2, ACPI_RESTAG_INTERRUPTSHARE}, /* V2 - ACPI 6.0 */ {( 7 * 8) + 0, ACPI_RESTAG_MODE}, {( 7 * 8) + 1, ACPI_RESTAG_DEVICEPOLARITY}, {(12 * 8), ACPI_RESTAG_SPEED}, @@ -300,7 +302,8 @@ static const ACPI_RESOURCE_TAG AcpiDmSpiSerialBusTags[] = static const ACPI_RESOURCE_TAG AcpiDmUartSerialBusTags[] = { - {( 6 * 8) + 0, ACPI_RESTAG_SLAVEMODE}, /* Note: not part of original macro */ + {( 6 * 8) + 0, ACPI_RESTAG_SLAVEMODE}, /* Note: not part of original macro */ + {( 6 * 8) + 2, ACPI_RESTAG_INTERRUPTSHARE}, /* V2 - ACPI 6.0 */ {( 7 * 8) + 0, ACPI_RESTAG_FLOWCONTROL}, {( 7 * 8) + 2, ACPI_RESTAG_STOPBITS}, {( 7 * 8) + 4, ACPI_RESTAG_LENGTH}, @@ -498,9 +501,9 @@ AcpiDmCheckResourceReference ( /* Lookup the buffer in the namespace */ Status = AcpiNsLookup (WalkState->ScopeInfo, - BufferNameOp->Common.Value.String, ACPI_TYPE_BUFFER, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, - &BufferNode); + BufferNameOp->Common.Value.String, ACPI_TYPE_BUFFER, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, + &BufferNode); if (ACPI_FAILURE (Status)) { return; @@ -621,8 +624,8 @@ AcpiGetTagPathname ( /* Get the individual resource descriptor and validate it */ - Aml = ACPI_CAST_PTR (AML_RESOURCE, - &Op->Named.Data[ResourceNode->Value]); + Aml = ACPI_CAST_PTR ( + AML_RESOURCE, &Op->Named.Data[ResourceNode->Value]); Status = AcpiUtValidateResource (NULL, Aml, &ResourceTableIndex); if (ACPI_FAILURE (Status)) @@ -650,7 +653,7 @@ AcpiGetTagPathname ( /* Get the full pathname to the parent buffer */ - RequiredSize = AcpiNsGetPathnameLength (BufferNode); + RequiredSize = AcpiNsBuildNormalizedPath (BufferNode, NULL, 0, FALSE); if (!RequiredSize) { return (NULL); @@ -662,12 +665,8 @@ AcpiGetTagPathname ( return (NULL); } - Status = AcpiNsBuildExternalPath (BufferNode, RequiredSize, Pathname); - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (Pathname); - return (NULL); - } + (void) AcpiNsBuildNormalizedPath (BufferNode, Pathname, + RequiredSize, FALSE); /* * Create the full path to the resource and tag by: remove the buffer name, @@ -679,10 +678,10 @@ AcpiGetTagPathname ( * end up in the final compiled AML, it's just an appearance issue for the * disassembled code. */ - Pathname[ACPI_STRLEN (Pathname) - ACPI_NAME_SIZE] = 0; - ACPI_STRNCAT (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE); - ACPI_STRCAT (Pathname, "."); - ACPI_STRNCAT (Pathname, Tag, ACPI_NAME_SIZE); + Pathname[strlen (Pathname) - ACPI_NAME_SIZE] = 0; + strncat (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE); + strcat (Pathname, "."); + strncat (Pathname, Tag, ACPI_NAME_SIZE); /* Internalize the namepath to AML format */ @@ -746,6 +745,7 @@ AcpiDmUpdateResourceName ( { AcpiGbl_NextResourceId = 0; AcpiGbl_NextPrefix++; + if (AcpiGbl_NextPrefix > ACPI_NUM_RES_PREFIX) { AcpiGbl_NextPrefix = 0; @@ -1032,9 +1032,9 @@ AcpiDmAddResourceToNamespace ( ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Context); Status = AcpiNsLookup (&ScopeInfo, "_TMP", ACPI_TYPE_LOCAL_RESOURCE, - ACPI_IMODE_LOAD_PASS2, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_PREFIX_IS_SCOPE, - NULL, &Node); + ACPI_IMODE_LOAD_PASS2, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_PREFIX_IS_SCOPE, + NULL, &Node); if (ACPI_FAILURE (Status)) { return (AE_OK); diff --git a/sys/contrib/dev/acpica/common/dmtable.c b/sys/contrib/dev/acpica/common/dmtable.c index 3820c94..36e56d9 100644 --- a/sys/contrib/dev/acpica/common/dmtable.c +++ b/sys/contrib/dev/acpica/common/dmtable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,15 +58,6 @@ AcpiAhGetTableInfo ( char *Signature); -/* Local Prototypes */ - -static void -AcpiDmCheckAscii ( - UINT8 *Target, - char *RepairedName, - UINT32 Count); - - /* Common format strings for commented values */ #define UINT8_FORMAT "%2.2X [%s]\n" @@ -118,6 +109,7 @@ static const char *AcpiDmEinjActions[] = "Check Busy Status", "Get Command Status", "Set Error Type With Address", + "Get Execute Timings", "Unknown Action" }; @@ -150,6 +142,7 @@ static const char *AcpiDmErstActions[] = "Get Error Address Range", "Get Error Address Length", "Get Error Attributes", + "Execute Timings", "Unknown Action" }; @@ -196,6 +189,7 @@ static const char *AcpiDmHestSubnames[] = "PCI Express AER (AER Endpoint)", "PCI Express/PCI-X Bridge AER", "Generic Hardware Error Source", + "Generic Hardware Error Source V2", "Unknown Subtable Type" /* Reserved */ }; @@ -208,6 +202,10 @@ static const char *AcpiDmHestNotifySubnames[] = "NMI", "CMCI", /* ACPI 5.0 */ "MCE", /* ACPI 5.0 */ + "GPIO", /* ACPI 6.0 */ + "SEA", /* ACPI 6.1 */ + "SEI", /* ACPI 6.1 */ + "GSIV", /* ACPI 6.1 */ "Unknown Notify Type" /* Reserved */ }; @@ -248,6 +246,7 @@ static const char *AcpiDmPcctSubnames[] = { "Generic Communications Subspace", /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */ "HW-Reduced Comm Subspace", /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE */ + "HW-Reduced Comm Subspace Type2", /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2 */ "Unknown Subtable Type" /* Reserved */ }; @@ -368,7 +367,7 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, NULL, TemplateSpmi}, {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, DtCompileSrat, TemplateSrat}, {ACPI_SIG_STAO, NULL, AcpiDmDumpStao, DtCompileStao, TemplateStao}, - {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, NULL, TemplateTcpa}, + {ACPI_SIG_TCPA, NULL, AcpiDmDumpTcpa, DtCompileTcpa, TemplateTcpa}, {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2, NULL, NULL, TemplateTpm2}, {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, DtCompileUefi, TemplateUefi}, {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc, AcpiDmDumpVrtc, DtCompileVrtc, TemplateVrtc}, @@ -500,7 +499,11 @@ AcpiDmDumpDataTable ( if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS)) { Length = Table->Length; - AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs); + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs); + if (ACPI_FAILURE (Status)) + { + return; + } } else if (ACPI_VALIDATE_RSDP_SIG (Table->Signature)) { @@ -528,7 +531,7 @@ AcpiDmDumpDataTable ( TableData = AcpiDmGetTableData (Table->Signature); if (!TableData) { - if (!ACPI_STRNCMP (Table->Signature, "OEM", 3)) + if (!strncmp (Table->Signature, "OEM", 3)) { AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n", Table->Signature); @@ -561,7 +564,11 @@ AcpiDmDumpDataTable ( { /* Simple table, just walk the info table */ - AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo); + Status = AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo); + if (ACPI_FAILURE (Status)) + { + return; + } } } @@ -694,7 +701,7 @@ AcpiDmLineHeader2 ( * SubtableLength - Length of this sub-descriptor * Info - Info table for this ACPI table * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Display ACPI table contents by walking the Info table. * @@ -720,6 +727,7 @@ AcpiDmDumpTable ( const AH_TABLE *TableData; const char *Name; BOOLEAN LastOutputBlankLine = FALSE; + ACPI_STATUS Status; char RepairedName[8]; @@ -856,7 +864,7 @@ AcpiDmDumpTable ( case ACPI_DMT_STRING: - ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1; + ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1; break; case ACPI_DMT_GAS: @@ -866,6 +874,7 @@ AcpiDmDumpTable ( AcpiOsPrintf ("\n"); LastOutputBlankLine = TRUE; } + ByteLength = sizeof (ACPI_GENERIC_ADDRESS); break; @@ -876,6 +885,7 @@ AcpiDmDumpTable ( AcpiOsPrintf ("\n"); LastOutputBlankLine = TRUE; } + ByteLength = sizeof (ACPI_HEST_NOTIFY); break; @@ -885,6 +895,7 @@ AcpiDmDumpTable ( { LastOutputBlankLine = FALSE; } + ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS); break; @@ -1018,6 +1029,7 @@ AcpiDmDumpTable ( } } } + AcpiOsPrintf ("\n"); break; @@ -1039,8 +1051,9 @@ AcpiDmDumpTable ( case ACPI_DMT_SIG: - AcpiDmCheckAscii (Target, RepairedName, 4); + AcpiUtCheckAndRepairAscii (Target, RepairedName, 4); AcpiOsPrintf ("\"%.4s\" ", RepairedName); + TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target)); if (TableData) { @@ -1054,19 +1067,19 @@ AcpiDmDumpTable ( case ACPI_DMT_NAME4: - AcpiDmCheckAscii (Target, RepairedName, 4); + AcpiUtCheckAndRepairAscii (Target, RepairedName, 4); AcpiOsPrintf ("\"%.4s\"\n", RepairedName); break; case ACPI_DMT_NAME6: - AcpiDmCheckAscii (Target, RepairedName, 6); + AcpiUtCheckAndRepairAscii (Target, RepairedName, 6); AcpiOsPrintf ("\"%.6s\"\n", RepairedName); break; case ACPI_DMT_NAME8: - AcpiDmCheckAscii (Target, RepairedName, 8); + AcpiUtCheckAndRepairAscii (Target, RepairedName, 8); AcpiOsPrintf ("\"%.8s\"\n", RepairedName); break; @@ -1086,6 +1099,7 @@ AcpiDmDumpTable ( AcpiOsPrintf ( " /* Incorrect checksum, should be %2.2X */", Temp8); } + AcpiOsPrintf ("\n"); break; @@ -1114,8 +1128,13 @@ AcpiDmDumpTable ( /* Generic Address Structure */ AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure"); - AcpiDmDumpTable (TableLength, CurrentOffset, Target, + Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target, sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + AcpiOsPrintf ("\n"); LastOutputBlankLine = TRUE; break; @@ -1250,8 +1269,13 @@ AcpiDmDumpTable ( AcpiOsPrintf (STRING_FORMAT, "Hardware Error Notification Structure"); - AcpiDmDumpTable (TableLength, CurrentOffset, Target, + Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target, sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + AcpiOsPrintf ("\n"); LastOutputBlankLine = TRUE; break; @@ -1275,8 +1299,13 @@ AcpiDmDumpTable ( AcpiOsPrintf (STRING_FORMAT, "IORT Memory Access Properties"); - AcpiDmDumpTable (TableLength, CurrentOffset, Target, + Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target, sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + LastOutputBlankLine = TRUE; break; @@ -1453,42 +1482,3 @@ AcpiDmDumpTable ( return (AE_OK); } - - -/******************************************************************************* - * - * FUNCTION: AcpiDmCheckAscii - * - * PARAMETERS: Name - Ascii string - * Count - Number of characters to check - * - * RETURN: None - * - * DESCRIPTION: Ensure that the requested number of characters are printable - * Ascii characters. Sets non-printable and null chars to <space>. - * - ******************************************************************************/ - -static void -AcpiDmCheckAscii ( - UINT8 *Name, - char *RepairedName, - UINT32 Count) -{ - UINT32 i; - - - for (i = 0; i < Count; i++) - { - RepairedName[i] = (char) Name[i]; - - if (!Name[i]) - { - return; - } - if (!isprint (Name[i])) - { - RepairedName[i] = ' '; - } - } -} diff --git a/sys/contrib/dev/acpica/common/dmtables.c b/sys/contrib/dev/acpica/common/dmtables.c new file mode 100644 index 0000000..f0963c5 --- /dev/null +++ b/sys/contrib/dev/acpica/common/dmtables.c @@ -0,0 +1,485 @@ +/****************************************************************************** + * + * Module Name: dmtables - disassembler ACPI table support + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/include/acapps.h> +#include <contrib/dev/acpica/include/acdispat.h> +#include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/include/actables.h> +#include <contrib/dev/acpica/include/acparser.h> + +#include <stdio.h> +#include <time.h> + +#define _COMPONENT ACPI_TOOLS + ACPI_MODULE_NAME ("dmtables") + + +/* Local prototypes */ + +static void +AdCreateTableHeader ( + char *Filename, + ACPI_TABLE_HEADER *Table); + +static ACPI_STATUS +AdStoreTable ( + ACPI_TABLE_HEADER *Table, + UINT32 *TableIndex); + + +extern ACPI_TABLE_DESC LocalTables[1]; +extern ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; + + +/****************************************************************************** + * + * FUNCTION: AdDisassemblerHeader + * + * PARAMETERS: Filename - Input file for the table + * TableType - Either AML or DataTable + * + * RETURN: None + * + * DESCRIPTION: Create the disassembler header, including ACPICA signon with + * current time and date. + * + *****************************************************************************/ + +void +AdDisassemblerHeader ( + char *Filename, + UINT8 TableType) +{ + time_t Timer; + + + time (&Timer); + + /* Header and input table info */ + + AcpiOsPrintf ("/*\n"); + AcpiOsPrintf (ACPI_COMMON_HEADER (AML_DISASSEMBLER_NAME, " * ")); + + if (TableType == ACPI_IS_AML_TABLE) + { + if (AcpiGbl_CstyleDisassembly) + { + AcpiOsPrintf ( + " * Disassembling to symbolic ASL+ operators\n" + " *\n"); + } + else + { + AcpiOsPrintf ( + " * Disassembling to non-symbolic legacy ASL operators\n" + " *\n"); + } + } + + AcpiOsPrintf (" * Disassembly of %s, %s", Filename, ctime (&Timer)); + AcpiOsPrintf (" *\n"); +} + + +/****************************************************************************** + * + * FUNCTION: AdCreateTableHeader + * + * PARAMETERS: Filename - Input file for the table + * Table - Pointer to the raw table + * + * RETURN: None + * + * DESCRIPTION: Create the ASL table header, including ACPICA signon with + * current time and date. + * + *****************************************************************************/ + +static void +AdCreateTableHeader ( + char *Filename, + ACPI_TABLE_HEADER *Table) +{ + UINT8 Checksum; + + + /* Reset globals for External statements */ + + AcpiGbl_NumExternalMethods = 0; + AcpiGbl_ResolvedExternalMethods = 0; + + /* + * Print file header and dump original table header + */ + AdDisassemblerHeader (Filename, ACPI_IS_AML_TABLE); + + AcpiOsPrintf (" * Original Table Header:\n"); + AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature); + AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length); + + /* Print and validate the revision */ + + AcpiOsPrintf (" * Revision 0x%2.2X", Table->Revision); + + switch (Table->Revision) + { + case 0: + + AcpiOsPrintf (" **** Invalid Revision"); + break; + + case 1: + + /* Revision of DSDT controls the ACPI integer width */ + + if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT)) + { + AcpiOsPrintf (" **** 32-bit table (V1), no 64-bit math support"); + } + break; + + default: + + break; + } + + /* Print and validate the table checksum */ + + AcpiOsPrintf ("\n * Checksum 0x%2.2X", Table->Checksum); + + Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length); + if (Checksum) + { + AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X", + (UINT8) (Table->Checksum - Checksum)); + } + + AcpiOsPrintf ("\n"); + AcpiOsPrintf (" * OEM ID \"%.6s\"\n", Table->OemId); + AcpiOsPrintf (" * OEM Table ID \"%.8s\"\n", Table->OemTableId); + AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision); + AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId); + AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision); + AcpiOsPrintf (" */\n"); + + /* + * Open the ASL definition block. + * + * Note: the AMLFilename string is left zero-length in order to just let + * the compiler create it when the disassembled file is compiled. This + * makes it easier to rename the disassembled ASL file if needed. + */ + AcpiOsPrintf ( + "DefinitionBlock (\"\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n", + Table->Signature, Table->Revision, + Table->OemId, Table->OemTableId, Table->OemRevision); +} + + +/****************************************************************************** + * + * FUNCTION: AdDisplayTables + * + * PARAMETERS: Filename - Input file for the table + * Table - Pointer to the raw table + * + * RETURN: Status + * + * DESCRIPTION: Display (disassemble) loaded tables and dump raw tables + * + *****************************************************************************/ + +ACPI_STATUS +AdDisplayTables ( + char *Filename, + ACPI_TABLE_HEADER *Table) +{ + + + if (!AcpiGbl_ParseOpRoot) + { + return (AE_NOT_EXIST); + } + + if (!AcpiGbl_DmOpt_Listing) + { + AdCreateTableHeader (Filename, Table); + } + + AcpiDmDisassemble (NULL, AcpiGbl_ParseOpRoot, ACPI_UINT32_MAX); + MpEmitMappingInfo (); + + if (AcpiGbl_DmOpt_Listing) + { + AcpiOsPrintf ("\n\nTable Header:\n"); + AcpiUtDebugDumpBuffer ((UINT8 *) Table, sizeof (ACPI_TABLE_HEADER), + DB_BYTE_DISPLAY, ACPI_UINT32_MAX); + + AcpiOsPrintf ("Table Body (Length 0x%X)\n", Table->Length); + AcpiUtDebugDumpBuffer (((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)), + Table->Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AdStoreTable + * + * PARAMETERS: Table - Table header + * TableIndex - Where the table index is returned + * + * RETURN: Status and table index. + * + * DESCRIPTION: Add an ACPI table to the global table list + * + ******************************************************************************/ + +static ACPI_STATUS +AdStoreTable ( + ACPI_TABLE_HEADER *Table, + UINT32 *TableIndex) +{ + ACPI_STATUS Status; + ACPI_TABLE_DESC *TableDesc; + + + Status = AcpiTbGetNextTableDescriptor (TableIndex, &TableDesc); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Initialize added table */ + + AcpiTbInitTableDescriptor (TableDesc, ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, Table); + Status = AcpiTbValidateTable (TableDesc); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AdGetLocalTables + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Get the ACPI tables from either memory or a file + * + *****************************************************************************/ + +ACPI_STATUS +AdGetLocalTables ( + void) +{ + ACPI_STATUS Status; + ACPI_TABLE_HEADER TableHeader; + ACPI_TABLE_HEADER *NewTable; + UINT32 TableIndex; + + + /* Get the DSDT via table override */ + + ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_DSDT); + AcpiOsTableOverride (&TableHeader, &NewTable); + if (!NewTable) + { + fprintf (stderr, "Could not obtain DSDT\n"); + return (AE_NO_ACPI_TABLES); + } + + AdWriteTable (NewTable, NewTable->Length, + ACPI_SIG_DSDT, NewTable->OemTableId); + + /* Store DSDT in the Table Manager */ + + Status = AdStoreTable (NewTable, &TableIndex); + if (ACPI_FAILURE (Status)) + { + fprintf (stderr, "Could not store DSDT\n"); + return (AE_NO_ACPI_TABLES); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AdParseTable + * + * PARAMETERS: Table - Pointer to the raw table + * OwnerId - Returned OwnerId of the table + * LoadTable - If add table to the global table list + * External - If this is an external table + * + * RETURN: Status + * + * DESCRIPTION: Parse an ACPI AML table + * + *****************************************************************************/ + +ACPI_STATUS +AdParseTable ( + ACPI_TABLE_HEADER *Table, + ACPI_OWNER_ID *OwnerId, + BOOLEAN LoadTable, + BOOLEAN External) +{ + ACPI_STATUS Status = AE_OK; + ACPI_WALK_STATE *WalkState; + UINT8 *AmlStart; + UINT32 AmlLength; + UINT32 TableIndex; + + + if (!Table) + { + return (AE_NOT_EXIST); + } + + /* Pass 1: Parse everything except control method bodies */ + + fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature); + + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)); + + /* Create the root object */ + + AcpiGbl_ParseOpRoot = AcpiPsCreateScopeOp (AmlStart); + if (!AcpiGbl_ParseOpRoot) + { + return (AE_NO_MEMORY); + } + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState (0, AcpiGbl_ParseOpRoot, NULL, NULL); + if (!WalkState) + { + return (AE_NO_MEMORY); + } + + Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParseOpRoot, + NULL, AmlStart, AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; + + Status = AcpiPsParseAml (WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* If LoadTable is FALSE, we are parsing the last loaded table */ + + TableIndex = AcpiGbl_RootTableList.CurrentTableCount - 1; + + /* Pass 2 */ + + if (LoadTable) + { + Status = AdStoreTable (Table, &TableIndex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + Status = AcpiTbAllocateOwnerId (TableIndex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (OwnerId) + { + Status = AcpiTbGetOwnerId (TableIndex, OwnerId); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + + fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature); + + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* No need to parse control methods of external table */ + + if (External) + { + return (AE_OK); + } + + /* + * Pass 3: Parse control methods and link their parse trees + * into the main parse tree + */ + fprintf (stderr, + "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n"); + + Status = AcpiDmParseDeferredOps (AcpiGbl_ParseOpRoot); + fprintf (stderr, "\n"); + + /* Process Resource Templates */ + + AcpiDmFindResources (AcpiGbl_ParseOpRoot); + + fprintf (stderr, "Parsing completed\n"); + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/common/dmtbdump.c b/sys/contrib/dev/acpica/common/dmtbdump.c index 94358e8..d79658f 100644 --- a/sys/contrib/dev/acpica/common/dmtbdump.c +++ b/sys/contrib/dev/acpica/common/dmtbdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -155,7 +155,7 @@ AcpiDmDumpUnicode ( for (i = 0; i < Length; i += 2) { - if (!ACPI_IS_PRINT (Buffer[i])) + if (!isprint (Buffer[i])) { goto DumpRawBuffer; } @@ -178,6 +178,7 @@ AcpiDmDumpUnicode ( { AcpiOsPrintf ("%c", Buffer[i]); } + AcpiOsPrintf ("\"\n"); return; @@ -208,16 +209,21 @@ AcpiDmDumpRsdp ( ACPI_TABLE_RSDP *Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); UINT32 Length = sizeof (ACPI_RSDP_COMMON); UINT8 Checksum; + ACPI_STATUS Status; /* Dump the common ACPI 1.0 portion */ - AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp1); + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp1); + if (ACPI_FAILURE (Status)) + { + return (Length); + } /* Validate the first checksum */ Checksum = AcpiDmGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON), - Rsdp->Checksum); + Rsdp->Checksum); if (Checksum != Rsdp->Checksum) { AcpiOsPrintf ("/* Incorrect Checksum above, should be 0x%2.2X */\n", @@ -229,12 +235,16 @@ AcpiDmDumpRsdp ( if (Rsdp->Revision > 0) { Length = Rsdp->Length; - AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp2); + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp2); + if (ACPI_FAILURE (Status)) + { + return (Length); + } /* Validate the extended checksum over entire RSDP */ Checksum = AcpiDmGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP), - Rsdp->ExtendedChecksum); + Rsdp->ExtendedChecksum); if (Checksum != Rsdp->ExtendedChecksum) { AcpiOsPrintf ( @@ -347,37 +357,64 @@ void AcpiDmDumpFadt ( ACPI_TABLE_HEADER *Table) { + ACPI_STATUS Status; + /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */ - AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt1); + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt1); + if (ACPI_FAILURE (Status)) + { + return; + } /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */ if ((Table->Length > ACPI_FADT_V1_SIZE) && (Table->Length <= ACPI_FADT_V2_SIZE)) { - AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt2); + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt2); + if (ACPI_FAILURE (Status)) + { + return; + } } /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */ else if (Table->Length > ACPI_FADT_V2_SIZE) { - AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt3); + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt3); + if (ACPI_FAILURE (Status)) + { + return; + } /* Check for FADT revision 5 fields and up (ACPI 5.0+) */ if (Table->Length > ACPI_FADT_V3_SIZE) { - AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt5); + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt5); + if (ACPI_FAILURE (Status)) + { + return; + } } /* Check for FADT revision 6 fields and up (ACPI 6.0+) */ if (Table->Length > ACPI_FADT_V3_SIZE) { - AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt6); + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt6); + if (ACPI_FAILURE (Status)) + { + return; + } } } @@ -454,7 +491,8 @@ AcpiDmValidateFadtLength ( } AcpiOsPrintf ( - "\n// ACPI Warning: FADT revision %X does not match length: found %X expected %X\n", + "\n// ACPI Warning: FADT revision %X does not match length: " + "found %X expected %X\n", Revision, Length, ExpectedLength); } @@ -496,7 +534,7 @@ AcpiDmDumpAsf ( /* Common subtable header */ Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Header.Length, AcpiDmTableInfoAsfHdr); + SubTable->Header.Length, AcpiDmTableInfoAsfHdr); if (ACPI_FAILURE (Status)) { return; @@ -548,12 +586,13 @@ AcpiDmDumpAsf ( default: - AcpiOsPrintf ("\n**** Unknown ASF subtable type 0x%X\n", SubTable->Header.Type); + AcpiOsPrintf ("\n**** Unknown ASF subtable type 0x%X\n", + SubTable->Header.Type); return; } Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Header.Length, InfoTable); + SubTable->Header.Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -570,7 +609,7 @@ AcpiDmDumpAsf ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, DataOffset, - DataTable, DataLength, DataInfoTable); + DataTable, DataLength, DataInfoTable); if (ACPI_FAILURE (Status)) { return; @@ -593,9 +632,12 @@ AcpiDmDumpAsf ( AcpiOsPrintf ("%2.2X ", *DataTable); DataTable++; DataOffset++; + if (DataOffset > Table->Length) { - AcpiOsPrintf ("**** ACPI table terminates in the middle of a data structure! (ASF! table)\n"); + AcpiOsPrintf ( + "**** ACPI table terminates in the middle of a " + "data structure! (ASF! table)\n"); return; } } @@ -619,7 +661,8 @@ AcpiDmDumpAsf ( } Offset += SubTable->Header.Length; - SubTable = ACPI_ADD_PTR (ACPI_ASF_INFO, SubTable, SubTable->Header.Length); + SubTable = ACPI_ADD_PTR (ACPI_ASF_INFO, SubTable, + SubTable->Header.Length); } } @@ -662,7 +705,7 @@ AcpiDmDumpCpep ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Header.Length, AcpiDmTableInfoCpep0); + SubTable->Header.Length, AcpiDmTableInfoCpep0); if (ACPI_FAILURE (Status)) { return; @@ -672,7 +715,7 @@ AcpiDmDumpCpep ( Offset += SubTable->Header.Length; SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable, - SubTable->Header.Length); + SubTable->Header.Length); } } @@ -716,7 +759,7 @@ AcpiDmDumpCsrt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoCsrt0); + SubTable->Length, AcpiDmTableInfoCsrt0); if (ACPI_FAILURE (Status)) { return; @@ -730,7 +773,7 @@ AcpiDmDumpCsrt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset + SubOffset, SharedInfoTable, - sizeof (ACPI_CSRT_SHARED_INFO), AcpiDmTableInfoCsrt1); + sizeof (ACPI_CSRT_SHARED_INFO), AcpiDmTableInfoCsrt1); if (ACPI_FAILURE (Status)) { return; @@ -748,7 +791,7 @@ AcpiDmDumpCsrt ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset + SubOffset, SubSubTable, - SubSubTable->Length, AcpiDmTableInfoCsrt2); + SubSubTable->Length, AcpiDmTableInfoCsrt2); if (ACPI_FAILURE (Status)) { return; @@ -762,8 +805,8 @@ AcpiDmDumpCsrt ( if (InfoLength) { Status = AcpiDmDumpTable (Length, - Offset + SubOffset + SubSubOffset, Table, - InfoLength, AcpiDmTableInfoCsrt2a); + Offset + SubOffset + SubSubOffset, Table, + InfoLength, AcpiDmTableInfoCsrt2a); if (ACPI_FAILURE (Status)) { return; @@ -775,14 +818,14 @@ AcpiDmDumpCsrt ( SubOffset += SubSubTable->Length; SubSubTable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, SubSubTable, - SubSubTable->Length); + SubSubTable->Length); } /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, SubTable, - SubTable->Length); + SubTable->Length); } } @@ -829,7 +872,7 @@ AcpiDmDumpDbg2 ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoDbg2Device); + SubTable->Length, AcpiDmTableInfoDbg2Device); if (ACPI_FAILURE (Status)) { return; @@ -845,7 +888,7 @@ AcpiDmDumpDbg2 ( Array = (UINT8 *) SubTable + ArrayOffset; Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array, - SubTable->Length, AcpiDmTableInfoDbg2Addr); + SubTable->Length, AcpiDmTableInfoDbg2Addr); if (ACPI_FAILURE (Status)) { return; @@ -862,7 +905,7 @@ AcpiDmDumpDbg2 ( Array = (UINT8 *) SubTable + ArrayOffset; Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array, - SubTable->Length, AcpiDmTableInfoDbg2Size); + SubTable->Length, AcpiDmTableInfoDbg2Size); if (ACPI_FAILURE (Status)) { return; @@ -877,7 +920,7 @@ AcpiDmDumpDbg2 ( Array = (UINT8 *) SubTable + ArrayOffset; Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array, - SubTable->Length, AcpiDmTableInfoDbg2Name); + SubTable->Length, AcpiDmTableInfoDbg2Name); if (ACPI_FAILURE (Status)) { return; @@ -888,8 +931,8 @@ AcpiDmDumpDbg2 ( if (SubTable->OemDataOffset) { Status = AcpiDmDumpTable (Length, Offset + SubTable->OemDataOffset, - Table, SubTable->OemDataLength, - AcpiDmTableInfoDbg2OemData); + Table, SubTable->OemDataLength, + AcpiDmTableInfoDbg2OemData); if (ACPI_FAILURE (Status)) { return; @@ -900,7 +943,7 @@ AcpiDmDumpDbg2 ( Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, SubTable, - SubTable->Length); + SubTable->Length); } } @@ -950,11 +993,12 @@ AcpiDmDumpDmar ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoDmarHdr); + SubTable->Length, AcpiDmTableInfoDmarHdr); if (ACPI_FAILURE (Status)) { return; } + AcpiOsPrintf ("\n"); switch (SubTable->Type) @@ -991,12 +1035,13 @@ AcpiDmDumpDmar ( default: - AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n", + SubTable->Type); return; } Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, InfoTable); + SubTable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -1018,7 +1063,7 @@ AcpiDmDumpDmar ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable, - ScopeTable->Length, AcpiDmTableInfoDmarScope); + ScopeTable->Length, AcpiDmTableInfoDmarScope); if (ACPI_FAILURE (Status)) { return; @@ -1034,7 +1079,8 @@ AcpiDmDumpDmar ( while (PathOffset < ScopeTable->Length) { - AcpiDmLineHeader ((PathOffset + ScopeOffset + Offset), 2, "PCI Path"); + AcpiDmLineHeader ((PathOffset + ScopeOffset + Offset), 2, + "PCI Path"); AcpiOsPrintf ("%2.2X,%2.2X\n", PciPath[0], PciPath[1]); /* Point to next PCI Path entry */ @@ -1055,7 +1101,8 @@ NextSubtable: /* Point to next subtable */ Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, SubTable, SubTable->Length); + SubTable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, SubTable, + SubTable->Length); } } @@ -1087,7 +1134,7 @@ AcpiDmDumpDrtm ( /* Main table */ Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, - AcpiDmTableInfoDrtm); + AcpiDmTableInfoDrtm); if (ACPI_FAILURE (Status)) { return; @@ -1102,12 +1149,13 @@ AcpiDmDumpDrtm ( DrtmVtl = ACPI_ADD_PTR (ACPI_DRTM_VTABLE_LIST, Table, Offset); AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, - DrtmVtl, ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables), - AcpiDmTableInfoDrtm0); + DrtmVtl, ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables), + AcpiDmTableInfoDrtm0); if (ACPI_FAILURE (Status)) { return; } + Offset += ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables); /* Dump Validated table addresses */ @@ -1117,12 +1165,13 @@ AcpiDmDumpDrtm ( (DrtmVtl->ValidatedTableCount > Count)) { Status = AcpiDmDumpTable (Table->Length, Offset, - ACPI_ADD_PTR (void, Table, Offset), sizeof (UINT64), - AcpiDmTableInfoDrtm0a); + ACPI_ADD_PTR (void, Table, Offset), sizeof (UINT64), + AcpiDmTableInfoDrtm0a); if (ACPI_FAILURE (Status)) { return; } + Offset += sizeof (UINT64); Count++; } @@ -1132,11 +1181,11 @@ AcpiDmDumpDrtm ( DrtmRl = ACPI_ADD_PTR (ACPI_DRTM_RESOURCE_LIST, Table, Offset); AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, - DrtmRl, ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources), - AcpiDmTableInfoDrtm1); + DrtmRl, ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources), + AcpiDmTableInfoDrtm1); if (ACPI_FAILURE (Status)) { - return; + return; } Offset += ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources); @@ -1148,9 +1197,8 @@ AcpiDmDumpDrtm ( (DrtmRl->ResourceCount > Count)) { Status = AcpiDmDumpTable (Table->Length, Offset, - ACPI_ADD_PTR (void, Table, Offset), - sizeof (ACPI_DRTM_RESOURCE), - AcpiDmTableInfoDrtm1a); + ACPI_ADD_PTR (void, Table, Offset), + sizeof (ACPI_DRTM_RESOURCE), AcpiDmTableInfoDrtm1a); if (ACPI_FAILURE (Status)) { return; @@ -1164,13 +1212,8 @@ AcpiDmDumpDrtm ( DrtmDps = ACPI_ADD_PTR (ACPI_DRTM_DPS_ID, Table, Offset); AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Table->Length, Offset, - DrtmDps, sizeof (ACPI_DRTM_DPS_ID), - AcpiDmTableInfoDrtm2); - if (ACPI_FAILURE (Status)) - { - return; - } + (void) AcpiDmDumpTable (Table->Length, Offset, + DrtmDps, sizeof (ACPI_DRTM_DPS_ID), AcpiDmTableInfoDrtm2); } @@ -1212,7 +1255,7 @@ AcpiDmDumpEinj ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoEinj0); + sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoEinj0); if (ACPI_FAILURE (Status)) { return; @@ -1222,7 +1265,7 @@ AcpiDmDumpEinj ( Offset += sizeof (ACPI_WHEA_HEADER); SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, SubTable, - sizeof (ACPI_WHEA_HEADER)); + sizeof (ACPI_WHEA_HEADER)); } } @@ -1265,7 +1308,7 @@ AcpiDmDumpErst ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoErst0); + sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoErst0); if (ACPI_FAILURE (Status)) { return; @@ -1275,7 +1318,7 @@ AcpiDmDumpErst ( Offset += sizeof (ACPI_WHEA_HEADER); SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, SubTable, - sizeof (ACPI_WHEA_HEADER)); + sizeof (ACPI_WHEA_HEADER)); } } @@ -1315,7 +1358,7 @@ AcpiDmDumpFpdt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoFpdtHdr); + SubTable->Length, AcpiDmTableInfoFpdtHdr); if (ACPI_FAILURE (Status)) { return; @@ -1335,7 +1378,8 @@ AcpiDmDumpFpdt ( default: - AcpiOsPrintf ("\n**** Unknown FPDT subtable type 0x%X\n\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown FPDT subtable type 0x%X\n\n", + SubTable->Type); /* Attempt to continue */ @@ -1348,7 +1392,7 @@ AcpiDmDumpFpdt ( } Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, InfoTable); + SubTable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -1358,7 +1402,8 @@ NextSubTable: /* Point to next subtable */ Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, SubTable, SubTable->Length); + SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, SubTable, + SubTable->Length); } } @@ -1407,7 +1452,7 @@ AcpiDmDumpGtdt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoGtdtHdr); + SubTable->Length, AcpiDmTableInfoGtdtHdr); if (ACPI_FAILURE (Status)) { return; @@ -1420,7 +1465,7 @@ AcpiDmDumpGtdt ( SubTableLength = sizeof (ACPI_GTDT_TIMER_BLOCK); GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, - SubTable))->TimerCount; + SubTable))->TimerCount; InfoTable = AcpiDmTableInfoGtdt0; break; @@ -1436,12 +1481,13 @@ AcpiDmDumpGtdt ( /* Cannot continue on unknown type - no length */ - AcpiOsPrintf ("\n**** Unknown GTDT subtable type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown GTDT subtable type 0x%X\n", + SubTable->Type); return; } Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, InfoTable); + SubTable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -1455,14 +1501,15 @@ AcpiDmDumpGtdt ( if (GtCount) { - GtxTable = ACPI_ADD_PTR (ACPI_GTDT_TIMER_ENTRY, SubTable, SubTableLength); + GtxTable = ACPI_ADD_PTR ( + ACPI_GTDT_TIMER_ENTRY, SubTable, SubTableLength); SubTableLength += GtCount * sizeof (ACPI_GTDT_TIMER_ENTRY); while (GtCount) { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, GtxTable, - sizeof (ACPI_GTDT_TIMER_ENTRY), AcpiDmTableInfoGtdt0a); + sizeof (ACPI_GTDT_TIMER_ENTRY), AcpiDmTableInfoGtdt0a); if (ACPI_FAILURE (Status)) { return; @@ -1528,7 +1575,7 @@ AcpiDmDumpHest ( InfoTable = AcpiDmTableInfoHest0; SubTableLength = sizeof (ACPI_HEST_IA_MACHINE_CHECK); BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, - SubTable))->NumHardwareBanks; + SubTable))->NumHardwareBanks; break; case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: @@ -1536,7 +1583,7 @@ AcpiDmDumpHest ( InfoTable = AcpiDmTableInfoHest1; SubTableLength = sizeof (ACPI_HEST_IA_CORRECTED); BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, - SubTable))->NumHardwareBanks; + SubTable))->NumHardwareBanks; break; case ACPI_HEST_TYPE_IA32_NMI: @@ -1569,17 +1616,24 @@ AcpiDmDumpHest ( SubTableLength = sizeof (ACPI_HEST_GENERIC); break; + case ACPI_HEST_TYPE_GENERIC_ERROR_V2: + + InfoTable = AcpiDmTableInfoHest10; + SubTableLength = sizeof (ACPI_HEST_GENERIC_V2); + break; + default: /* Cannot continue on unknown type - no length */ - AcpiOsPrintf ("\n**** Unknown HEST subtable type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown HEST subtable type 0x%X\n", + SubTable->Type); return; } AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTableLength, InfoTable); + SubTableLength, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -1593,18 +1647,20 @@ AcpiDmDumpHest ( if (BankCount) { - BankTable = ACPI_ADD_PTR (ACPI_HEST_IA_ERROR_BANK, SubTable, SubTableLength); + BankTable = ACPI_ADD_PTR (ACPI_HEST_IA_ERROR_BANK, SubTable, + SubTableLength); SubTableLength += BankCount * sizeof (ACPI_HEST_IA_ERROR_BANK); while (BankCount) { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, BankTable, - sizeof (ACPI_HEST_IA_ERROR_BANK), AcpiDmTableInfoHestBank); + sizeof (ACPI_HEST_IA_ERROR_BANK), AcpiDmTableInfoHestBank); if (ACPI_FAILURE (Status)) { return; } + Offset += sizeof (ACPI_HEST_IA_ERROR_BANK); BankTable++; BankCount--; @@ -1663,7 +1719,7 @@ AcpiDmDumpIort ( if (Iort->NodeOffset > Offset) { Status = AcpiDmDumpTable (Table->Length, Offset, Table, - Iort->NodeOffset - Offset, AcpiDmTableInfoIortPad); + Iort->NodeOffset - Offset, AcpiDmTableInfoIortPad); if (ACPI_FAILURE (Status)) { return; @@ -1679,7 +1735,7 @@ AcpiDmDumpIort ( AcpiOsPrintf ("\n"); Length = ACPI_OFFSET (ACPI_IORT_NODE, NodeData); Status = AcpiDmDumpTable (Table->Length, Offset, - IortNode, Length, AcpiDmTableInfoIortHdr); + IortNode, Length, AcpiDmTableInfoIortHdr); if (ACPI_FAILURE (Status)) { return; @@ -1701,7 +1757,7 @@ AcpiDmDumpIort ( InfoTable = AcpiDmTableInfoIort1; Length = ACPI_OFFSET (ACPI_IORT_NAMED_COMPONENT, DeviceName); String = ACPI_ADD_PTR (char, IortNode, NodeOffset + Length); - Length += ACPI_STRLEN (String) + 1; + Length += strlen (String) + 1; break; case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: @@ -1717,6 +1773,12 @@ AcpiDmDumpIort ( IortSmmu = ACPI_ADD_PTR (ACPI_IORT_SMMU, IortNode, NodeOffset); break; + case ACPI_IORT_NODE_SMMU_V3: + + InfoTable = AcpiDmTableInfoIort4; + Length = IortNode->Length - NodeOffset; + break; + default: AcpiOsPrintf ("\n**** Unknown IORT node type 0x%X\n", @@ -1736,8 +1798,8 @@ AcpiDmDumpIort ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset, - ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), - Length, InfoTable); + ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), + Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -1758,8 +1820,8 @@ AcpiDmDumpIort ( for (i = 0; i < IortItsGroup->ItsCount; i++) { Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset, - ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), - 4, AcpiDmTableInfoIort0a); + ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), + 4, AcpiDmTableInfoIort0a); NodeOffset += 4; } } @@ -1772,8 +1834,8 @@ AcpiDmDumpIort ( if (IortNode->Length > NodeOffset) { Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset, - Table, IortNode->Length - NodeOffset, - AcpiDmTableInfoIort1a); + Table, IortNode->Length - NodeOffset, + AcpiDmTableInfoIort1a); if (ACPI_FAILURE (Status)) { return; @@ -1792,15 +1854,24 @@ AcpiDmDumpIort ( Length = 2 * sizeof (UINT64); NodeOffset = IortSmmu->GlobalInterruptOffset; Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset, - ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), - Length, AcpiDmTableInfoIort3a); + ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), + Length, AcpiDmTableInfoIort3a); + if (ACPI_FAILURE (Status)) + { + return; + } NodeOffset = IortSmmu->ContextInterruptOffset; for (i = 0; i < IortSmmu->ContextInterruptCount; i++) { Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset, - ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), - 8, AcpiDmTableInfoIort3b); + ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), + 8, AcpiDmTableInfoIort3b); + if (ACPI_FAILURE (Status)) + { + return; + } + NodeOffset += 8; } @@ -1808,8 +1879,13 @@ AcpiDmDumpIort ( for (i = 0; i < IortSmmu->PmuInterruptCount; i++) { Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset, - ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), - 8, AcpiDmTableInfoIort3c); + ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), + 8, AcpiDmTableInfoIort3c); + if (ACPI_FAILURE (Status)) + { + return; + } + NodeOffset += 8; } } @@ -1828,8 +1904,13 @@ AcpiDmDumpIort ( AcpiOsPrintf ("\n"); Length = sizeof (ACPI_IORT_ID_MAPPING); Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset, - ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), - Length, AcpiDmTableInfoIortMap); + ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset), + Length, AcpiDmTableInfoIortMap); + if (ACPI_FAILURE (Status)) + { + return; + } + NodeOffset += Length; } @@ -1887,7 +1968,7 @@ AcpiDmDumpIvrs ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoIvrsHdr); + SubTable->Length, AcpiDmTableInfoIvrsHdr); if (ACPI_FAILURE (Status)) { return; @@ -1926,7 +2007,7 @@ AcpiDmDumpIvrs ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Length, InfoTable); + SubTable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -1938,7 +2019,7 @@ AcpiDmDumpIvrs ( { EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE); DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, SubTable, - sizeof (ACPI_IVRS_HARDWARE)); + sizeof (ACPI_IVRS_HARDWARE)); while (EntryOffset < (Offset + SubTable->Length)) { @@ -2003,11 +2084,15 @@ AcpiDmDumpIvrs ( /* Dump the Device Entry */ Status = AcpiDmDumpTable (Table->Length, EntryOffset, - DeviceEntry, EntryLength, InfoTable); + DeviceEntry, EntryLength, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } EntryOffset += EntryLength; DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, DeviceEntry, - EntryLength); + EntryLength); } } @@ -2055,7 +2140,7 @@ AcpiDmDumpLpit ( /* Common subtable header */ Status = AcpiDmDumpTable (Length, Offset, SubTable, - sizeof (ACPI_LPIT_HEADER), AcpiDmTableInfoLpitHdr); + sizeof (ACPI_LPIT_HEADER), AcpiDmTableInfoLpitHdr); if (ACPI_FAILURE (Status)) { return; @@ -2073,16 +2158,18 @@ AcpiDmDumpLpit ( /* Cannot continue on unknown type - no length */ - AcpiOsPrintf ("\n**** Unknown LPIT subtable type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown LPIT subtable type 0x%X\n", + SubTable->Type); return; } Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTableLength, InfoTable); + SubTableLength, InfoTable); if (ACPI_FAILURE (Status)) { return; } + AcpiOsPrintf ("\n"); /* Point to next subtable */ @@ -2134,7 +2221,7 @@ AcpiDmDumpMadt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoMadtHdr); + SubTable->Length, AcpiDmTableInfoMadtHdr); if (ACPI_FAILURE (Status)) { return; @@ -2224,7 +2311,8 @@ AcpiDmDumpMadt ( default: - AcpiOsPrintf ("\n**** Unknown MADT subtable type 0x%X\n\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown MADT subtable type 0x%X\n\n", + SubTable->Type); /* Attempt to continue */ @@ -2233,11 +2321,12 @@ AcpiDmDumpMadt ( AcpiOsPrintf ("Invalid zero length subtable\n"); return; } + goto NextSubTable; } Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, InfoTable); + SubTable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -2247,7 +2336,8 @@ NextSubTable: /* Point to next subtable */ Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, SubTable, SubTable->Length); + SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, SubTable, + SubTable->Length); } } @@ -2295,7 +2385,7 @@ AcpiDmDumpMcfg ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - sizeof (ACPI_MCFG_ALLOCATION), AcpiDmTableInfoMcfg0); + sizeof (ACPI_MCFG_ALLOCATION), AcpiDmTableInfoMcfg0); if (ACPI_FAILURE (Status)) { return; @@ -2305,7 +2395,7 @@ AcpiDmDumpMcfg ( Offset += sizeof (ACPI_MCFG_ALLOCATION); SubTable = ACPI_ADD_PTR (ACPI_MCFG_ALLOCATION, SubTable, - sizeof (ACPI_MCFG_ALLOCATION)); + sizeof (ACPI_MCFG_ALLOCATION)); } } @@ -2355,7 +2445,7 @@ AcpiDmDumpMpst ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable0, - sizeof (ACPI_MPST_POWER_NODE), AcpiDmTableInfoMpst0); + sizeof (ACPI_MPST_POWER_NODE), AcpiDmTableInfoMpst0); if (ACPI_FAILURE (Status)) { return; @@ -2376,7 +2466,7 @@ AcpiDmDumpMpst ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable0A, - sizeof (ACPI_MPST_POWER_STATE), AcpiDmTableInfoMpst0A); + sizeof (ACPI_MPST_POWER_STATE), AcpiDmTableInfoMpst0A); if (ACPI_FAILURE (Status)) { return; @@ -2399,7 +2489,7 @@ AcpiDmDumpMpst ( while (ComponentCount) { Status = AcpiDmDumpTable (Table->Length, Offset, SubTable0B, - sizeof (ACPI_MPST_COMPONENT), AcpiDmTableInfoMpst0B); + sizeof (ACPI_MPST_COMPONENT), AcpiDmTableInfoMpst0B); if (ACPI_FAILURE (Status)) { return; @@ -2424,7 +2514,7 @@ AcpiDmDumpMpst ( AcpiOsPrintf ("\n"); SubTable1 = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, SubTable0); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable1, - sizeof (ACPI_MPST_DATA_HDR), AcpiDmTableInfoMpst1); + sizeof (ACPI_MPST_DATA_HDR), AcpiDmTableInfoMpst1); if (ACPI_FAILURE (Status)) { return; @@ -2435,13 +2525,14 @@ AcpiDmDumpMpst ( /* Subtable: Memory Power State Characteristics structure(s) */ - SubTable2 = ACPI_ADD_PTR (ACPI_MPST_POWER_DATA, SubTable1, sizeof (ACPI_MPST_DATA_HDR)); + SubTable2 = ACPI_ADD_PTR (ACPI_MPST_POWER_DATA, SubTable1, + sizeof (ACPI_MPST_DATA_HDR)); while ((Offset < Table->Length) && SubtableCount) { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable2, - sizeof (ACPI_MPST_POWER_DATA), AcpiDmTableInfoMpst2); + sizeof (ACPI_MPST_POWER_DATA), AcpiDmTableInfoMpst2); if (ACPI_FAILURE (Status)) { return; @@ -2492,7 +2583,7 @@ AcpiDmDumpMsct ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - sizeof (ACPI_MSCT_PROXIMITY), AcpiDmTableInfoMsct0); + sizeof (ACPI_MSCT_PROXIMITY), AcpiDmTableInfoMsct0); if (ACPI_FAILURE (Status)) { return; @@ -2501,7 +2592,8 @@ AcpiDmDumpMsct ( /* Point to next subtable */ Offset += sizeof (ACPI_MSCT_PROXIMITY); - SubTable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, SubTable, sizeof (ACPI_MSCT_PROXIMITY)); + SubTable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, SubTable, + sizeof (ACPI_MSCT_PROXIMITY)); } } @@ -2544,7 +2636,7 @@ AcpiDmDumpMtmr ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - sizeof (ACPI_MTMR_ENTRY), AcpiDmTableInfoMtmr0); + sizeof (ACPI_MTMR_ENTRY), AcpiDmTableInfoMtmr0); if (ACPI_FAILURE (Status)) { return; @@ -2553,7 +2645,8 @@ AcpiDmDumpMtmr ( /* Point to next subtable */ Offset += sizeof (ACPI_MTMR_ENTRY); - SubTable = ACPI_ADD_PTR (ACPI_MTMR_ENTRY, SubTable, sizeof (ACPI_MTMR_ENTRY)); + SubTable = ACPI_ADD_PTR (ACPI_MTMR_ENTRY, SubTable, + sizeof (ACPI_MTMR_ENTRY)); } } @@ -2603,7 +2696,7 @@ AcpiDmDumpNfit ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoNfitHdr); + SubTable->Length, AcpiDmTableInfoNfitHdr); if (ACPI_FAILURE (Status)) { return; @@ -2656,7 +2749,8 @@ AcpiDmDumpNfit ( break; default: - AcpiOsPrintf ("\n**** Unknown NFIT subtable type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown NFIT subtable type 0x%X\n", + SubTable->Type); /* Attempt to continue */ @@ -2670,7 +2764,7 @@ AcpiDmDumpNfit ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Length, InfoTable); + SubTable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -2685,21 +2779,28 @@ AcpiDmDumpNfit ( for (i = 0; i < Interleave->LineCount; i++) { Status = AcpiDmDumpTable (Table->Length, Offset + FieldOffset, - &Interleave->LineOffset[i], - sizeof (UINT32), AcpiDmTableInfoNfit2a); + &Interleave->LineOffset[i], + sizeof (UINT32), AcpiDmTableInfoNfit2a); + if (ACPI_FAILURE (Status)) + { + return; + } + FieldOffset += sizeof (UINT32); } break; case ACPI_NFIT_TYPE_SMBIOS: - Length = SubTable->Length - sizeof (ACPI_NFIT_SMBIOS) + sizeof (UINT8); + Length = SubTable->Length - + sizeof (ACPI_NFIT_SMBIOS) + sizeof (UINT8); + if (Length) { Status = AcpiDmDumpTable (Table->Length, - sizeof (ACPI_NFIT_SMBIOS) - sizeof (UINT8), - SmbiosInfo, - Length, AcpiDmTableInfoNfit3a); + sizeof (ACPI_NFIT_SMBIOS) - sizeof (UINT8), + SmbiosInfo, + Length, AcpiDmTableInfoNfit3a); if (ACPI_FAILURE (Status)) { return; @@ -2713,8 +2814,13 @@ AcpiDmDumpNfit ( for (i = 0; i < Hint->HintCount; i++) { Status = AcpiDmDumpTable (Table->Length, Offset + FieldOffset, - &Hint->HintAddress[i], - sizeof (UINT64), AcpiDmTableInfoNfit6a); + &Hint->HintAddress[i], + sizeof (UINT64), AcpiDmTableInfoNfit6a); + if (ACPI_FAILURE (Status)) + { + return; + } + FieldOffset += sizeof (UINT64); } break; @@ -2773,7 +2879,7 @@ AcpiDmDumpPcct ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Header.Length, AcpiDmTableInfoPcctHdr); + SubTable->Header.Length, AcpiDmTableInfoPcctHdr); if (ACPI_FAILURE (Status)) { return; @@ -2791,6 +2897,11 @@ AcpiDmDumpPcct ( InfoTable = AcpiDmTableInfoPcct1; break; + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2: + + InfoTable = AcpiDmTableInfoPcct2; + break; + default: AcpiOsPrintf ( @@ -2801,7 +2912,7 @@ AcpiDmDumpPcct ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Header.Length, InfoTable); + SubTable->Header.Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -2811,7 +2922,7 @@ AcpiDmDumpPcct ( Offset += SubTable->Header.Length; SubTable = ACPI_ADD_PTR (ACPI_PCCT_SUBSPACE, SubTable, - SubTable->Header.Length); + SubTable->Header.Length); } } @@ -2863,7 +2974,7 @@ AcpiDmDumpPmtt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoPmttHdr); + SubTable->Length, AcpiDmTableInfoPmttHdr); if (ACPI_FAILURE (Status)) { return; @@ -2882,7 +2993,7 @@ AcpiDmDumpPmtt ( /* Dump the fixed-length portion of the subtable */ Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoPmtt0); + SubTable->Length, AcpiDmTableInfoPmtt0); if (ACPI_FAILURE (Status)) { return; @@ -2901,8 +3012,8 @@ AcpiDmDumpPmtt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, - Offset + MemOffset, MemSubTable, - MemSubTable->Length, AcpiDmTableInfoPmttHdr); + Offset + MemOffset, MemSubTable, + MemSubTable->Length, AcpiDmTableInfoPmttHdr); if (ACPI_FAILURE (Status)) { return; @@ -2921,8 +3032,8 @@ AcpiDmDumpPmtt ( /* Dump the fixed-length portion of the controller subtable */ Status = AcpiDmDumpTable (Length, - Offset + MemOffset, MemSubTable, - MemSubTable->Length, AcpiDmTableInfoPmtt1); + Offset + MemOffset, MemSubTable, + MemSubTable->Length, AcpiDmTableInfoPmtt1); if (ACPI_FAILURE (Status)) { return; @@ -2940,8 +3051,8 @@ AcpiDmDumpPmtt ( DomainCount) { Status = AcpiDmDumpTable (Length, - Offset + MemOffset + DomainOffset, DomainArray, - sizeof (ACPI_PMTT_DOMAIN), AcpiDmTableInfoPmtt1a); + Offset + MemOffset + DomainOffset, DomainArray, + sizeof (ACPI_PMTT_DOMAIN), AcpiDmTableInfoPmtt1a); if (ACPI_FAILURE (Status)) { return; @@ -2971,8 +3082,8 @@ AcpiDmDumpPmtt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, - Offset + MemOffset + DimmOffset, DimmSubTable, - DimmSubTable->Length, AcpiDmTableInfoPmttHdr); + Offset + MemOffset + DimmOffset, DimmSubTable, + DimmSubTable->Length, AcpiDmTableInfoPmttHdr); if (ACPI_FAILURE (Status)) { return; @@ -2991,8 +3102,8 @@ AcpiDmDumpPmtt ( /* Dump the fixed-length DIMM subtable */ Status = AcpiDmDumpTable (Length, - Offset + MemOffset + DimmOffset, DimmSubTable, - DimmSubTable->Length, AcpiDmTableInfoPmtt2); + Offset + MemOffset + DimmOffset, DimmSubTable, + DimmSubTable->Length, AcpiDmTableInfoPmtt2); if (ACPI_FAILURE (Status)) { return; @@ -3039,7 +3150,7 @@ AcpiDmDumpS3pt ( { ACPI_STATUS Status; UINT32 Offset = sizeof (ACPI_TABLE_S3PT); - ACPI_S3PT_HEADER *SubTable; + ACPI_FPDT_HEADER *SubTable; ACPI_DMTABLE_INFO *InfoTable; ACPI_TABLE_S3PT *S3ptTable = ACPI_CAST_PTR (ACPI_TABLE_S3PT, Tables); @@ -3052,14 +3163,14 @@ AcpiDmDumpS3pt ( return 0; } - SubTable = ACPI_ADD_PTR (ACPI_S3PT_HEADER, S3ptTable, Offset); + SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, S3ptTable, Offset); while (Offset < S3ptTable->Length) { /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (S3ptTable->Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoS3ptHdr); + SubTable->Length, AcpiDmTableInfoS3ptHdr); if (ACPI_FAILURE (Status)) { return 0; @@ -3079,7 +3190,8 @@ AcpiDmDumpS3pt ( default: - AcpiOsPrintf ("\n**** Unknown S3PT subtable type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown S3PT subtable type 0x%X\n", + SubTable->Type); /* Attempt to continue */ @@ -3093,7 +3205,7 @@ AcpiDmDumpS3pt ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (S3ptTable->Length, Offset, SubTable, - SubTable->Length, InfoTable); + SubTable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return 0; @@ -3103,7 +3215,7 @@ NextSubTable: /* Point to next subtable */ Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_S3PT_HEADER, SubTable, SubTable->Length); + SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, SubTable, SubTable->Length); } return (S3ptTable->Length); @@ -3126,8 +3238,9 @@ void AcpiDmDumpSlic ( ACPI_TABLE_HEADER *Table) { - AcpiDmDumpTable (Table->Length, sizeof (ACPI_TABLE_HEADER), Table, - Table->Length - sizeof (*Table), AcpiDmTableInfoSlic); + + (void) AcpiDmDumpTable (Table->Length, sizeof (ACPI_TABLE_HEADER), Table, + Table->Length - sizeof (*Table), AcpiDmTableInfoSlic); } @@ -3180,7 +3293,8 @@ AcpiDmDumpSlit ( if (Offset >= Table->Length) { - AcpiOsPrintf ("\n**** Not enough room in table for all localities\n"); + AcpiOsPrintf ( + "\n**** Not enough room in table for all localities\n"); return; } @@ -3248,7 +3362,7 @@ AcpiDmDumpSrat ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoSratHdr); + SubTable->Length, AcpiDmTableInfoSratHdr); if (ACPI_FAILURE (Status)) { return; @@ -3277,7 +3391,8 @@ AcpiDmDumpSrat ( break; default: - AcpiOsPrintf ("\n**** Unknown SRAT subtable type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown SRAT subtable type 0x%X\n", + SubTable->Type); /* Attempt to continue */ @@ -3291,7 +3406,7 @@ AcpiDmDumpSrat ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Length, InfoTable); + SubTable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -3301,7 +3416,8 @@ NextSubTable: /* Point to next subtable */ Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, SubTable, SubTable->Length); + SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, SubTable, + SubTable->Length); } } @@ -3344,7 +3460,7 @@ AcpiDmDumpStao ( while (Offset < Table->Length) { Namepath = ACPI_ADD_PTR (char, Table, Offset); - StringLength = ACPI_STRLEN (Namepath) + 1; + StringLength = strlen (Namepath) + 1; AcpiDmLineHeader (Offset, StringLength, "Namestring"); AcpiOsPrintf ("\"%s\"\n", Namepath); @@ -3358,6 +3474,77 @@ AcpiDmDumpStao ( /******************************************************************************* * + * FUNCTION: AcpiDmDumpTcpa + * + * PARAMETERS: Table - A TCPA table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a TCPA. + * + * NOTE: There are two versions of the table with the same signature: + * the client version and the server version. The common + * PlatformClass field is used to differentiate the two types of + * tables. + * + ******************************************************************************/ + +void +AcpiDmDumpTcpa ( + ACPI_TABLE_HEADER *Table) +{ + UINT32 Offset = sizeof (ACPI_TABLE_TCPA_HDR); + ACPI_TABLE_TCPA_HDR *CommonHeader = ACPI_CAST_PTR ( + ACPI_TABLE_TCPA_HDR, Table); + ACPI_TABLE_TCPA_HDR *SubTable = ACPI_ADD_PTR ( + ACPI_TABLE_TCPA_HDR, Table, Offset); + ACPI_STATUS Status; + + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, + 0, AcpiDmTableInfoTcpaHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* + * Examine the PlatformClass field to determine the table type. + * Either a client or server table. Only one. + */ + switch (CommonHeader->PlatformClass) + { + case ACPI_TCPA_CLIENT_TABLE: + + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + Table->Length - Offset, AcpiDmTableInfoTcpaClient); + break; + + case ACPI_TCPA_SERVER_TABLE: + + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + Table->Length - Offset, AcpiDmTableInfoTcpaServer); + break; + + default: + + AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n", + CommonHeader->PlatformClass); + Status = AE_ERROR; + break; + } + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("\n**** Cannot disassemble TCPA table\n"); + } +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmDumpVrtc * * PARAMETERS: Table - A VRTC table @@ -3394,7 +3581,7 @@ AcpiDmDumpVrtc ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - sizeof (ACPI_VRTC_ENTRY), AcpiDmTableInfoVrtc0); + sizeof (ACPI_VRTC_ENTRY), AcpiDmTableInfoVrtc0); if (ACPI_FAILURE (Status)) { return; @@ -3403,7 +3590,8 @@ AcpiDmDumpVrtc ( /* Point to next subtable */ Offset += sizeof (ACPI_VRTC_ENTRY); - SubTable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, SubTable, sizeof (ACPI_VRTC_ENTRY)); + SubTable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, SubTable, + sizeof (ACPI_VRTC_ENTRY)); } } @@ -3446,7 +3634,7 @@ AcpiDmDumpWdat ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0); + sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0); if (ACPI_FAILURE (Status)) { return; @@ -3455,10 +3643,12 @@ AcpiDmDumpWdat ( /* Point to next subtable */ Offset += sizeof (ACPI_WDAT_ENTRY); - SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, SubTable, sizeof (ACPI_WDAT_ENTRY)); + SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, SubTable, + sizeof (ACPI_WDAT_ENTRY)); } } + /******************************************************************************* * * FUNCTION: AcpiDmDumpWpbt @@ -3497,10 +3687,6 @@ AcpiDmDumpWpbt ( /* Dump the arguments buffer */ - AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength, + (void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength, AcpiDmTableInfoWpbt0); - if (ACPI_FAILURE (Status)) - { - return; - } } diff --git a/sys/contrib/dev/acpica/common/dmtbinfo.c b/sys/contrib/dev/acpica/common/dmtbinfo.c index a803c70..cce6c5c 100644 --- a/sys/contrib/dev/acpica/common/dmtbinfo.c +++ b/sys/contrib/dev/acpica/common/dmtbinfo.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -113,7 +113,7 @@ #define ACPI_SPMI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SPMI,f) #define ACPI_SRAT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SRAT,f) #define ACPI_STAO_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_STAO,f) -#define ACPI_TCPA_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TCPA,f) +#define ACPI_TCPA_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TCPA_HDR,f) #define ACPI_TPM2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TPM2,f) #define ACPI_UEFI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_UEFI,f) #define ACPI_WAET_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WAET,f) @@ -150,8 +150,8 @@ #define ACPI_EINJ0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_ERST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_FPDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f) -#define ACPI_FPDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_BOOT,f) -#define ACPI_FPDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_S3PT_PTR,f) +#define ACPI_FPDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_BOOT_POINTER,f) +#define ACPI_FPDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_S3PT_POINTER,f) #define ACPI_GTDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_BLOCK,f) #define ACPI_GTDT0a_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_ENTRY,f) #define ACPI_GTDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_WATCHDOG,f) @@ -163,12 +163,14 @@ #define ACPI_HEST7_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_AER,f) #define ACPI_HEST8_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_AER_BRIDGE,f) #define ACPI_HEST9_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_GENERIC,f) +#define ACPI_HEST10_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_GENERIC_V2,f) #define ACPI_HESTN_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_NOTIFY,f) #define ACPI_HESTB_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_ERROR_BANK,f) #define ACPI_IORT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_ITS_GROUP,f) #define ACPI_IORT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_NAMED_COMPONENT,f) #define ACPI_IORT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_ROOT_COMPLEX,f) #define ACPI_IORT3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU,f) +#define ACPI_IORT4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU_V3,f) #define ACPI_IORTA_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_MEMORY_ACCESS,f) #define ACPI_IORTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_NODE,f) #define ACPI_IORTM_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_ID_MAPPING,f) @@ -216,12 +218,13 @@ #define ACPI_NFIT6_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_FLUSH_ADDRESS,f) #define ACPI_PCCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_SUBSPACE,f) #define ACPI_PCCT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_HW_REDUCED,f) +#define ACPI_PCCT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_HW_REDUCED_TYPE2,f) #define ACPI_PMTT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_SOCKET,f) #define ACPI_PMTT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_CONTROLLER,f) #define ACPI_PMTT1A_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_DOMAIN,f) #define ACPI_PMTT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_PHYSICAL_COMPONENT,f) #define ACPI_PMTTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_HEADER,f) -#define ACPI_S3PTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_S3PT_HEADER,f) +#define ACPI_S3PTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f) #define ACPI_S3PT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_S3PT_RESUME,f) #define ACPI_S3PT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_S3PT_SUSPEND,f) #define ACPI_SLIC_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SLIC,f) @@ -230,6 +233,8 @@ #define ACPI_SRAT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_MEM_AFFINITY,f) #define ACPI_SRAT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f) #define ACPI_SRAT3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_GICC_AFFINITY,f) +#define ACPI_TCPA_CLIENT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TCPA_CLIENT,f) +#define ACPI_TCPA_SERVER_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TCPA_SERVER,f) #define ACPI_VRTC0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_VRTC_ENTRY,f) #define ACPI_WDAT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WDAT_ENTRY,f) @@ -253,6 +258,7 @@ #define ACPI_GTDT0a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_TIMER_ENTRY,f,o) #define ACPI_GTDT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_WATCHDOG,f,o) #define ACPI_IORT3_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_SMMU,f,o) +#define ACPI_IORT4_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_SMMU_V3,f,o) #define ACPI_IORTA_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_MEMORY_ACCESS,f,o) #define ACPI_IORTM_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_ID_MAPPING,f,o) #define ACPI_LPITH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_LPIT_HEADER,f,o) @@ -274,6 +280,7 @@ #define ACPI_NFIT4_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_NFIT_CONTROL_REGION,f,o) #define ACPI_PCCT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_PCCT,f,o) #define ACPI_PCCT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PCCT_HW_REDUCED,f,o) +#define ACPI_PCCT2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PCCT_HW_REDUCED_TYPE2,f,o) #define ACPI_PMTTH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PMTT_HEADER,f,o) #define ACPI_WDDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_WDDT,f,o) #define ACPI_EINJ0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_WHEA_HEADER,f,o) @@ -1092,11 +1099,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFpdtHdr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt0[] = { {ACPI_DMT_UINT32, ACPI_FPDT0_OFFSET (Reserved), "Reserved", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ResetEnd), "Reset End", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (LoadStart), "Load Image Start", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (StartupStart), "Start Image Start", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ExitServicesEntry), "Exit Services Entry", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ExitServicesExit), "Exit Services Exit", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT1_OFFSET (Address), "FPDT Boot Record Address", 0}, ACPI_DMT_TERMINATOR }; @@ -1105,10 +1108,18 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt0[] = ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt1[] = { {ACPI_DMT_UINT32, ACPI_FPDT1_OFFSET (Reserved), "Reserved", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT1_OFFSET (Address), "S3PT Address", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT1_OFFSET (Address), "S3PT Record Address", 0}, ACPI_DMT_TERMINATOR }; +#if 0 + /* Boot Performance Record, not supported at this time. */ + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ResetEnd), "Reset End", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (LoadStart), "Load Image Start", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (StartupStart), "Start Image Start", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ExitServicesEntry), "Exit Services Entry", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ExitServicesExit), "Exit Services Exit", 0}, +#endif /******************************************************************************* * @@ -1340,6 +1351,26 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[] = ACPI_DMT_TERMINATOR }; +/* 10: Generic Hardware Error Source - Version 2 */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoHest10[] = +{ + ACPI_DM_HEST_HEADER, + {ACPI_DMT_UINT16, ACPI_HEST10_OFFSET (RelatedSourceId), "Related Source Id", 0}, + {ACPI_DMT_UINT8, ACPI_HEST10_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_HEST10_OFFSET (Enabled), "Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_HEST10_OFFSET (RecordsToPreallocate), "Records To Preallocate", 0}, + {ACPI_DMT_UINT32, ACPI_HEST10_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record", 0}, + {ACPI_DMT_UINT32, ACPI_HEST10_OFFSET (MaxRawDataLength), "Max Raw Data Length", 0}, + {ACPI_DMT_GAS, ACPI_HEST10_OFFSET (ErrorStatusAddress), "Error Status Address", 0}, + {ACPI_DMT_HESTNTFY, ACPI_HEST10_OFFSET (Notify), "Notify", 0}, + {ACPI_DMT_UINT32, ACPI_HEST10_OFFSET (ErrorBlockLength), "Error Status Block Length", 0}, + {ACPI_DMT_GAS, ACPI_HEST10_OFFSET (ReadAckRegister), "Read Ack Register", 0}, + {ACPI_DMT_UINT64, ACPI_HEST10_OFFSET (ReadAckPreserve), "Read Ack Preserve", 0}, + {ACPI_DMT_UINT64, ACPI_HEST10_OFFSET (ReadAckWrite), "Read Ack Write", 0}, + ACPI_DMT_TERMINATOR +}; + ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[] = { {ACPI_DMT_HESTNTYP, ACPI_HESTN_OFFSET (Type), "Notify Type", 0}, @@ -1534,6 +1565,23 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoIort3c[] = ACPI_DMT_TERMINATOR }; +/* 0x04: SMMUv3 */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIort4[] = +{ + {ACPI_DMT_UINT64, ACPI_IORT4_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (Flags), "Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_IORT4_FLAG_OFFSET (Flags, 0), "COHACC Override", 0}, + {ACPI_DMT_FLAG1, ACPI_IORT4_FLAG_OFFSET (Flags, 0), "HTTU Override", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_IORT4_OFFSET (VatosAddress), "VATOS Address", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (Model), "Model", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (EventGsiv), "Event GSIV", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (PriGsiv), "PRI GSIV", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (GerrGsiv), "GERR GSIV", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (SyncGsiv), "Sync GSIV", 0}, + ACPI_DMT_TERMINATOR +}; /******************************************************************************* * @@ -2139,6 +2187,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoNfit1[] = {ACPI_DMT_FLAG3, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Device not armed", 0}, {ACPI_DMT_FLAG4, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Health events observed", 0}, {ACPI_DMT_FLAG5, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Health events enabled", 0}, + {ACPI_DMT_FLAG6, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Mapping failed", 0}, {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (Reserved), "Reserved", 0}, ACPI_DMT_TERMINATOR }; @@ -2185,7 +2234,10 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoNfit4[] = {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemVendorId), "Subsystem Vendor Id", 0}, {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemDeviceId), "Subsystem Device Id", 0}, {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemRevisionId), "Subsystem Revision Id", 0}, - {ACPI_DMT_UINT48, ACPI_NFIT4_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_NFIT4_OFFSET (ValidFields), "Valid Fields", 0}, + {ACPI_DMT_UINT8, ACPI_NFIT4_OFFSET (ManufacturingLocation), "Manufacturing Location", 0}, + {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (ManufacturingDate), "Manufacturing Date", 0}, + {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Reserved[0]), "Reserved", 0}, {ACPI_DMT_UINT32, ACPI_NFIT4_OFFSET (SerialNumber), "Serial Number", 0}, {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Code), "Code", 0}, {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Windows), "Window Count", 0}, @@ -2289,6 +2341,29 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[] = ACPI_DMT_TERMINATOR }; +/* 2: HW-reduced Communications Subspace Type 2 (ACPI 6.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoPcct2[] = +{ + {ACPI_DMT_UINT32, ACPI_PCCT2_OFFSET (DoorbellInterrupt), "Doorbell Interrupt", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT2_OFFSET (Flags), "Flags (Decoded Below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_PCCT2_FLAG_OFFSET (Flags,0), "Polarity", 0}, + {ACPI_DMT_FLAG1, ACPI_PCCT2_FLAG_OFFSET (Flags,0), "Mode", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT2_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT2_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT2_OFFSET (Length), "Address Length", 0}, + {ACPI_DMT_GAS, ACPI_PCCT2_OFFSET (DoorbellRegister), "Doorbell Register", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT2_OFFSET (PreserveMask), "Preserve Mask", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT2_OFFSET (WriteMask), "Write Mask", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT2_OFFSET (Latency), "Command Latency", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT2_OFFSET (MaxAccessRate), "Maximum Access Rate", 0}, + {ACPI_DMT_UINT16, ACPI_PCCT2_OFFSET (MinTurnaroundTime), "Minimum Turnaround Time", 0}, + {ACPI_DMT_GAS, ACPI_PCCT2_OFFSET (DoorbellAckRegister), "Doorbell ACK Register", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT2_OFFSET (AckPreserveMask), "ACK Preserve Mask", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT2_OFFSET (AckWriteMask), "ACK Write Mask", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -2611,15 +2686,52 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoStaoStr[] = /******************************************************************************* * - * TCPA - Trusted Computing Platform Alliance table + * TCPA - Trusted Computing Platform Alliance table (Client) + * + * NOTE: There are two versions of the table with the same signature -- + * the client version and the server version. The common PlatformClass + * field is used to differentiate the two types of tables. * ******************************************************************************/ -ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[] = +ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaHdr[] = +{ + {ACPI_DMT_UINT16, ACPI_TCPA_OFFSET (PlatformClass), "Platform Class", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaClient[] = +{ + {ACPI_DMT_UINT32, ACPI_TCPA_CLIENT_OFFSET (MinimumLogLength), "Min Event Log Length", 0}, + {ACPI_DMT_UINT64, ACPI_TCPA_CLIENT_OFFSET (LogAddress), "Event Log Address", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaServer[] = { - {ACPI_DMT_UINT16, ACPI_TCPA_OFFSET (Reserved), "Reserved", 0}, - {ACPI_DMT_UINT32, ACPI_TCPA_OFFSET (MaxLogLength), "Max Event Log Length", 0}, - {ACPI_DMT_UINT64, ACPI_TCPA_OFFSET (LogAddress), "Event Log Address", 0}, + {ACPI_DMT_UINT16, ACPI_TCPA_SERVER_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_TCPA_SERVER_OFFSET (MinimumLogLength), "Min Event Log Length", 0}, + {ACPI_DMT_UINT64, ACPI_TCPA_SERVER_OFFSET (LogAddress), "Event Log Address", 0}, + {ACPI_DMT_UINT16, ACPI_TCPA_SERVER_OFFSET (SpecRevision), "Specification Revision", 0}, + {ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (DeviceFlags), "Device Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_TCPA_SERVER_OFFSET (DeviceFlags), "Pci Device", 0}, + {ACPI_DMT_FLAG1, ACPI_TCPA_SERVER_OFFSET (DeviceFlags), "Bus is Pnp", 0}, + {ACPI_DMT_FLAG2, ACPI_TCPA_SERVER_OFFSET (DeviceFlags), "Address Valid", 0}, + {ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "Interrupt Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "GPE SCI Triggered", 0}, + {ACPI_DMT_FLAG3, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "Global System Interrupt", 0}, + {ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (GpeNumber), "Gpe Number", 0}, + {ACPI_DMT_UINT24, ACPI_TCPA_SERVER_OFFSET (Reserved2[0]), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_TCPA_SERVER_OFFSET (GlobalInterrupt), "Global Interrupt", 0}, + {ACPI_DMT_GAS, ACPI_TCPA_SERVER_OFFSET (Address), "Address", 0}, + {ACPI_DMT_UINT32, ACPI_TCPA_SERVER_OFFSET (Reserved3), "Reserved", 0}, + {ACPI_DMT_GAS, ACPI_TCPA_SERVER_OFFSET (ConfigAddress), "Configuration Address", 0}, + {ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (Group), "Pci Group", 0}, + {ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (Bus), "Pci Bus", 0}, + {ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (Device), "Pci Device", 0}, + {ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (Function), "Pci Function", 0}, ACPI_DMT_TERMINATOR }; @@ -2632,7 +2744,8 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[] = ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2[] = { - {ACPI_DMT_UINT32, ACPI_TPM2_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT16, ACPI_TPM2_OFFSET (PlatformClass), "Platform Class", 0}, + {ACPI_DMT_UINT16, ACPI_TPM2_OFFSET (Reserved), "Reserved", 0}, {ACPI_DMT_UINT64, ACPI_TPM2_OFFSET (ControlAddress), "Control Address", 0}, {ACPI_DMT_UINT32, ACPI_TPM2_OFFSET (StartMethod), "Start Method", 0}, ACPI_DMT_TERMINATOR diff --git a/sys/contrib/dev/acpica/common/getopt.c b/sys/contrib/dev/acpica/common/getopt.c index b93156c..e860851 100644 --- a/sys/contrib/dev/acpica/common/getopt.c +++ b/sys/contrib/dev/acpica/common/getopt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ * Option strings: * "f" - Option has no arguments * "f:" - Option requires an argument + * "f+" - Option has an optional argument * "f^" - Option has optional single-char sub-options * "f|" - Option has required single-char sub-options */ @@ -90,6 +91,7 @@ AcpiGetoptArgument ( int argc, char **argv) { + AcpiGbl_Optind--; CurrentCharPtr++; @@ -145,7 +147,7 @@ AcpiGetopt( { return (ACPI_OPT_END); } - else if (ACPI_STRCMP (argv[AcpiGbl_Optind], "--") == 0) + else if (strcmp (argv[AcpiGbl_Optind], "--") == 0) { AcpiGbl_Optind++; return (ACPI_OPT_END); @@ -159,7 +161,7 @@ AcpiGetopt( /* Make sure that the option is legal */ if (CurrentChar == ':' || - (OptsPtr = ACPI_STRCHR (opts, CurrentChar)) == NULL) + (OptsPtr = strchr (opts, CurrentChar)) == NULL) { ACPI_OPTION_ERROR ("Illegal option: -", CurrentChar); @@ -182,7 +184,8 @@ AcpiGetopt( } else if (++AcpiGbl_Optind >= argc) { - ACPI_OPTION_ERROR ("Option requires an argument: -", CurrentChar); + ACPI_OPTION_ERROR ( + "Option requires an argument: -", CurrentChar); CurrentCharPtr = 1; return ('?'); @@ -243,7 +246,9 @@ AcpiGetopt( } else { - ACPI_OPTION_ERROR ("Option requires a single-character suboption: -", CurrentChar); + ACPI_OPTION_ERROR ( + "Option requires a single-character suboption: -", + CurrentChar); CurrentCharPtr = 1; return ('?'); diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c index 3c3eee8..8823783 100644 --- a/sys/contrib/dev/acpica/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,6 +50,15 @@ ACPI_MODULE_NAME ("aslanalyze") +/* Local Prototypes */ + +static ACPI_STATUS +ApDeviceSubtreeWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + + /******************************************************************************* * * FUNCTION: AnIsInternalMethod @@ -67,8 +76,8 @@ AnIsInternalMethod ( ACPI_PARSE_OBJECT *Op) { - if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) || - (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI"))) + if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) || + (!strcmp (Op->Asl.ExternalName, "_OSI"))) { return (TRUE); } @@ -94,8 +103,8 @@ AnGetInternalMethodReturnType ( ACPI_PARSE_OBJECT *Op) { - if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) || - (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI"))) + if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) || + (!strcmp (Op->Asl.ExternalName, "_OSI"))) { return (ACPI_BTYPE_STRING); } @@ -139,8 +148,7 @@ AnCheckId ( Length = strlen (Op->Asl.Value.String); if (!Length) { - AslError (ASL_ERROR, ASL_MSG_NULL_STRING, - Op, NULL); + AslError (ASL_ERROR, ASL_MSG_NULL_STRING, Op, NULL); return; } @@ -191,7 +199,7 @@ AnCheckId ( return; } - /* _HID Length is valid (7 or 8), now check the prefix (first 3 or 4 chars) */ + /* _HID Length is valid (7 or 8), now check prefix (first 3 or 4 chars) */ if (Length == 7) { @@ -231,8 +239,8 @@ AnCheckId ( { if (!isxdigit ((int) Op->Asl.Value.String[i])) { - AslError (ASL_ERROR, ASL_MSG_HID_SUFFIX, - Op, &Op->Asl.Value.String[i]); + AslError (ASL_ERROR, ASL_MSG_HID_SUFFIX, + Op, &Op->Asl.Value.String[i]); break; } } @@ -309,6 +317,12 @@ AnCheckMethodReturnValue ( Node = ArgOp->Asl.Node; + if (!Node) + { + /* No error message, this can happen and is OK */ + + return; + } /* Examine the parent op of this method */ @@ -323,7 +337,8 @@ AnCheckMethodReturnValue ( { /* Method SOMETIMES returns a value, SOMETIMES not */ - AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, + Op, Op->Asl.ExternalName); } else if (!(ThisNodeBtype & RequiredBtypes)) { @@ -400,12 +415,13 @@ AnIsResultUsed ( { return (TRUE); } + return (FALSE); /* Not used if one of these is the parent */ case PARSEOP_METHOD: - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: case PARSEOP_ELSE: return (FALSE); @@ -462,7 +478,7 @@ ApCheckForGpeNameConflict ( /* Verify 3rd/4th chars are a valid hex value */ - GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); + GpeNumber = strtoul (&Name[2], NULL, 16); if (GpeNumber == ACPI_UINT32_MAX) { return; @@ -572,6 +588,108 @@ ApCheckRegMethod ( /******************************************************************************* * + * FUNCTION: ApFindNameInDeviceTree + * + * PARAMETERS: Name - Name to search for + * Op - Current parse op + * + * RETURN: TRUE if name found in the same scope as Op. + * + * DESCRIPTION: Determine if a name appears in the same scope as Op, as either + * a Method() or a Name(). "Same scope" can mean under an If or + * Else statement. + * + * NOTE: Detects _HID/_ADR in this type of construct (legal in ACPI 6.1+) + * + * Scope (\_SB.PCI0) + * { + * Device (I2C0) + * { + * If (SMD0 != 4) { + * Name (_HID, "INT3442") + * } Else { + * Name (_ADR, 0x400) + * } + * } + * } + ******************************************************************************/ + +BOOLEAN +ApFindNameInDeviceTree ( + char *Name, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + + + Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD, + ApDeviceSubtreeWalk, NULL, Name); + + if (Status == AE_CTRL_TRUE) + { + return (TRUE); /* Found a match */ + } + + return (FALSE); +} + + +/* Callback function for interface above */ + +static ACPI_STATUS +ApDeviceSubtreeWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + char *Name = ACPI_CAST_PTR (char, Context); + + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_DEVICE: + + /* Level 0 is the starting device, ignore it */ + + if (Level > 0) + { + /* Ignore sub-devices */ + + return (AE_CTRL_DEPTH); + } + break; + + case PARSEOP_NAME: + case PARSEOP_METHOD: + + /* These are what we are looking for */ + + if (ACPI_COMPARE_NAME (Name, Op->Asl.NameSeg)) + { + return (AE_CTRL_TRUE); + } + return (AE_CTRL_DEPTH); + + case PARSEOP_SCOPE: + case PARSEOP_FIELD: + case PARSEOP_OPERATIONREGION: + + /* + * We want to ignore these, because either they can be large + * subtrees or open a scope to somewhere else. + */ + return (AE_CTRL_DEPTH); + + default: + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: ApFindNameInScope * * PARAMETERS: Name - Name to search for diff --git a/sys/contrib/dev/acpica/compiler/aslascii.c b/sys/contrib/dev/acpica/compiler/aslascii.c index 08e4630..e2166d8 100644 --- a/sys/contrib/dev/acpica/compiler/aslascii.c +++ b/sys/contrib/dev/acpica/compiler/aslascii.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ */ #include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/include/actables.h> #include <contrib/dev/acpica/include/acapps.h> #define _COMPONENT ACPI_COMPILER @@ -63,90 +64,7 @@ FlConsumeNewComment ( /******************************************************************************* * - * FUNCTION: FlCheckForAcpiTable - * - * PARAMETERS: Handle - Open input file - * - * RETURN: Status - * - * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the - * following checks on what would be the table header: - * 0) File must be at least as long as an ACPI_TABLE_HEADER - * 1) The header length field must match the file size - * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII - * - ******************************************************************************/ - -ACPI_STATUS -FlCheckForAcpiTable ( - FILE *Handle) -{ - ACPI_TABLE_HEADER Table; - UINT32 FileSize; - size_t Actual; - UINT32 i; - - - /* Read a potential table header */ - - Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); - fseek (Handle, 0, SEEK_SET); - - if (Actual < sizeof (ACPI_TABLE_HEADER)) - { - return (AE_ERROR); - } - - /* Header length field must match the file size */ - - FileSize = CmGetFileSize (Handle); - if (Table.Length != FileSize) - { - return (AE_ERROR); - } - - /* - * These fields must be ASCII: - * Signature, OemId, OemTableId, AslCompilerId. - * We allow a NULL terminator in OemId and OemTableId. - */ - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) - { - return (AE_ERROR); - } - - if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) - { - return (AE_ERROR); - } - } - - printf ("Binary file appears to be a valid ACPI table, disassembling\n"); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: FlCheckForAscii + * FUNCTION: FlIsFileAsciiSource * * PARAMETERS: Filename - Full input filename * DisplayErrors - TRUE if error messages desired @@ -163,7 +81,7 @@ FlCheckForAcpiTable ( ******************************************************************************/ ACPI_STATUS -FlCheckForAscii ( +FlIsFileAsciiSource ( char *Filename, BOOLEAN DisplayErrors) { @@ -177,6 +95,11 @@ FlCheckForAscii ( /* Open file in text mode so file offset is always accurate */ Handle = fopen (Filename, "rb"); + if (!Handle) + { + perror ("Could not open input file"); + return (AE_ERROR); + } Status.Line = 1; Status.Offset = 0; @@ -226,7 +149,7 @@ FlCheckForAscii ( /* Ensure character is either printable or a "space" char */ - else if (!ACPI_IS_PRINT (Byte) && !ACPI_IS_SPACE (Byte)) + else if (!isprint (Byte) && !isspace (Byte)) { if ((BadBytes < 10) && (DisplayErrors)) { diff --git a/sys/contrib/dev/acpica/compiler/aslbtypes.c b/sys/contrib/dev/acpica/compiler/aslbtypes.c index 0ba219a..37075e4 100644 --- a/sys/contrib/dev/acpica/compiler/aslbtypes.c +++ b/sys/contrib/dev/acpica/compiler/aslbtypes.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -78,7 +78,6 @@ AnMapArgTypeToBtype ( switch (ArgType) { - /* Simple types */ case ARGI_ANYTYPE: @@ -100,9 +99,10 @@ AnMapArgTypeToBtype ( case ARGI_DDBHANDLE: /* * DDBHandleObject := SuperName - * ACPI_BTYPE_REFERENCE: Index reference as parameter of Load/Unload + * ACPI_BTYPE_REFERENCE_OBJECT: + * Index reference as parameter of Load/Unload */ - return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE); + return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE_OBJECT); /* Interchangeable types */ /* @@ -133,9 +133,24 @@ AnMapArgTypeToBtype ( case ARGI_REFERENCE: - return (ACPI_BTYPE_REFERENCE); + return (ACPI_BTYPE_NAMED_REFERENCE); /* Name or Namestring */ case ARGI_TARGETREF: + + /* + * Target operand for most math and logic operators. + * Package objects not allowed as target. + */ + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DEBUG_OBJECT | + ACPI_BTYPE_REFERENCE_OBJECT); + + case ARGI_STORE_TARGET: + + /* Special target for Store(), includes packages */ + + return (ACPI_BTYPE_DATA | ACPI_BTYPE_DEBUG_OBJECT | + ACPI_BTYPE_REFERENCE_OBJECT); + case ARGI_FIXED_TARGET: case ARGI_SIMPLE_TARGET: @@ -149,28 +164,33 @@ AnMapArgTypeToBtype ( * Used only by SizeOf operator */ return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | - ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE); + ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE_OBJECT); case ARGI_COMPLEXOBJ: /* Buffer, String, or package */ - return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE); + return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | + ACPI_BTYPE_PACKAGE); case ARGI_REF_OR_STRING: - return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE); + /* Used by DeRefOf operator only */ + + return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE_OBJECT); case ARGI_REGION_OR_BUFFER: /* Used by Load() only. Allow buffers in addition to regions/fields */ - return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | ACPI_BTYPE_FIELD_UNIT); + return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | + ACPI_BTYPE_FIELD_UNIT); case ARGI_DATAREFOBJ: - return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | - ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE); + /* Used by Store() only, as the source operand */ + + return (ACPI_BTYPE_DATA_REFERENCE | ACPI_BTYPE_REFERENCE_OBJECT); default: @@ -200,7 +220,6 @@ AnMapEtypeToBtype ( UINT32 Etype) { - if (Etype == ACPI_TYPE_ANY) { return (ACPI_BTYPE_OBJECTS_AND_REFS); @@ -274,7 +293,7 @@ AnMapEtypeToBtype ( case ACPI_TYPE_LOCAL_RESOURCE: case ACPI_TYPE_LOCAL_RESOURCE_FIELD: - return (ACPI_BTYPE_REFERENCE); + return (ACPI_BTYPE_REFERENCE_OBJECT); default: @@ -307,7 +326,6 @@ AnFormatBtype ( *Buffer = 0; - if (Btype == 0) { strcat (Buffer, "NoReturnValue"); @@ -322,6 +340,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, AcpiUtGetTypeName (Type)); } @@ -334,6 +353,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, "Reference"); } @@ -345,6 +365,7 @@ AnFormatBtype ( { strcat (Buffer, "|"); } + First = FALSE; strcat (Buffer, "Resource"); } @@ -387,11 +408,25 @@ AnGetBtype ( Node = Op->Asl.Node; if (!Node) { + /* These are not expected to have a node at this time */ + + if ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEWORDFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEDWORDFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEQWORDFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEBYTEFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEBITFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEFIELD) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) + { + return (ACPI_UINT32_MAX - 1); + } + DbgPrint (ASL_DEBUG_OUTPUT, - "No attached Nsnode: [%s] at line %u name [%s], ignoring typecheck\n", + "No attached Nsnode: [%s] at line %u name [%s], " + "ignoring typecheck. Parent [%s]\n", Op->Asl.ParseOpName, Op->Asl.LineNumber, - Op->Asl.ExternalName); - return (ACPI_UINT32_MAX); + Op->Asl.ExternalName, Op->Asl.Parent->Asl.ParseOpName); + return (ACPI_UINT32_MAX - 1); } ThisNodeBtype = AnMapEtypeToBtype (Node->Type); @@ -401,12 +436,6 @@ AnGetBtype ( "could not map type"); } - /* - * Since it was a named reference, enable the - * reference bit also - */ - ThisNodeBtype |= ACPI_BTYPE_REFERENCE; - if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) { ReferencedNode = Node->Op; diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c index 8dd30f3..cf1f170 100644 --- a/sys/contrib/dev/acpica/compiler/aslcodegen.c +++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,22 +97,16 @@ CgGenerateAmlOutput ( void) { - DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n"); - /* Generate the AML output file */ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); Gbl_SourceLine = 0; Gbl_NextError = Gbl_ErrorLog; - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL); - DbgPrint (ASL_TREE_OUTPUT, - "%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr" - " Parent Child Next Flags AcTyp Final Col L\n", - 76, " "); - + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2); CgCloseTable (); } @@ -136,61 +130,64 @@ CgAmlWriteWalk ( void *Context) { - /* - * Print header at level 0. Alignment assumes 32-bit pointers - */ - if (!Level) + /* Generate the AML for this node */ + + CgWriteNode (Op); + + if (!Gbl_DebugFlag) { - DbgPrint (ASL_TREE_OUTPUT, - "Final parse tree used for AML output:\n"); - DbgPrint (ASL_TREE_OUTPUT, - "%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr" - " Parent Child Next Flags AcTyp Final Col L\n", - 76, " "); + return (AE_OK); } - /* Debug output */ + /* Print header at level 0. Alignment assumes 32-bit pointers */ - DbgPrint (ASL_TREE_OUTPUT, - "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); - UtPrintFormattedName (Op->Asl.ParseOpcode, Level); - - if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG || - Op->Asl.ParseOpcode == PARSEOP_NAMESTRING || - Op->Asl.ParseOpcode == PARSEOP_METHODCALL) + if (!Level) { DbgPrint (ASL_TREE_OUTPUT, - "%10.32s ", Op->Asl.ExternalName); + "\nFinal parse tree used for AML output:\n"); + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2); } - else + + /* Dump ParseOp name and possible value */ + + switch (Op->Asl.ParseOpcode) { - DbgPrint (ASL_TREE_OUTPUT, " "); - } + case PARSEOP_NAMESEG: + case PARSEOP_NAMESTRING: + case PARSEOP_METHODCALL: + case PARSEOP_STRING_LITERAL: - DbgPrint (ASL_TREE_OUTPUT, - "%08X %04X %04X %01X %04X %04X %04X %04X " - "%08X %08X %08X %08X %08X %08X %04X %02d %02d\n", - /* 1 */ (UINT32) Op->Asl.Value.Integer, - /* 2 */ Op->Asl.ParseOpcode, - /* 3 */ Op->Asl.AmlOpcode, - /* 4 */ Op->Asl.AmlOpcodeLength, - /* 5 */ Op->Asl.AmlPkgLenBytes, - /* 6 */ Op->Asl.AmlLength, - /* 7 */ Op->Asl.AmlSubtreeLength, - /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0, - /* 9 */ Op, - /* 10 */ Op->Asl.Parent, - /* 11 */ Op->Asl.Child, - /* 12 */ Op->Asl.Next, - /* 13 */ Op->Asl.CompileFlags, - /* 14 */ Op->Asl.AcpiBtype, - /* 15 */ Op->Asl.FinalAmlLength, - /* 16 */ Op->Asl.Column, - /* 17 */ Op->Asl.LineNumber); + UtDumpStringOp (Op, Level); + break; - /* Generate the AML for this node */ + default: + + UtDumpBasicOp (Op, Level); + break; + } + + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_DEBUG2, + /* 1 */ (UINT32) Op->Asl.Value.Integer, + /* 2 */ Op->Asl.ParseOpcode, + /* 3 */ Op->Asl.AmlOpcode, + /* 4 */ Op->Asl.AmlOpcodeLength, + /* 5 */ Op->Asl.AmlPkgLenBytes, + /* 6 */ Op->Asl.AmlLength, + /* 7 */ Op->Asl.AmlSubtreeLength, + /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0, + /* 9 */ Op, + /* 10 */ Op->Asl.Parent, + /* 11 */ Op->Asl.Child, + /* 12 */ Op->Asl.Next, + /* 13 */ Op->Asl.CompileFlags, + /* 14 */ Op->Asl.AcpiBtype, + /* 15 */ Op->Asl.FinalAmlLength, + /* 16 */ Op->Asl.Column, + /* 17 */ Op->Asl.LineNumber, + /* 18 */ Op->Asl.EndLine, + /* 19 */ Op->Asl.LogicalLineNumber, + /* 20 */ Op->Asl.EndLogicalLine); - CgWriteNode (Op); return (AE_OK); } @@ -271,7 +268,8 @@ CgWriteAmlOpcode ( /* These opcodes should not get here */ printf ("Found a node with an unassigned AML opcode\n"); - FlPrintFile (ASL_FILE_STDERR, "Found a node with an unassigned AML opcode\n"); + FlPrintFile (ASL_FILE_STDERR, + "Found a node with an unassigned AML opcode\n"); return; case AML_INT_RESERVEDFIELD_OP: @@ -354,8 +352,10 @@ CgWriteAmlOpcode ( */ PkgLen.Len >>= 4; - /* Now we can write the remaining bytes - either 1, 2, or 3 bytes */ - + /* + * Now we can write the remaining bytes - + * either 1, 2, or 3 bytes + */ for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++) { CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1); @@ -464,50 +464,100 @@ CgWriteTableHeader ( /* Table length. Checksum zero for now, will rewrite later */ - TableHeader.Length = Gbl_TableLength; + TableHeader.Length = sizeof (ACPI_TABLE_HEADER) + + Op->Asl.AmlSubtreeLength; TableHeader.Checksum = 0; + Op->Asl.FinalAmlOffset = ftell (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + + /* Write entire header and clear the table header global */ + CgLocalWriteAmlData (Op, &TableHeader, sizeof (ACPI_TABLE_HEADER)); + memset (&TableHeader, 0, sizeof (ACPI_TABLE_HEADER)); } /******************************************************************************* * - * FUNCTION: CgCloseTable + * FUNCTION: CgUpdateHeader * - * PARAMETERS: None. + * PARAMETERS: Op - Op for the Definition Block * * RETURN: None. * * DESCRIPTION: Complete the ACPI table by calculating the checksum and - * re-writing the header. + * re-writing the header for the input definition block * ******************************************************************************/ static void -CgCloseTable ( - void) +CgUpdateHeader ( + ACPI_PARSE_OBJECT *Op) { signed char Sum; + UINT32 i; + UINT32 Length; UINT8 FileByte; + UINT8 Checksum; - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - Sum = 0; + /* Calculate the checksum over the entire definition block */ - /* Calculate the checksum over the entire file */ + Sum = 0; + Length = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength; + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset); - while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK) + for (i = 0; i < Length; i++) { + if (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) != AE_OK) + { + printf ("EOF while reading checksum bytes\n"); + return; + } + Sum = (signed char) (Sum + FileByte); } - /* Re-write the table header with the checksum */ + Checksum = (UINT8) (0 - Sum); + + /* Re-write the the checksum byte */ + + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset + + ACPI_OFFSET (ACPI_TABLE_HEADER, Checksum)); + + FlWriteFile (ASL_FILE_AML_OUTPUT, &Checksum, 1); +} + + +/******************************************************************************* + * + * FUNCTION: CgCloseTable + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Complete the ACPI table by calculating the checksum and + * re-writing each table header. This allows support for + * multiple definition blocks in a single source file. + * + ******************************************************************************/ + +static void +CgCloseTable ( + void) +{ + ACPI_PARSE_OBJECT *Op; + - TableHeader.Checksum = (UINT8) (0 - Sum); + /* Process all definition blocks */ - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER)); + Op = Gbl_ParseTreeRoot->Asl.Child; + while (Op) + { + CgUpdateHeader (Op); + Op = Op->Asl.Next; + } } @@ -534,13 +584,18 @@ CgWriteNode ( /* TBD: this may not be the best place for this check */ if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) || - (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) || (Op->Asl.ParseOpcode == PARSEOP_INCLUDE) || (Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END)) { return; } + if ((Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && + Gbl_DoExternals == FALSE) + { + return; + } + Op->Asl.FinalAmlLength = 0; switch (Op->Asl.AmlOpcode) @@ -583,7 +638,7 @@ CgWriteNode ( break; - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: CgWriteTableHeader (Op); break; diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c index 0b0ca7a..3dbd0f6 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica/compiler/aslcompile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,9 +100,16 @@ CmDoCompile ( Event = UtBeginEvent ("Preprocess input file"); if (Gbl_PreprocessFlag) { + /* Enter compiler name as a #define */ + + PrAddDefine (ASL_DEFINE, "", FALSE); + /* Preprocessor */ PrDoPreprocess (); + Gbl_CurrentLineNumber = 1; + Gbl_LogicalLineNumber = 1; + if (Gbl_PreprocessOnly) { UtEndEvent (Event); @@ -112,6 +119,7 @@ CmDoCompile ( } UtEndEvent (Event); + /* Build the parse tree */ Event = UtBeginEvent ("Parse source code and build parse tree"); @@ -122,14 +130,15 @@ CmDoCompile ( if (Gbl_SyntaxError) { - fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n"); + fprintf (stderr, + "Compiler aborting due to parser-detected syntax error(s)\n"); LsDumpParseTree (); goto ErrorExit; } /* Did the parse tree get successfully constructed? */ - if (!RootNode) + if (!Gbl_ParseTreeRoot) { /* * If there are no errors, then we have some sort of @@ -157,29 +166,29 @@ CmDoCompile ( LsDumpParseTree (); - OpcGetIntegerWidth (RootNode); + OpcGetIntegerWidth (Gbl_ParseTreeRoot->Asl.Child); UtEndEvent (Event); /* Pre-process parse tree for any operator transforms */ Event = UtBeginEvent ("Parse tree transforms"); DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - TrAmlTransformWalk, NULL, NULL); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + TrAmlTransformWalkBegin, TrAmlTransformWalkEnd, NULL); UtEndEvent (Event); /* Generate AML opcodes corresponding to the parse tokens */ Event = UtBeginEvent ("Generate AML opcodes"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + DbgPrint (ASL_DEBUG_OUTPUT, "Generating AML opcodes\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL); UtEndEvent (Event); /* * Now that the input is parsed, we can open the AML output file. - * Note: by default, the name of this file comes from the table descriptor - * within the input file. + * Note: by default, the name of this file comes from the table + * descriptor within the input file. */ Event = UtBeginEvent ("Open AML output file"); Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix); @@ -194,12 +203,12 @@ CmDoCompile ( Event = UtBeginEvent ("Constant folding via AML interpreter"); DbgPrint (ASL_DEBUG_OUTPUT, - "\nInterpreting compile-time constant expressions\n\n"); + "Interpreting compile-time constant expressions\n\n"); if (Gbl_FoldConstants) { - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - OpcAmlConstantWalk, NULL, NULL); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, + NULL, OpcAmlConstantWalk, NULL); } else { @@ -211,16 +220,16 @@ CmDoCompile ( Event = UtBeginEvent ("Updating AML opcodes after constant folding"); DbgPrint (ASL_DEBUG_OUTPUT, - "\nUpdating AML opcodes after constant folding\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + "Updating AML opcodes after constant folding\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeUpdateWalk, NULL); UtEndEvent (Event); /* Calculate all AML package lengths */ Event = UtBeginEvent ("Generate AML package lengths"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); UtEndEvent (Event); @@ -246,7 +255,8 @@ CmDoCompile ( /* Namespace loading */ Event = UtBeginEvent ("Create ACPI Namespace"); - Status = LdLoadNamespace (RootNode); + DbgPrint (ASL_DEBUG_OUTPUT, "Creating ACPI Namespace\n\n"); + Status = LdLoadNamespace (Gbl_ParseTreeRoot); UtEndEvent (Event); if (ACPI_FAILURE (Status)) { @@ -255,7 +265,9 @@ CmDoCompile ( /* Namespace cross-reference */ - AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace"); + AslGbl_NamespaceEvent = UtBeginEvent ( + "Cross reference parse tree and Namespace"); + DbgPrint (ASL_DEBUG_OUTPUT, "Cross referencing namespace\n\n"); Status = XfCrossReferenceNamespace (); if (ACPI_FAILURE (Status)) { @@ -267,6 +279,17 @@ CmDoCompile ( LkFindUnreferencedObjects (); UtEndEvent (AslGbl_NamespaceEvent); + /* Resolve External Declarations */ + + if (Gbl_DoExternals) + { + Event = UtBeginEvent ("Resolve all Externals"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL); + UtEndEvent (Event); + } + /* * Semantic analysis. This can happen only after the * namespace has been loaded and cross-referenced. @@ -276,33 +299,50 @@ CmDoCompile ( Event = UtBeginEvent ("Analyze control method return types"); AnalysisWalkInfo.MethodStack = NULL; - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, + DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method analysis\n\n"); + + if (Gbl_CrossReferenceOutput) + { + OtPrintHeaders ("Part 1: Object Reference Map " + "(Object references from within each control method)"); + } + + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, MtMethodAnalysisWalkBegin, MtMethodAnalysisWalkEnd, &AnalysisWalkInfo); UtEndEvent (Event); + /* Generate the object cross-reference file if requested */ + + Event = UtBeginEvent ("Generate cross-reference file"); + OtCreateXrefFile (); + UtEndEvent (Event); + /* Semantic error checking part two - typing of method returns */ Event = UtBeginEvent ("Determine object types returned by methods"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method typing\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, AnMethodTypingWalkEnd, NULL); UtEndEvent (Event); /* Semantic error checking part three - operand type checking */ Event = UtBeginEvent ("Analyze AML operand types"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, - NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); + DbgPrint (ASL_DEBUG_OUTPUT, + "Semantic analysis - Operand type checking\n\n"); + if (Gbl_DoTypechecking) + { + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, + NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); + } UtEndEvent (Event); /* Semantic error checking part four - other miscellaneous checks */ Event = UtBeginEvent ("Miscellaneous analysis"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - miscellaneous\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, AnOtherSemanticAnalysisWalkBegin, NULL, &AnalysisWalkInfo); UtEndEvent (Event); @@ -310,16 +350,17 @@ CmDoCompile ( /* Calculate all AML package lengths */ Event = UtBeginEvent ("Finish AML package length generation"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); UtEndEvent (Event); /* Code generation - emit the AML */ Event = UtBeginEvent ("Generate AML code and write output files"); + DbgPrint (ASL_DEBUG_OUTPUT, "Writing AML byte code\n\n"); CgGenerateAmlOutput (); UtEndEvent (Event); @@ -579,8 +620,8 @@ CmDumpAllEvents ( { ASL_EVENT_INFO *Event; UINT32 Delta; - UINT32 USec; - UINT32 MSec; + UINT32 MicroSeconds; + UINT32 MilliSeconds; UINT32 i; @@ -600,23 +641,23 @@ CmDumpAllEvents ( Delta = (UINT32) (Event->EndTime - Event->StartTime); - USec = Delta / ACPI_100NSEC_PER_USEC; - MSec = Delta / ACPI_100NSEC_PER_MSEC; + MicroSeconds = Delta / ACPI_100NSEC_PER_USEC; + MilliSeconds = Delta / ACPI_100NSEC_PER_MSEC; /* Round milliseconds up */ - if ((USec - (MSec * ACPI_USEC_PER_MSEC)) >= 500) + if ((MicroSeconds - (MilliSeconds * ACPI_USEC_PER_MSEC)) >= 500) { - MSec++; + MilliSeconds++; } DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n", - USec, MSec, Event->EventName); + MicroSeconds, MilliSeconds, Event->EventName); if (Gbl_CompileTimesFlag) { printf ("%8u usec %8u msec - %s\n", - USec, MSec, Event->EventName); + MicroSeconds, MilliSeconds, Event->EventName); } } @@ -708,7 +749,7 @@ CmCleanupAndExit ( /* Close all open files */ /* - * Take care with the preprocessor file (.i), it might be the same + * Take care with the preprocessor file (.pre), it might be the same * as the "input" file, depending on where the compiler has terminated * or aborted. Prevent attempt to close the same file twice in * loop below. @@ -733,10 +774,9 @@ CmCleanupAndExit ( FlDeleteFile (ASL_FILE_AML_OUTPUT); } - /* Delete the preprocessor output file (.i) unless -li flag is set */ + /* Delete the preprocessor temp file unless full debug was specified */ - if (!Gbl_PreprocessorOutputFlag && - Gbl_PreprocessFlag) + if (Gbl_PreprocessFlag && !Gbl_KeepPreprocessorTempFile) { FlDeleteFile (ASL_FILE_PREPROCESSOR); } @@ -752,8 +792,6 @@ CmCleanupAndExit ( * Note: Handles are cleared by FlCloseFile above, so we look at the * filename instead, to determine if the .SRC file was actually * created. - * - * TBD: SourceOutput should be .TMP, then rename if we want to keep it? */ if (!Gbl_SourceOutputFlag) { @@ -805,7 +843,7 @@ CmDeleteCaches ( Gbl_ParseOpCount = 0; Gbl_ParseOpCacheNext = NULL; Gbl_ParseOpCacheLast = NULL; - RootNode = NULL; + Gbl_ParseTreeRoot = NULL; /* Generic string cache */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h index 181b36c..4062ce2 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -167,11 +167,7 @@ CmDeleteCaches ( * aslascii - ascii support */ ACPI_STATUS -FlCheckForAcpiTable ( - FILE *Handle); - -ACPI_STATUS -FlCheckForAscii ( +FlIsFileAsciiSource ( char *Filename, BOOLEAN DisplayErrors); @@ -291,6 +287,10 @@ ApFindNameInScope ( char *Name, ACPI_PARSE_OBJECT *Op); +BOOLEAN +ApFindNameInDeviceTree ( + char *Name, + ACPI_PARSE_OBJECT *Op); /* * aslerror - error handling/reporting @@ -542,6 +542,14 @@ OptOptimizeNamePath ( /* + * aslpld - ToPLD macro support + */ +void +OpcDoPld ( + ACPI_PARSE_OBJECT *Op); + + +/* * aslprintf - Printf/Fprintf macros */ void @@ -656,7 +664,13 @@ ApCheckPackage ( * asltransform - parse tree transformations */ ACPI_STATUS -TrAmlTransformWalk ( +TrAmlTransformWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +ACPI_STATUS +TrAmlTransformWalkEnd ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); @@ -673,6 +687,25 @@ TrWalkParseTree ( ASL_WALK_CALLBACK AscendingCallback, void *Context); +/* + * aslexternal - External opcode support + */ +ACPI_STATUS +ExAmlExternalWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +ACPI_STATUS +ExAmlExternalWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +void +ExDoExternal ( + ACPI_PARSE_OBJECT *Op); + /* Values for "Visitation" parameter above */ #define ASL_WALK_VISIT_DOWNWARD 0x01 @@ -680,6 +713,11 @@ TrWalkParseTree ( #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD) +void +TrSetParent ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *ParentOp); + ACPI_PARSE_OBJECT * TrAllocateNode ( UINT32 ParseOpcode); @@ -741,6 +779,10 @@ TrSetEndLineNumber ( ACPI_PARSE_OBJECT *Op); void +TrSetCurrentFilename ( + ACPI_PARSE_OBJECT *Op); + +void TrWalkTree ( void); @@ -909,6 +951,24 @@ XfCrossReferenceNamespace ( /* + * aslxrefout + */ +void +OtPrintHeaders ( + char *Message); + +void +OtCreateXrefFile ( + void); + +void +OtXrefWalkPart1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + ASL_METHOD_INFO *MethodInfo); + + +/* * aslutils - common compiler utilites */ void @@ -923,6 +983,30 @@ DbgPrint ( #define ASL_PARSE_OUTPUT 1 #define ASL_TREE_OUTPUT 2 +UINT8 +UtIsBigEndianMachine ( + void); + +BOOLEAN +UtQueryForOverwrite ( + char *Pathname); + +void +UtDumpStringOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level); + +void +UtDumpIntegerOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + UINT32 IntegerLength); + +void +UtDumpBasicOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level); + void UtDisplaySupportedTables ( void); @@ -944,11 +1028,6 @@ UtLocalCalloc ( UINT32 Size); void -UtPrintFormattedName ( - UINT16 ParseOpcode, - UINT32 Level); - -void UtDisplaySummary ( UINT32 FileId); @@ -1002,12 +1081,6 @@ UINT64 UtDoConstant ( char *String); -ACPI_STATUS -UtStrtoul64 ( - char *String, - UINT32 Base, - UINT64 *RetInteger); - /* * asluuid - UUID support @@ -1281,6 +1354,6 @@ DtDoCompile( ACPI_STATUS DtCreateTemplates ( - char *Signature); + char **argv); #endif /* __ASLCOMPILER_H */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l index 621f5ae..8dd8069 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -156,6 +156,9 @@ NamePathTail [.]{NameSeg} "^=" { count (3); return (PARSEOP_EXP_XOR_EQ); } "|=" { count (3); return (PARSEOP_EXP_OR_EQ); } +"[" { count (3); return(PARSEOP_EXP_INDEX_LEFT); } +"]" { count (0); return(PARSEOP_EXP_INDEX_RIGHT); } + /* * Begin standard ASL grammar @@ -207,7 +210,7 @@ NamePathTail [.]{NameSeg} "Debug" { count (1); return (PARSEOP_DEBUG); } "Decrement" { count (3); return (PARSEOP_DECREMENT); } "Default" { count (3); return (PARSEOP_DEFAULT); } -"DefinitionBlock" { count (1); return (PARSEOP_DEFINITIONBLOCK); } +"DefinitionBlock" { count (1); return (PARSEOP_DEFINITION_BLOCK); } "DeRefOf" { count (3); return (PARSEOP_DEREFOF); } "Device" { count (2); return (PARSEOP_DEVICE); } "Divide" { count (3); return (PARSEOP_DIVIDE); } @@ -329,6 +332,7 @@ NamePathTail [.]{NameSeg} "GpioInt" { count (1); return (PARSEOP_GPIO_INT); } "GpioIo" { count (1); return (PARSEOP_GPIO_IO); } "I2cSerialBus" { count (1); return (PARSEOP_I2C_SERIALBUS); } +"I2cSerialBusV2" { count (1); return (PARSEOP_I2C_SERIALBUS_V2); } "Interrupt" { count (1); return (PARSEOP_INTERRUPT); } "IO" { count (1); return (PARSEOP_IO); } "IRQ" { count (1); return (PARSEOP_IRQ); } @@ -341,9 +345,11 @@ NamePathTail [.]{NameSeg} "QWordSpace" { count (1); return (PARSEOP_QWORDSPACE); } "Register" { count (1); return (PARSEOP_REGISTER); } "SpiSerialBus" { count (1); return (PARSEOP_SPI_SERIALBUS); } +"SpiSerialBusV2" { count (1); return (PARSEOP_SPI_SERIALBUS_V2); } "StartDependentFn" { count (1); return (PARSEOP_STARTDEPENDENTFN); } "StartDependentFnNoPri" { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); } "UartSerialBus" { count (1); return (PARSEOP_UART_SERIALBUS); } +"UartSerialBusV2" { count (1); return (PARSEOP_UART_SERIALBUS_V2); } "VendorLong" { count (1); return (PARSEOP_VENDORLONG); } "VendorShort" { count (1); return (PARSEOP_VENDORSHORT); } "WordBusNumber" { count (1); return (PARSEOP_WORDBUSNUMBER); } @@ -669,9 +675,14 @@ NamePathTail [.]{NameSeg} /* printf debug macros */ + "printf" { count (0); return (PARSEOP_PRINTF); } "fprintf" { count (0); return (PARSEOP_FPRINTF); } + /* Other macros */ + +"For" { count (0); return (PARSEOP_FOR); } + /* Predefined compiler names */ "__DATE__" { count (0); return (PARSEOP___DATE__); } @@ -709,7 +720,7 @@ NamePathTail [.]{NameSeg} return (PARSEOP_NAMESTRING); } . { count (1); - if (ACPI_IS_PRINT (*AslCompilertext)) + if (isprint ((int) *AslCompilertext)) { sprintf (MsgBuffer, "Invalid character (%c), expecting ASL keyword or name", diff --git a/sys/contrib/dev/acpica/compiler/aslcstyle.y b/sys/contrib/dev/acpica/compiler/aslcstyle.y new file mode 100644 index 0000000..62a7b65 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslcstyle.y @@ -0,0 +1,209 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslcstyle.y - Production rules for symbolic operators + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +') + +/******************************************************************************* + * + * Production rules for the symbolic (c-style) operators + * + ******************************************************************************/ + +/* + * ASL Extensions: C-style math/logical operators and expressions. + * The implementation transforms these operators into the standard + * AML opcodes and syntax. + * + * Supported operators and precedence rules (high-to-low) + * + * NOTE: The operator precedence and associativity rules are + * implemented by the tokens in asltokens.y + * + * (left-to-right): + * 1) ( ) expr++ expr-- + * + * (right-to-left): + * 2) ! ~ + * + * (left-to-right): + * 3) * / % + * 4) + - + * 5) >> << + * 6) < > <= >= + * 7) == != + * 8) & + * 9) ^ + * 10) | + * 11) && + * 12) || + * + * (right-to-left): + * 13) = += -= *= /= %= <<= >>= &= ^= |= + */ + +Expression + + /* Unary operators */ + + : PARSEOP_EXP_LOGICAL_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);} + TermArg {$$ = TrLinkChildren ($<n>2,1,$3);} + | PARSEOP_EXP_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);} + TermArg {$$ = TrLinkChildren ($<n>2,2,$3,TrCreateNullTarget ());} + + | SuperName PARSEOP_EXP_INCREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);} + {$$ = TrLinkChildren ($<n>3,1,$1);} + | SuperName PARSEOP_EXP_DECREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);} + {$$ = TrLinkChildren ($<n>3,1,$1);} + + /* Binary operators: math and logical */ + + | TermArg PARSEOP_EXP_ADD {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), + TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + + | TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + | TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} + + | TermArg PARSEOP_EXP_GREATER {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_GREATER_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATEREQUAL);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_LESS {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_LESS_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LLESSEQUAL);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + + | TermArg PARSEOP_EXP_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_NOT_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LNOTEQUAL);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + + | TermArg PARSEOP_EXP_LOGICAL_AND {$<n>$ = TrCreateLeafNode (PARSEOP_LAND);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + | TermArg PARSEOP_EXP_LOGICAL_OR {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);} + TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} + + /* Parentheses */ + + | '(' TermArg ')' { $$ = $2;} + + /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */ + + | SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT + {$$ = TrCreateLeafNode (PARSEOP_INDEX); + TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} + ; + + /* Index term -- "BUF1[5] = " on left-hand side of an equals (target) */ + +IndexExpTerm + + : SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT + {$$ = TrCreateLeafNode (PARSEOP_INDEX); + TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} + ; + +EqualsTerm + + /* All assignment-type operations */ + + : SuperName PARSEOP_EXP_EQUALS + TermArg {$$ = TrCreateAssignmentNode ($1, $3);} + + | TermArg PARSEOP_EXP_ADD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_DIV_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_MOD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_MUL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_SHL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_SHR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_SUB_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_AND_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_OR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + + | TermArg PARSEOP_EXP_XOR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, + TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} + ; diff --git a/sys/contrib/dev/acpica/compiler/asldebug.c b/sys/contrib/dev/acpica/compiler/asldebug.c new file mode 100644 index 0000000..0fa8c0a --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/asldebug.c @@ -0,0 +1,253 @@ +/****************************************************************************** + * + * Module Name: asldebug -- Debug output support + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include "aslcompiler.y.h" + + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("asldebug") + + +/* Local prototypes */ + +static void +UtDumpParseOpName ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + UINT32 DataLength); + + +/******************************************************************************* + * + * FUNCTION: UtDumpIntegerOp + * + * PARAMETERS: Op - Current parse op + * Level - Current output indentation level + * IntegerLength - Output length of the integer (2/4/8/16) + * + * RETURN: None + * + * DESCRIPTION: Emit formatted debug output for "integer" ops. + * Note: IntegerLength must be one of 2,4,8,16. + * + ******************************************************************************/ + +void +UtDumpIntegerOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + UINT32 IntegerLength) +{ + + /* Emit the ParseOp name, leaving room for the integer */ + + UtDumpParseOpName (Op, Level, IntegerLength); + + /* Emit the integer based upon length */ + + switch (IntegerLength) + { + case 2: /* Byte */ + case 4: /* Word */ + case 8: /* Dword */ + + DbgPrint (ASL_TREE_OUTPUT, + "%*.*X", IntegerLength, IntegerLength, Op->Asl.Value.Integer); + break; + + case 16: /* Qword and Integer */ + + DbgPrint (ASL_TREE_OUTPUT, + "%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); + break; + + default: + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: UtDumpStringOp + * + * PARAMETERS: Op - Current parse op + * Level - Current output indentation level + * + * RETURN: None + * + * DESCRIPTION: Emit formatted debug output for String/Pathname ops. + * + ******************************************************************************/ + +void +UtDumpStringOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level) +{ + char *String; + + + String = Op->Asl.Value.String; + + if (Op->Asl.ParseOpcode != PARSEOP_STRING_LITERAL) + { + /* + * For the "path" ops NAMEPATH, NAMESEG, METHODCALL -- if the + * ExternalName is valid, it takes precedence. In these cases the + * Value.String is the raw "internal" name from the AML code, which + * we don't want to use, because it contains non-ascii characters. + */ + if (Op->Asl.ExternalName) + { + String = Op->Asl.ExternalName; + } + } + + if (!String) + { + DbgPrint (ASL_TREE_OUTPUT, + " ERROR: Could not find a valid String/Path pointer\n"); + return; + } + + /* Emit the ParseOp name, leaving room for the string */ + + UtDumpParseOpName (Op, Level, strlen (String)); + DbgPrint (ASL_TREE_OUTPUT, "%s", String); +} + + +/******************************************************************************* + * + * FUNCTION: UtDumpBasicOp + * + * PARAMETERS: Op - Current parse op + * Level - Current output indentation level + * + * RETURN: None + * + * DESCRIPTION: Generic formatted debug output for "basic" ops that have no + * associated strings or integer values. + * + ******************************************************************************/ + +void +UtDumpBasicOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level) +{ + + /* Just print out the ParseOp name, there is no extra data */ + + UtDumpParseOpName (Op, Level, 0); +} + + +/******************************************************************************* + * + * FUNCTION: UtDumpParseOpName + * + * PARAMETERS: Op - Current parse op + * Level - Current output indentation level + * DataLength - Length of data to appear after the name + * + * RETURN: None + * + * DESCRIPTION: Indent and emit the ascii ParseOp name for the op + * + ******************************************************************************/ + +static void +UtDumpParseOpName ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + UINT32 DataLength) +{ + char *ParseOpName; + UINT32 IndentLength; + UINT32 NameLength; + UINT32 LineLength; + UINT32 PaddingLength; + + + /* Emit the LineNumber/IndentLevel prefix on each output line */ + + DbgPrint (ASL_TREE_OUTPUT, + "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); + + ParseOpName = UtGetOpName (Op->Asl.ParseOpcode); + + /* Calculate various lengths for output alignment */ + + IndentLength = Level * DEBUG_SPACES_PER_INDENT; + NameLength = strlen (ParseOpName); + LineLength = IndentLength + 1 + NameLength + 1 + DataLength; + PaddingLength = (DEBUG_MAX_LINE_LENGTH + 1) - LineLength; + + /* Parse tree indentation is based upon the nesting/indent level */ + + if (Level) + { + DbgPrint (ASL_TREE_OUTPUT, "%*s", IndentLength, " "); + } + + /* Emit the actual name here */ + + DbgPrint (ASL_TREE_OUTPUT, " %s", ParseOpName); + + /* Emit extra padding blanks for alignment of later data items */ + + if (LineLength > DEBUG_MAX_LINE_LENGTH) + { + /* Split a long line immediately after the ParseOpName string */ + + DbgPrint (ASL_TREE_OUTPUT, "\n%*s", + (DEBUG_FULL_LINE_LENGTH - DataLength), " "); + } + else + { + DbgPrint (ASL_TREE_OUTPUT, "%*s", PaddingLength, " "); + } +} diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h index 0697276..f615cb2 100644 --- a/sys/contrib/dev/acpica/compiler/asldefine.h +++ b/sys/contrib/dev/acpica/compiler/asldefine.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,8 +52,9 @@ #define AML_DISASSEMBLER_NAME "AML/ASL+ Disassembler" #define ASL_INVOCATION_NAME "iasl" #define ASL_CREATOR_ID "INTL" +#define ASL_DEFINE "__IASL__" -#define ASL_COMPLIANCE "Supports ACPI Specification Revision 6.0" +#define ASL_COMPLIANCE "Supports ACPI Specification Revision 6.1" /* Configuration constants */ @@ -103,31 +104,12 @@ #define AML_DEFAULT_ARG_OP (UINT16) 0xDDDD -/* filename suffixes for output files */ - -#define FILE_SUFFIX_PREPROCESSOR "i" -#define FILE_SUFFIX_AML_CODE "aml" -#define FILE_SUFFIX_MAP "map" -#define FILE_SUFFIX_LISTING "lst" -#define FILE_SUFFIX_HEX_DUMP "hex" -#define FILE_SUFFIX_DEBUG "txt" -#define FILE_SUFFIX_SOURCE "src" -#define FILE_SUFFIX_NAMESPACE "nsp" -#define FILE_SUFFIX_ASM_SOURCE "asm" -#define FILE_SUFFIX_C_SOURCE "c" -#define FILE_SUFFIX_DISASSEMBLY "dsl" -#define FILE_SUFFIX_ASM_INCLUDE "inc" -#define FILE_SUFFIX_C_INCLUDE "h" -#define FILE_SUFFIX_ASL_CODE "asl" -#define FILE_SUFFIX_C_OFFSET "offset.h" - - /* Types for input files */ -#define ASL_INPUT_TYPE_BINARY 0 -#define ASL_INPUT_TYPE_ACPI_TABLE 1 -#define ASL_INPUT_TYPE_ASCII_ASL 2 -#define ASL_INPUT_TYPE_ASCII_DATA 3 +#define ASL_INPUT_TYPE_BINARY 0 +#define ASL_INPUT_TYPE_BINARY_ACPI_TABLE 1 +#define ASL_INPUT_TYPE_ASCII_ASL 2 +#define ASL_INPUT_TYPE_ASCII_DATA 3 /* Misc */ @@ -136,6 +118,7 @@ #define ASL_ABORT TRUE #define ASL_NO_ABORT FALSE #define ASL_EOF ACPI_UINT32_MAX +#define ASL_IGNORE_LINE (ACPI_UINT32_MAX -1) /* Listings */ @@ -152,12 +135,6 @@ #define ACPI_COMPILER_RESERVED_NAME (ACPI_UINT32_MAX - 3) -/* String to Integer conversion */ - -#define NEGATIVE 1 -#define POSITIVE 0 - - /* Helper macros for resource tag creation */ #define RsCreateMultiBitField \ @@ -178,4 +155,34 @@ #define RsCreateQwordField(Op, Name, ByteOffset) \ RsCreateResourceField (Op, Name, ByteOffset, 0, 64); + +/* + * Macros for debug output + */ + +#define DEBUG_MAX_LINE_LENGTH 61 +#define DEBUG_SPACES_PER_INDENT 3 +#define DEBUG_FULL_LINE_LENGTH 71 + +#define ASL_PARSE_TREE_FULL_LINE "\n%71.71s" + +/* Header/Trailer for original parse tree directly from the parser */ + +#define ASL_PARSE_TREE_HEADER1 \ + "%*s Value P_Op Flags Line# End# LogL# EndL#\n", 65, " " + +#define ASL_PARSE_TREE_DEBUG1 \ + " %4.4X %8.8X %5d %5d %5d %5d" + +/* Header/Trailer for processed parse tree used for AML generation */ + +#define ASL_PARSE_TREE_HEADER2 \ + "%*s NameString Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"\ + " Parent Child Next Flags AcTyp Final Col"\ + " Line# End# LogL# EndL#\n", 60, " " + +#define ASL_PARSE_TREE_DEBUG2 \ + " %08X %04X %04X %01X %04X %04X %05X %05X "\ + "%08X %08X %08X %08X %08X %08X %04X %02d %5d %5d %5d %5d\n" + #endif /* ASLDEFINE.H */ diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c index 9b8928c..f71d56a 100644 --- a/sys/contrib/dev/acpica/compiler/aslerror.c +++ b/sys/contrib/dev/acpica/compiler/aslerror.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -267,8 +267,10 @@ AePrintException ( if (!Enode->SourceLine) { - /* Use the merged header/source file if present, otherwise use input file */ - + /* + * Use the merged header/source file if present, otherwise + * use input file + */ SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle; if (!SourceFile) { @@ -314,18 +316,18 @@ AePrintException ( fprintf (OutputFile, " %6u: ", Enode->LineNumber); /* - * If not at EOF, get the corresponding source code line and - * display it. Don't attempt this if we have a premature EOF - * condition. + * If not at EOF, get the corresponding source code line + * and display it. Don't attempt this if we have a + * premature EOF condition. */ if (!PrematureEOF) { /* - * Seek to the offset in the combined source file, read - * the source line, and write it to the output. + * Seek to the offset in the combined source file, + * read the source line, and write it to the output. */ - Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, - (int) SEEK_SET); + Actual = fseek (SourceFile, + (long) Enode->LogicalByteOffset, (int) SEEK_SET); if (Actual) { fprintf (OutputFile, @@ -561,11 +563,11 @@ AslCommonError2 ( /* Keep a copy of the extra message */ - ACPI_STRCPY (MessageBuffer, ExtraMessage); + strcpy (MessageBuffer, ExtraMessage); } LineBuffer = UtLocalCalloc (strlen (SourceLine) + 1); - ACPI_STRCPY (LineBuffer, SourceLine); + strcpy (LineBuffer, SourceLine); /* Initialize the error node */ @@ -647,7 +649,7 @@ AslCommonError ( /* Keep a copy of the extra message */ - ACPI_STRCPY (MessageBuffer, ExtraMessage); + strcpy (MessageBuffer, ExtraMessage); } /* Initialize the error node */ @@ -880,16 +882,17 @@ AslCoreSubsystemError ( if (Op) { - AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber, - Op->Asl.LogicalLineNumber, - Op->Asl.LogicalByteOffset, - Op->Asl.Column, - Op->Asl.Filename, MsgBuffer); + AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, + Op->Asl.LineNumber, + Op->Asl.LogicalLineNumber, + Op->Asl.LogicalByteOffset, + Op->Asl.Column, + Op->Asl.Filename, MsgBuffer); } else { - AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0, - 0, 0, 0, NULL, MsgBuffer); + AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, + 0, 0, 0, 0, NULL, MsgBuffer); } if (Abort) diff --git a/sys/contrib/dev/acpica/compiler/aslexternal.c b/sys/contrib/dev/acpica/compiler/aslexternal.c new file mode 100644 index 0000000..30d4d0a --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslexternal.c @@ -0,0 +1,498 @@ +/****************************************************************************** + * + * Module Name: aslexternal - ASL External opcode compiler support + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include "aslcompiler.y.h" +#include <contrib/dev/acpica/include/acparser.h> +#include <contrib/dev/acpica/include/amlcode.h> +#include <contrib/dev/acpica/include/acnamesp.h> + + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslexternal") + + +/* Local prototypes */ + +static void +ExInsertArgCount ( + ACPI_PARSE_OBJECT *Op); + +static void +ExMoveExternals ( + ACPI_PARSE_OBJECT *DefinitionBlockOp); + + +/******************************************************************************* + * + * FUNCTION: ExDoExternal + * + * PARAMETERS: Op - Current Parse node + * + * RETURN: None + * + * DESCRIPTION: Add an External() definition to the global list. This list + * is used to generate External opcodes. + * + ******************************************************************************/ + +void +ExDoExternal ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *ListOp; + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *ArgCountOp; + + + ArgCountOp = Op->Asl.Child->Asl.Next->Asl.Next; + ArgCountOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; + ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST; + ArgCountOp->Asl.Value.Integer = 0; + UtSetParseOpName (ArgCountOp); + + /* Create new list node of arbitrary type */ + + ListOp = TrAllocateNode (PARSEOP_DEFAULT_ARG); + + /* Store External node as child */ + + ListOp->Asl.Child = Op; + ListOp->Asl.Next = NULL; + + if (Gbl_ExternalsListHead) + { + /* Link new External to end of list */ + + Prev = Gbl_ExternalsListHead; + Next = Prev; + while (Next) + { + Prev = Next; + Next = Next->Asl.Next; + } + + Prev->Asl.Next = ListOp; + } + else + { + Gbl_ExternalsListHead = ListOp; + } +} + + +/******************************************************************************* + * + * FUNCTION: ExInsertArgCount + * + * PARAMETERS: Op - Op for a method invocation + * + * RETURN: None + * + * DESCRIPTION: Obtain the number of arguments for a control method -- from + * the actual invocation. + * + ******************************************************************************/ + +static void +ExInsertArgCount ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *NameOp; + ACPI_PARSE_OBJECT *Child; + ACPI_PARSE_OBJECT *ArgCountOp; + char * ExternalName; + char * CallName; + UINT16 ArgCount = 0; + ACPI_STATUS Status; + + + CallName = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE); + + Next = Gbl_ExternalsListHead; + while (Next) + { + ArgCount = 0; + + /* Skip if External node already handled */ + + if (Next->Asl.Child->Asl.CompileFlags & NODE_VISITED) + { + Next = Next->Asl.Next; + continue; + } + + NameOp = Next->Asl.Child->Asl.Child; + ExternalName = AcpiNsGetNormalizedPathname (NameOp->Asl.Node, TRUE); + + if (strcmp (CallName, ExternalName)) + { + ACPI_FREE (ExternalName); + Next = Next->Asl.Next; + continue; + } + + Next->Asl.Child->Asl.CompileFlags |= NODE_VISITED; + + /* + * Since we will reposition Externals to the Root, set Namepath + * to the fully qualified name and recalculate the aml length + */ + Status = UtInternalizeName (ExternalName, + &NameOp->Asl.Value.String); + + ACPI_FREE (ExternalName); + if (ACPI_FAILURE (Status)) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, + NULL, "- Could not Internalize External"); + break; + } + + NameOp->Asl.AmlLength = strlen (NameOp->Asl.Value.String); + + /* Get argument count */ + + Child = Op->Asl.Child; + while (Child) + { + ArgCount++; + Child = Child->Asl.Next; + } + + /* Setup ArgCount operand */ + + ArgCountOp = Next->Asl.Child->Asl.Child->Asl.Next->Asl.Next; + ArgCountOp->Asl.Value.Integer = ArgCount; + break; + } + + ACPI_FREE (CallName); +} + + +/******************************************************************************* + * + * FUNCTION: ExAmlExternalWalkBegin + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: None + * + * DESCRIPTION: Parse tree walk to create external opcode list for methods. + * + ******************************************************************************/ + +ACPI_STATUS +ExAmlExternalWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + + /* External list head saved in the definition block op */ + + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) + { + Gbl_ExternalsListHead = Op->Asl.Value.Arg; + } + + if (!Gbl_ExternalsListHead) + { + return (AE_OK); + } + + if (Op->Asl.ParseOpcode != PARSEOP_METHODCALL) + { + return (AE_OK); + } + + /* + * The NameOp child under an ExternalOp gets turned into PARSE_METHODCALL + * by XfNamespaceLocateBegin(). Ignore these. + */ + if (Op->Asl.Parent && + Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_EXTERNAL) + { + return (AE_OK); + } + + ExInsertArgCount (Op); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: ExAmlExternalWalkEnd + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: None + * + * DESCRIPTION: Parse tree walk to create external opcode list for methods. + * Here, we just want to catch the case where a definition block + * has been completed. Then we move all of the externals into + * a single block in the parse tree and thus the AML code. + * + ******************************************************************************/ + +ACPI_STATUS +ExAmlExternalWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) + { + /* + * Process any existing external list. (Support for + * multiple definition blocks in a single file/compile) + */ + ExMoveExternals (Op); + Gbl_ExternalsListHead = NULL; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: ExMoveExternals + * + * PARAMETERS: DefinitionBlockOp - Op for current definition block + * + * RETURN: None + * + * DESCRIPTION: Move all externals present in the source file into a single + * block of AML code, surrounded by an "If (0)" to prevent + * AML interpreters from attempting to execute the External + * opcodes. + * + ******************************************************************************/ + +static void +ExMoveExternals ( + ACPI_PARSE_OBJECT *DefinitionBlockOp) +{ + ACPI_PARSE_OBJECT *ParentOp; + ACPI_PARSE_OBJECT *ExternalOp; + ACPI_PARSE_OBJECT *PredicateOp; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + ACPI_OBJECT_TYPE ObjType; + UINT32 i; + + + if (!Gbl_ExternalsListHead) + { + return; + } + + /* Remove the External nodes from the tree */ + + NextOp = Gbl_ExternalsListHead; + while (NextOp) + { + /* + * The External is stored in child pointer of each node in the + * list + */ + ExternalOp = NextOp->Asl.Child; + + /* Set line numbers (for listings, etc.) */ + + ExternalOp->Asl.LineNumber = 0; + ExternalOp->Asl.LogicalLineNumber = 0; + + Next = ExternalOp->Asl.Child; + Next->Asl.LineNumber = 0; + Next->Asl.LogicalLineNumber = 0; + + Next = Next->Asl.Next; + Next->Asl.LineNumber = 0; + Next->Asl.LogicalLineNumber = 0; + + Next = Next->Asl.Next; + Next->Asl.LineNumber = 0; + Next->Asl.LogicalLineNumber = 0; + + Next = Next->Asl.Next; + Next->Asl.LineNumber = 0; + Next->Asl.LogicalLineNumber = 0; + + ParentOp = ExternalOp->Asl.Parent; + Prev = Next = ParentOp->Asl.Child; + + /* Now find the External node's position in parse tree */ + + while (Next != ExternalOp) + { + Prev = Next; + Next = Next->Asl.Next; + } + + /* Remove the External from the parse tree */ + + if (Prev == ExternalOp) + { + /* External was the first child node */ + + ParentOp->Asl.Child = ExternalOp->Asl.Next; + } + + Prev->Asl.Next = ExternalOp->Asl.Next; + ExternalOp->Asl.Next = NULL; + ExternalOp->Asl.Parent = Gbl_ExternalsListHead; + + /* Point the External to the next in the list */ + + if (NextOp->Asl.Next) + { + ExternalOp->Asl.Next = NextOp->Asl.Next->Asl.Child; + } + + NextOp = NextOp->Asl.Next; + } + + /* + * Loop again to remove MethodObj Externals for which + * a MethodCall was not found (dead external reference) + */ + Prev = Gbl_ExternalsListHead->Asl.Child; + Next = Prev; + while (Next) + { + ObjType = (ACPI_OBJECT_TYPE) + Next->Asl.Child->Asl.Next->Asl.Value.Integer; + + if (ObjType == ACPI_TYPE_METHOD && + !(Next->Asl.CompileFlags & NODE_VISITED)) + { + if (Next == Prev) + { + Gbl_ExternalsListHead->Asl.Child = Next->Asl.Next; + Next->Asl.Next = NULL; + Prev = Gbl_ExternalsListHead->Asl.Child; + Next = Prev; + continue; + } + else + { + Prev->Asl.Next = Next->Asl.Next; + Next->Asl.Next = NULL; + Next = Prev->Asl.Next; + continue; + } + } + + Prev = Next; + Next = Next->Asl.Next; + } + + /* If list is now empty, don't bother to make If (0) block */ + + if (!Gbl_ExternalsListHead->Asl.Child) + { + return; + } + + /* Convert Gbl_ExternalsListHead parent to If(). */ + + Gbl_ExternalsListHead->Asl.ParseOpcode = PARSEOP_IF; + Gbl_ExternalsListHead->Asl.AmlOpcode = AML_IF_OP; + Gbl_ExternalsListHead->Asl.CompileFlags = NODE_AML_PACKAGE; + UtSetParseOpName (Gbl_ExternalsListHead); + + /* Create a Zero op for the If predicate */ + + PredicateOp = TrAllocateNode (PARSEOP_ZERO); + PredicateOp->Asl.AmlOpcode = AML_ZERO_OP; + + PredicateOp->Asl.Parent = Gbl_ExternalsListHead; + PredicateOp->Asl.Child = NULL; + PredicateOp->Asl.Next = Gbl_ExternalsListHead->Asl.Child; + Gbl_ExternalsListHead->Asl.Child = PredicateOp; + + /* Set line numbers (for listings, etc.) */ + + Gbl_ExternalsListHead->Asl.LineNumber = 0; + Gbl_ExternalsListHead->Asl.LogicalLineNumber = 0; + + PredicateOp->Asl.LineNumber = 0; + PredicateOp->Asl.LogicalLineNumber = 0; + + /* Insert block back in the list */ + + Prev = DefinitionBlockOp->Asl.Child; + Next = Prev; + + /* Find last default arg */ + + for (i = 0; i < 6; i++) + { + Prev = Next; + Next = Prev->Asl.Next; + } + + if (Next) + { + /* Definition Block is not empty */ + + Gbl_ExternalsListHead->Asl.Next = Next; + } + else + { + /* Definition Block is empty. */ + + Gbl_ExternalsListHead->Asl.Next = NULL; + } + + Prev->Asl.Next = Gbl_ExternalsListHead; + Gbl_ExternalsListHead->Asl.Parent = Prev->Asl.Parent; +} diff --git a/sys/contrib/dev/acpica/compiler/aslfileio.c b/sys/contrib/dev/acpica/compiler/aslfileio.c index cf726dd..f1c664f 100644 --- a/sys/contrib/dev/acpica/compiler/aslfileio.c +++ b/sys/contrib/dev/acpica/compiler/aslfileio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -70,6 +70,7 @@ FlFileError ( sprintf (MsgBuffer, "\"%s\" (%s) - %s", Gbl_Files[FileId].Filename, Gbl_Files[FileId].Description, strerror (errno)); + AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer); } @@ -218,6 +219,19 @@ FlWriteFile ( FlFileError (FileId, ASL_MSG_WRITE); AslAbort (); } + + if ((FileId == ASL_FILE_PREPROCESSOR) && Gbl_PreprocessorOutputFlag) + { + /* Duplicate the output to the user preprocessor (.i) file */ + + Actual = fwrite ((char *) Buffer, 1, Length, + Gbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle); + if (Actual != Length) + { + FlFileError (FileId, ASL_MSG_WRITE); + AslAbort (); + } + } } @@ -247,7 +261,6 @@ FlPrintFile ( va_start (Args, Format); - Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args); va_end (Args); @@ -256,6 +269,30 @@ FlPrintFile ( FlFileError (FileId, ASL_MSG_WRITE); AslAbort (); } + + if ((FileId == ASL_FILE_PREPROCESSOR) && + Gbl_PreprocessorOutputFlag) + { + /* + * Duplicate the output to the user preprocessor (.i) file, + * except: no #line directives. + */ + if (!strncmp (Format, "#line", 5)) + { + return; + } + + va_start (Args, Format); + Actual = vfprintf (Gbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle, + Format, Args); + va_end (Args); + + if (Actual == -1) + { + FlFileError (FileId, ASL_MSG_WRITE); + AslAbort (); + } + } } diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c index d8c9ed5..fc2eaaa 100644 --- a/sys/contrib/dev/acpica/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica/compiler/aslfiles.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/include/acapps.h> +#include <contrib/dev/acpica/compiler/dtcompiler.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslfiles") @@ -55,7 +56,6 @@ FlOpenIncludeWithPrefix ( ACPI_PARSE_OBJECT *Op, char *Filename); - #ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS FlParseInputPathname ( @@ -84,7 +84,6 @@ FlSetLineNumber ( LineNumber, Gbl_LogicalLineNumber); Gbl_CurrentLineNumber = LineNumber; - Gbl_LogicalLineNumber = LineNumber; } @@ -262,7 +261,8 @@ FlMergePathnames ( /* Build the final merged pathname */ ConcatenatePaths: - Pathname = UtStringCacheCalloc (strlen (CommonPath) + strlen (FilePathname) + 2); + Pathname = UtStringCacheCalloc ( + strlen (CommonPath) + strlen (FilePathname) + 2); if (LastElement && *CommonPath) { strcpy (Pathname, CommonPath); @@ -303,6 +303,7 @@ FlOpenIncludeWithPrefix ( { FILE *IncludeFile; char *Pathname; + UINT32 OriginalLineNumber; /* Build the full pathname to the file */ @@ -322,13 +323,21 @@ FlOpenIncludeWithPrefix ( return (NULL); } -#ifdef _MUST_HANDLE_COMMENTS /* - * Check entire include file for any # preprocessor directives. + * Check the entire include file for any # preprocessor directives. * This is because there may be some confusion between the #include - * preprocessor directive and the ASL Include statement. + * preprocessor directive and the ASL Include statement. A file included + * by the ASL include cannot contain preprocessor directives because + * the preprocessor has already run by the time the ASL include is + * recognized (by the compiler, not the preprocessor.) + * + * Note: DtGetNextLine strips/ignores comments. + * Save current line number since DtGetNextLine modifies it. */ - while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, IncludeFile)) + Gbl_CurrentLineNumber--; + OriginalLineNumber = Gbl_CurrentLineNumber; + + while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF) { if (Gbl_CurrentLineBuffer[0] == '#') { @@ -336,7 +345,8 @@ FlOpenIncludeWithPrefix ( Op, "use #include instead"); } } -#endif + + Gbl_CurrentLineNumber = OriginalLineNumber; /* Must seek back to the start of the file */ @@ -414,7 +424,8 @@ FlOpenIncludeFile ( * * Construct the file pathname from the global directory name. */ - IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op, Op->Asl.Value.String); + IncludeFile = FlOpenIncludeWithPrefix ( + Gbl_DirectoryPath, Op, Op->Asl.Value.String); if (IncludeFile) { return; @@ -427,7 +438,8 @@ FlOpenIncludeFile ( NextDir = Gbl_IncludeDirList; while (NextDir) { - IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op, Op->Asl.Value.String); + IncludeFile = FlOpenIncludeWithPrefix ( + NextDir->Dir, Op, Op->Asl.Value.String); if (IncludeFile) { return; @@ -538,9 +550,29 @@ FlOpenMiscOutputFiles ( char *Filename; + /* Create/Open a map file if requested */ + + if (Gbl_MapfileFlag) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_MAP); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + /* Open the hex file, text mode (closed at compiler exit) */ + + FlOpenFile (ASL_FILE_MAP_OUTPUT, Filename, "w+t"); + + AslCompilerSignon (ASL_FILE_MAP_OUTPUT); + AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT); + } + /* All done for disassembler */ - if (Gbl_FileType == ASL_INPUT_TYPE_ACPI_TABLE) + if (Gbl_FileType == ASL_INPUT_TYPE_BINARY_ACPI_TABLE) { return (AE_OK); } @@ -579,8 +611,6 @@ FlOpenMiscOutputFiles ( /* Open the debug file as STDERR, text mode */ - /* TBD: hide this behind a FlReopenFile function */ - Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename; Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = freopen (Filename, "w+t", stderr); @@ -588,19 +618,39 @@ FlOpenMiscOutputFiles ( if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle) { /* - * A problem with freopen is that on error, - * we no longer have stderr. + * A problem with freopen is that on error, we no longer + * have stderr and cannot emit normal error messages. + * Emit error to stdout, close files, and exit. */ - Gbl_DebugFlag = FALSE; - memcpy (stderr, stdout, sizeof (FILE)); - FlFileError (ASL_FILE_DEBUG_OUTPUT, ASL_MSG_DEBUG_FILENAME); - AslAbort (); + fprintf (stdout, + "\nCould not open debug output file: %s\n\n", Filename); + + CmCleanupAndExit (); + exit (1); } AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT); AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT); } + /* Create/Open a cross-reference output file if asked */ + + if (Gbl_CrossReferenceOutput) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_XREF); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + FlOpenFile (ASL_FILE_XREF_OUTPUT, Filename, "w+t"); + + AslCompilerSignon (ASL_FILE_XREF_OUTPUT); + AslCompilerFileHeader (ASL_FILE_XREF_OUTPUT); + } + /* Create/Open a listing output file if asked */ if (Gbl_ListingFlag) @@ -621,7 +671,7 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT); } - /* Create the preprocessor output file if preprocessor enabled */ + /* Create the preprocessor output temp file if preprocessor enabled */ if (Gbl_PreprocessFlag) { @@ -636,6 +686,23 @@ FlOpenMiscOutputFiles ( FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t"); } + /* + * Create the "user" preprocessor output file if -li flag set. + * Note, this file contains no embedded #line directives. + */ + if (Gbl_PreprocessorOutputFlag) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROC_USER); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + FlOpenFile (ASL_FILE_PREPROCESSOR_USER, Filename, "w+t"); + } + /* All done for data table compiler */ if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA) @@ -787,26 +854,6 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT); } - /* Create/Open a map file if requested */ - - if (Gbl_MapfileFlag) - { - Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_MAP); - if (!Filename) - { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, - 0, 0, 0, 0, NULL, NULL); - return (AE_ERROR); - } - - /* Open the hex file, text mode (closed at compiler exit) */ - - FlOpenFile (ASL_FILE_MAP_OUTPUT, Filename, "w+t"); - - AslCompilerSignon (ASL_FILE_MAP_OUTPUT); - AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT); - } - return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c index 26b786d..78a1a60 100644 --- a/sys/contrib/dev/acpica/compiler/aslfold.c +++ b/sys/contrib/dev/acpica/compiler/aslfold.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,7 +100,8 @@ TrInstallReducedConstant ( * * RETURN: Status * - * DESCRIPTION: Reduce an Op and its subtree to a constant if possible + * DESCRIPTION: Reduce an Op and its subtree to a constant if possible. + * Called during ascent of the parse tree. * ******************************************************************************/ @@ -192,9 +193,7 @@ OpcAmlConstantWalk ( OpcUpdateIntegerNode (Op, 0); } - /* Abort the walk of this subtree, we are done with it */ - - return (AE_CTRL_DEPTH); + return (AE_OK); } @@ -206,7 +205,8 @@ OpcAmlConstantWalk ( * * RETURN: Status * - * DESCRIPTION: Check one Op for a type 3/4/5 AML opcode + * DESCRIPTION: Check one Op for a reducible type 3/4/5 AML opcode. + * This is performed via an upward walk of the parse subtree. * ******************************************************************************/ @@ -218,6 +218,8 @@ OpcAmlCheckForConstant ( { ACPI_WALK_STATE *WalkState = Context; ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *NextOp; + const ACPI_OPCODE_INFO *OpInfo; WalkState->Op = Op; @@ -228,19 +230,6 @@ OpcAmlCheckForConstant ( Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName); /* - * TBD: Ignore buffer constants for now. The problem is that these - * constants have been transformed into RAW_DATA at this point, from - * the parse tree transform process which currently happens before - * the constant folding process. We may need to defer this transform - * for buffer until after the constant folding. - */ - if (WalkState->Opcode == AML_BUFFER_OP) - { - Status = AE_TYPE; - goto CleanupAndExit; - } - - /* * These opcodes do not appear in the OpcodeInfo table, but * they represent constants, so abort the constant walk now. */ @@ -254,11 +243,95 @@ OpcAmlCheckForConstant ( goto CleanupAndExit; } + /* + * Search upwards for a possible Name() operator. This is done + * because a type 3/4/5 opcode within a Name() expression + * MUST be reduced to a simple constant. + */ + NextOp = Op->Asl.Parent; + while (NextOp) + { + /* Finished if we find a Name() opcode */ + + if (NextOp->Asl.AmlOpcode == AML_NAME_OP) + { + break; + } + + /* + * Any "deferred" opcodes contain one or more TermArg parameters, + * and thus are not required to be folded to constants at compile + * time. This affects things like Buffer() and Package() objects. + * We just ignore them here. However, any sub-expressions can and + * will still be typechecked. Note: These are called the + * "deferred" opcodes in the AML interpreter. + */ + OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode); + if (OpInfo->Flags & AML_DEFER) + { + NextOp = NULL; + break; + } + + NextOp = NextOp->Asl.Parent; + } + /* Type 3/4/5 opcodes have the AML_CONSTANT flag set */ if (!(WalkState->OpInfo->Flags & AML_CONSTANT)) { - /* Not 3/4/5 opcode, but maybe can convert to STORE */ + /* + * From the ACPI specification: + * + * "The Type 3/4/5 opcodes return a value and can be used in an + * expression that evaluates to a constant. These opcodes may be + * evaluated at ASL compile-time. To ensure that these opcodes + * will evaluate to a constant, the following rules apply: The + * term cannot have a destination (target) operand, and must have + * either a Type3Opcode, Type4Opcode, Type5Opcode, ConstExprTerm, + * Integer, BufferTerm, Package, or String for all arguments." + */ + + /* + * The value (second) operand for the Name() operator MUST + * reduce to a single constant, as per the ACPI specification + * (the operand is a DataObject). This also implies that there + * can be no target operand. Name() is the only ASL operator + * with a "DataObject" as an operand and is thus special- + * cased here. + */ + if (NextOp) /* Inspect a Name() operator */ + { + /* Error if there is a target operand */ + + if (Op->Asl.CompileFlags & NODE_IS_TARGET) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, NULL); + Status = AE_TYPE; + } + + /* Error if expression cannot be reduced (folded) */ + + if (!(NextOp->Asl.CompileFlags & NODE_COULD_NOT_REDUCE)) + { + /* Ensure only one error message per statement */ + + NextOp->Asl.CompileFlags |= NODE_COULD_NOT_REDUCE; + DbgPrint (ASL_PARSE_OUTPUT, + "**** Could not reduce operands for NAME opcode ****\n"); + + AslError (ASL_ERROR, ASL_MSG_CONSTANT_REQUIRED, Op, + "Constant is required for Name operator"); + Status = AE_TYPE; + } + } + + if (ACPI_FAILURE (Status)) + { + goto CleanupAndExit; + } + + /* This is not a 3/4/5 opcode, but maybe can convert to STORE */ if (Op->Asl.CompileFlags & NODE_IS_TARGET) { @@ -270,13 +343,35 @@ OpcAmlCheckForConstant ( /* Expression cannot be reduced */ DbgPrint (ASL_PARSE_OUTPUT, - "**** Not a Type 3/4/5 opcode (%s) ****", + "**** Not a Type 3/4/5 opcode or cannot reduce/fold (%s) ****\n", Op->Asl.ParseOpName); Status = AE_TYPE; goto CleanupAndExit; } + /* + * TBD: Ignore buffer constants for now. The problem is that these + * constants have been transformed into RAW_DATA at this point, from + * the parse tree transform process which currently happens before + * the constant folding process. We may need to defer this transform + * for buffer until after the constant folding. + */ + if (WalkState->Opcode == AML_BUFFER_OP) + { + DbgPrint (ASL_PARSE_OUTPUT, + "\nBuffer constant reduction is not supported yet\n"); + + if (NextOp) /* Found a Name() operator, error */ + { + AslError (ASL_ERROR, ASL_MSG_UNSUPPORTED, Op, + "Buffer expression cannot be reduced"); + } + + Status = AE_TYPE; + goto CleanupAndExit; + } + /* Debug output */ DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345"); @@ -292,6 +387,7 @@ OpcAmlCheckForConstant ( DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET"); } } + if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG) { DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG"); @@ -380,10 +476,12 @@ TrSimpleConstantReduction ( return (Status); } + /* Disconnect any existing children, install new constant */ + + Op->Asl.Child = NULL; TrInstallReducedConstant (Op, ObjDesc); UtSetParseOpName (Op); - Op->Asl.Child = NULL; return (AE_OK); } @@ -419,9 +517,6 @@ TrTransformToStoreOp ( ACPI_STATUS Status; - DbgPrint (ASL_PARSE_OUTPUT, - "Reduction/Transform to StoreOp: Store(Constant, Target)\n"); - /* Extract the operands */ Child1 = Op->Asl.Child; @@ -443,6 +538,10 @@ TrTransformToStoreOp ( } } + DbgPrint (ASL_PARSE_OUTPUT, + "Reduction/Transform to StoreOp: Store(%s, %s)\n", + Child1->Asl.ParseOpName, Child2->Asl.ParseOpName); + /* * Create a NULL (zero) target so that we can use the * interpreter to evaluate the expression. @@ -494,6 +593,10 @@ TrTransformToStoreOp ( goto EvalError; } + /* Truncate any subtree expressions, they have been evaluated */ + + Child1->Asl.Child = NULL; + /* Folded constant is in ObjDesc, store into Child1 */ TrInstallReducedConstant (Child1, ObjDesc); @@ -505,11 +608,6 @@ TrTransformToStoreOp ( UtSetParseOpName (Op); Op->Common.Parent = OriginalParent; - /* Truncate any subtree expressions, they have been evaluated */ - - Child1->Asl.Child = NULL; - Child2->Asl.Child = NULL; - /* First child is the folded constant */ /* Second child will be the target */ @@ -547,7 +645,8 @@ TrInstallReducedConstant ( ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ObjDesc) { - ACPI_PARSE_OBJECT *RootOp; + ACPI_PARSE_OBJECT *LengthOp; + ACPI_PARSE_OBJECT *DataOp; TotalFolds++; @@ -574,17 +673,22 @@ TrInstallReducedConstant ( Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; Op->Common.AmlOpcode = AML_STRING_OP; - Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1; + Op->Asl.AmlLength = strlen (ObjDesc->String.Pointer) + 1; Op->Common.Value.String = ObjDesc->String.Pointer; DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (STRING) %s\n\n", Op->Common.Value.String); - break; case ACPI_TYPE_BUFFER: - + /* + * Create a new parse subtree of the form: + * + * BUFFER (Buffer AML opcode) + * INTEGER (Buffer length in bytes) + * RAW_DATA (Buffer byte data) + */ Op->Asl.ParseOpcode = PARSEOP_BUFFER; Op->Common.AmlOpcode = AML_BUFFER_OP; Op->Asl.CompileFlags = NODE_AML_PACKAGE; @@ -592,28 +696,24 @@ TrInstallReducedConstant ( /* Child node is the buffer length */ - RootOp = TrAllocateNode (PARSEOP_INTEGER); + LengthOp = TrAllocateNode (PARSEOP_INTEGER); - RootOp->Asl.AmlOpcode = AML_DWORD_OP; - RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length; - RootOp->Asl.Parent = Op; + LengthOp->Asl.AmlOpcode = AML_DWORD_OP; + LengthOp->Asl.Value.Integer = ObjDesc->Buffer.Length; + LengthOp->Asl.Parent = Op; + (void) OpcSetOptimalIntegerSize (LengthOp); - (void) OpcSetOptimalIntegerSize (RootOp); - - Op->Asl.Child = RootOp; - Op = RootOp; - UtSetParseOpName (Op); + Op->Asl.Child = LengthOp; - /* Peer to the child is the raw buffer data */ + /* Next child is the raw buffer data */ - RootOp = TrAllocateNode (PARSEOP_RAW_DATA); - RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - RootOp->Asl.AmlLength = ObjDesc->Buffer.Length; - RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer; - RootOp->Asl.Parent = Op->Asl.Parent; + DataOp = TrAllocateNode (PARSEOP_RAW_DATA); + DataOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + DataOp->Asl.AmlLength = ObjDesc->Buffer.Length; + DataOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer; + DataOp->Asl.Parent = Op; - Op->Asl.Next = RootOp; - Op = RootOp; + LengthOp->Asl.Next = DataOp; DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (BUFFER) length %X\n\n", diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h index c61b8ff..6f35c24 100644 --- a/sys/contrib/dev/acpica/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica/compiler/aslglobal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,6 +73,7 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = {NULL, NULL, "Binary Output:", "AML Output"}, {NULL, NULL, "Source Output:", "Source Output"}, {NULL, NULL, "Preprocessor: ", "Preprocessor Output"}, + {NULL, NULL, "Preprocessor: ", "Preprocessor Temp File"}, {NULL, NULL, "Listing File: ", "Listing Output"}, {NULL, NULL, "Hex Dump: ", "Hex Table Output"}, {NULL, NULL, "Namespace: ", "Namespace Output"}, @@ -82,7 +83,8 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = {NULL, NULL, "ASM Include: ", "Assembly Header Output"}, {NULL, NULL, "C Include: ", "C Header Output"}, {NULL, NULL, "Offset Table: ", "C Offset Table Output"}, - {NULL, NULL, "Device Map: ", "Device Map Output"} + {NULL, NULL, "Device Map: ", "Device Map Output"}, + {NULL, NULL, "Cross Ref: ", "Cross-reference Output"} }; #else @@ -123,10 +125,10 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_CurrentLineBuffer, NUL ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, NULL); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LineBufferSize, ASL_DEFAULT_LINE_BUFFER_SIZE); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0); -ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_PreviousLineNumber, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0); +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_OriginalInputFileSize, 0); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_SyntaxError, 0); /* Exception reporting */ @@ -146,7 +148,9 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_MapfileFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PreprocessorOutputFlag, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_KeepPreprocessorTempFile, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CrossReferenceOutput, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OffsetTableFlag, FALSE); @@ -175,6 +179,9 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoTemplates, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileGeneric, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AllExceptionsDisabled, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PruneParseTree, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoTypechecking, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_EnableReferenceTypechecking, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoExternals, TRUE); #define HEX_OUTPUT_NONE 0 @@ -193,6 +200,7 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, ASL_EXTERN ASL_INCLUDE_DIR ASL_INIT_GLOBAL (*Gbl_IncludeDirList, NULL); ASL_EXTERN char *Gbl_CurrentInputFilename; ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_ExternalRefFilename, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_PreviousIncludeFilename, NULL); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE); @@ -235,14 +243,15 @@ ASL_EXTERN ACPI_SERIAL_INFO ASL_INIT_GLOBAL (*Gbl_SerialList, NULL); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_TempCount, 0); -ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*RootNode, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ParseTreeRoot, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ExternalsListHead, NULL); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TableLength, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_SourceLine, 0); ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL); -ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_FileType, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_Signature, NULL); -ASL_EXTERN char *Gbl_TemplateSignature; + +ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0); @@ -264,7 +273,7 @@ ASL_EXTERN ACPI_TABLE_HEADER TableHeader; /* Event timing */ -#define ASL_NUM_EVENTS 20 +#define ASL_NUM_EVENTS 24 ASL_EXTERN ASL_EVENT_INFO AslGbl_Events[ASL_NUM_EVENTS]; ASL_EXTERN UINT8 AslGbl_NextEvent; ASL_EXTERN UINT8 AslGbl_NamespaceEvent; diff --git a/sys/contrib/dev/acpica/compiler/aslhex.c b/sys/contrib/dev/acpica/compiler/aslhex.c index f24de1c..fd80925 100644 --- a/sys/contrib/dev/acpica/compiler/aslhex.c +++ b/sys/contrib/dev/acpica/compiler/aslhex.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,7 +50,6 @@ * This module emits ASCII hex output files in either C, ASM, or ASL format */ - /* Local prototypes */ static void @@ -223,6 +222,7 @@ HxDoHexOutputC ( FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", HEX_TABLE_LINE_SIZE - LineLength + 1, " "); @@ -310,6 +310,7 @@ HxDoHexOutputAsl ( FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", HEX_TABLE_LINE_SIZE - LineLength + 1, " "); @@ -393,6 +394,7 @@ HxDoHexOutputAsm ( FlPrintFile (ASL_FILE_HEX_OUTPUT, " ; %8.8X", Offset); LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); Offset += LineLength; diff --git a/sys/contrib/dev/acpica/compiler/asllength.c b/sys/contrib/dev/acpica/compiler/asllength.c index 618b63f..2c57794 100644 --- a/sys/contrib/dev/acpica/compiler/asllength.c +++ b/sys/contrib/dev/acpica/compiler/asllength.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -132,10 +132,11 @@ LnPackageLengthWalk ( if ((Op->Asl.Parent) && (Op->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) { - Op->Asl.Parent->Asl.AmlSubtreeLength += (Op->Asl.AmlLength + - Op->Asl.AmlOpcodeLength + - Op->Asl.AmlPkgLenBytes + - Op->Asl.AmlSubtreeLength); + Op->Asl.Parent->Asl.AmlSubtreeLength += ( + Op->Asl.AmlLength + + Op->Asl.AmlOpcodeLength + + Op->Asl.AmlPkgLenBytes + + Op->Asl.AmlSubtreeLength); } return (AE_OK); } @@ -229,7 +230,7 @@ CgGenerateAmlOpcodeLength ( if (Op->Asl.CompileFlags & NODE_AML_PACKAGE) { Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount ( - Op, Op->Asl.AmlSubtreeLength); + Op, Op->Asl.AmlSubtreeLength); } /* Data opcode lengths are easy */ @@ -332,10 +333,9 @@ CgGenerateAmlLengths ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: - Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + - Op->Asl.AmlSubtreeLength; + Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength; break; case PARSEOP_NAMESEG: @@ -365,7 +365,6 @@ CgGenerateAmlLengths ( Op->Asl.ExternalName = Op->Asl.Value.String; Op->Asl.Value.String = Buffer; Op->Asl.CompileFlags |= NODE_NAME_INTERNALIZED; - Op->Asl.AmlLength = strlen (Buffer); /* @@ -391,7 +390,7 @@ CgGenerateAmlLengths ( Op->Asl.AmlOpcodeLength = 0; Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, - (UINT32) Op->Asl.Value.Integer); + (UINT32) Op->Asl.Value.Integer); break; case PARSEOP_RAW_DATA: @@ -400,7 +399,6 @@ CgGenerateAmlLengths ( break; case PARSEOP_DEFAULT_ARG: - case PARSEOP_EXTERNAL: case PARSEOP_INCLUDE: case PARSEOP_INCLUDE_END: @@ -408,6 +406,14 @@ CgGenerateAmlLengths ( break; + case PARSEOP_EXTERNAL: + + if (Gbl_DoExternals == TRUE) + { + CgGenerateAmlOpcodeLength (Op); + } + break; + default: CgGenerateAmlOpcodeLength (Op); diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c index a8fe2de..45ab1e2 100644 --- a/sys/contrib/dev/acpica/compiler/asllisting.c +++ b/sys/contrib/dev/acpica/compiler/asllisting.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -163,16 +163,16 @@ LsGenerateListing ( LsDoOffsetTableHeader (FileId); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlOffsetWalk, - NULL, (void *) ACPI_TO_POINTER (FileId)); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + LsAmlOffsetWalk, NULL, (void *) ACPI_TO_POINTER (FileId)); LsDoOffsetTableFooter (FileId); return; } /* Process all parse nodes */ - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk, - NULL, (void *) ACPI_TO_POINTER (FileId)); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + LsAmlListingWalk, NULL, (void *) ACPI_TO_POINTER (FileId)); /* Final processing */ @@ -212,6 +212,12 @@ LsAmlListingWalk ( return (AE_OK); } + if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) || + (FileId == ASL_FILE_C_INCLUDE_OUTPUT)) + { + return (AE_OK); + } + /* Write the hex bytes to the listing file(s) (if requested) */ for (i = 0; i < Op->Asl.FinalAmlLength; i++) @@ -221,6 +227,7 @@ LsAmlListingWalk ( FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ); AslAbort (); } + LsWriteListingHexBytes (&FileByte, 1, FileId); } @@ -251,8 +258,12 @@ LsDumpParseTree ( } DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER1); + + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, LsTreeWriteWalk, NULL, NULL); + + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER1); } @@ -263,15 +274,69 @@ LsTreeWriteWalk ( void *Context) { - /* Debug output */ + /* Dump ParseOp name and possible value */ + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_NAMESEG: + case PARSEOP_NAMESTRING: + case PARSEOP_METHODCALL: + case PARSEOP_STRING_LITERAL: + + UtDumpStringOp (Op, Level); + break; + + case PARSEOP_BYTECONST: + + UtDumpIntegerOp (Op, Level, 2); + break; + + case PARSEOP_WORDCONST: + case PARSEOP_PACKAGE_LENGTH: + + UtDumpIntegerOp (Op, Level, 4); + break; + + case PARSEOP_DWORDCONST: + case PARSEOP_EISAID: + + UtDumpIntegerOp (Op, Level, 8); + break; + + case PARSEOP_QWORDCONST: + case PARSEOP_INTEGER: + case PARSEOP_ONE: + case PARSEOP_ZERO: + case PARSEOP_ONES: + + UtDumpIntegerOp (Op, Level, 16); + break; + + case PARSEOP_INCLUDE: + + DbgPrint (ASL_TREE_OUTPUT, + "Open: %s\n", Op->Asl.Value.String); + return (AE_OK); + + case PARSEOP_INCLUDE_END: + + DbgPrint (ASL_TREE_OUTPUT, + "Close: %s\n", Op->Asl.Filename); + return (AE_OK); + + default: + + UtDumpBasicOp (Op, Level); + break; + } - DbgPrint (ASL_TREE_OUTPUT, - "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); + /* Dump the remaining data */ - UtPrintFormattedName (Op->Asl.ParseOpcode, Level); + DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_DEBUG1, + Op->Asl.ParseOpcode, Op->Asl.CompileFlags, + Op->Asl.LineNumber, Op->Asl.EndLine, + Op->Asl.LogicalLineNumber, Op->Asl.EndLogicalLine); - DbgPrint (ASL_TREE_OUTPUT, " (%.4X) Flags %8.8X", - Op->Asl.ParseOpcode, Op->Asl.CompileFlags); TrPrintNodeCompileFlags (Op->Asl.CompileFlags); DbgPrint (ASL_TREE_OUTPUT, "\n"); return (AE_OK); @@ -316,7 +381,7 @@ LsWriteNodeToListing ( { switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: case PARSEOP_METHODCALL: case PARSEOP_INCLUDE: case PARSEOP_INCLUDE_END: @@ -362,36 +427,49 @@ LsWriteNodeToListing ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: + + /* Always start a definition block at AML offset zero */ + Gbl_CurrentAmlOffset = 0; LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId); /* Use the table Signature and TableId to build a unique name */ - if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) + switch (FileId) { + case ASL_FILE_ASM_SOURCE_OUTPUT: + FlPrintFile (FileId, "%s_%s_Header \\\n", Gbl_TableSignature, Gbl_TableId); - } - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + FlPrintFile (FileId, " unsigned char %s_%s_Header [] =\n {\n", Gbl_TableSignature, Gbl_TableId); - } - if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) - { + break; + + case ASL_FILE_ASM_INCLUDE_OUTPUT: + FlPrintFile (FileId, "extrn %s_%s_Header : byte\n", Gbl_TableSignature, Gbl_TableId); - } - if (FileId == ASL_FILE_C_INCLUDE_OUTPUT) - { + break; + + case ASL_FILE_C_INCLUDE_OUTPUT: + FlPrintFile (FileId, "extern unsigned char %s_%s_Header [];\n", Gbl_TableSignature, Gbl_TableId); + break; + + default: + break; } + return; @@ -411,7 +489,7 @@ LsWriteNodeToListing ( /* Create a new listing node and push it */ - LsPushNode (Op->Asl.Child->Asl.Value.String); + LsPushNode (Op->Asl.Value.String); return; @@ -540,31 +618,41 @@ LsWriteNodeToListing ( /* Create the appropriate symbol in the output file */ - if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) + switch (FileId) { + case ASL_FILE_ASM_SOURCE_OUTPUT: + FlPrintFile (FileId, "%s_%s_%s \\\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); - } - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + FlPrintFile (FileId, " unsigned char %s_%s_%s [] =\n {\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); - } - if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) - { + break; + + case ASL_FILE_ASM_INCLUDE_OUTPUT: + FlPrintFile (FileId, "extrn %s_%s_%s : byte\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); - } - if (FileId == ASL_FILE_C_INCLUDE_OUTPUT) - { + break; + + case ASL_FILE_C_INCLUDE_OUTPUT: + FlPrintFile (FileId, "extern unsigned char %s_%s_%s [];\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); + break; + + default: + break; } } + ACPI_FREE (Pathname); } break; diff --git a/sys/contrib/dev/acpica/compiler/asllistsup.c b/sys/contrib/dev/acpica/compiler/asllistsup.c index 694fbc8..754f8c9 100644 --- a/sys/contrib/dev/acpica/compiler/asllistsup.c +++ b/sys/contrib/dev/acpica/compiler/asllistsup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,6 +88,7 @@ LsDumpAscii ( FlPrintFile (FileId, "."); } } + FlPrintFile (FileId, "\""); } @@ -185,7 +186,6 @@ LsCheckException ( (LineNumber >= Gbl_NextError->LogicalLineNumber)) { AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n"); - Gbl_NextError = Gbl_NextError->Next; } @@ -576,6 +576,7 @@ LsFlushListingBuffer ( { FlPrintFile (FileId, ","); } + FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]); } diff --git a/sys/contrib/dev/acpica/compiler/aslload.c b/sys/contrib/dev/acpica/compiler/aslload.c index c8ae3ad..f14e01d 100644 --- a/sys/contrib/dev/acpica/compiler/aslload.c +++ b/sys/contrib/dev/acpica/compiler/aslload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -104,8 +104,6 @@ LdLoadNamespace ( ACPI_WALK_STATE *WalkState; - DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n"); - /* Create a new walk state */ WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); @@ -196,12 +194,11 @@ LdLoadFieldElements ( default: Status = AcpiNsLookup (WalkState->ScopeInfo, - Child->Asl.Value.String, - ACPI_TYPE_LOCAL_REGION_FIELD, - ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | - ACPI_NS_ERROR_IF_FOUND, - NULL, &Node); + Child->Asl.Value.String, + ACPI_TYPE_LOCAL_REGION_FIELD, + ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND, NULL, &Node); if (ACPI_FAILURE (Status)) { if (Status != AE_ALREADY_EXISTS) @@ -266,9 +263,9 @@ LdLoadResourceElements ( * This opens a scope, so later field names are guaranteed to be new/unique. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, - ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, - WalkState, &Node); + ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, + WalkState, &Node); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -296,11 +293,11 @@ LdLoadResourceElements ( if (InitializerOp->Asl.ExternalName) { Status = AcpiNsLookup (WalkState->ScopeInfo, - InitializerOp->Asl.ExternalName, - ACPI_TYPE_LOCAL_RESOURCE_FIELD, - ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, - NULL, &Node); + InitializerOp->Asl.ExternalName, + ACPI_TYPE_LOCAL_RESOURCE_FIELD, + ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); if (ACPI_FAILURE (Status)) { return (Status); @@ -344,6 +341,7 @@ LdNamespace1Begin ( { ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *MethodOp; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; @@ -500,8 +498,8 @@ LdNamespace1Begin ( * handle this case. Perhaps someday this case can go away. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -509,9 +507,9 @@ LdNamespace1Begin ( /* The name was not found, go ahead and create it */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, - ACPI_TYPE_LOCAL_SCOPE, - ACPI_IMODE_LOAD_PASS1, Flags, - WalkState, &(Node)); + ACPI_TYPE_LOCAL_SCOPE, + ACPI_IMODE_LOAD_PASS1, Flags, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -534,6 +532,35 @@ LdNamespace1Begin ( return_ACPI_STATUS (Status); } + else /* Status AE_OK */ + { + /* + * Do not allow references to external scopes from the DSDT. + * This is because the DSDT is always loaded first, and the + * external reference cannot be resolved -- causing a runtime + * error because Scope() must be resolved immediately. + * 10/2015. + */ + if ((Node->Flags & ANOBJ_IS_EXTERNAL) && + (ACPI_COMPARE_NAME (Gbl_TableSignature, "DSDT"))) + { + /* However, allowed if the reference is within a method */ + + MethodOp = Op->Asl.Parent; + while (MethodOp && + (MethodOp->Asl.ParseOpcode != PARSEOP_METHOD)) + { + MethodOp = MethodOp->Asl.Parent; + } + + if (!MethodOp) + { + /* Not in a control method, error */ + + AslError (ASL_ERROR, ASL_MSG_CROSS_TABLE_SCOPE, Op, NULL); + } + } + } /* We found a node with this name, now check the type */ @@ -569,7 +596,7 @@ LdNamespace1Begin ( Node->Type = ACPI_TYPE_LOCAL_SCOPE; Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, - WalkState); + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -591,7 +618,7 @@ LdNamespace1Begin ( */ Node->Type = ACPI_TYPE_LOCAL_SCOPE; Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, - WalkState); + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -611,7 +638,7 @@ LdNamespace1Begin ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n", - Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); + Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); /* The name must not already exist */ @@ -624,7 +651,7 @@ LdNamespace1Begin ( * parse tree later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -658,8 +685,38 @@ LdNamespace1Begin ( return_ACPI_STATUS (Status); } } + + Status = AE_OK; + } + else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + { + /* + * Allow externals in same scope as the definition of the + * actual object. Similar to C. Allows multiple definition + * blocks that refer to each other in the same file. + */ Status = AE_OK; } + else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && + (ObjectType == ACPI_TYPE_ANY)) + { + /* Allow update of externals of unknown type. */ + + if (AcpiNsOpensScope (ActualObjectType)) + { + Node->Type = (UINT8) ActualObjectType; + Status = AE_OK; + } + else + { + sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, + AcpiUtGetTypeName (Node->Type)); + AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); + return_ACPI_STATUS (AE_OK); + } + } else { /* Valid error, object already exists */ @@ -818,8 +875,8 @@ LdNamespace2Begin ( /* Get the NS node associated with the target. It must exist. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &TargetNode); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &TargetNode); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -832,9 +889,9 @@ LdNamespace2Begin ( * This prevents more errors later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, - ACPI_TYPE_ANY, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, - WalkState, &(Node)); + ACPI_TYPE_ANY, + ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, + WalkState, &(Node)); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/asllookup.c b/sys/contrib/dev/acpica/compiler/asllookup.c index a527a38..3e216cc 100644 --- a/sys/contrib/dev/acpica/compiler/asllookup.c +++ b/sys/contrib/dev/acpica/compiler/asllookup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -119,8 +119,73 @@ LkIsObjectUsed ( { ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); ACPI_NAMESPACE_NODE *Next; + ASL_METHOD_LOCAL *MethodLocals; + ASL_METHOD_LOCAL *MethodArgs; + UINT32 i; + if (Node->Type == ACPI_TYPE_METHOD) + { + if (!Node->Op || !Node->MethodLocals) + { + return (AE_OK); + } + + MethodLocals = (ASL_METHOD_LOCAL *) Node->MethodLocals; + MethodArgs = (ASL_METHOD_LOCAL *) Node->MethodArgs; + + /* + * Analysis of LocalX variables + */ + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + /* Warn for Locals that are set but never referenced */ + + if ((MethodLocals[i].Flags & ASL_LOCAL_INITIALIZED) && + (!(MethodLocals[i].Flags & ASL_LOCAL_REFERENCED))) + { + sprintf (MsgBuffer, "Local%u", i); + AslError (ASL_WARNING, ASL_MSG_LOCAL_NOT_USED, + MethodLocals[i].Op, MsgBuffer); + } + } + + /* + * Analysis of ArgX variables (standard method arguments, + * and remaining unused ArgX can also be used as locals) + */ + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + if (MethodArgs[i].Flags & ASL_ARG_IS_LOCAL) + { + /* Warn if ArgX is being used as a local, but not referenced */ + + if ((MethodArgs[i].Flags & ASL_ARG_INITIALIZED) && + (!(MethodArgs[i].Flags & ASL_ARG_REFERENCED))) + { + sprintf (MsgBuffer, "Arg%u", i); + AslError (ASL_WARNING, ASL_MSG_ARG_AS_LOCAL_NOT_USED, + MethodArgs[i].Op, MsgBuffer); + } + } + else + { + /* + * Remark if a normal method ArgX is not referenced. + * We ignore the predefined methods since often, not + * all arguments are needed or used. + */ + if ((Node->Name.Ascii[0] != '_') && + (!(MethodArgs[i].Flags & ASL_ARG_REFERENCED))) + { + sprintf (MsgBuffer, "Arg%u", i); + AslError (ASL_REMARK, ASL_MSG_ARG_NOT_USED, + MethodArgs[i].Op, MsgBuffer); + } + } + } + } + /* Referenced flag is set during the namespace xref */ if (Node->Flags & ANOBJ_IS_REFERENCED) @@ -142,6 +207,7 @@ LkIsObjectUsed ( case ACPI_TYPE_POWER: case ACPI_TYPE_THERMAL: case ACPI_TYPE_LOCAL_RESOURCE: + case ACPI_TYPE_LOCAL_RESOURCE_FIELD: /* Names assigned to descriptor elements */ return (AE_OK); @@ -162,8 +228,8 @@ LkIsObjectUsed ( * Issue a remark even if it is a reserved name (starts * with an underscore). */ - sprintf (MsgBuffer, "Name is within method [%4.4s]", - Next->Name.Ascii); + sprintf (MsgBuffer, "Name [%4.4s] is within a method [%4.4s]", + Node->Name.Ascii, Next->Name.Ascii); AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), MsgBuffer); return (AE_OK); diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c index 99745ad..25c7b9a 100644 --- a/sys/contrib/dev/acpica/compiler/aslmain.c +++ b/sys/contrib/dev/acpica/compiler/aslmain.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,36 +73,6 @@ static void AslInitialize ( void); -UINT8 -AcpiIsBigEndianMachine ( - void); - - -/******************************************************************************* - * - * FUNCTION: AcpiIsBigEndianMachine - * - * PARAMETERS: None - * - * RETURN: TRUE if machine is big endian - * FALSE if machine is little endian - * - * DESCRIPTION: Detect whether machine is little endian or big endian. - * - ******************************************************************************/ - -UINT8 -AcpiIsBigEndianMachine ( - void) -{ - union { - UINT32 Integer; - UINT8 Bytes[4]; - } Overlay = {0xFF000000}; - - return (Overlay.Bytes[0]); /* Returns 0xFF (TRUE) for big endian */ -} - /******************************************************************************* * @@ -127,7 +97,8 @@ Usage ( printf ("\nGeneral:\n"); ACPI_OPTION ("-@ <file>", "Specify command file"); ACPI_OPTION ("-I <dir>", "Specify additional include directory"); - ACPI_OPTION ("-T <sig>|ALL|*", "Create table template file for ACPI <Sig>"); + ACPI_OPTION ("-T <sig list>|ALL", "Create ACPI table template/example files"); + ACPI_OPTION ("-T <count>", "Emit DSDT and <count> SSDTs to same file"); ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); ACPI_OPTION ("-v", "Display compiler version"); ACPI_OPTION ("-vo", "Enable optimization comments"); @@ -160,6 +131,7 @@ Usage ( ACPI_OPTION ("-of", "Disable constant folding"); ACPI_OPTION ("-oi", "Disable integer optimization to Zero/One/Ones"); ACPI_OPTION ("-on", "Disable named reference string optimization"); + ACPI_OPTION ("-ot", "Disable typechecking"); ACPI_OPTION ("-cr", "Disable Resource Descriptor error checking"); ACPI_OPTION ("-in", "Ignore NoOp operators"); ACPI_OPTION ("-r <revision>", "Override table header Revision (1-255)"); @@ -175,6 +147,7 @@ Usage ( ACPI_OPTION ("-lm", "Create hardware summary map file (*.map)"); ACPI_OPTION ("-ln", "Create namespace file (*.nsp)"); ACPI_OPTION ("-ls", "Create combined source file (expanded includes) (*.src)"); + ACPI_OPTION ("-lx", "Create cross-reference file (*.xrf)"); printf ("\nData Table Compiler:\n"); ACPI_OPTION ("-G", "Compile custom table that contains generic operators"); @@ -192,6 +165,7 @@ Usage ( ACPI_OPTION ("-e <f1 f2 ...>", "Include ACPI table(s) for external symbol resolution"); ACPI_OPTION ("-fe <file>", "Specify external symbol declaration file"); ACPI_OPTION ("-in", "Ignore NoOp opcodes"); + ACPI_OPTION ("-l", "Disassemble to mixed ASL and AML code"); ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file"); printf ("\nDebug Options:\n"); @@ -202,7 +176,7 @@ Usage ( ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); ACPI_OPTION ("-m <size>", "Set internal line buffer size (in Kbytes)"); ACPI_OPTION ("-n", "Parse only, no output generation"); - ACPI_OPTION ("-ot", "Display compile times and statistics"); + ACPI_OPTION ("-oc", "Display compile times and statistics"); ACPI_OPTION ("-x <level>", "Set debug level for trace output"); ACPI_OPTION ("-z", "Do not insert new compiler ID for DataTables"); } @@ -261,7 +235,7 @@ AslSignalHandler ( /* Close all open files */ - Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */ + Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .pre file is same as source file */ for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++) { @@ -298,6 +272,14 @@ AslInitialize ( UINT32 i; + AcpiGbl_DmOpt_Verbose = FALSE; + + /* Default integer width is 64 bits */ + + AcpiGbl_IntegerBitWidth = 64; + AcpiGbl_IntegerNybbleWidth = 16; + AcpiGbl_IntegerByteWidth = 8; + for (i = 0; i < ASL_NUM_FILES; i++) { Gbl_Files[i].Handle = NULL; @@ -341,7 +323,7 @@ main ( * be little-endian, and support for big-endian machines needs to * be implemented. */ - if (AcpiIsBigEndianMachine ()) + if (UtIsBigEndianMachine ()) { fprintf (stderr, "iASL is not currently supported on big-endian machines.\n"); diff --git a/sys/contrib/dev/acpica/compiler/aslmap.c b/sys/contrib/dev/acpica/compiler/aslmap.c index 90252cb..e213336 100644 --- a/sys/contrib/dev/acpica/compiler/aslmap.c +++ b/sys/contrib/dev/acpica/compiler/aslmap.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -123,6 +123,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = { /*! [Begin] no source code translation (keep the table structure) */ + /* AML Opcode Value Flags Btype */ /* ACCESSAS */ OP_TABLE_ENTRY (AML_INT_ACCESSFIELD_OP, 0, 0, 0), /* ACCESSATTRIB_BLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_BLOCK, 0, 0), @@ -237,11 +238,12 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* GPIOINT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* GPIOIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* I2CSERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* I2CSERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* IF */ OP_TABLE_ENTRY (AML_IF_OP, 0, NODE_AML_PACKAGE, 0), /* INCLUDE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* INCLUDE_END */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* INCREMENT */ OP_TABLE_ENTRY (AML_INCREMENT_OP, 0, 0, ACPI_BTYPE_INTEGER), -/* INDEX */ OP_TABLE_ENTRY (AML_INDEX_OP, 0, 0, ACPI_BTYPE_REFERENCE), +/* INDEX */ OP_TABLE_ENTRY (AML_INDEX_OP, 0, 0, ACPI_BTYPE_REFERENCE_OBJECT), /* INDEXFIELD */ OP_TABLE_ENTRY (AML_INDEX_FIELD_OP, 0, NODE_AML_PACKAGE, 0), /* INTEGER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, ACPI_BTYPE_INTEGER), /* INTERRUPT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), @@ -312,23 +314,23 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* NOR */ OP_TABLE_ENTRY (AML_BIT_NOR_OP, 0, 0, ACPI_BTYPE_INTEGER), /* NOT */ OP_TABLE_ENTRY (AML_BIT_NOT_OP, 0, 0, ACPI_BTYPE_INTEGER), /* NOTIFY */ OP_TABLE_ENTRY (AML_NOTIFY_OP, 0, 0, 0), -/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER), -/* OBJECTTYPE_BFF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER_FIELD, 0, 0), -/* OBJECTTYPE_BUF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER, 0, 0), -/* OBJECTTYPE_DDB */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DDB_HANDLE, 0, 0), -/* OBJECTTYPE_DEV */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DEVICE, 0, 0), -/* OBJECTTYPE_EVT */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_EVENT, 0, 0), -/* OBJECTTYPE_FLD */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_FIELD_UNIT, 0, 0), -/* OBJECTTYPE_INT */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_INTEGER, 0, 0), -/* OBJECTTYPE_MTH */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_METHOD, 0, 0), -/* OBJECTTYPE_MTX */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_MUTEX, 0, 0), -/* OBJECTTYPE_OPR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_REGION, 0, 0), -/* OBJECTTYPE_PKG */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_PACKAGE, 0, 0), -/* OBJECTTYPE_POW */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_POWER, 0, 0), -/* OBJECTTYPE_PRO */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_PROCESSOR, 0, 0), -/* OBJECTTYPE_STR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_STRING, 0, 0), -/* OBJECTTYPE_THZ */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_THERMAL, 0, 0), -/* OBJECTTYPE_UNK */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_ANY, 0, 0), +/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_OBJECT_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER), +/* OBJECTTYPE_BFF */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_BUFFER_FIELD, 0, 0), +/* OBJECTTYPE_BUF */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_BUFFER, 0, 0), +/* OBJECTTYPE_DDB */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_DDB_HANDLE, 0, 0), +/* OBJECTTYPE_DEV */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_DEVICE, 0, 0), +/* OBJECTTYPE_EVT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_EVENT, 0, 0), +/* OBJECTTYPE_FLD */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_FIELD_UNIT, 0, 0), +/* OBJECTTYPE_INT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_INTEGER, 0, 0), +/* OBJECTTYPE_MTH */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_METHOD, 0, 0), +/* OBJECTTYPE_MTX */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_MUTEX, 0, 0), +/* OBJECTTYPE_OPR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_REGION, 0, 0), +/* OBJECTTYPE_PKG */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_PACKAGE, 0, 0), +/* OBJECTTYPE_POW */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_POWER, 0, 0), +/* OBJECTTYPE_PRO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_PROCESSOR, 0, 0), +/* OBJECTTYPE_STR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_STRING, 0, 0), +/* OBJECTTYPE_THZ */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_THERMAL, 0, 0), +/* OBJECTTYPE_UNK */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_ANY, 0, 0), /* OFFSET */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0), /* ONE */ OP_TABLE_ENTRY (AML_ONE_OP, 0, 0, ACPI_BTYPE_INTEGER), /* ONES */ OP_TABLE_ENTRY (AML_ONES_OP, 0, 0, ACPI_BTYPE_INTEGER), @@ -357,7 +359,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* RAW_DATA */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* READWRITETYPE_BOTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* READWRITETYPE_READONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), -/* REFOF */ OP_TABLE_ENTRY (AML_REF_OF_OP, 0, 0, ACPI_BTYPE_REFERENCE), +/* REFOF */ OP_TABLE_ENTRY (AML_REF_OF_OP, 0, 0, ACPI_BTYPE_REFERENCE_OBJECT), /* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_CMOS, 0, 0), /* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_EC, 0, 0), /* REGIONSPACE_FFIXEDHW */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_FIXED_HARDWARE, 0, 0), @@ -394,6 +396,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* SLAVEMODE_DEVICEINIT */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* SLEEP */ OP_TABLE_ENTRY (AML_SLEEP_OP, 0, 0, 0), /* SPISERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* SPISERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* STALL */ OP_TABLE_ENTRY (AML_STALL_OP, 0, 0, 0), /* STARTDEPENDENTFN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* STARTDEPENDENTFN_NOPRI */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), @@ -419,6 +422,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* TYPE_STATIC */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* TYPE_TRANSLATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* UART_SERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* UART_SERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* UNICODE */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, NODE_AML_PACKAGE, 0), /* UNLOAD */ OP_TABLE_ENTRY (AML_UNLOAD_OP, 0, 0, 0), /* UPDATERULE_ONES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ONES, 0, 0), @@ -478,6 +482,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* HORIZONTALOFFSET */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* PRINTF */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE), /* FPRINTF */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE), +/* ASLCODE */ OP_TABLE_ENTRY (0, 0, 0, 0) /*! [End] no source code translation !*/ }; diff --git a/sys/contrib/dev/acpica/compiler/aslmapenter.c b/sys/contrib/dev/acpica/compiler/aslmapenter.c index 87ad28a..8aa66b7 100644 --- a/sys/contrib/dev/acpica/compiler/aslmapenter.c +++ b/sys/contrib/dev/acpica/compiler/aslmapenter.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -239,7 +239,7 @@ MpCreateGpioInfo ( /* Sort on source DeviceName first */ while (NextGpio && - (ACPI_STRCMP (DeviceName, NextGpio->DeviceName) > 0)) + (strcmp (DeviceName, NextGpio->DeviceName) > 0)) { PrevGpio = NextGpio; NextGpio = NextGpio->Next; @@ -248,8 +248,8 @@ MpCreateGpioInfo ( /* Now sort on the PinNumber */ while (NextGpio && - (NextGpio->PinNumber < PinNumber) && - !ACPI_STRCMP (DeviceName, NextGpio->DeviceName)) + (NextGpio->PinNumber < PinNumber) && + !strcmp (DeviceName, NextGpio->DeviceName)) { PrevGpio = NextGpio; NextGpio = NextGpio->Next; @@ -316,7 +316,7 @@ MpCreateSerialInfo ( /* Sort on source DeviceName */ while (NextSerial && - (ACPI_STRCMP (DeviceName, NextSerial->DeviceName) > 0)) + (strcmp (DeviceName, NextSerial->DeviceName) > 0)) { PrevSerial = NextSerial; NextSerial = NextSerial->Next; @@ -326,7 +326,7 @@ MpCreateSerialInfo ( while (NextSerial && (NextSerial->Address < Address) && - !ACPI_STRCMP (DeviceName, NextSerial->DeviceName)) + !strcmp (DeviceName, NextSerial->DeviceName)) { PrevSerial = NextSerial; NextSerial = NextSerial->Next; diff --git a/sys/contrib/dev/acpica/compiler/aslmapoutput.c b/sys/contrib/dev/acpica/compiler/aslmapoutput.c index 622b1bd..c8cd545 100644 --- a/sys/contrib/dev/acpica/compiler/aslmapoutput.c +++ b/sys/contrib/dev/acpica/compiler/aslmapoutput.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -207,7 +207,7 @@ MpEmitGpioInfo ( /* Print header info for the controller itself */ if (!PrevDeviceName || - ACPI_STRCMP (PrevDeviceName, Info->DeviceName)) + strcmp (PrevDeviceName, Info->DeviceName)) { FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\nGPIO Controller: %-8s %-28s", @@ -360,7 +360,7 @@ MpEmitSerialInfo ( /* Print header info for the controller itself */ if (!PrevDeviceName || - ACPI_STRCMP (PrevDeviceName, Info->DeviceName)) + strcmp (PrevDeviceName, Info->DeviceName)) { FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ", Type); @@ -453,7 +453,7 @@ MpEmitDeviceTree ( /* Walk the namespace from the root */ (void) AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL); + ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL); } @@ -533,7 +533,7 @@ MpXrefDevices ( /* Walk the entire parse tree */ - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, MpNamespaceXrefBegin, NULL, Info); if (!Info->References) diff --git a/sys/contrib/dev/acpica/compiler/aslmaputils.c b/sys/contrib/dev/acpica/compiler/aslmaputils.c index 7b2e611..a9d5136 100644 --- a/sys/contrib/dev/acpica/compiler/aslmaputils.c +++ b/sys/contrib/dev/acpica/compiler/aslmaputils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.c b/sys/contrib/dev/acpica/compiler/aslmessages.c index c57fd2d..1545aba 100644 --- a/sys/contrib/dev/acpica/compiler/aslmessages.c +++ b/sys/contrib/dev/acpica/compiler/aslmessages.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -130,7 +130,7 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_HID_SUFFIX */ "_HID suffix must be all hex digits", /* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file", /* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file", -/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT version < 2)", +/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT or SSDT version < 2)", /* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode", /* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)", /* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)", @@ -224,7 +224,7 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_TAG_SMALLER */ "ResourceTag smaller than Field", /* ASL_MSG_TIMEOUT */ "Result is not used, possible operator timeout will be missed", /* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)", -/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT version < 2)", +/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT or SSDT version < 2)", /* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", /* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", /* ASL_MSG_UNSUPPORTED */ "Unsupported feature", @@ -235,7 +235,12 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_BUFFER_ALLOCATION */ "Could not allocate line buffer", /* ASL_MSG_MISSING_DEPENDENCY */ "Missing dependency", /* ASL_MSG_ILLEGAL_FORWARD_REF */ "Illegal forward reference within a method", -/* ASL_MSG_ILLEGAL_METHOD_REF */ "Illegal reference across two methods" +/* ASL_MSG_ILLEGAL_METHOD_REF */ "Illegal reference across two methods", +/* ASL_MSG_LOCAL_NOT_USED */ "Method Local is set but never used", +/* ASL_MSG_ARG_AS_LOCAL_NOT_USED */ "Method Argument (as a local) is set but never used", +/* ASL_MSG_ARG_NOT_USED */ "Method Argument is never used", +/* ASL_MSG_CONSTANT_REQUIRED */ "Non-reducible expression", +/* ASL_MSG_CROSS_TABLE_SCOPE */ "Illegal open scope on external object from within DSDT" }; /* Table compiler */ diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.h b/sys/contrib/dev/acpica/compiler/aslmessages.h index 9837d54..0ee063f 100644 --- a/sys/contrib/dev/acpica/compiler/aslmessages.h +++ b/sys/contrib/dev/acpica/compiler/aslmessages.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -238,6 +238,11 @@ typedef enum ASL_MSG_MISSING_DEPENDENCY, ASL_MSG_ILLEGAL_FORWARD_REF, ASL_MSG_ILLEGAL_METHOD_REF, + ASL_MSG_LOCAL_NOT_USED, + ASL_MSG_ARG_AS_LOCAL_NOT_USED, + ASL_MSG_ARG_NOT_USED, + ASL_MSG_CONSTANT_REQUIRED, + ASL_MSG_CROSS_TABLE_SCOPE, /* These messages are used by the Data Table compiler only */ diff --git a/sys/contrib/dev/acpica/compiler/aslmethod.c b/sys/contrib/dev/acpica/compiler/aslmethod.c index fa9216e..b16982a 100644 --- a/sys/contrib/dev/acpica/compiler/aslmethod.c +++ b/sys/contrib/dev/acpica/compiler/aslmethod.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ /* Local prototypes */ -void +static void MtCheckNamedObjectInMethod ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo); @@ -93,6 +93,13 @@ MtMethodAnalysisWalkBegin ( UINT8 ActualArgs = 0; + /* Build cross-reference output file if requested */ + + if (Gbl_CrossReferenceOutput) + { + OtXrefWalkPart1 (Op, Level, MethodInfo); + } + switch (Op->Asl.ParseOpcode) { case PARSEOP_METHOD: @@ -101,7 +108,7 @@ MtMethodAnalysisWalkBegin ( /* Create and init method info */ - MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); + MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); MethodInfo->Next = WalkInfo->MethodStack; MethodInfo->Op = Op; @@ -186,7 +193,9 @@ MtMethodAnalysisWalkBegin ( NextParamType = NextType->Asl.Child; while (NextParamType) { - MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType); + MethodInfo->ValidArgTypes[ActualArgs] |= + AnMapObjTypeToBtype (NextParamType); + NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; NextParamType = NextParamType->Asl.Next; } @@ -195,6 +204,7 @@ MtMethodAnalysisWalkBegin ( { MethodInfo->ValidArgTypes[ActualArgs] = AnMapObjTypeToBtype (NextType); + NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; ActualArgs++; } @@ -251,11 +261,12 @@ MtMethodAnalysisWalkBegin ( * Local was used outside a control method, or there was an error * in the method declaration. */ - AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); + AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, + Op, Op->Asl.ExternalName); return (AE_ERROR); } - RegisterNumber = (Op->Asl.AmlOpcode & 0x000F); + RegisterNumber = (Op->Asl.AmlOpcode & 0x0007); /* * If the local is being used as a target, mark the local @@ -294,7 +305,8 @@ MtMethodAnalysisWalkBegin ( * Arg was used outside a control method, or there was an error * in the method declaration. */ - AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); + AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, + Op, Op->Asl.ExternalName); return (AE_ERROR); } @@ -317,7 +329,7 @@ MtMethodAnalysisWalkBegin ( * The only operator that accepts an uninitialized value is ObjectType() */ else if ((!MethodInfo->ArgInitialized[RegisterNumber]) && - (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) + (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) { AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName); } @@ -394,10 +406,8 @@ MtMethodAnalysisWalkBegin ( case PARSEOP_DEVICE: - Next = Op->Asl.Child; - - if (!ApFindNameInScope (METHOD_NAME__HID, Next) && - !ApFindNameInScope (METHOD_NAME__ADR, Next)) + if (!ApFindNameInDeviceTree (METHOD_NAME__HID, Op) && + !ApFindNameInDeviceTree (METHOD_NAME__ADR, Op)) { AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, "Device object requires a _HID or _ADR in same scope"); @@ -418,7 +428,8 @@ MtMethodAnalysisWalkBegin ( i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); if (i < ACPI_VALID_RESERVED_NAME_MAX) { - AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, + Op, Op->Asl.ExternalName); } break; @@ -430,7 +441,7 @@ MtMethodAnalysisWalkBegin ( /* Special typechecking for _HID */ - if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg)) + if (!strcmp (METHOD_NAME__HID, Op->Asl.NameSeg)) { Next = Op->Asl.Child->Asl.Next; AnCheckId (Next, ASL_TYPE_HID); @@ -438,7 +449,7 @@ MtMethodAnalysisWalkBegin ( /* Special typechecking for _CID */ - else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg)) + else if (!strcmp (METHOD_NAME__CID, Op->Asl.NameSeg)) { Next = Op->Asl.Child->Asl.Next; @@ -487,7 +498,7 @@ MtMethodAnalysisWalkBegin ( * ******************************************************************************/ -void +static void MtCheckNamedObjectInMethod ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo) @@ -495,9 +506,10 @@ MtCheckNamedObjectInMethod ( const ACPI_OPCODE_INFO *OpInfo; - /* We don't care about actual method declarations */ + /* We don't care about actual method declarations or scopes */ - if (Op->Asl.AmlOpcode == AML_METHOD_OP) + if ((Op->Asl.AmlOpcode == AML_METHOD_OP) || + (Op->Asl.AmlOpcode == AML_SCOPE_OP)) { return; } @@ -677,7 +689,8 @@ MtMethodAnalysisWalkEnd ( */ if (Op->Asl.Next) { - AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL); + AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, + Op->Asl.Next, NULL); } break; diff --git a/sys/contrib/dev/acpica/compiler/aslnamesp.c b/sys/contrib/dev/acpica/compiler/aslnamesp.c index 720d394..f8149c5 100644 --- a/sys/contrib/dev/acpica/compiler/aslnamesp.c +++ b/sys/contrib/dev/acpica/compiler/aslnamesp.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,16 +124,16 @@ NsDisplayNamespace ( /* Walk entire namespace from the root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, NsDoOneNamespaceObject, NULL, - NULL, NULL); + ACPI_UINT32_MAX, FALSE, NsDoOneNamespaceObject, NULL, + NULL, NULL); /* Print the full pathname for each namespace node */ FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\nNamespace pathnames\n\n"); Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, NsDoOnePathname, NULL, - NULL, NULL); + ACPI_UINT32_MAX, FALSE, NsDoOnePathname, NULL, + NULL, NULL); return (Status); } @@ -168,8 +168,7 @@ NsDoOneNamespaceObject ( FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5u [%u] %*s %4.4s - %s", Gbl_NumNamespaceObjects, Level, (Level * 3), " ", - &Node->Name, - AcpiUtGetTypeName (Node->Type)); + &Node->Name, AcpiUtGetTypeName (Node->Type)); Op = Node->Op; ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object); @@ -218,11 +217,13 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value 0x%8.8X%8.8X]", ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); @@ -234,11 +235,13 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value \"%s\"]", Op->Asl.Value.String); @@ -251,6 +254,7 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Offset 0x%04X Length 0x%04X bits]", Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer); @@ -303,11 +307,13 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + Op = Op->Asl.Child; if ((Op->Asl.ParseOpcode == PARSEOP_BYTECONST) || @@ -325,11 +331,13 @@ NsDoOneNamespaceObject ( { Op = Op->Asl.Child; } + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + Op = Op->Asl.Child; if (Op && (Op->Asl.ParseOpcode == PARSEOP_INTEGER)) @@ -409,7 +417,7 @@ NsDoOnePathname ( TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (Node, &TargetPath); + Status = AcpiNsHandleToPathname (Node, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { return (Status); @@ -417,6 +425,5 @@ NsDoOnePathname ( FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%s\n", TargetPath.Pointer); ACPI_FREE (TargetPath.Pointer); - return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/asloffset.c b/sys/contrib/dev/acpica/compiler/asloffset.c index 14f7e95..bb57d35 100644 --- a/sys/contrib/dev/acpica/compiler/asloffset.c +++ b/sys/contrib/dev/acpica/compiler/asloffset.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -363,7 +363,7 @@ LsEmitOffsetTableEntry ( /* Get the full pathname to the namespace node */ TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (Node, &TargetPath); + Status = AcpiNsHandleToPathname (Node, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { return; diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c index d4dbbe3..41de07e 100644 --- a/sys/contrib/dev/acpica/compiler/aslopcodes.c +++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,62 +68,9 @@ OpcDoEisaId ( ACPI_PARSE_OBJECT *Op); static void -OpcDoPld ( - ACPI_PARSE_OBJECT *Op); - -static void OpcDoUuId ( ACPI_PARSE_OBJECT *Op); -static UINT8 * -OpcEncodePldBuffer ( - ACPI_PLD_INFO *PldInfo); - - -/* ToPld strings */ - -static char *AslPldPanelList[] = -{ - "TOP", - "BOTTOM", - "LEFT", - "RIGHT", - "FRONT", - "BACK", - "UNKNOWN", - NULL -}; - -static char *AslPldVerticalPositionList[] = -{ - "UPPER", - "CENTER", - "LOWER", - NULL -}; - -static char *AslPldHorizontalPositionList[] = -{ - "LEFT", - "CENTER", - "RIGHT", - NULL -}; - -static char *AslPldShapeList[] = -{ - "ROUND", - "OVAL", - "SQUARE", - "VERTICALRECTANGLE", - "HORIZONTALRECTANGLE", - "VERTICALTRAPEZOID", - "HORIZONTALTRAPEZOID", - "UNKNOWN", - "CHAMFERED", - NULL -}; - /******************************************************************************* * @@ -260,7 +207,7 @@ OpcSetOptimalIntegerSize ( */ if (Op->Asl.Parent && Op->Asl.Parent->Asl.Parent && - (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) + (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) { return (0); } @@ -330,11 +277,13 @@ OpcSetOptimalIntegerSize ( Op->Asl.AmlOpcode = AML_BYTE_OP; return (1); } + if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX) { Op->Asl.AmlOpcode = AML_WORD_OP; return (2); } + if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX) { Op->Asl.AmlOpcode = AML_DWORD_OP; @@ -398,6 +347,7 @@ OpcDoAccessAs ( { AttribOp->Asl.Value.Integer = 0; } + AttribOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; AttribOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; @@ -486,21 +436,21 @@ OpcDoConnection ( * First Child -> BufferLength * Second Child -> Descriptor Buffer (raw byte data) */ - BufferOp->Asl.ParseOpcode = PARSEOP_BUFFER; - BufferOp->Asl.AmlOpcode = AML_BUFFER_OP; - BufferOp->Asl.CompileFlags = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC; + BufferOp->Asl.ParseOpcode = PARSEOP_BUFFER; + BufferOp->Asl.AmlOpcode = AML_BUFFER_OP; + BufferOp->Asl.CompileFlags = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC; UtSetParseOpName (BufferOp); - BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; + BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; BufferLengthOp->Asl.Value.Integer = Rnode->BufferLength; (void) OpcSetOptimalIntegerSize (BufferLengthOp); UtSetParseOpName (BufferLengthOp); - BufferDataOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; - BufferDataOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN; - BufferDataOp->Asl.AmlOpcodeLength = 0; - BufferDataOp->Asl.AmlLength = Rnode->BufferLength; - BufferDataOp->Asl.Value.Buffer = (UINT8 *) Rnode; + BufferDataOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + BufferDataOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN; + BufferDataOp->Asl.AmlOpcodeLength = 0; + BufferDataOp->Asl.AmlLength = Rnode->BufferLength; + BufferDataOp->Asl.Value.Buffer = (UINT8 *) Rnode; UtSetParseOpName (BufferDataOp); } @@ -564,8 +514,8 @@ OpcDoUnicode ( * Just set the buffer size node to be the buffer length, regardless * of whether it was previously an integer or a default_arg placeholder */ - BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; - BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; + BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; + BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; BufferLengthOp->Asl.Value.Integer = Length; UtSetParseOpName (BufferLengthOp); @@ -573,11 +523,11 @@ OpcDoUnicode ( /* The Unicode string is a raw data buffer */ - InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString; - InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - InitializerOp->Asl.AmlLength = Length; - InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; - InitializerOp->Asl.Child = NULL; + InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString; + InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + InitializerOp->Asl.AmlLength = Length; + InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + InitializerOp->Asl.Child = NULL; UtSetParseOpName (InitializerOp); } @@ -636,7 +586,7 @@ OpcDoEisaId ( * The EISAID string must be exactly 7 characters and of the form * "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001") */ - if (ACPI_STRLEN (InString) != 7) + if (strlen (InString) != 7) { Status = AE_BAD_PARAMETER; } @@ -706,695 +656,6 @@ OpcDoEisaId ( /******************************************************************************* * - * FUNCTION: OpcEncodePldBuffer - * - * PARAMETERS: PldInfo - _PLD buffer struct (Using local struct) - * - * RETURN: Encode _PLD buffer suitable for return value from _PLD - * - * DESCRIPTION: Bit-packs a _PLD buffer struct. - * - ******************************************************************************/ - -static UINT8 * -OpcEncodePldBuffer ( - ACPI_PLD_INFO *PldInfo) -{ - UINT32 *Buffer; - UINT32 Dword; - - - Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE); - if (!Buffer) - { - return (NULL); - } - - /* First 32 bits */ - - Dword = 0; - ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision); - ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor); - ACPI_PLD_SET_RED (&Dword, PldInfo->Red); - ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green); - ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue); - ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword); - - /* Second 32 bits */ - - Dword = 0; - ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width); - ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height); - ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword); - - /* Third 32 bits */ - - Dword = 0; - ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible); - ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock); - ACPI_PLD_SET_LID (&Dword, PldInfo->Lid); - ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel); - ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition); - ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition); - ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape); - ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation); - ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken); - ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition); - ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay); - ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword); - - /* Fourth 32 bits */ - - Dword = 0; - ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable); - ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired); - ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber); - ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber); - ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference); - ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation); - ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order); - ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword); - - if (PldInfo->Revision >= 2) - { - /* Fifth 32 bits */ - - Dword = 0; - ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset); - ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset); - ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword); - } - - return (ACPI_CAST_PTR (UINT8, Buffer)); -} - - -/******************************************************************************* - * - * FUNCTION: OpcStrupr (strupr) - * - * PARAMETERS: SrcString - The source string to convert - * - * RETURN: None - * - * DESCRIPTION: Convert string to uppercase - * - * NOTE: This is not a POSIX function, so it appears here, not in utclib.c - * - ******************************************************************************/ - -static void -OpcStrupr ( - char *SrcString) -{ - char *String; - - - if (!SrcString) - { - return; - } - - /* Walk entire string, uppercasing the letters */ - - for (String = SrcString; *String; String++) - { - *String = (char) toupper ((int) *String); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: OpcFindName - * - * PARAMETERS: List - Array of char strings to be searched - * Name - Char string to string for - * Index - Index value to set if found - * - * RETURN: TRUE if any names matched, FALSE otherwise - * - * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to - * equivalent parameter value. - * - ******************************************************************************/ - -static BOOLEAN -OpcFindName ( - char **List, - char *Name, - UINT64 *Index) -{ - char *Str; - UINT32 i; - - - OpcStrupr (Name); - - for (i = 0, Str = List[0]; Str; i++, Str = List[i]) - { - if (!(ACPI_STRNCMP (Str, Name, ACPI_STRLEN (Name)))) - { - *Index = i; - return (TRUE); - } - } - - return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION: OpcDoPld - * - * PARAMETERS: Op - Parse node - * - * RETURN: None - * - * DESCRIPTION: Convert ToPLD macro to 20-byte buffer - * - ******************************************************************************/ - -static void -OpcDoPld ( - ACPI_PARSE_OBJECT *Op) -{ - UINT8 *Buffer; - ACPI_PARSE_OBJECT *Node; - ACPI_PLD_INFO PldInfo; - ACPI_PARSE_OBJECT *NewOp; - - - if (!Op) - { - AslError(ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL); - return; - } - - if (Op->Asl.ParseOpcode != PARSEOP_TOPLD) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL); - return; - } - - Buffer = UtLocalCalloc (ACPI_PLD_BUFFER_SIZE); - if (!Buffer) - { - AslError(ASL_ERROR, ASL_MSG_BUFFER_ALLOCATION, Op, NULL); - return; - } - - ACPI_MEMSET (&PldInfo, 0, sizeof (ACPI_PLD_INFO)); - - Node = Op->Asl.Child; - while (Node) - { - switch (Node->Asl.ParseOpcode) - { - case PARSEOP_PLD_REVISION: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 127) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.Revision = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_IGNORECOLOR: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.IgnoreColor = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_RED: - case PARSEOP_PLD_GREEN: - case PARSEOP_PLD_BLUE: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 255) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_RED) - { - PldInfo.Red = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else if (Node->Asl.ParseOpcode == PARSEOP_PLD_GREEN) - { - PldInfo.Green = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_BLUE */ - { - PldInfo.Blue = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - break; - - case PARSEOP_PLD_WIDTH: - case PARSEOP_PLD_HEIGHT: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 65535) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_WIDTH) - { - PldInfo.Width = (UINT16) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_HEIGHT */ - { - PldInfo.Height = (UINT16) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_USERVISIBLE: - case PARSEOP_PLD_DOCK: - case PARSEOP_PLD_LID: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE) - { - PldInfo.UserVisible = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else if (Node->Asl.ParseOpcode == PARSEOP_PLD_DOCK) - { - PldInfo.Dock = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else - { - PldInfo.Lid = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_PANEL: - - if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) - { - if (Node->Asl.Child->Asl.Value.Integer > 6) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - else /* PARSEOP_STRING */ - { - if (!OpcFindName(AslPldPanelList, - Node->Asl.Child->Asl.Value.String, - &Node->Asl.Child->Asl.Value.Integer)) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); - break; - } - } - - PldInfo.Panel = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_VERTICALPOSITION: - - if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) - { - if (Node->Asl.Child->Asl.Value.Integer > 2) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - else /* PARSEOP_STRING */ - { - if (!OpcFindName(AslPldVerticalPositionList, - Node->Asl.Child->Asl.Value.String, - &Node->Asl.Child->Asl.Value.Integer)) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); - break; - } - } - - PldInfo.VerticalPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_HORIZONTALPOSITION: - - if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) - { - if (Node->Asl.Child->Asl.Value.Integer > 2) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - else /* PARSEOP_STRING */ - { - if (!OpcFindName(AslPldHorizontalPositionList, - Node->Asl.Child->Asl.Value.String, - &Node->Asl.Child->Asl.Value.Integer)) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); - break; - } - } - - PldInfo.HorizontalPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_SHAPE: - - if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) - { - if (Node->Asl.Child->Asl.Value.Integer > 8) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - else /* PARSEOP_STRING */ - { - if (!OpcFindName(AslPldShapeList, - Node->Asl.Child->Asl.Value.String, - &Node->Asl.Child->Asl.Value.Integer)) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); - break; - } - } - - PldInfo.Shape = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_GROUPORIENTATION: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.GroupOrientation = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_GROUPTOKEN: - case PARSEOP_PLD_GROUPPOSITION: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 255) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN) - { - PldInfo.GroupToken = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_GROUPPOSITION */ - { - PldInfo.GroupPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_BAY: - case PARSEOP_PLD_EJECTABLE: - case PARSEOP_PLD_EJECTREQUIRED: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_BAY) - { - PldInfo.Bay = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else if (Node->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE) - { - PldInfo.Ejectable = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_EJECTREQUIRED */ - { - PldInfo.OspmEjectRequired = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_CABINETNUMBER: - case PARSEOP_PLD_CARDCAGENUMBER: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 255) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER) - { - PldInfo.CabinetNumber = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_CARDCAGENUMBER */ - { - PldInfo.CardCageNumber = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_REFERENCE: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.Reference = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_ROTATION: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 7) - { - switch (Node->Asl.Child->Asl.Value.Integer) - { - case 45: - - Node->Asl.Child->Asl.Value.Integer = 1; - break; - - case 90: - - Node->Asl.Child->Asl.Value.Integer = 2; - break; - - case 135: - - Node->Asl.Child->Asl.Value.Integer = 3; - break; - - case 180: - - Node->Asl.Child->Asl.Value.Integer = 4; - break; - - case 225: - - Node->Asl.Child->Asl.Value.Integer = 5; - break; - - case 270: - - Node->Asl.Child->Asl.Value.Integer = 6; - break; - - case 315: - - Node->Asl.Child->Asl.Value.Integer = 7; - break; - - default: - - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - - PldInfo.Rotation = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_ORDER: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 31) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.Order = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_VERTICALOFFSET: - case PARSEOP_PLD_HORIZONTALOFFSET: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 65535) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET) - { - PldInfo.VerticalOffset = (UINT16) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_HORIZONTALOFFSET */ - { - PldInfo.HorizontalOffset = (UINT16) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - default: - - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - Node = Node->Asl.Next; - } - - Buffer = OpcEncodePldBuffer(&PldInfo); - - /* Change Op to a Buffer */ - - Op->Asl.ParseOpcode = PARSEOP_BUFFER; - Op->Common.AmlOpcode = AML_BUFFER_OP; - - /* Disable further optimization */ - - Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; - UtSetParseOpName (Op); - - /* Child node is the buffer length */ - - NewOp = TrAllocateNode (PARSEOP_INTEGER); - - NewOp->Asl.AmlOpcode = AML_BYTE_OP; - NewOp->Asl.Value.Integer = 20; - NewOp->Asl.Parent = Op; - - Op->Asl.Child = NewOp; - Op = NewOp; - - /* Peer to the child is the raw buffer data */ - - NewOp = TrAllocateNode (PARSEOP_RAW_DATA); - NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - NewOp->Asl.AmlLength = 20; - NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); - NewOp->Asl.Parent = Op->Asl.Parent; - - Op->Asl.Next = NewOp; -} - - -/******************************************************************************* - * * FUNCTION: OpcDoUuId * * PARAMETERS: Op - Parse node @@ -1442,9 +703,9 @@ OpcDoUuId ( NewOp = TrAllocateNode (PARSEOP_INTEGER); - NewOp->Asl.AmlOpcode = AML_BYTE_OP; + NewOp->Asl.AmlOpcode = AML_BYTE_OP; NewOp->Asl.Value.Integer = 16; - NewOp->Asl.Parent = Op; + NewOp->Asl.Parent = Op; Op->Asl.Child = NewOp; Op = NewOp; @@ -1452,10 +713,10 @@ OpcDoUuId ( /* Peer to the child is the raw buffer data */ NewOp = TrAllocateNode (PARSEOP_RAW_DATA); - NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - NewOp->Asl.AmlLength = 16; - NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); - NewOp->Asl.Parent = Op->Asl.Parent; + NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + NewOp->Asl.AmlLength = 16; + NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); + NewOp->Asl.Parent = Op->Asl.Parent; Op->Asl.Next = NewOp; } @@ -1551,14 +812,16 @@ OpcGenerateAmlOpcode ( case PARSEOP_INCLUDE: - Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; Gbl_HasIncludeFiles = TRUE; break; case PARSEOP_EXTERNAL: - Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + if (Gbl_DoExternals == FALSE) + { + Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + } break; case PARSEOP_TIMER: diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c index b2972d4..68e760c 100644 --- a/sys/contrib/dev/acpica/compiler/asloperands.c +++ b/sys/contrib/dev/acpica/compiler/asloperands.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -188,14 +188,16 @@ OpnDoMethod ( { AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); } + Concurrency = (UINT8) Next->Asl.Value.Integer; } /* Put the bits in their proper places */ - MethodFlags = (UINT8) ((NumArgs & 0x7) | - ((Serialized & 0x1) << 3) | - ((Concurrency & 0xF) << 4)); + MethodFlags = (UINT8) + ((NumArgs & 0x7) | + ((Serialized & 0x1) << 3) | + ((Concurrency & 0xF) << 4)); /* Use the last node for the combined flags byte */ @@ -272,9 +274,9 @@ OpnDoFieldCommon ( /* Set the node to RAW_DATA */ Next->Asl.Value.Integer = FieldFlags; - Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; - Next->Asl.AmlLength = 1; - Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; + Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; + Next->Asl.AmlLength = 1; + Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; /* Process the FieldUnitList */ @@ -345,8 +347,8 @@ OpnDoFieldCommon ( /* Named or reserved field entry */ - PkgLengthNode = Next->Asl.Child; - NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer; + PkgLengthNode = Next->Asl.Child; + NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer; CurrentBitOffset += NewBitOffset; /* Save the current AccessAs value for error checking later */ @@ -601,9 +603,9 @@ OpnDoBuffer ( { /* For buffers, this is a list of raw bytes */ - InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; - InitializerOp->Asl.AmlLength = 1; - InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; + InitializerOp->Asl.AmlLength = 1; + InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; BufferLength++; InitializerOp = ASL_GET_PEER_NODE (InitializerOp); @@ -618,9 +620,9 @@ OpnDoBuffer ( */ BufferLength = strlen (InitializerOp->Asl.Value.String) + 1; - InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - InitializerOp->Asl.AmlLength = BufferLength; - InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + InitializerOp->Asl.AmlLength = BufferLength; + InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; break; case PARSEOP_RAW_DATA: @@ -636,7 +638,7 @@ OpnDoBuffer ( AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp, "Unknown buffer initializer opcode"); printf ("Unknown buffer initializer opcode [%s]\n", - UtGetOpName (InitializerOp->Asl.ParseOpcode)); + UtGetOpName (InitializerOp->Asl.ParseOpcode)); return; } @@ -660,8 +662,8 @@ OpnDoBuffer ( * Just set the buffer size node to be the buffer length, regardless * of whether it was previously an integer or a default_arg placeholder */ - BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; - BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; + BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; + BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; BufferLengthOp->Asl.Value.Integer = BufferLength; (void) OpcSetOptimalIntegerSize (BufferLengthOp); @@ -839,9 +841,9 @@ OpnDoLoadTable ( Next = Next->Asl.Next; if (Next->Asl.ParseOpcode == PARSEOP_ZERO) { - Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; - Next->Asl.Value.String = "\\"; - Next->Asl.AmlLength = 2; + Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; + Next->Asl.Value.String = "\\"; + Next->Asl.AmlLength = 2; OpcGenerateAmlOpcode (Next); } @@ -923,6 +925,7 @@ OpnDoDefinitionBlock ( Gbl_OutputFilenamePrefix = Filename; UtConvertBackslashes (Gbl_OutputFilenamePrefix); } + Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; /* Signature */ @@ -932,13 +935,13 @@ OpnDoDefinitionBlock ( if (Child->Asl.Value.String) { Gbl_TableSignature = Child->Asl.Value.String; - if (ACPI_STRLEN (Gbl_TableSignature) != 4) + if (strlen (Gbl_TableSignature) != ACPI_NAME_SIZE) { AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, - "Length not exactly 4"); + "Length is not exactly 4"); } - for (i = 0; i < 4; i++) + for (i = 0; i < ACPI_NAME_SIZE; i++) { if (!isalnum ((int) Gbl_TableSignature[i])) { @@ -967,9 +970,9 @@ OpnDoDefinitionBlock ( Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; if (Child->Asl.Value.String) { - Length = ACPI_STRLEN (Child->Asl.Value.String); + Length = strlen (Child->Asl.Value.String); Gbl_TableId = UtStringCacheCalloc (Length + 1); - ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String); + strcpy (Gbl_TableId, Child->Asl.Value.String); /* * Convert anything non-alphanumeric to an underscore. This @@ -1046,15 +1049,12 @@ OpnAttachNameToNode ( ACPI_PARSE_OBJECT *Child = NULL; - if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) - { - Child = UtGetArg (Op, 0); - } - else switch (Op->Asl.AmlOpcode) + switch (Op->Asl.AmlOpcode) { case AML_DATA_REGION_OP: case AML_DEVICE_OP: case AML_EVENT_OP: + case AML_EXTERNAL_OP: case AML_METHOD_OP: case AML_MUTEX_OP: case AML_REGION_OP: @@ -1131,7 +1131,7 @@ OpnGenerateAmlOperands ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: OpnDoDefinitionBlock (Op); break; @@ -1185,9 +1185,6 @@ OpnGenerateAmlOperands ( case PARSEOP_NAMESTRING: case PARSEOP_METHODCALL: case PARSEOP_STRING_LITERAL: - - break; - default: break; diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c index 1079f9c..9c26d27 100644 --- a/sys/contrib/dev/acpica/compiler/aslopt.c +++ b/sys/contrib/dev/acpica/compiler/aslopt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ ACPI_MODULE_NAME ("aslopt") -static UINT32 OptTotal = 0; +static UINT32 OptTotal = 0; /* Local prototypes */ @@ -132,15 +132,15 @@ OptSearchToRoot ( * name in the search path before the one we want, the nodes will * not match, and we cannot use this optimization. */ - Path = &(((char *) TargetPath->Pointer)[TargetPath->Length - - ACPI_NAME_SIZE]), + Path = &(((char *) TargetPath->Pointer)[ + TargetPath->Length - ACPI_NAME_SIZE]), ScopeInfo.Scope.Node = CurrentNode; /* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */ Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &(Node)); + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { return (Status); @@ -168,12 +168,12 @@ OptSearchToRoot ( /* We must allocate a new string for the name (TargetPath gets deleted) */ *NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1); - ACPI_STRCPY (*NewPath, Path); + strcpy (*NewPath, Path); - if (ACPI_STRNCMP (*NewPath, "_T_", 3)) + if (strncmp (*NewPath, "_T_", 3)) { - AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op, - *NewPath); + AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, + Op, *NewPath); } return (AE_OK); @@ -217,7 +217,7 @@ OptBuildShortestPath ( UINT32 Index; UINT32 NumCarats; UINT32 i; - char *NewPath; + char *NewPathInternal; char *NewPathExternal; ACPI_NAMESPACE_NODE *Node; ACPI_GENERIC_STATE ScopeInfo; @@ -253,11 +253,11 @@ OptBuildShortestPath ( { /* Compare two single NameSegs */ + Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1; + if (!ACPI_COMPARE_NAME ( - &((char *) TargetPath->Pointer)[ - (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1], - &((char *) CurrentPath->Pointer)[ - (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1])) + &(ACPI_CAST_PTR (char, TargetPath->Pointer)) [Index], + &(ACPI_CAST_PTR (char, CurrentPath->Pointer)) [Index])) { /* Mismatch */ @@ -292,13 +292,13 @@ OptBuildShortestPath ( /* Determine how many prefix Carats are required */ NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) - - NumCommonSegments; + NumCommonSegments; /* * Construct a new target string */ - NewPathExternal = ACPI_ALLOCATE_ZEROED ( - TargetPath->Length + NumCarats + 1); + NewPathExternal = + ACPI_ALLOCATE_ZEROED (TargetPath->Length + NumCarats + 1); /* Insert the Carats into the Target string */ @@ -315,7 +315,8 @@ OptBuildShortestPath ( /* Special handling for exact subpath in a name declaration */ - if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length)) + if (IsDeclaration && SubPath && + (CurrentPath->Length > TargetPath->Length)) { /* * The current path is longer than the target, and the target is a @@ -341,7 +342,8 @@ OptBuildShortestPath ( Index = TargetPath->Length; } - ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]); + strcpy (&NewPathExternal[i], + &(ACPI_CAST_PTR (char, TargetPath->Pointer))[Index]); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal)); /* @@ -349,22 +351,24 @@ OptBuildShortestPath ( * string to make sure that this is in fact an optimization. If the * original string is already optimal, there is no point in continuing. */ - Status = AcpiNsInternalizeName (NewPathExternal, &NewPath); + Status = AcpiNsInternalizeName (NewPathExternal, &NewPathInternal); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Internalizing new NamePath", ASL_NO_ABORT); - ACPI_FREE (NewPathExternal); - return (Status); + goto Cleanup; } - if (ACPI_STRLEN (NewPath) >= AmlNameStringLength) + if (strlen (NewPathInternal) >= AmlNameStringLength) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " NOT SHORTER (New %u old %u)", - (UINT32) ACPI_STRLEN (NewPath), (UINT32) AmlNameStringLength)); - ACPI_FREE (NewPathExternal); - return (AE_NOT_FOUND); + (UINT32) strlen (NewPathInternal), + (UINT32) AmlNameStringLength)); + + ACPI_FREE (NewPathInternal); + Status = AE_NOT_FOUND; + goto Cleanup; } /* @@ -372,9 +376,9 @@ OptBuildShortestPath ( * looking for. This is simply a sanity check on the new * path that has been created. */ - Status = AcpiNsLookup (&ScopeInfo, NewPath, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); + Status = AcpiNsLookup (&ScopeInfo, NewPathInternal, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); if (ACPI_SUCCESS (Status)) { /* Found the namepath, but make sure the node is correct */ @@ -385,7 +389,7 @@ OptBuildShortestPath ( AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION, Op, NewPathExternal); - *ReturnNewPath = NewPath; + *ReturnNewPath = NewPathInternal; } else { @@ -401,11 +405,15 @@ OptBuildShortestPath ( { /* The lookup failed, we obviously cannot use this optimization */ + ACPI_FREE (NewPathInternal); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND")); AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op, "Not using optimized name - did not find node"); } +Cleanup: + ACPI_FREE (NewPathExternal); return (Status); } @@ -446,7 +454,7 @@ OptOptimizeNameDeclaration ( if (((CurrentNode == AcpiGbl_RootNode) || - (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) && + (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) && (ACPI_IS_ROOT_PREFIX (AmlNameString[0]))) { /* @@ -458,7 +466,7 @@ OptOptimizeNameDeclaration ( /* Debug output */ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, *NewPath, - NULL, &NewPathExternal); + NULL, &NewPathExternal); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Externalizing NamePath", @@ -474,8 +482,8 @@ OptOptimizeNameDeclaration ( * We know that we are at the root, so NULL is used for the scope. */ Status = AcpiNsLookup (NULL, *NewPath, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); if (ACPI_SUCCESS (Status)) { /* Found the namepath, but make sure the node is correct */ @@ -597,7 +605,7 @@ OptOptimizeNamePath ( * The original path must be longer than one NameSeg (4 chars) for there * to be any possibility that it can be optimized to a shorter string */ - AmlNameStringLength = ACPI_STRLEN (AmlNameString); + AmlNameStringLength = strlen (AmlNameString); if (AmlNameStringLength <= ACPI_NAME_SIZE) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, @@ -633,6 +641,7 @@ OptOptimizeNamePath ( { NextOp = NextOp->Asl.Parent; } + if (NextOp && NextOp->Asl.Node) { CurrentNode = NextOp->Asl.Node; @@ -655,31 +664,33 @@ OptOptimizeNamePath ( * format -- something we can easily manipulate */ TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (TargetNode, &TargetPath); + Status = AcpiNsHandleToPathname (TargetNode, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Getting Target NamePath", ASL_NO_ABORT); return_VOID; } + TargetPath.Length--; /* Subtract one for null terminator */ /* CurrentPath is the path to this scope (where we are in the namespace) */ CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath); + Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath, FALSE); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Getting Current NamePath", ASL_NO_ABORT); return_VOID; } + CurrentPath.Length--; /* Subtract one for null terminator */ /* Debug output only */ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString, - NULL, &ExternalNameString); + NULL, &ExternalNameString); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Externalizing NamePath", @@ -705,7 +716,7 @@ OptOptimizeNamePath ( * a reference. */ Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode, - TargetNode, AmlNameString, &NewPath); + TargetNode, AmlNameString, &NewPath); if (ACPI_FAILURE (Status)) { /* @@ -713,8 +724,8 @@ OptOptimizeNamePath ( * optimize the namestring with carats (up-arrow) */ Status = OptBuildShortestPath (Op, WalkState, CurrentNode, - TargetNode, &CurrentPath, &TargetPath, - AmlNameStringLength, 1, &NewPath); + TargetNode, &CurrentPath, &TargetPath, + AmlNameStringLength, 1, &NewPath); } } else @@ -726,7 +737,7 @@ OptOptimizeNamePath ( * NameSeg of the NamePath */ Status = OptSearchToRoot (Op, WalkState, CurrentNode, - TargetNode, &TargetPath, &NewPath); + TargetNode, &TargetPath, &NewPath); if (ACPI_FAILURE (Status)) { /* @@ -734,8 +745,8 @@ OptOptimizeNamePath ( * optimize the namestring with carats (up-arrow) */ Status = OptBuildShortestPath (Op, WalkState, CurrentNode, - TargetNode, &CurrentPath, &TargetPath, - AmlNameStringLength, 0, &NewPath); + TargetNode, &CurrentPath, &TargetPath, + AmlNameStringLength, 0, &NewPath); } } @@ -745,7 +756,7 @@ OptOptimizeNamePath ( */ if (ACPI_SUCCESS (Status)) { - HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath)); + HowMuchShorter = (AmlNameStringLength - strlen (NewPath)); OptTotal += HowMuchShorter; ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, @@ -761,12 +772,12 @@ OptOptimizeNamePath ( * (alias name) is the second operand */ Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath; - Op->Asl.Child->Asl.Next->Asl.AmlLength = ACPI_STRLEN (NewPath); + Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath); } else { Op->Asl.Child->Asl.Value.String = NewPath; - Op->Asl.Child->Asl.AmlLength = ACPI_STRLEN (NewPath); + Op->Asl.Child->Asl.AmlLength = strlen (NewPath); } } else if (Flags & AML_CREATE) @@ -781,14 +792,14 @@ OptOptimizeNamePath ( /* Update the parse node with the new NamePath */ NextOp->Asl.Value.String = NewPath; - NextOp->Asl.AmlLength = ACPI_STRLEN (NewPath); + NextOp->Asl.AmlLength = strlen (NewPath); } else { /* Update the parse node with the new NamePath */ Op->Asl.Value.String = NewPath; - Op->Asl.AmlLength = ACPI_STRLEN (NewPath); + Op->Asl.AmlLength = strlen (NewPath); } } else diff --git a/sys/contrib/dev/acpica/compiler/asloptions.c b/sys/contrib/dev/acpica/compiler/asloptions.c index cc20bcd..aee4564 100644 --- a/sys/contrib/dev/acpica/compiler/asloptions.c +++ b/sys/contrib/dev/acpica/compiler/asloptions.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,7 +68,7 @@ AslDoResponseFile ( #define ASL_TOKEN_SEPARATORS " \t\n" -#define ASL_SUPPORTED_OPTIONS "@:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z" +#define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z" /******************************************************************************* @@ -107,7 +107,7 @@ AslCommandLine ( if (Gbl_DoTemplates) { - Status = DtCreateTemplates (Gbl_TemplateSignature); + Status = DtCreateTemplates (argv); if (ACPI_FAILURE (Status)) { exit (-1); @@ -184,6 +184,24 @@ AslDoOptions ( } break; + case 'a': /* Debug options */ + + switch (AcpiGbl_Optarg[0]) + { + case 'r': + + Gbl_EnableReferenceTypechecking = TRUE; + break; + + default: + + printf ("Unknown option: -a%s\n", AcpiGbl_Optarg); + return (-1); + } + + break; + + case 'b': /* Debug options */ switch (AcpiGbl_Optarg[0]) @@ -194,6 +212,7 @@ AslDoOptions ( DtParserdebug = 1; PrParserdebug = 1; Gbl_DebugFlag = TRUE; + Gbl_KeepPreprocessorTempFile = TRUE; break; case 'p': /* Prune ASL parse tree */ @@ -312,7 +331,8 @@ AslDoOptions ( Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); if (ACPI_FAILURE (Status)) { - printf ("Could not add %s to external list\n", argv[AcpiGbl_Optind]); + printf ("Could not add %s to external list\n", + argv[AcpiGbl_Optind]); return (-1); } @@ -439,6 +459,7 @@ AslDoOptions ( /* Produce listing file (Mixed source/aml) */ Gbl_ListingFlag = TRUE; + AcpiGbl_DmOpt_Listing = TRUE; break; case 'i': @@ -469,6 +490,13 @@ AslDoOptions ( Gbl_SourceOutputFlag = TRUE; break; + case 'x': + + /* Produce cross-reference file */ + + Gbl_CrossReferenceOutput = TRUE; + break; + default: printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); @@ -504,6 +532,24 @@ AslDoOptions ( Gbl_ReferenceOptimizationFlag = FALSE; break; + case 'c': + + /* Display compile time(s) */ + + Gbl_CompileTimesFlag = TRUE; + break; + + case 'e': + + /* iASL: Disable External opcode generation */ + + Gbl_DoExternals = FALSE; + + /* Disassembler: Emit embedded external operators */ + + AcpiGbl_DmEmitExternalOpcodes = TRUE; + break; + case 'f': /* Disable folding on "normal" expressions */ @@ -527,9 +573,9 @@ AslDoOptions ( case 't': - /* Display compile time(s) */ + /* Disable heavy typechecking */ - Gbl_CompileTimesFlag = TRUE; + Gbl_DoTypechecking = FALSE; break; default: @@ -634,7 +680,6 @@ AslDoOptions ( case 'T': /* Create a ACPI table template file */ Gbl_DoTemplates = TRUE; - Gbl_TemplateSignature = AcpiGbl_Optarg; break; case 'v': /* Version and verbosity settings */ diff --git a/sys/contrib/dev/acpica/compiler/aslparser.y b/sys/contrib/dev/acpica/compiler/aslparser.y index 223a49d..17cd5be 100644 --- a/sys/contrib/dev/acpica/compiler/aslparser.y +++ b/sys/contrib/dev/acpica/compiler/aslparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,7 @@ * each list element and possibly overflow on very large lists (>4000 items). * This dramatically reduces use of the parse stack overall. * - * ArgList, TermList, Objectlist, ByteList, DWordList, PackageList, + * ArgList, TermList, ByteList, DWordList, PackageList, * ResourceMacroList, and FieldUnitList */ @@ -99,7 +99,7 @@ AslLocalAllocate ( * These shift/reduce conflicts are expected. There should be zero * reduce/reduce conflicts. */ -%expect 89 +%expect 101 /*! [Begin] no source code translation */ @@ -122,6 +122,8 @@ m4_include(asltypes.y) /* Production rules */ m4_include(aslrules.y) +m4_include(aslcstyle.y) +m4_include(aslresources.y) %% /*! [End] no source code translation !*/ diff --git a/sys/contrib/dev/acpica/compiler/aslpld.c b/sys/contrib/dev/acpica/compiler/aslpld.c new file mode 100644 index 0000000..39f51e1 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslpld.c @@ -0,0 +1,729 @@ +/****************************************************************************** + * + * Module Name: aslpld - Implementation of ASL ToPLD macro + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include "aslcompiler.y.h" +#include <contrib/dev/acpica/include/amlcode.h> + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslpld") + + +/* Local prototypes */ + +static UINT8 * +OpcEncodePldBuffer ( + ACPI_PLD_INFO *PldInfo); + +static BOOLEAN +OpcFindName ( + const char **List, + char *Name, + UINT32 *Index); + + +/******************************************************************************* + * + * FUNCTION: OpcDoPld + * + * PARAMETERS: Op - Current parse node + * + * RETURN: None + * + * DESCRIPTION: Convert ToPLD macro to 20-byte buffer + * + * The ToPLD parse tree looks like this: + * + * TOPLD + * PLD_REVISION + * INTEGER + * PLD_IGNORECOLOR + * INTEGER + * ... + * etc. + * + ******************************************************************************/ + +void +OpcDoPld ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PLD_INFO PldInfo; + UINT8 *Buffer; + ACPI_PARSE_OBJECT *ThisOp; + ACPI_PARSE_OBJECT *NewOp; + UINT16 ParseOpcode; + UINT32 Value; + + + if (!Op) + { + AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL); + return; + } + + if (Op->Asl.ParseOpcode != PARSEOP_TOPLD) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL); + return; + } + + memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO)); + + /* Traverse the list of PLD Ops (one per PLD field) */ + + ThisOp = Op->Asl.Child; + while (ThisOp) + { + /* Get child values */ + + ParseOpcode = ThisOp->Asl.Child->Asl.ParseOpcode; + Value = (UINT32) ThisOp->Asl.Child->Asl.Value.Integer; + + switch (ThisOp->Asl.ParseOpcode) + { + case PARSEOP_PLD_REVISION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 127) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Revision = (UINT8) Value; + break; + + case PARSEOP_PLD_IGNORECOLOR: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.IgnoreColor = (UINT8) Value; + break; + + case PARSEOP_PLD_RED: + case PARSEOP_PLD_GREEN: + case PARSEOP_PLD_BLUE: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_RED) + { + PldInfo.Red = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GREEN) + { + PldInfo.Green = (UINT8) Value; + } + else /* PARSEOP_PLD_BLUE */ + { + PldInfo.Blue = (UINT8) Value; + } + break; + + case PARSEOP_PLD_WIDTH: + case PARSEOP_PLD_HEIGHT: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 65535) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_WIDTH) + { + PldInfo.Width = (UINT16) Value; + } + else /* PARSEOP_PLD_HEIGHT */ + { + PldInfo.Height = (UINT16) Value; + } + + break; + + case PARSEOP_PLD_USERVISIBLE: + case PARSEOP_PLD_DOCK: + case PARSEOP_PLD_LID: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE) + { + PldInfo.UserVisible = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_DOCK) + { + PldInfo.Dock = (UINT8) Value; + } + else + { + PldInfo.Lid = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_PANEL: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 6) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldPanelList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.Panel = (UINT8) Value; + break; + + case PARSEOP_PLD_VERTICALPOSITION: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 2) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldVerticalPositionList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.VerticalPosition = (UINT8) Value; + break; + + case PARSEOP_PLD_HORIZONTALPOSITION: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 2) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldHorizontalPositionList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.HorizontalPosition = (UINT8) Value; + break; + + case PARSEOP_PLD_SHAPE: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 8) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldShapeList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.Shape = (UINT8) Value; + break; + + case PARSEOP_PLD_GROUPORIENTATION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.GroupOrientation = (UINT8) Value; + break; + + case PARSEOP_PLD_GROUPTOKEN: + case PARSEOP_PLD_GROUPPOSITION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN) + { + PldInfo.GroupToken = (UINT8) Value; + } + else /* PARSEOP_PLD_GROUPPOSITION */ + { + PldInfo.GroupPosition = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_BAY: + case PARSEOP_PLD_EJECTABLE: + case PARSEOP_PLD_EJECTREQUIRED: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_BAY) + { + PldInfo.Bay = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE) + { + PldInfo.Ejectable = (UINT8) Value; + } + else /* PARSEOP_PLD_EJECTREQUIRED */ + { + PldInfo.OspmEjectRequired = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_CABINETNUMBER: + case PARSEOP_PLD_CARDCAGENUMBER: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER) + { + PldInfo.CabinetNumber = (UINT8) Value; + } + else /* PARSEOP_PLD_CARDCAGENUMBER */ + { + PldInfo.CardCageNumber = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_REFERENCE: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Reference = (UINT8) Value; + break; + + case PARSEOP_PLD_ROTATION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 7) + { + switch (Value) + { + case 45: + + Value = 1; + break; + + case 90: + + Value = 2; + break; + + case 135: + + Value = 3; + break; + + case 180: + + Value = 4; + break; + + case 225: + + Value = 5; + break; + + case 270: + + Value = 6; + break; + + case 315: + + Value = 7; + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + + PldInfo.Rotation = (UINT8) Value; + break; + + case PARSEOP_PLD_ORDER: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 31) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Order = (UINT8) Value; + break; + + case PARSEOP_PLD_VERTICALOFFSET: + case PARSEOP_PLD_HORIZONTALOFFSET: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 65535) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET) + { + PldInfo.VerticalOffset = (UINT16) Value; + } + else /* PARSEOP_PLD_HORIZONTALOFFSET */ + { + PldInfo.HorizontalOffset = (UINT16) Value; + } + + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + ThisOp = ThisOp->Asl.Next; + } + + Buffer = OpcEncodePldBuffer (&PldInfo); + + /* Change Op to a Buffer */ + + Op->Asl.ParseOpcode = PARSEOP_BUFFER; + Op->Common.AmlOpcode = AML_BUFFER_OP; + + /* Disable further optimization */ + + Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; + UtSetParseOpName (Op); + + /* Child node is the buffer length */ + + NewOp = TrAllocateNode (PARSEOP_INTEGER); + + NewOp->Asl.AmlOpcode = AML_BYTE_OP; + NewOp->Asl.Value.Integer = 20; + NewOp->Asl.Parent = Op; + + Op->Asl.Child = NewOp; + Op = NewOp; + + /* Peer to the child is the raw buffer data */ + + NewOp = TrAllocateNode (PARSEOP_RAW_DATA); + NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + NewOp->Asl.AmlLength = 20; + NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); + NewOp->Asl.Parent = Op->Asl.Parent; + + Op->Asl.Next = NewOp; +} + + +/******************************************************************************* + * + * FUNCTION: OpcEncodePldBuffer + * + * PARAMETERS: PldInfo - _PLD buffer struct (Using local struct) + * + * RETURN: Encode _PLD buffer suitable for return value from _PLD + * + * DESCRIPTION: Bit-packs a _PLD buffer struct. + * + ******************************************************************************/ + +static UINT8 * +OpcEncodePldBuffer ( + ACPI_PLD_INFO *PldInfo) +{ + UINT32 *Buffer; + UINT32 Dword; + + + Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE); + if (!Buffer) + { + return (NULL); + } + + /* First 32 bits */ + + Dword = 0; + ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision); + ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor); + ACPI_PLD_SET_RED (&Dword, PldInfo->Red); + ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green); + ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue); + ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword); + + /* Second 32 bits */ + + Dword = 0; + ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width); + ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height); + ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword); + + /* Third 32 bits */ + + Dword = 0; + ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible); + ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock); + ACPI_PLD_SET_LID (&Dword, PldInfo->Lid); + ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel); + ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition); + ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition); + ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape); + ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation); + ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken); + ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition); + ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay); + ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword); + + /* Fourth 32 bits */ + + Dword = 0; + ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable); + ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired); + ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber); + ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber); + ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference); + ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation); + ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order); + ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword); + + /* Revision 2 adds an additional DWORD */ + + if (PldInfo->Revision >= 2) + { + /* Fifth 32 bits */ + + Dword = 0; + ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset); + ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset); + ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword); + } + + return (ACPI_CAST_PTR (UINT8, Buffer)); +} + + +/******************************************************************************* + * + * FUNCTION: OpcFindName + * + * PARAMETERS: List - Array of char strings to be searched + * Name - Char string to string for + * Index - Index value to set if found + * + * RETURN: TRUE if any names matched, FALSE otherwise + * + * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to + * equivalent parameter value. + * + ******************************************************************************/ + +static BOOLEAN +OpcFindName ( + const char **List, + char *Name, + UINT32 *Index) +{ + const char *NameString; + UINT32 i; + + + AcpiUtStrupr (Name); + + for (i = 0, NameString = List[0]; + NameString; + i++, NameString = List[i]) + { + if (!(strncmp (NameString, Name, strlen (Name)))) + { + *Index = i; + return (TRUE); + } + } + + return (FALSE); +} diff --git a/sys/contrib/dev/acpica/compiler/aslpredef.c b/sys/contrib/dev/acpica/compiler/aslpredef.c index 9a6778d..673a4ba 100644 --- a/sys/contrib/dev/acpica/compiler/aslpredef.c +++ b/sys/contrib/dev/acpica/compiler/aslpredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -259,7 +259,7 @@ ApCheckPredefinedReturnValue ( */ Gbl_AllExceptionsDisabled = TRUE; Index = ApCheckForPredefinedName (MethodInfo->Op, - MethodInfo->Op->Asl.NameSeg); + MethodInfo->Op->Asl.NameSeg); Gbl_AllExceptionsDisabled = FALSE; switch (Index) @@ -454,8 +454,8 @@ ApCheckForPredefinedName ( if (Name[0] == 0) { - AcpiOsPrintf ("Found a null name, external = %s\n", - Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "zero length name found"); } /* All reserved names are prefixed with a single underscore */ @@ -571,7 +571,8 @@ ApCheckForSpecialName ( * warning and force the user to manually change the names. So, we * will issue a remark instead. */ - AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName); + AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, + Op, Op->Asl.ExternalName); return (ACPI_COMPILER_RESERVED_NAME); } @@ -580,8 +581,8 @@ ApCheckForSpecialName ( * warning, since the entire namespace starting with an underscore is * reserved by the ACPI spec. */ - AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, - Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, + Op, Op->Asl.ExternalName); return (ACPI_NOT_RESERVED_NAME); } diff --git a/sys/contrib/dev/acpica/compiler/aslprepkg.c b/sys/contrib/dev/acpica/compiler/aslprepkg.c index be0a4c4..c70144a 100644 --- a/sys/contrib/dev/acpica/compiler/aslprepkg.c +++ b/sys/contrib/dev/acpica/compiler/aslprepkg.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ /* Local prototypes */ -static void +static ACPI_PARSE_OBJECT * ApCheckPackageElements ( const char *PredefinedName, ACPI_PARSE_OBJECT *Op, @@ -88,6 +88,11 @@ ApPackageTooLarge ( UINT32 Count, UINT32 ExpectedCount); +static void +ApCustomPackage ( + ACPI_PARSE_OBJECT *ParentOp, + const ACPI_PREDEFINED_INFO *Predefined); + /******************************************************************************* * @@ -168,6 +173,11 @@ ApCheckPackage ( switch (Package->RetInfo.Type) { + case ACPI_PTYPE_CUSTOM: + + ApCustomPackage (ParentOp, Predefined); + break; + case ACPI_PTYPE1_FIXED: /* * The package count is fixed and there are no subpackages @@ -238,6 +248,7 @@ ApCheckPackage ( ApCheckObjectType (Predefined->Info.Name, Op, Package->RetInfo3.TailObjectType, i); } + Op = Op->Asl.Next; } break; @@ -381,6 +392,86 @@ PackageTooSmall: /******************************************************************************* * + * FUNCTION: ApCustomPackage + * + * PARAMETERS: ParentOp - Parse op for the package + * Predefined - Pointer to package-specific info for + * the method + * + * RETURN: None + * + * DESCRIPTION: Validate packages that don't fit into the standard model and + * require custom code. + * + * NOTE: Currently used for the _BIX method only. When needed for two or more + * methods, probably a detect/dispatch mechanism will be required. + * + ******************************************************************************/ + +static void +ApCustomPackage ( + ACPI_PARSE_OBJECT *ParentOp, + const ACPI_PREDEFINED_INFO *Predefined) +{ + ACPI_PARSE_OBJECT *Op; + UINT32 Count; + UINT32 ExpectedCount; + UINT32 Version; + + + /* First child is the package length */ + + Op = ParentOp->Asl.Child; + Count = (UINT32) Op->Asl.Value.Integer; + + /* Get the version number, must be Integer */ + + Op = Op->Asl.Next; + Version = (UINT32) Op->Asl.Value.Integer; + if (Op->Asl.ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer); + return; + } + + /* Validate count (# of elements) */ + + ExpectedCount = 21; /* Version 1 */ + if (Version == 0) + { + ExpectedCount = 20; /* Version 0 */ + } + + if (Count < ExpectedCount) + { + ApPackageTooSmall (Predefined->Info.Name, ParentOp, + Count, ExpectedCount); + return; + } + else if (Count > ExpectedCount) + { + ApPackageTooLarge (Predefined->Info.Name, ParentOp, + Count, ExpectedCount); + } + + /* Validate all elements of the package */ + + Op = ApCheckPackageElements (Predefined->Info.Name, Op, + ACPI_RTYPE_INTEGER, 16, + ACPI_RTYPE_STRING, 4); + + /* Version 1 has a single trailing integer */ + + if (Version > 0) + { + ApCheckPackageElements (Predefined->Info.Name, Op, + ACPI_RTYPE_INTEGER, 1, 0, 0); + } +} + + +/******************************************************************************* + * * FUNCTION: ApCheckPackageElements * * PARAMETERS: PredefinedName - Name of the predefined object @@ -390,7 +481,9 @@ PackageTooSmall: * Type2 - Object type for second group * Count2 - Count for second group * - * RETURN: None + * RETURN: Next Op peer in the parse tree, after all specified elements + * have been validated. Used for multiple validations (calls + * to this function). * * DESCRIPTION: Validate all elements of a package. Works with packages that * are defined to contain up to two groups of different object @@ -398,7 +491,7 @@ PackageTooSmall: * ******************************************************************************/ -static void +static ACPI_PARSE_OBJECT * ApCheckPackageElements ( const char *PredefinedName, ACPI_PARSE_OBJECT *Op, @@ -430,6 +523,8 @@ ApCheckPackageElements ( ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1)); Op = Op->Asl.Next; } + + return (Op); } diff --git a/sys/contrib/dev/acpica/compiler/aslprintf.c b/sys/contrib/dev/acpica/compiler/aslprintf.c index c8647ea..7ec3e10 100644 --- a/sys/contrib/dev/acpica/compiler/aslprintf.c +++ b/sys/contrib/dev/acpica/compiler/aslprintf.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -186,7 +186,7 @@ OpcParsePrintf ( if (StringToProcess) { NewString = UtStringCacheCalloc (StringLength + 1); - ACPI_STRNCPY (NewString, StartPosition, StringLength); + strncpy (NewString, StartPosition, StringLength); NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL); NewOp->Asl.Value.String = NewString; @@ -275,7 +275,7 @@ OpcParsePrintf ( if (StringToProcess) { NewString = UtStringCacheCalloc (StringLength + 1); - ACPI_STRNCPY (NewString, StartPosition, StringLength); + strncpy (NewString, StartPosition, StringLength); NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL); NewOp->Asl.Value.String = NewString; diff --git a/sys/contrib/dev/acpica/compiler/aslprune.c b/sys/contrib/dev/acpica/compiler/aslprune.c index 1a36928..b392621 100644 --- a/sys/contrib/dev/acpica/compiler/aslprune.c +++ b/sys/contrib/dev/acpica/compiler/aslprune.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,6 +63,8 @@ PrPrintObjectAtLevel ( const char *ObjectName); +/* Structure used for the pruning parse tree walk */ + typedef struct acpi_prune_info { UINT32 PruneLevel; @@ -120,7 +122,7 @@ AslPruneParseTree ( AcpiOsPrintf ("\nRemoving Objects:\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, PrTreePruneWalk, NULL, ACPI_CAST_PTR (void, &PruneObj)); AcpiOsPrintf ("\n%u Total Objects Removed\n", PruneObj.Count); diff --git a/sys/contrib/dev/acpica/compiler/aslresource.c b/sys/contrib/dev/acpica/compiler/aslresource.c index 5f513d7..cdeb1db 100644 --- a/sys/contrib/dev/acpica/compiler/aslresource.c +++ b/sys/contrib/dev/acpica/compiler/aslresource.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -396,6 +396,7 @@ RsGetStringDataLength ( { return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1)); } + InitializerOp = ASL_GET_PEER_NODE (InitializerOp); } @@ -431,7 +432,6 @@ RsAllocateResourceNode ( Rnode->Buffer = UtLocalCalloc (Size); Rnode->BufferLength = Size; - return (Rnode); } @@ -467,7 +467,6 @@ RsCreateResourceField ( Op->Asl.ExternalName = Name; Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD; - Op->Asl.Value.Tag.BitOffset = (ByteOffset * 8) + BitOffset; Op->Asl.Value.Tag.BitLength = BitLength; } @@ -866,16 +865,19 @@ RsDoOneResourceDescriptor ( break; case PARSEOP_I2C_SERIALBUS: + case PARSEOP_I2C_SERIALBUS_V2: Rnode = RsDoI2cSerialBusDescriptor (Info); break; case PARSEOP_SPI_SERIALBUS: + case PARSEOP_SPI_SERIALBUS_V2: Rnode = RsDoSpiSerialBusDescriptor (Info); break; case PARSEOP_UART_SERIALBUS: + case PARSEOP_UART_SERIALBUS_V2: Rnode = RsDoUartSerialBusDescriptor (Info); break; @@ -888,7 +890,7 @@ RsDoOneResourceDescriptor ( default: printf ("Unknown resource descriptor type [%s]\n", - Info->DescriptorTypeOp->Asl.ParseOpName); + Info->DescriptorTypeOp->Asl.ParseOpName); break; } @@ -904,7 +906,8 @@ RsDoOneResourceDescriptor ( if (Rnode) { Info->DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength; - Info->DescriptorTypeOp->Asl.Extra = ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; + Info->DescriptorTypeOp->Asl.Extra = + ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; } return (Rnode); diff --git a/sys/contrib/dev/acpica/compiler/aslresources.y b/sys/contrib/dev/acpica/compiler/aslresources.y new file mode 100644 index 0000000..074536b --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslresources.y @@ -0,0 +1,1248 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslresources.y - Bison/Yacc production rules for resources + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +') + +/******************************************************************************* + * + * ASL Parameter Keyword Terms + * + ******************************************************************************/ + +AccessAttribKeyword + : PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK);} + | PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK_CALL);} + | PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BYTE);} + | PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_QUICK );} + | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);} + | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);} + | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);} + | PARSEOP_ACCESSATTRIB_MULTIBYTE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);} + ByteConst + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_ACCESSATTRIB_RAW_BYTES '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);} + ByteConst + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_ACCESSATTRIB_RAW_PROCESS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} + ByteConst + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + ; + +AccessTypeKeyword + : PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_ANY);} + | PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BYTE);} + | PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_WORD);} + | PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_DWORD);} + | PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_QWORD);} + | PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BUF);} + ; + +AddressingModeKeyword + : PARSEOP_ADDRESSINGMODE_7BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_7BIT);} + | PARSEOP_ADDRESSINGMODE_10BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_10BIT);} + ; + +AddressKeyword + : PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_MEMORY);} + | PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_RESERVED);} + | PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_NVS);} + | PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_ACPI);} + ; + +AddressSpaceKeyword + : ByteConst {$$ = UtCheckIntegerRange ($1, 0x0A, 0xFF);} + | RegionSpaceKeyword {} + ; + +BitsPerByteKeyword + : PARSEOP_BITSPERBYTE_FIVE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_FIVE);} + | PARSEOP_BITSPERBYTE_SIX {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SIX);} + | PARSEOP_BITSPERBYTE_SEVEN {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SEVEN);} + | PARSEOP_BITSPERBYTE_EIGHT {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_EIGHT);} + | PARSEOP_BITSPERBYTE_NINE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_NINE);} + ; + +ClockPhaseKeyword + : PARSEOP_CLOCKPHASE_FIRST {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_FIRST);} + | PARSEOP_CLOCKPHASE_SECOND {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_SECOND);} + ; + +ClockPolarityKeyword + : PARSEOP_CLOCKPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_LOW);} + | PARSEOP_CLOCKPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_HIGH);} + ; + +DecodeKeyword + : PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_POS);} + | PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_SUB);} + ; + +DevicePolarityKeyword + : PARSEOP_DEVICEPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_LOW);} + | PARSEOP_DEVICEPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_HIGH);} + ; + +DMATypeKeyword + : PARSEOP_DMATYPE_A {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_A);} + | PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_COMPATIBILITY);} + | PARSEOP_DMATYPE_B {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_B);} + | PARSEOP_DMATYPE_F {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);} + ; + +EndianKeyword + : PARSEOP_ENDIAN_LITTLE {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_LITTLE);} + | PARSEOP_ENDIAN_BIG {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_BIG);} + ; + +FlowControlKeyword + : PARSEOP_FLOWCONTROL_HW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_HW);} + | PARSEOP_FLOWCONTROL_NONE {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_NONE);} + | PARSEOP_FLOWCONTROL_SW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_SW);} + ; + +InterruptLevel + : PARSEOP_INTLEVEL_ACTIVEBOTH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEBOTH);} + | PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEHIGH);} + | PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVELOW);} + ; + +InterruptTypeKeyword + : PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_EDGE);} + | PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_LEVEL);} + ; + +IODecodeKeyword + : PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_16);} + | PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_10);} + ; + +IoRestrictionKeyword + : PARSEOP_IORESTRICT_IN {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_IN);} + | PARSEOP_IORESTRICT_OUT {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_OUT);} + | PARSEOP_IORESTRICT_NONE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_NONE);} + | PARSEOP_IORESTRICT_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_PRESERVE);} + ; + +LockRuleKeyword + : PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_LOCK);} + | PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_NOLOCK);} + ; + +MatchOpKeyword + : PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);} + | PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);} + | PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLE);} + | PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLT);} + | PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGE);} + | PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGT);} + ; + +MaxKeyword + : PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_FIXED);} + | PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_NOTFIXED);} + ; + +MemTypeKeyword + : PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_CACHEABLE);} + | PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_WRITECOMBINING);} + | PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_PREFETCHABLE);} + | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);} + ; + +MinKeyword + : PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_FIXED);} + | PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_NOTFIXED);} + ; + +ObjectTypeKeyword + : PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} + | PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_INT);} + | PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_STR);} + | PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BUF);} + | PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PKG);} + | PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_FLD);} + | PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DEV);} + | PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_EVT);} + | PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTH);} + | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);} + | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);} + | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);} + | PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PRO);} + | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);} + | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);} + | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);} + ; + +ParityTypeKeyword + : PARSEOP_PARITYTYPE_SPACE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_SPACE);} + | PARSEOP_PARITYTYPE_MARK {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_MARK);} + | PARSEOP_PARITYTYPE_ODD {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_ODD);} + | PARSEOP_PARITYTYPE_EVEN {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_EVEN);} + | PARSEOP_PARITYTYPE_NONE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_NONE);} + ; + +PinConfigByte + : PinConfigKeyword {$$ = $1;} + | ByteConstExpr {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} + ; + +PinConfigKeyword + : PARSEOP_PIN_NOPULL {$$ = TrCreateLeafNode (PARSEOP_PIN_NOPULL);} + | PARSEOP_PIN_PULLDOWN {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDOWN);} + | PARSEOP_PIN_PULLUP {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLUP);} + | PARSEOP_PIN_PULLDEFAULT {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDEFAULT);} + ; + +PldKeyword + : PARSEOP_PLD_REVISION {$$ = TrCreateLeafNode (PARSEOP_PLD_REVISION);} + | PARSEOP_PLD_IGNORECOLOR {$$ = TrCreateLeafNode (PARSEOP_PLD_IGNORECOLOR);} + | PARSEOP_PLD_RED {$$ = TrCreateLeafNode (PARSEOP_PLD_RED);} + | PARSEOP_PLD_GREEN {$$ = TrCreateLeafNode (PARSEOP_PLD_GREEN);} + | PARSEOP_PLD_BLUE {$$ = TrCreateLeafNode (PARSEOP_PLD_BLUE);} + | PARSEOP_PLD_WIDTH {$$ = TrCreateLeafNode (PARSEOP_PLD_WIDTH);} + | PARSEOP_PLD_HEIGHT {$$ = TrCreateLeafNode (PARSEOP_PLD_HEIGHT);} + | PARSEOP_PLD_USERVISIBLE {$$ = TrCreateLeafNode (PARSEOP_PLD_USERVISIBLE);} + | PARSEOP_PLD_DOCK {$$ = TrCreateLeafNode (PARSEOP_PLD_DOCK);} + | PARSEOP_PLD_LID {$$ = TrCreateLeafNode (PARSEOP_PLD_LID);} + | PARSEOP_PLD_PANEL {$$ = TrCreateLeafNode (PARSEOP_PLD_PANEL);} + | PARSEOP_PLD_VERTICALPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_VERTICALPOSITION);} + | PARSEOP_PLD_HORIZONTALPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_HORIZONTALPOSITION);} + | PARSEOP_PLD_SHAPE {$$ = TrCreateLeafNode (PARSEOP_PLD_SHAPE);} + | PARSEOP_PLD_GROUPORIENTATION {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPORIENTATION);} + | PARSEOP_PLD_GROUPTOKEN {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPTOKEN);} + | PARSEOP_PLD_GROUPPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPPOSITION);} + | PARSEOP_PLD_BAY {$$ = TrCreateLeafNode (PARSEOP_PLD_BAY);} + | PARSEOP_PLD_EJECTABLE {$$ = TrCreateLeafNode (PARSEOP_PLD_EJECTABLE);} + | PARSEOP_PLD_EJECTREQUIRED {$$ = TrCreateLeafNode (PARSEOP_PLD_EJECTREQUIRED);} + | PARSEOP_PLD_CABINETNUMBER {$$ = TrCreateLeafNode (PARSEOP_PLD_CABINETNUMBER);} + | PARSEOP_PLD_CARDCAGENUMBER {$$ = TrCreateLeafNode (PARSEOP_PLD_CARDCAGENUMBER);} + | PARSEOP_PLD_REFERENCE {$$ = TrCreateLeafNode (PARSEOP_PLD_REFERENCE);} + | PARSEOP_PLD_ROTATION {$$ = TrCreateLeafNode (PARSEOP_PLD_ROTATION);} + | PARSEOP_PLD_ORDER {$$ = TrCreateLeafNode (PARSEOP_PLD_ORDER);} + | PARSEOP_PLD_RESERVED {$$ = TrCreateLeafNode (PARSEOP_PLD_RESERVED);} + | PARSEOP_PLD_VERTICALOFFSET {$$ = TrCreateLeafNode (PARSEOP_PLD_VERTICALOFFSET);} + | PARSEOP_PLD_HORIZONTALOFFSET {$$ = TrCreateLeafNode (PARSEOP_PLD_HORIZONTALOFFSET);} + ; + +RangeTypeKeyword + : PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ISAONLY);} + | PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_NONISAONLY);} + | PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ENTIRE);} + ; + +RegionSpaceKeyword + : PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IO);} + | PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_MEM);} + | PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCI);} + | PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_EC);} + | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);} + | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);} + | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);} + | PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IPMI);} + | PARSEOP_REGIONSPACE_GPIO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GPIO);} + | PARSEOP_REGIONSPACE_GSBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GSBUS);} + | PARSEOP_REGIONSPACE_PCC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCC);} + | PARSEOP_REGIONSPACE_FFIXEDHW {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_FFIXEDHW);} + ; + +ResourceTypeKeyword + : PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_PRODUCER);} + ; + +SerializeRuleKeyword + : PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_SERIAL);} + | PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL);} + ; + +ShareTypeKeyword + : PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHARED);} + | PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVE);} + | PARSEOP_SHARETYPE_SHAREDWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHAREDWAKE);} + | PARSEOP_SHARETYPE_EXCLUSIVEWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);} + ; + +SlaveModeKeyword + : PARSEOP_SLAVEMODE_CONTROLLERINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_CONTROLLERINIT);} + | PARSEOP_SLAVEMODE_DEVICEINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_DEVICEINIT);} + ; + +StopBitsKeyword + : PARSEOP_STOPBITS_TWO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_TWO);} + | PARSEOP_STOPBITS_ONEPLUSHALF {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONEPLUSHALF);} + | PARSEOP_STOPBITS_ONE {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONE);} + | PARSEOP_STOPBITS_ZERO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ZERO);} + ; + +TranslationKeyword + : PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_SPARSE);} + | PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_DENSE);} + ; + +TypeKeyword + : PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafNode (PARSEOP_TYPE_TRANSLATION);} + | PARSEOP_TYPE_STATIC {$$ = TrCreateLeafNode (PARSEOP_TYPE_STATIC);} + ; + +UpdateRuleKeyword + : PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_PRESERVE);} + | PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ONES);} + | PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ZEROS);} + ; + +WireModeKeyword + : PARSEOP_WIREMODE_FOUR {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_FOUR);} + | PARSEOP_WIREMODE_THREE {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_THREE);} + ; + +XferSizeKeyword + : PARSEOP_XFERSIZE_8 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_8, 0);} + | PARSEOP_XFERSIZE_16 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_16, 1);} + | PARSEOP_XFERSIZE_32 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | PARSEOP_XFERSIZE_64 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_64, 3);} + | PARSEOP_XFERSIZE_128 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_128, 4);} + | PARSEOP_XFERSIZE_256 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_256, 5);} + ; + +XferTypeKeyword + : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);} + | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);} + | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_16);} + ; + + +/******************************************************************************* + * + * ASL Resource Template Terms + * + ******************************************************************************/ + +/* + * Note: Create two default nodes to allow conversion to a Buffer AML opcode + * Also, insert the EndTag at the end of the template. + */ +ResourceTemplateTerm + : PARSEOP_RESOURCETEMPLATE '(' ')' + '{' + ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG), + TrCreateLeafNode (PARSEOP_DEFAULT_ARG), + $5, + TrCreateLeafNode (PARSEOP_ENDTAG));} + ; + +ResourceMacroList + : {$$ = NULL;} + | ResourceMacroList + ResourceMacroTerm {$$ = TrLinkPeerNode ($1,$2);} + ; + +ResourceMacroTerm + : DMATerm {} + | DWordIOTerm {} + | DWordMemoryTerm {} + | DWordSpaceTerm {} + | EndDependentFnTerm {} + | ExtendedIOTerm {} + | ExtendedMemoryTerm {} + | ExtendedSpaceTerm {} + | FixedDmaTerm {} + | FixedIOTerm {} + | GpioIntTerm {} + | GpioIoTerm {} + | I2cSerialBusTerm {} + | I2cSerialBusTermV2 {} + | InterruptTerm {} + | IOTerm {} + | IRQNoFlagsTerm {} + | IRQTerm {} + | Memory24Term {} + | Memory32FixedTerm {} + | Memory32Term {} + | QWordIOTerm {} + | QWordMemoryTerm {} + | QWordSpaceTerm {} + | RegisterTerm {} + | SpiSerialBusTerm {} + | SpiSerialBusTermV2 {} + | StartDependentFnNoPriTerm {} + | StartDependentFnTerm {} + | UartSerialBusTerm {} + | UartSerialBusTermV2 {} + | VendorLongTerm {} + | VendorShortTerm {} + | WordBusNumberTerm {} + | WordIOTerm {} + | WordSpaceTerm {} + ; + +DMATerm + : PARSEOP_DMA '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DMA);} + DMATypeKeyword + OptionalBusMasterKeyword + ',' XferTypeKeyword + OptionalNameString_Last + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$5,$7,$8,$11);} + | PARSEOP_DMA '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordIOTerm + : PARSEOP_DWORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_DWORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordMemoryTerm + : PARSEOP_DWORDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} + | PARSEOP_DWORDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +DWordSpaceTerm + : PARSEOP_DWORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_DWORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +EndDependentFnTerm + : PARSEOP_ENDDEPENDENTFN '(' + ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} + | PARSEOP_ENDDEPENDENTFN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedIOTerm + : PARSEOP_EXTENDEDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} + | PARSEOP_EXTENDEDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedMemoryTerm + : PARSEOP_EXTENDEDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} + | PARSEOP_EXTENDEDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedSpaceTerm + : PARSEOP_EXTENDEDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,13,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} + | PARSEOP_EXTENDEDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FixedDmaTerm + : PARSEOP_FIXEDDMA '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} + WordConstExpr /* 04: DMA RequestLines */ + ',' WordConstExpr /* 06: DMA Channels */ + OptionalXferSize /* 07: DMA TransferSize */ + OptionalNameString /* 08: DescriptorName */ + ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$7,$8);} + | PARSEOP_FIXEDDMA '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +FixedIOTerm + : PARSEOP_FIXEDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} + WordConstExpr + ',' ByteConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} + | PARSEOP_FIXEDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +GpioIntTerm + : PARSEOP_GPIO_INT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} + InterruptTypeKeyword /* 04: InterruptType */ + ',' InterruptLevel /* 06: InterruptLevel */ + OptionalShareType /* 07: SharedType */ + ',' PinConfigByte /* 09: PinConfig */ + OptionalWordConstExpr /* 10: DebounceTimeout */ + ',' StringData /* 12: ResourceSource */ + OptionalByteConstExpr /* 13: ResourceSourceIndex */ + OptionalResourceType /* 14: ResourceType */ + OptionalNameString /* 15: DescriptorName */ + OptionalBuffer_Last /* 16: VendorData */ + ')' '{' + DWordConstExpr '}' {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);} + | PARSEOP_GPIO_INT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +GpioIoTerm + : PARSEOP_GPIO_IO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} + OptionalShareType_First /* 04: SharedType */ + ',' PinConfigByte /* 06: PinConfig */ + OptionalWordConstExpr /* 07: DebounceTimeout */ + OptionalWordConstExpr /* 08: DriveStrength */ + OptionalIoRestriction /* 09: IoRestriction */ + ',' StringData /* 11: ResourceSource */ + OptionalByteConstExpr /* 12: ResourceSourceIndex */ + OptionalResourceType /* 13: ResourceType */ + OptionalNameString /* 14: DescriptorName */ + OptionalBuffer_Last /* 15: VendorData */ + ')' '{' + DWordList '}' {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);} + | PARSEOP_GPIO_IO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +I2cSerialBusTerm + : PARSEOP_I2C_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} + WordConstExpr /* 04: SlaveAddress */ + OptionalSlaveMode /* 05: SlaveMode */ + ',' DWordConstExpr /* 07: ConnectionSpeed */ + OptionalAddressingMode /* 08: AddressingMode */ + ',' StringData /* 10: ResourceSource */ + OptionalByteConstExpr /* 11: ResourceSourceIndex */ + OptionalResourceType /* 12: ResourceType */ + OptionalNameString /* 13: DescriptorName */ + OptionalBuffer_Last /* 14: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,10,$4,$5,$7,$8,$10,$11,$12,$13, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$14);} + | PARSEOP_I2C_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +I2cSerialBusTermV2 + : PARSEOP_I2C_SERIALBUS_V2 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS_V2);} + WordConstExpr /* 04: SlaveAddress */ + OptionalSlaveMode /* 05: SlaveMode */ + ',' DWordConstExpr /* 07: ConnectionSpeed */ + OptionalAddressingMode /* 08: AddressingMode */ + ',' StringData /* 10: ResourceSource */ + OptionalByteConstExpr /* 11: ResourceSourceIndex */ + OptionalResourceType /* 12: ResourceType */ + OptionalNameString /* 13: DescriptorName */ + OptionalShareType /* 14: Share */ + OptionalBuffer_Last /* 15: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,10,$4,$5,$7,$8,$10,$11,$12,$13, + $14,$15);} + | PARSEOP_I2C_SERIALBUS_V2 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +InterruptTerm + : PARSEOP_INTERRUPT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INTERRUPT);} + OptionalResourceType_First + ',' InterruptTypeKeyword + ',' InterruptLevel + OptionalShareType + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' '{' + DWordList '}' {$$ = TrLinkChildren ($<n>3,8,$4,$6,$8,$9,$10,$11,$12,$15);} + | PARSEOP_INTERRUPT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IOTerm + : PARSEOP_IO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IO);} + IODecodeKeyword + ',' WordConstExpr + ',' WordConstExpr + ',' ByteConstExpr + ',' ByteConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_IO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IRQNoFlagsTerm + : PARSEOP_IRQNOFLAGS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_IRQNOFLAGS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +IRQTerm + : PARSEOP_IRQ '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IRQ);} + InterruptTypeKeyword + ',' InterruptLevel + OptionalShareType + OptionalNameString_Last + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$7,$8,$11);} + | PARSEOP_IRQ '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory24Term + : PARSEOP_MEMORY24 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY24);} + OptionalReadWriteKeyword + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_MEMORY24 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory32FixedTerm + : PARSEOP_MEMORY32FIXED '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} + OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$8,$9);} + | PARSEOP_MEMORY32FIXED '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +Memory32Term + : PARSEOP_MEMORY32 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32);} + OptionalReadWriteKeyword + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} + | PARSEOP_MEMORY32 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordIOTerm + : PARSEOP_QWORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_QWORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordMemoryTerm + : PARSEOP_QWORDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' OptionalReadWriteKeyword + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} + | PARSEOP_QWORDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +QWordSpaceTerm + : PARSEOP_QWORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_QWORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +RegisterTerm + : PARSEOP_REGISTER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_REGISTER);} + AddressSpaceKeyword + ',' ByteConstExpr + ',' ByteConstExpr + ',' QWordConstExpr + OptionalAccessSize + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$11,$12);} + | PARSEOP_REGISTER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SpiSerialBusTerm + : PARSEOP_SPI_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} + WordConstExpr /* 04: DeviceSelection */ + OptionalDevicePolarity /* 05: DevicePolarity */ + OptionalWireMode /* 06: WireMode */ + ',' ByteConstExpr /* 08: DataBitLength */ + OptionalSlaveMode /* 09: SlaveMode */ + ',' DWordConstExpr /* 11: ConnectionSpeed */ + ',' ClockPolarityKeyword /* 13: ClockPolarity */ + ',' ClockPhaseKeyword /* 15: ClockPhase */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalBuffer_Last /* 21: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$21);} + | PARSEOP_SPI_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +SpiSerialBusTermV2 + : PARSEOP_SPI_SERIALBUS_V2 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS_V2);} + WordConstExpr /* 04: DeviceSelection */ + OptionalDevicePolarity /* 05: DevicePolarity */ + OptionalWireMode /* 06: WireMode */ + ',' ByteConstExpr /* 08: DataBitLength */ + OptionalSlaveMode /* 09: SlaveMode */ + ',' DWordConstExpr /* 11: ConnectionSpeed */ + ',' ClockPolarityKeyword /* 13: ClockPolarity */ + ',' ClockPhaseKeyword /* 15: ClockPhase */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalShareType /* 21: Share */ + OptionalBuffer_Last /* 22: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20, + $21,$22);} + | PARSEOP_SPI_SERIALBUS_V2 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StartDependentFnNoPriTerm + : PARSEOP_STARTDEPENDENTFN_NOPRI '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);} + ')' '{' + ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,1,$6);} + | PARSEOP_STARTDEPENDENTFN_NOPRI '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StartDependentFnTerm + : PARSEOP_STARTDEPENDENTFN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);} + ByteConstExpr + ',' ByteConstExpr + ')' '{' + ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$9);} + | PARSEOP_STARTDEPENDENTFN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +UartSerialBusTerm + : PARSEOP_UART_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} + DWordConstExpr /* 04: ConnectionSpeed */ + OptionalBitsPerByte /* 05: BitsPerByte */ + OptionalStopBits /* 06: StopBits */ + ',' ByteConstExpr /* 08: LinesInUse */ + OptionalEndian /* 09: Endianess */ + OptionalParityType /* 10: Parity */ + OptionalFlowControl /* 11: FlowControl */ + ',' WordConstExpr /* 13: Rx BufferSize */ + ',' WordConstExpr /* 15: Tx BufferSize */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalBuffer_Last /* 21: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20, + TrCreateLeafNode (PARSEOP_DEFAULT_ARG),$21);} + | PARSEOP_UART_SERIALBUS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +UartSerialBusTermV2 + : PARSEOP_UART_SERIALBUS_V2 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS_V2);} + DWordConstExpr /* 04: ConnectionSpeed */ + OptionalBitsPerByte /* 05: BitsPerByte */ + OptionalStopBits /* 06: StopBits */ + ',' ByteConstExpr /* 08: LinesInUse */ + OptionalEndian /* 09: Endianess */ + OptionalParityType /* 10: Parity */ + OptionalFlowControl /* 11: FlowControl */ + ',' WordConstExpr /* 13: Rx BufferSize */ + ',' WordConstExpr /* 15: Tx BufferSize */ + ',' StringData /* 17: ResourceSource */ + OptionalByteConstExpr /* 18: ResourceSourceIndex */ + OptionalResourceType /* 19: ResourceType */ + OptionalNameString /* 20: DescriptorName */ + OptionalShareType /* 21: Share */ + OptionalBuffer_Last /* 22: VendorData */ + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20, + $21,$22);} + | PARSEOP_UART_SERIALBUS_V2 '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +VendorLongTerm + : PARSEOP_VENDORLONG '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORLONG);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_VENDORLONG '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +VendorShortTerm + : PARSEOP_VENDORSHORT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);} + OptionalNameString_First + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_VENDORSHORT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordBusNumberTerm + : PARSEOP_WORDBUSNUMBER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,12,$4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);} + | PARSEOP_WORDBUSNUMBER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordIOTerm + : PARSEOP_WORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} + | PARSEOP_WORDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +WordSpaceTerm + : PARSEOP_WORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} + ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_WORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + +/******* Object References ***********************************************/ + +/* Allow IO, DMA, IRQ Resource macro names to also be used as identifiers */ + +NameString + : NameSeg {} + | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) AslCompilerlval.s);} + | PARSEOP_IO {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");} + | PARSEOP_DMA {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");} + | PARSEOP_IRQ {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");} + ; + +NameSeg + : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) AslCompilerlval.s);} + ; + + +/******************************************************************************* + * + * ASL Helper Terms + * + ******************************************************************************/ + +OptionalBusMasterKeyword + : ',' {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} + | ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} + | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);} + ; + +OptionalAccessAttribTerm + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ByteConstExpr {$$ = $2;} + | ',' AccessAttribKeyword {$$ = $2;} + ; + +OptionalAccessSize + : {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} + | ',' ByteConstExpr {$$ = $2;} + ; + +OptionalAddressingMode + : ',' {$$ = NULL;} + | ',' AddressingModeKeyword {$$ = $2;} + ; + +OptionalAddressRange + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' AddressKeyword {$$ = $2;} + ; + +OptionalBitsPerByte + : ',' {$$ = NULL;} + | ',' BitsPerByteKeyword {$$ = $2;} + ; + +OptionalBuffer_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' RawDataBufferTerm {$$ = $2;} + ; + +OptionalByteConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ByteConstExpr {$$ = $2;} + ; + +OptionalDecodeType + : ',' {$$ = NULL;} + | ',' DecodeKeyword {$$ = $2;} + ; + +OptionalDevicePolarity + : ',' {$$ = NULL;} + | ',' DevicePolarityKeyword {$$ = $2;} + ; + +OptionalDWordConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' DWordConstExpr {$$ = $2;} + ; + +OptionalEndian + : ',' {$$ = NULL;} + | ',' EndianKeyword {$$ = $2;} + ; + +OptionalFlowControl + : ',' {$$ = NULL;} + | ',' FlowControlKeyword {$$ = $2;} + ; + +OptionalIoRestriction + : ',' {$$ = NULL;} + | ',' IoRestrictionKeyword {$$ = $2;} + ; + +OptionalListString + : {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ + | ',' TermArg {$$ = $2;} + ; + +OptionalMaxType + : ',' {$$ = NULL;} + | ',' MaxKeyword {$$ = $2;} + ; + +OptionalMemType + : ',' {$$ = NULL;} + | ',' MemTypeKeyword {$$ = $2;} + ; + +OptionalMinType + : ',' {$$ = NULL;} + | ',' MinKeyword {$$ = $2;} + ; + +OptionalNameString + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' NameString {$$ = $2;} + ; + +OptionalNameString_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' NameString {$$ = $2;} + ; + +OptionalNameString_First + : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} + | NameString {$$ = $1;} + ; + +OptionalObjectTypeKeyword + : {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} + | ',' ObjectTypeKeyword {$$ = $2;} + ; + +OptionalParityType + : ',' {$$ = NULL;} + | ',' ParityTypeKeyword {$$ = $2;} + ; + +OptionalQWordConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' QWordConstExpr {$$ = $2;} + ; + +OptionalRangeType + : ',' {$$ = NULL;} + | ',' RangeTypeKeyword {$$ = $2;} + ; + +OptionalReadWriteKeyword + : {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} + | PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} + | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);} + ; + +OptionalResourceType_First + : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ResourceTypeKeyword {$$ = $1;} + ; + +OptionalResourceType + : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ',' {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} + | ',' ResourceTypeKeyword {$$ = $2;} + ; + +OptionalSlaveMode + : ',' {$$ = NULL;} + | ',' SlaveModeKeyword {$$ = $2;} + ; + +OptionalShareType + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ShareTypeKeyword {$$ = $2;} + ; + +OptionalShareType_First + : {$$ = NULL;} + | ShareTypeKeyword {$$ = $1;} + ; + +OptionalStopBits + : ',' {$$ = NULL;} + | ',' StopBitsKeyword {$$ = $2;} + ; + +OptionalStringData + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' StringData {$$ = $2;} + ; + +OptionalTranslationType_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TranslationKeyword {$$ = $2;} + ; + +OptionalType + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TypeKeyword {$$ = $2;} + ; + +OptionalType_Last + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' TypeKeyword {$$ = $2;} + ; + +OptionalWireMode + : ',' {$$ = NULL;} + | ',' WireModeKeyword {$$ = $2;} + ; + +OptionalWordConstExpr + : ',' {$$ = NULL;} + | ',' WordConstExpr {$$ = $2;} + ; + +OptionalXferSize + : {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} + | ',' XferSizeKeyword {$$ = $2;} + ; diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1.c b/sys/contrib/dev/acpica/compiler/aslrestype1.c index 4ac0635..dbe88a8 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,7 +86,6 @@ RsDoEndTagDescriptor ( Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE; Descriptor->EndTag.Checksum = 0; - return (Rnode); } @@ -114,8 +113,8 @@ RsDoEndDependentDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT)); Descriptor = Rnode->Buffer; - Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT | - ASL_RDESC_END_DEPEND_SIZE; + Descriptor->EndDpf.DescriptorType = + ACPI_RESOURCE_NAME_END_DEPENDENT | ASL_RDESC_END_DEPEND_SIZE; return (Rnode); } @@ -151,7 +150,7 @@ RsDoMemory24Descriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24)); Descriptor = Rnode->Buffer; - Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24; + Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24; Descriptor->Memory24.ResourceLength = 9; /* Process all child initialization nodes */ @@ -257,7 +256,7 @@ RsDoMemory32Descriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32)); Descriptor = Rnode->Buffer; - Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32; + Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32; Descriptor->Memory32.ResourceLength = 17; /* Process all child initialization nodes */ @@ -360,7 +359,7 @@ RsDoMemory32FixedDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32)); Descriptor = Rnode->Buffer; - Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32; + Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32; Descriptor->FixedMemory32.ResourceLength = 9; /* Process all child initialization nodes */ @@ -448,8 +447,8 @@ RsDoStartDependentDescriptor ( /* Descriptor has priority byte */ - Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | - (ASL_RDESC_ST_DEPEND_SIZE + 0x01); + Descriptor->StartDpf.DescriptorType = + ACPI_RESOURCE_NAME_START_DEPENDENT | (ASL_RDESC_ST_DEPEND_SIZE + 0x01); /* Process all child initialization nodes */ @@ -493,8 +492,8 @@ RsDoStartDependentDescriptor ( * must keep track of the offset of not only each descriptor, but each * element (field) within each descriptor as well. */ - CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, - NextRnode); + CurrentByteOffset += RsLinkDescriptorChain ( + &PreviousRnode, NextRnode); break; } @@ -536,8 +535,8 @@ RsDoStartDependentNoPriDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)); Descriptor = Rnode->Buffer; - Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | - ASL_RDESC_ST_DEPEND_SIZE; + Descriptor->StartDpf.DescriptorType = + ACPI_RESOURCE_NAME_START_DEPENDENT | ASL_RDESC_ST_DEPEND_SIZE; PreviousRnode = Rnode; /* Increment offset past StartDependentNoPri descriptor */ @@ -599,7 +598,7 @@ RsDoVendorSmallDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7); Descriptor = Rnode->Buffer; - Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL; + Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL; VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER); /* Process all child initialization nodes */ diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1i.c b/sys/contrib/dev/acpica/compiler/aslrestype1i.c index 36e2400..7d9d691 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1i.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1i.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,8 +88,8 @@ RsDoDmaDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); Descriptor = Rnode->Buffer; - Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA | - ASL_RDESC_DMA_SIZE; + Descriptor->Dma.DescriptorType = + ACPI_RESOURCE_NAME_DMA | ASL_RDESC_DMA_SIZE; /* Process all child initialization nodes */ @@ -282,8 +282,8 @@ RsDoFixedIoDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); Descriptor = Rnode->Buffer; - Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO | - ASL_RDESC_FIXED_IO_SIZE; + Descriptor->Io.DescriptorType = + ACPI_RESOURCE_NAME_FIXED_IO | ASL_RDESC_FIXED_IO_SIZE; /* Process all child initialization nodes */ @@ -365,8 +365,8 @@ RsDoIoDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); Descriptor = Rnode->Buffer; - Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO | - ASL_RDESC_IO_SIZE; + Descriptor->Io.DescriptorType = + ACPI_RESOURCE_NAME_IO | ASL_RDESC_IO_SIZE; /* Process all child initialization nodes */ @@ -476,8 +476,8 @@ RsDoIrqDescriptor ( /* Length = 3 (with flag byte) */ Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | - (ASL_RDESC_IRQ_SIZE + 0x01); + Descriptor->Irq.DescriptorType = + ACPI_RESOURCE_NAME_IRQ | (ASL_RDESC_IRQ_SIZE + 0x01); /* Process all child initialization nodes */ @@ -596,8 +596,8 @@ RsDoIrqNoFlagsDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | - ASL_RDESC_IRQ_SIZE; + Descriptor->Irq.DescriptorType = + ACPI_RESOURCE_NAME_IRQ | ASL_RDESC_IRQ_SIZE; /* Process all child initialization nodes */ diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2.c b/sys/contrib/dev/acpica/compiler/aslrestype2.c index af93a9e..ba6fb8e 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -147,6 +147,7 @@ RsDoGeneralRegisterDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + return (Rnode); } @@ -213,7 +214,7 @@ RsDoInterruptDescriptor ( 1 + OptionIndex + StringLength); Descriptor = Rnode->Buffer; - Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ; + Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ; /* * Initial descriptor length -- may be enlarged if there are @@ -223,7 +224,7 @@ RsDoInterruptDescriptor ( Descriptor->ExtendedIrq.InterruptCount = 0; Rover = ACPI_CAST_PTR (AML_RESOURCE, - (&(Descriptor->ExtendedIrq.Interrupts[0]))); + (&(Descriptor->ExtendedIrq.Interrupts[0]))); /* Process all child initialization nodes */ @@ -382,9 +383,10 @@ RsDoInterruptDescriptor ( (Descriptor->ExtendedIrq.ResourceLength + StringLength); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) - - ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType)) - + OptionIndex + StringLength; + Rnode->BufferLength = + (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) - + ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType)) + + OptionIndex + StringLength; return (Rnode); } @@ -431,7 +433,7 @@ RsDoVendorLargeDescriptor ( Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_LARGE) + i); Descriptor = Rnode->Buffer; - Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE; + Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE; Descriptor->VendorLarge.ResourceLength = (UINT16) i; /* Point to end-of-descriptor for vendor data */ diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2d.c b/sys/contrib/dev/acpica/compiler/aslrestype2d.c index 25cbed9..a23e01e 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2d.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2d.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,11 +91,11 @@ RsDoDwordIoDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); Descriptor = Rnode->Buffer; Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -325,7 +325,7 @@ RsDoDwordMemoryDescriptor ( Descriptor = Rnode->Buffer; Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -556,7 +556,7 @@ RsDoDwordSpaceDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); Descriptor = Rnode->Buffer; Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2e.c b/sys/contrib/dev/acpica/compiler/aslrestype2e.c index ddb7ea3..fc85635 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2e.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2e.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,14 +87,14 @@ RsDoExtendedIoDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - Descriptor->ExtAddress64.ResourceLength = (UINT16) + Descriptor->ExtAddress64.ResourceLength = (UINT16) (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - sizeof (AML_RESOURCE_LARGE_HEADER)); @@ -143,7 +143,7 @@ RsDoExtendedIoDescriptor ( RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY, CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); GranOp = InitializerOp; - break; + break; case 6: /* Address Min */ @@ -263,11 +263,11 @@ RsDoExtendedMemoryDescriptor ( sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - Descriptor->ExtAddress64.ResourceLength = (UINT16) + Descriptor->ExtAddress64.ResourceLength = (UINT16) (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - sizeof (AML_RESOURCE_LARGE_HEADER)); @@ -441,13 +441,13 @@ RsDoExtendedSpaceDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - Descriptor->ExtAddress64.ResourceLength = (UINT16) + Descriptor->ExtAddress64.ResourceLength = (UINT16) (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - sizeof (AML_RESOURCE_LARGE_HEADER)); diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2q.c b/sys/contrib/dev/acpica/compiler/aslrestype2q.c index 16398e5..65d2257 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2q.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2q.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,11 +91,11 @@ RsDoQwordIoDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -312,11 +312,11 @@ RsDoQwordMemoryDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -541,7 +541,7 @@ RsDoQwordSpaceDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2s.c b/sys/contrib/dev/acpica/compiler/aslrestype2s.c index 73680c2..3b72f90 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2s.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2s.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -313,17 +313,19 @@ RsDoGpioIntDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; - Descriptor->Gpio.ResourceLength = DescriptorSize; - Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; - Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; - Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_INT; + Descriptor->Gpio.ResourceLength = DescriptorSize; + Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; + Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; + Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_INT; /* Build pointers to optional areas */ - InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); + InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, + sizeof (AML_RESOURCE_GPIO)); PinList = InterruptList; ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); @@ -336,11 +338,6 @@ RsDoGpioIntDescriptor ( Descriptor->Gpio.ResSourceOffset = (UINT16) ACPI_PTR_DIFF (ResourceSource, Descriptor); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n", - "GpioInt", Descriptor->Gpio.ResourceLength, (UINT16) sizeof (AML_RESOURCE_GPIO), - ResSourceLength, VendorLength, InterruptLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -397,7 +394,8 @@ RsDoGpioIntDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->Gpio.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->Gpio.ResSourceIndex = + (UINT8) InitializerOp->Asl.Value.Integer; } break; @@ -422,7 +420,7 @@ RsDoGpioIntDescriptor ( ACPI_PTR_DIFF (VendorData, Descriptor); if (RsGetVendorData (InitializerOp, VendorData, - (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) { Descriptor->Gpio.VendorLength = VendorLength; } @@ -430,7 +428,7 @@ RsDoGpioIntDescriptor ( default: /* - * PINs come through here, repeatedly. Each PIN must be a DWORD. + * PINs come through here, repeatedly. Each PIN must be a WORD. * NOTE: there is no "length" field for this, so from ACPI spec: * The number of pins in the table can be calculated from: * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 @@ -459,7 +457,7 @@ RsDoGpioIntDescriptor ( /* Create a named field at the start of the list */ - RsCreateDwordField (InitializerOp, ACPI_RESTAG_PIN, + RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN, CurrentByteOffset + Descriptor->Gpio.PinTableOffset); } break; @@ -468,7 +466,8 @@ RsDoGpioIntDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); + MpSaveGpioInfo (Info->MappingOp, Descriptor, + PinCount, PinList, ResourceSource); return (Rnode); } @@ -524,13 +523,14 @@ RsDoGpioIoDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; - Descriptor->Gpio.ResourceLength = DescriptorSize; - Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; - Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; - Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_IO; + Descriptor->Gpio.ResourceLength = DescriptorSize; + Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; + Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; + Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_IO; /* Build pointers to optional areas */ @@ -547,11 +547,6 @@ RsDoGpioIoDescriptor ( Descriptor->Gpio.ResSourceOffset = (UINT16) ACPI_PTR_DIFF (ResourceSource, Descriptor); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n", - "GpioIo", Descriptor->Gpio.ResourceLength, (UINT16) sizeof (AML_RESOURCE_GPIO), - ResSourceLength, VendorLength, InterruptLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -632,7 +627,7 @@ RsDoGpioIoDescriptor ( ACPI_PTR_DIFF (VendorData, Descriptor); if (RsGetVendorData (InitializerOp, VendorData, - (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) { Descriptor->Gpio.VendorLength = VendorLength; } @@ -640,7 +635,7 @@ RsDoGpioIoDescriptor ( default: /* - * PINs come through here, repeatedly. Each PIN must be a DWORD. + * PINs come through here, repeatedly. Each PIN must be a WORD. * NOTE: there is no "length" field for this, so from ACPI spec: * The number of pins in the table can be calculated from: * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 @@ -669,7 +664,7 @@ RsDoGpioIoDescriptor ( /* Create a named field at the start of the list */ - RsCreateDwordField (InitializerOp, ACPI_RESTAG_PIN, + RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN, CurrentByteOffset + Descriptor->Gpio.PinTableOffset); } break; @@ -678,7 +673,8 @@ RsDoGpioIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); + MpSaveGpioInfo (Info->MappingOp, Descriptor, + PinCount, PinList, ResourceSource); return (Rnode); } @@ -727,27 +723,27 @@ RsDoI2cSerialBusDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; Descriptor->I2cSerialBus.ResourceLength = DescriptorSize; Descriptor->I2cSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; - Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION; + Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION; Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION; - Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE; + Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE; Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength; + if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_I2C_SERIALBUS_V2) + { + Descriptor->I2cSerialBus.RevisionId = 2; + } + /* Build pointers to optional areas */ VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_I2C_SERIALBUS)); ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", - "I2cSerialBus", Descriptor->I2cSerialBus.ResourceLength, - (UINT16) sizeof (AML_RESOURCE_I2C_SERIALBUS), ResSourceLength, - VendorLength, Descriptor->I2cSerialBus.TypeDataLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -797,7 +793,8 @@ RsDoI2cSerialBusDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->I2cSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->I2cSerialBus.ResSourceIndex = + (UINT8) InitializerOp->Asl.Value.Integer; } break; @@ -811,7 +808,18 @@ RsDoI2cSerialBusDescriptor ( UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; - case 8: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + case 8: + /* + * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor + * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from + * the ASL parser) + */ + RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.Flags), 2); + break; + + case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ RsGetVendorData (InitializerOp, VendorData, CurrentByteOffset + sizeof (AML_RESOURCE_I2C_SERIALBUS)); @@ -874,27 +882,28 @@ RsDoSpiSerialBusDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; Descriptor->SpiSerialBus.ResourceLength = DescriptorSize; Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; - Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION; + Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION; Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION; - Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE; + Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE; Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength; + if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_SPI_SERIALBUS_V2) + { + Descriptor->I2cSerialBus.RevisionId = 2; + } + /* Build pointers to optional areas */ - VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_SPI_SERIALBUS)); + VendorData = ACPI_ADD_PTR (UINT8, Descriptor, + sizeof (AML_RESOURCE_SPI_SERIALBUS)); ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", - "SpiSerialBus", Descriptor->SpiSerialBus.ResourceLength, - (UINT16) sizeof (AML_RESOURCE_SPI_SERIALBUS), ResSourceLength, - VendorLength, Descriptor->SpiSerialBus.TypeDataLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -972,7 +981,8 @@ RsDoSpiSerialBusDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->SpiSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->SpiSerialBus.ResSourceIndex = + (UINT8) InitializerOp->Asl.Value.Integer; } break; @@ -986,7 +996,18 @@ RsDoSpiSerialBusDescriptor ( UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; - case 12: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + case 12: + /* + * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor + * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from + * the ASL parser) + */ + RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 2); + break; + + case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ RsGetVendorData (InitializerOp, VendorData, CurrentByteOffset + sizeof (AML_RESOURCE_SPI_SERIALBUS)); @@ -1049,27 +1070,27 @@ RsDoUartSerialBusDescriptor ( /* Allocate the local resource node and initialize */ - Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); Descriptor = Rnode->Buffer; Descriptor->UartSerialBus.ResourceLength = DescriptorSize; Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; - Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION; + Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION; Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION; - Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE; + Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE; Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength; + if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_UART_SERIALBUS_V2) + { + Descriptor->I2cSerialBus.RevisionId = 2; + } + /* Build pointers to optional areas */ VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_UART_SERIALBUS)); ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); - DbgPrint (ASL_DEBUG_OUTPUT, - "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", - "UartSerialBus", Descriptor->UartSerialBus.ResourceLength, - (UINT16) sizeof (AML_RESOURCE_UART_SERIALBUS), ResSourceLength, - VendorLength, Descriptor->UartSerialBus.TypeDataLength); - /* Process all child initialization nodes */ for (i = 0; InitializerOp; i++) @@ -1154,7 +1175,8 @@ RsDoUartSerialBusDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->UartSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->UartSerialBus.ResSourceIndex = + (UINT8) InitializerOp->Asl.Value.Integer; } break; @@ -1178,7 +1200,18 @@ RsDoUartSerialBusDescriptor ( UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; - case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + case 13: + /* + * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor + * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from + * the ASL parser) + */ + RsSetFlagBits (&Descriptor->UartSerialBus.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 2); + break; + + case 14: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ RsGetVendorData (InitializerOp, VendorData, CurrentByteOffset + sizeof (AML_RESOURCE_UART_SERIALBUS)); diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2w.c b/sys/contrib/dev/acpica/compiler/aslrestype2w.c index a9f4771..f3b7757 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2w.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2w.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,11 +91,11 @@ RsDoWordIoDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -312,11 +312,11 @@ RsDoWordBusNumberDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; /* * Initial descriptor length -- may be enlarged if there are @@ -517,10 +517,10 @@ RsDoWordSpaceDescriptor ( CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; /* * Initial descriptor length -- may be enlarged if there are diff --git a/sys/contrib/dev/acpica/compiler/aslrules.y b/sys/contrib/dev/acpica/compiler/aslrules.y index dbe0882..a5d8387 100644 --- a/sys/contrib/dev/acpica/compiler/aslrules.y +++ b/sys/contrib/dev/acpica/compiler/aslrules.y @@ -1,12 +1,12 @@ NoEcho(' /****************************************************************************** * - * Module Name: aslrules.y - Bison/Yacc production rules + * Module Name: aslrules.y - Main Bison/Yacc production rules * *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,24 +46,19 @@ NoEcho(' /******************************************************************************* * - * Production rules start here + * ASL Root and Secondary Terms * ******************************************************************************/ /* - * ASL Names - * - * Root rule. Allow multiple #line directives before the definition block + * Root term. Allow multiple #line directives before the definition block * to handle output from preprocessors */ -ASLCode - : DefinitionBlockTerm +AslCode + : DefinitionBlockList {$<n>$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_ASL_CODE),1, $1);} | error {YYABORT; $$ = NULL;} ; -/* - * Blocks, Data, and Opcodes - */ /* * Note concerning support for "module-level code". @@ -79,9 +74,13 @@ ASLCode * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the * original use of {TermList} instead (see below.) This allows the use * of Type1 and Type2 opcodes at module level. + * + * 04/2016: The module-level code is now allowed in the following terms: + * DeviceTerm, PowerResTerm, ProcessorTerm, ScopeTerm, ThermalZoneTerm. + * The ObjectList term is obsolete and has been removed. */ DefinitionBlockTerm - : PARSEOP_DEFINITIONBLOCK '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITIONBLOCK);} + : PARSEOP_DEFINITION_BLOCK '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK);} String ',' String ',' ByteConst ',' @@ -92,150 +91,167 @@ DefinitionBlockTerm '{' TermList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);} ; - /* - * ASL Extensions: C-style math/logical operators and expressions. - * The implementation transforms these operators into the standard - * AML opcodes and syntax. - * - * Supported operators and precedence rules (high-to-low) - * - * NOTE: The operator precedence and associativity rules are - * implemented by the tokens in asltokens.y - * - * (left-to-right): - * 1) ( ) expr++ expr-- - * - * (right-to-left): - * 2) ! ~ - * - * (left-to-right): - * 3) * / % - * 4) + - - * 5) >> << - * 6) < > <= >= - * 7) == != - * 8) & - * 9) ^ - * 10) | - * 11) && - * 12) || - * - * (right-to-left): - * 13) = += -= *= /= %= <<= >>= &= ^= |= - */ -Expression - - /* Unary operators */ - - : PARSEOP_EXP_LOGICAL_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);} - TermArg {$$ = TrLinkChildren ($<n>2,1,$3);} - | PARSEOP_EXP_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);} - TermArg {$$ = TrLinkChildren ($<n>2,2,$3,TrCreateNullTarget ());} - - | SuperName PARSEOP_EXP_INCREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);} - {$$ = TrLinkChildren ($<n>3,1,$1);} - | SuperName PARSEOP_EXP_DECREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);} - {$$ = TrLinkChildren ($<n>3,1,$1);} - - /* Binary operators: math and logical */ - - | TermArg PARSEOP_EXP_ADD {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} - TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), - TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - - | TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - | TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} - - | TermArg PARSEOP_EXP_GREATER {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} - TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} - | TermArg PARSEOP_EXP_GREATER_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATEREQUAL);} - TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} - | TermArg PARSEOP_EXP_LESS {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);} - TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} - | TermArg PARSEOP_EXP_LESS_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LLESSEQUAL);} - TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} - - | TermArg PARSEOP_EXP_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);} - TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} - | TermArg PARSEOP_EXP_NOT_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LNOTEQUAL);} - TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} - - | TermArg PARSEOP_EXP_LOGICAL_AND {$<n>$ = TrCreateLeafNode (PARSEOP_LAND);} - TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} - | TermArg PARSEOP_EXP_LOGICAL_OR {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);} - TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} - - /* Parentheses */ - - | '(' TermArg ')' { $$ = $2;} - ; - -EqualsTerm - - /* All assignment-type operations */ - - : SuperName PARSEOP_EXP_EQUALS - TermArg {$$ = TrCreateAssignmentNode ($1, $3);} - - | TermArg PARSEOP_EXP_ADD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} - - | TermArg PARSEOP_EXP_DIV_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} - TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} - - | TermArg PARSEOP_EXP_MOD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} - - | TermArg PARSEOP_EXP_MUL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} - - | TermArg PARSEOP_EXP_SHL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} - - | TermArg PARSEOP_EXP_SHR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} - - | TermArg PARSEOP_EXP_SUB_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} +DefinitionBlockList + : DefinitionBlockTerm + | DefinitionBlockTerm + DefinitionBlockList {$$ = TrLinkPeerNodes (2, $1,$2);} + ; - | TermArg PARSEOP_EXP_AND_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} +SuperName + : NameString {} + | ArgTerm {} + | LocalTerm {} + | DebugTerm {} + | Type6Opcode {} - | TermArg PARSEOP_EXP_OR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} +Target + : {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ + | ',' {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ + | ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} + ; - | TermArg PARSEOP_EXP_XOR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, - TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} +TermArg + : Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | DataObject {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | NameString {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | ArgTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | LocalTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} ; +/* + NOTE: Removed from TermArg due to reduce/reduce conflicts: + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} -/* ACPI 3.0 -- allow semicolons between terms */ +*/ + +MethodInvocationTerm + : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);} + ArgList ')' {$$ = TrLinkChildNode ($1,$4);} + ; + +/* OptionalCount must appear before ByteList or an incorrect reduction will result */ + +OptionalCount + : {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ + | ',' {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ + | ',' TermArg {$$ = $2;} + ; + +VarPackageLengthTerm + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | TermArg {$$ = $1;} + ; + + +/******* List Terms **************************************************/ + +ArgList + : {$$ = NULL;} + | TermArg + | ArgList ',' /* Allows a trailing comma at list end */ + | ArgList ',' + TermArg {$$ = TrLinkPeerNode ($1,$3);} + ; + +ByteList + : {$$ = NULL;} + | ByteConstExpr + | ByteList ',' /* Allows a trailing comma at list end */ + | ByteList ',' + ByteConstExpr {$$ = TrLinkPeerNode ($1,$3);} + ; + +DWordList + : {$$ = NULL;} + | DWordConstExpr + | DWordList ',' /* Allows a trailing comma at list end */ + | DWordList ',' + DWordConstExpr {$$ = TrLinkPeerNode ($1,$3);} + ; + +FieldUnitList + : {$$ = NULL;} + | FieldUnit + | FieldUnitList ',' /* Allows a trailing comma at list end */ + | FieldUnitList ',' + FieldUnit {$$ = TrLinkPeerNode ($1,$3);} + ; + +FieldUnit + : FieldUnitEntry {} + | OffsetTerm {} + | AccessAsTerm {} + | ConnectionTerm {} + ; + +FieldUnitEntry + : ',' AmlPackageLengthTerm {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);} + | NameSeg ',' + AmlPackageLengthTerm {$$ = TrLinkChildNode ($1,$3);} + ; + +Object + : CompilerDirective {} + | NamedObject {} + | NameSpaceModifier {} + ; + +PackageList + : {$$ = NULL;} + | PackageElement + | PackageList ',' /* Allows a trailing comma at list end */ + | PackageList ',' + PackageElement {$$ = TrLinkPeerNode ($1,$3);} + ; + +PackageElement + : DataObject {} + | NameString {} + ; + + /* Rules for specifying the type of one method argument or return value */ + +ParameterTypePackage + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | ParameterTypePackage ',' + ObjectTypeKeyword {$$ = TrLinkPeerNodes (2,$1,$3);} + ; + +ParameterTypePackageList + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | '{' ParameterTypePackage '}' {$$ = $2;} + ; + +OptionalParameterTypePackage + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' ParameterTypePackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + ; + + /* Rules for specifying the types for method arguments */ + +ParameterTypesPackage + : ParameterTypePackageList {$$ = $1;} + | ParameterTypesPackage ',' + ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} + ; + +ParameterTypesPackageList + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | '{' ParameterTypesPackage '}' {$$ = $2;} + ; + +OptionalParameterTypesPackage + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' ParameterTypesPackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + ; + + /* ACPI 3.0 -- allow semicolons between terms */ TermList : {$$ = NULL;} @@ -256,22 +272,44 @@ Term | error {$$ = AslDoError(); yyclearin;} ; -CompilerDirective - : IncludeTerm {} - | ExternalTerm {} - ; +/* + * Case-Default list; allow only one Default term and unlimited Case terms + */ +CaseDefaultTermList + : {$$ = NULL;} + | CaseTerm {} + | DefaultTerm {} + | CaseDefaultTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} + | CaseDefaultTermList + DefaultTerm {$$ = TrLinkPeerNode ($1,$2);} + +/* Original - attempts to force zero or one default term within the switch */ -ObjectList +/* +CaseDefaultTermList : {$$ = NULL;} - | ObjectList Object {$$ = TrLinkPeerNode ($1,$2);} - | error {$$ = AslDoError(); yyclearin;} + | CaseTermList + DefaultTerm + CaseTermList {$$ = TrLinkPeerNode ($1,TrLinkPeerNode ($2, $3));} + | CaseTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} ; -Object - : CompilerDirective {} - | NamedObject {} - | NameSpaceModifier {} +CaseTermList + : {$$ = NULL;} + | CaseTerm {} + | CaseTermList + CaseTerm {$$ = TrLinkPeerNode ($1,$2);} ; +*/ + + +/******************************************************************************* + * + * ASL Data and Constant Terms + * + ******************************************************************************/ DataObject : BufferData {} @@ -303,6 +341,94 @@ StringData | String {} ; +ByteConst + : Integer {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} + ; + +WordConst + : Integer {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} + ; + +DWordConst + : Integer {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} + ; + +QWordConst + : Integer {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} + ; + +/* + * The NODE_COMPILE_TIME_CONST flag in the following constant expressions + * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes + * to simple integers. It is an error if these types of expressions cannot be + * reduced, since the AML grammar for ****ConstExpr requires a simple constant. + * Note: The required byte length of the constant is passed through to the + * constant folding code in the node AmlLength field. + */ +ByteConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} + | ByteConst {} + ; + +WordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} + | WordConst {} + ; + +DWordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} + | DWordConst {} + ; + +QWordConstExpr + : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} + | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} + | QWordConst {} + ; + +ConstTerm + : ConstExprTerm {} + | PARSEOP_REVISION {$$ = TrCreateLeafNode (PARSEOP_REVISION);} + ; + +ConstExprTerm + : PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);} + | PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);} + | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);} + | PARSEOP___DATE__ {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);} + | PARSEOP___FILE__ {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);} + | PARSEOP___LINE__ {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);} + | PARSEOP___PATH__ {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);} + ; + +Integer + : PARSEOP_INTEGER {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);} + ; + +String + : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);} + ; + + +/******************************************************************************* + * + * ASL Opcode Terms + * + ******************************************************************************/ + +CompilerDirective + : IncludeTerm {} + | IncludeEndTerm {} + | ExternalTerm {} + ; + NamedObject : BankFieldTerm {} | CreateBitFieldTerm {} @@ -331,40 +457,17 @@ NameSpaceModifier | ScopeTerm {} ; -MethodInvocationTerm - : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);} - ArgList ')' {$$ = TrLinkChildNode ($1,$4);} - ; - -ArgList - : {$$ = NULL;} - | TermArg - | ArgList ',' /* Allows a trailing comma at list end */ - | ArgList ',' - TermArg {$$ = TrLinkPeerNode ($1,$3);} - ; - -/* -Removed from TermArg due to reduce/reduce conflicts - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2BufferOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2BufferOrStringOpcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - -*/ - -TermArg - : Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | DataObject {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | NameString {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | ArgTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | LocalTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - ; +/* For ObjectType: SuperName except for MethodInvocationTerm */ -Target - : {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ - | ',' {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ - | ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} +ObjectTypeName + : NameString {} + | ArgTerm {} + | LocalTerm {} + | DebugTerm {} + | RefOfTerm {} + | DerefOfTerm {} + | IndexTerm {} +/* | MethodInvocationTerm {} */ /* Caused reduce/reduce with Type6Opcode->MethodInvocationTerm */ ; RequiredTarget @@ -377,46 +480,6 @@ SimpleTarget | ArgTerm {} ; -/* Rules for specifying the type of one method argument or return value */ - -ParameterTypePackage - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | ParameterTypePackage ',' - ObjectTypeKeyword {$$ = TrLinkPeerNodes (2,$1,$3);} - ; - -ParameterTypePackageList - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypePackage '}' {$$ = $2;} - ; - -OptionalParameterTypePackage - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypePackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} - ; - -/* Rules for specifying the types for method arguments */ - -ParameterTypesPackage - : ParameterTypePackageList {$$ = $1;} - | ParameterTypesPackage ',' - ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} - ; - -ParameterTypesPackageList - : {$$ = NULL;} - | ObjectTypeKeyword {$$ = $1;} - | '{' ParameterTypesPackage '}' {$$ = $2;} - ; - -OptionalParameterTypesPackage - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypesPackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} - ; - - /* Opcode types */ Type1Opcode @@ -424,7 +487,8 @@ Type1Opcode | BreakPointTerm {} | ContinueTerm {} | FatalTerm {} - | IfElseTerm {} + | ForTerm {} + | ElseIfTerm {} | LoadTerm {} | NoOpTerm {} | NotifyTerm {} @@ -457,7 +521,6 @@ Type2Opcode /* * Type 3/4/5 opcodes */ - Type2IntegerOpcode /* "Type3" opcodes */ : Expression {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} | AddTerm {} @@ -515,7 +578,6 @@ Type2BufferOrStringOpcode /* * A type 3 opcode evaluates to an Integer and cannot have a destination operand */ - Type3Opcode : EISAIDTerm {} ; @@ -530,7 +592,6 @@ Type4Opcode ; */ - Type5Opcode : ResourceTemplateTerm {} | UnicodeTerm {} @@ -542,34 +603,74 @@ Type6Opcode : RefOfTerm {} | DerefOfTerm {} | IndexTerm {} + | IndexExpTerm {} | MethodInvocationTerm {} ; -IncludeTerm - : PARSEOP_INCLUDE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE);} - String ')' {TrLinkChildren ($<n>3,1,$4);FlOpenIncludeFile ($4);} - TermList - IncludeEndTerm {$$ = TrLinkPeerNodes (3,$<n>3,$7,$8);} + +/******************************************************************************* + * + * ASL Primary Terms + * + ******************************************************************************/ + +AccessAsTerm + : PARSEOP_ACCESSAS '(' + AccessTypeKeyword + OptionalAccessAttribTerm + ')' {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);} + | PARSEOP_ACCESSAS '(' + error ')' {$$ = AslDoError(); yyclearin;} ; -IncludeEndTerm - : PARSEOP_INCLUDE_END {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);} +AcquireTerm + : PARSEOP_ACQUIRE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACQUIRE);} + SuperName + ',' WordConstExpr + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$6);} + | PARSEOP_ACQUIRE '(' + error ')' {$$ = AslDoError(); yyclearin;} ; -ExternalTerm - : PARSEOP_EXTERNAL '(' - NameString - OptionalObjectTypeKeyword - OptionalParameterTypePackage - OptionalParameterTypesPackage - ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} - | PARSEOP_EXTERNAL '(' +AddTerm + : PARSEOP_ADD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} + | PARSEOP_ADD '(' error ')' {$$ = AslDoError(); yyclearin;} ; +AliasTerm + : PARSEOP_ALIAS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ALIAS);} + NameString + NameStringItem + ')' {$$ = TrLinkChildren ($<n>3,2,$4, + TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));} + | PARSEOP_ALIAS '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; -/******* Named Objects *******************************************************/ +AndTerm + : PARSEOP_AND '(' {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} + | PARSEOP_AND '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; +ArgTerm + : PARSEOP_ARG0 {$$ = TrCreateLeafNode (PARSEOP_ARG0);} + | PARSEOP_ARG1 {$$ = TrCreateLeafNode (PARSEOP_ARG1);} + | PARSEOP_ARG2 {$$ = TrCreateLeafNode (PARSEOP_ARG2);} + | PARSEOP_ARG3 {$$ = TrCreateLeafNode (PARSEOP_ARG3);} + | PARSEOP_ARG4 {$$ = TrCreateLeafNode (PARSEOP_ARG4);} + | PARSEOP_ARG5 {$$ = TrCreateLeafNode (PARSEOP_ARG5);} + | PARSEOP_ARG6 {$$ = TrCreateLeafNode (PARSEOP_ARG6);} + ; BankFieldTerm : PARSEOP_BANKFIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_BANKFIELD);} @@ -585,41 +686,54 @@ BankFieldTerm error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} ; -FieldUnitList - : {$$ = NULL;} - | FieldUnit - | FieldUnitList ',' /* Allows a trailing comma at list end */ - | FieldUnitList ',' - FieldUnit {$$ = TrLinkPeerNode ($1,$3);} +BreakTerm + : PARSEOP_BREAK {$$ = TrCreateNode (PARSEOP_BREAK, 0);} ; -FieldUnit - : FieldUnitEntry {} - | OffsetTerm {} - | AccessAsTerm {} - | ConnectionTerm {} +BreakPointTerm + : PARSEOP_BREAKPOINT {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);} ; -FieldUnitEntry - : ',' AmlPackageLengthTerm {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);} - | NameSeg ',' - AmlPackageLengthTerm {$$ = TrLinkChildNode ($1,$3);} +BufferTerm + : PARSEOP_BUFFER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_BUFFER);} + OptionalBufferLength + ')' '{' + BufferTermData '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_BUFFER '(' + error ')' {$$ = AslDoError(); yyclearin;} ; -OffsetTerm - : PARSEOP_OFFSET '(' - AmlPackageLengthTerm - ')' {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);} - | PARSEOP_OFFSET '(' +BufferTermData + : ByteList {} + | StringData {} + ; + +CaseTerm + : PARSEOP_CASE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CASE);} + DataObject + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_CASE '(' error ')' {$$ = AslDoError(); yyclearin;} ; -AccessAsTerm - : PARSEOP_ACCESSAS '(' - AccessTypeKeyword - OptionalAccessAttribTerm - ')' {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);} - | PARSEOP_ACCESSAS '(' +ConcatTerm + : PARSEOP_CONCATENATE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATE);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} + | PARSEOP_CONCATENATE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ConcatResTerm + : PARSEOP_CONCATENATERESTEMPLATE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);} + TermArg + TermArgItem + Target + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} + | PARSEOP_CONCATENATERESTEMPLATE '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -638,6 +752,28 @@ ConnectionTerm error ')' {$$ = AslDoError(); yyclearin;} ; +CondRefOfTerm + : PARSEOP_CONDREFOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONDREFOF);} + SuperName + Target + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_CONDREFOF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ContinueTerm + : PARSEOP_CONTINUE {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);} + ; + +CopyObjectTerm + : PARSEOP_COPYOBJECT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);} + TermArg + ',' SimpleTarget + ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));} + | PARSEOP_COPYOBJECT '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + CreateBitFieldTerm : PARSEOP_CREATEBITFIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);} TermArg @@ -710,204 +846,64 @@ DataRegionTerm error ')' {$$ = AslDoError(); yyclearin;} ; -DeviceTerm - : PARSEOP_DEVICE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEVICE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_DEVICE '(' - error ')' {$$ = AslDoError(); yyclearin;} +DebugTerm + : PARSEOP_DEBUG {$$ = TrCreateLeafNode (PARSEOP_DEBUG);} ; -EventTerm - : PARSEOP_EVENT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EVENT);} - NameString - ')' {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));} - | PARSEOP_EVENT '(' +DecTerm + : PARSEOP_DECREMENT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_DECREMENT '(' error ')' {$$ = AslDoError(); yyclearin;} ; -FieldTerm - : PARSEOP_FIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIELD);} - NameString - ',' AccessTypeKeyword - ',' LockRuleKeyword - ',' UpdateRuleKeyword - ')' '{' - FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$13);} - | PARSEOP_FIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} +DefaultTerm + : PARSEOP_DEFAULT '{' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFAULT);} + TermList '}' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_DEFAULT '{' + error '}' {$$ = AslDoError(); yyclearin;} ; -FunctionTerm - : PARSEOP_FUNCTION '(' {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);} - NameString - OptionalParameterTypePackage - OptionalParameterTypesPackage - ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), - TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), - TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), - TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} - | PARSEOP_FUNCTION '(' +DerefOfTerm + : PARSEOP_DEREFOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEREFOF);} + TermArg + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_DEREFOF '(' error ')' {$$ = AslDoError(); yyclearin;} ; -IndexFieldTerm - : PARSEOP_INDEXFIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} - NameString - NameStringItem - ',' AccessTypeKeyword - ',' LockRuleKeyword - ',' UpdateRuleKeyword - ')' '{' - FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,6,$4,$5,$7,$9,$11,$14);} - | PARSEOP_INDEXFIELD '(' - error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} - ; - -MethodTerm - : PARSEOP_METHOD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);} +DeviceTerm + : PARSEOP_DEVICE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEVICE);} NameString - OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);} - OptionalSerializeRuleKeyword - OptionalByteConstExpr - OptionalParameterTypePackage - OptionalParameterTypesPackage ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);} - | PARSEOP_METHOD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -MutexTerm - : PARSEOP_MUTEX '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MUTEX);} - NameString - ',' ByteConstExpr - ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} - | PARSEOP_MUTEX '(' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_DEVICE '(' error ')' {$$ = AslDoError(); yyclearin;} ; -OpRegionTerm - : PARSEOP_OPERATIONREGION '(' {$<n>$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);} - NameString - ',' OpRegionSpaceIdTerm - TermArgItem +DivideTerm + : PARSEOP_DIVIDE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} + TermArg TermArgItem - ')' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);} - | PARSEOP_OPERATIONREGION '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -OpRegionSpaceIdTerm - : RegionSpaceKeyword {} - | ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} - ; - -PowerResTerm - : PARSEOP_POWERRESOURCE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);} - NameString - ',' ByteConstExpr - ',' WordConstExpr - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);} - | PARSEOP_POWERRESOURCE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ProcessorTerm - : PARSEOP_PROCESSOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_PROCESSOR);} - NameString - ',' ByteConstExpr - OptionalDWordConstExpr - OptionalByteConstExpr - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);} - | PARSEOP_PROCESSOR '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ThermalZoneTerm - : PARSEOP_THERMALZONE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_THERMALZONE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_THERMALZONE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Namespace modifiers *************************************************/ - - -AliasTerm - : PARSEOP_ALIAS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ALIAS);} - NameString - NameStringItem - ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));} - | PARSEOP_ALIAS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NameTerm - : PARSEOP_NAME '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NAME);} - NameString - ',' DataObject - ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} - | PARSEOP_NAME '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ScopeTerm - : PARSEOP_SCOPE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SCOPE);} - NameString - ')' '{' - ObjectList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} - | PARSEOP_SCOPE '(' + Target + Target + ')' {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);} + | PARSEOP_DIVIDE '(' error ')' {$$ = AslDoError(); yyclearin;} ; - -/******* Type 1 opcodes *******************************************************/ - - -BreakTerm - : PARSEOP_BREAK {$$ = TrCreateNode (PARSEOP_BREAK, 0);} - ; - -BreakPointTerm - : PARSEOP_BREAKPOINT {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);} - ; - -ContinueTerm - : PARSEOP_CONTINUE {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);} - ; - -FatalTerm - : PARSEOP_FATAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FATAL);} - ByteConstExpr - ',' DWordConstExpr - TermArgItem - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} - | PARSEOP_FATAL '(' +EISAIDTerm + : PARSEOP_EISAID '(' + StringData ')' {$$ = TrUpdateNode (PARSEOP_EISAID, $3);} + | PARSEOP_EISAID '(' error ')' {$$ = AslDoError(); yyclearin;} ; -IfElseTerm +ElseIfTerm : IfTerm ElseTerm {$$ = TrLinkPeerNode ($1,$2);} ; -IfTerm - : PARSEOP_IF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IF);} - TermArg - ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - - | PARSEOP_IF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - ElseTerm : {$$ = NULL;} | PARSEOP_ELSE '{' {$<n>$ = TrCreateLeafNode (PARSEOP_ELSE);} @@ -933,275 +929,133 @@ ElseTerm error {$$ = AslDoError(); yyclearin;} ; -LoadTerm - : PARSEOP_LOAD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LOAD);} +EventTerm + : PARSEOP_EVENT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EVENT);} NameString - RequiredTarget - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_LOAD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -NoOpTerm - : PARSEOP_NOOP {$$ = TrCreateNode (PARSEOP_NOOP, 0);} - ; - -NotifyTerm - : PARSEOP_NOTIFY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NOTIFY);} - SuperName - TermArgItem - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_NOTIFY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ReleaseTerm - : PARSEOP_RELEASE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RELEASE);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_RELEASE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ResetTerm - : PARSEOP_RESET '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RESET);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_RESET '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ReturnTerm - : PARSEOP_RETURN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RETURN);} - OptionalReturnArg - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));} - | PARSEOP_RETURN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SignalTerm - : PARSEOP_SIGNAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SIGNAL);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_SIGNAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SleepTerm - : PARSEOP_SLEEP '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SLEEP);} - TermArg - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_SLEEP '(' + ')' {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));} + | PARSEOP_EVENT '(' error ')' {$$ = AslDoError(); yyclearin;} ; -StallTerm - : PARSEOP_STALL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STALL);} - TermArg - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_STALL '(' +ExternalTerm + : PARSEOP_EXTERNAL '(' + NameString + OptionalObjectTypeKeyword + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} + | PARSEOP_EXTERNAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; -SwitchTerm - : PARSEOP_SWITCH '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SWITCH);} - TermArg - ')' '{' - CaseDefaultTermList '}' - {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_SWITCH '(' +FatalTerm + : PARSEOP_FATAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FATAL);} + ByteConstExpr + ',' DWordConstExpr + TermArgItem + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} + | PARSEOP_FATAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; -/* - * Case-Default list; allow only one Default term and unlimited Case terms - */ - -CaseDefaultTermList - : {$$ = NULL;} - | CaseTerm {} - | DefaultTerm {} - | CaseDefaultTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - | CaseDefaultTermList - DefaultTerm {$$ = TrLinkPeerNode ($1,$2);} - -/* Original - attempts to force zero or one default term within the switch */ - -/* -CaseDefaultTermList - : {$$ = NULL;} - | CaseTermList - DefaultTerm - CaseTermList {$$ = TrLinkPeerNode ($1,TrLinkPeerNode ($2, $3));} - | CaseTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - ; - -CaseTermList - : {$$ = NULL;} - | CaseTerm {} - | CaseTermList - CaseTerm {$$ = TrLinkPeerNode ($1,$2);} - ; -*/ - -CaseTerm - : PARSEOP_CASE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CASE);} - DataObject +FieldTerm + : PARSEOP_FIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIELD);} + NameString + ',' AccessTypeKeyword + ',' LockRuleKeyword + ',' UpdateRuleKeyword ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_CASE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DefaultTerm - : PARSEOP_DEFAULT '{' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFAULT);} - TermList '}' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_DEFAULT '{' - error '}' {$$ = AslDoError(); yyclearin;} - ; - -UnloadTerm - : PARSEOP_UNLOAD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UNLOAD);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_UNLOAD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WhileTerm - : PARSEOP_WHILE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WHILE);} - TermArg - ')' '{' TermList '}' - {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_WHILE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Type 2 opcodes *******************************************************/ - -AcquireTerm - : PARSEOP_ACQUIRE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACQUIRE);} - SuperName - ',' WordConstExpr - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$6);} - | PARSEOP_ACQUIRE '(' - error ')' {$$ = AslDoError(); yyclearin;} + FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$13);} + | PARSEOP_FIELD '(' + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} ; -AddTerm - : PARSEOP_ADD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} +FindSetLeftBitTerm + : PARSEOP_FINDSETLEFTBIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);} TermArg - TermArgItem Target - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} - | PARSEOP_ADD '(' + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_FINDSETLEFTBIT '(' error ')' {$$ = AslDoError(); yyclearin;} ; -AndTerm - : PARSEOP_AND '(' {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} +FindSetRightBitTerm + : PARSEOP_FINDSETRIGHTBIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);} TermArg - TermArgItem Target - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} - | PARSEOP_AND '(' + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_FINDSETRIGHTBIT '(' error ')' {$$ = AslDoError(); yyclearin;} ; -ConcatTerm - : PARSEOP_CONCATENATE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATE);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} - | PARSEOP_CONCATENATE '(' - error ')' {$$ = AslDoError(); yyclearin;} + /* Convert a For() loop to a While() loop */ +ForTerm + : PARSEOP_FOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WHILE);} + OptionalTermArg ',' {} + OptionalPredicate ',' + OptionalTermArg {$<n>$ = TrLinkPeerNode ($4,$<n>3); + TrSetParent ($9,$<n>3);} /* New parent is WHILE */ + ')' '{' TermList '}' {$<n>$ = TrLinkChildren ($<n>3,2,$7,$13);} + {$<n>$ = TrLinkPeerNode ($13,$9); + $$ = $<n>10;} ; -ConcatResTerm - : PARSEOP_CONCATENATERESTEMPLATE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);} - TermArg - TermArgItem - Target - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);} - | PARSEOP_CONCATENATERESTEMPLATE '(' - error ')' {$$ = AslDoError(); yyclearin;} +OptionalPredicate + : {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, 1);} + | TermArg {$$ = $1;} ; -CondRefOfTerm - : PARSEOP_CONDREFOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_CONDREFOF);} - SuperName - Target - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_CONDREFOF '(' +FprintfTerm + : PARSEOP_FPRINTF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FPRINTF);} + TermArg ',' + StringData + PrintfArgList + ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} + | PARSEOP_FPRINTF '(' error ')' {$$ = AslDoError(); yyclearin;} ; -CopyObjectTerm - : PARSEOP_COPYOBJECT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);} +FromBCDTerm + : PARSEOP_FROMBCD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FROMBCD);} TermArg - ',' SimpleTarget - ')' {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));} - | PARSEOP_COPYOBJECT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DecTerm - : PARSEOP_DECREMENT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);} - SuperName - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_DECREMENT '(' + Target + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_FROMBCD '(' error ')' {$$ = AslDoError(); yyclearin;} ; -DerefOfTerm - : PARSEOP_DEREFOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEREFOF);} - TermArg - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_DEREFOF '(' +FunctionTerm + : PARSEOP_FUNCTION '(' {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);} + NameString + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), + TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} + | PARSEOP_FUNCTION '(' error ')' {$$ = AslDoError(); yyclearin;} ; -DivideTerm - : PARSEOP_DIVIDE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} +IfTerm + : PARSEOP_IF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IF);} TermArg - TermArgItem - Target - Target - ')' {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);} - | PARSEOP_DIVIDE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} -FindSetLeftBitTerm - : PARSEOP_FINDSETLEFTBIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);} - TermArg - Target - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_FINDSETLEFTBIT '(' + | PARSEOP_IF '(' error ')' {$$ = AslDoError(); yyclearin;} ; -FindSetRightBitTerm - : PARSEOP_FINDSETRIGHTBIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);} - TermArg - Target - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_FINDSETRIGHTBIT '(' - error ')' {$$ = AslDoError(); yyclearin;} +IncludeTerm + : PARSEOP_INCLUDE '(' + String ')' {$$ = TrUpdateNode (PARSEOP_INCLUDE, $3); + FlOpenIncludeFile ($3);} ; -FromBCDTerm - : PARSEOP_FROMBCD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FROMBCD);} - TermArg - Target - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_FROMBCD '(' - error ')' {$$ = AslDoError(); yyclearin;} +IncludeEndTerm + : PARSEOP_INCLUDE_END {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE_END); TrSetCurrentFilename ($$);} ; IncTerm @@ -1212,6 +1066,19 @@ IncTerm error ')' {$$ = AslDoError(); yyclearin;} ; +IndexFieldTerm + : PARSEOP_INDEXFIELD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} + NameString + NameStringItem + ',' AccessTypeKeyword + ',' LockRuleKeyword + ',' UpdateRuleKeyword + ')' '{' + FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,6,$4,$5,$7,$9,$11,$14);} + | PARSEOP_INDEXFIELD '(' + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} + ; + IndexTerm : PARSEOP_INDEX '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INDEX);} TermArg @@ -1240,6 +1107,15 @@ LEqualTerm error ')' {$$ = AslDoError(); yyclearin;} ; +LGreaterEqualTerm + : PARSEOP_LGREATEREQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);} + TermArg + TermArgItem + ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));} + | PARSEOP_LGREATEREQUAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + LGreaterTerm : PARSEOP_LGREATER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} TermArg @@ -1249,12 +1125,12 @@ LGreaterTerm error ')' {$$ = AslDoError(); yyclearin;} ; -LGreaterEqualTerm - : PARSEOP_LGREATEREQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);} +LLessEqualTerm + : PARSEOP_LLESSEQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} TermArg TermArgItem ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));} - | PARSEOP_LGREATEREQUAL '(' + | PARSEOP_LLESSEQUAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -1267,12 +1143,12 @@ LLessTerm error ')' {$$ = AslDoError(); yyclearin;} ; -LLessEqualTerm - : PARSEOP_LLESSEQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} +LNotEqualTerm + : PARSEOP_LNOTEQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);} TermArg TermArgItem ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));} - | PARSEOP_LLESSEQUAL '(' + | PARSEOP_LNOTEQUAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -1284,15 +1160,6 @@ LNotTerm error ')' {$$ = AslDoError(); yyclearin;} ; -LNotEqualTerm - : PARSEOP_LNOTEQUAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);} - TermArg - TermArgItem - ')' {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));} - | PARSEOP_LNOTEQUAL '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - LoadTableTerm : PARSEOP_LOADTABLE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LOADTABLE);} TermArg @@ -1306,6 +1173,26 @@ LoadTableTerm error ')' {$$ = AslDoError(); yyclearin;} ; +LoadTerm + : PARSEOP_LOAD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LOAD);} + NameString + RequiredTarget + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_LOAD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +LocalTerm + : PARSEOP_LOCAL0 {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);} + | PARSEOP_LOCAL1 {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);} + | PARSEOP_LOCAL2 {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);} + | PARSEOP_LOCAL3 {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);} + | PARSEOP_LOCAL4 {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);} + | PARSEOP_LOCAL5 {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);} + | PARSEOP_LOCAL6 {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);} + | PARSEOP_LOCAL7 {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);} + ; + LOrTerm : PARSEOP_LOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);} TermArg @@ -1328,6 +1215,20 @@ MatchTerm error ')' {$$ = AslDoError(); yyclearin;} ; +MethodTerm + : PARSEOP_METHOD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);} + NameString + OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);} + OptionalSerializeRuleKeyword + OptionalByteConstExpr + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);} + | PARSEOP_METHOD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + MidTerm : PARSEOP_MID '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MID);} TermArg @@ -1359,6 +1260,24 @@ MultiplyTerm error ')' {$$ = AslDoError(); yyclearin;} ; +MutexTerm + : PARSEOP_MUTEX '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MUTEX);} + NameString + ',' ByteConstExpr + ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} + | PARSEOP_MUTEX '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +NameTerm + : PARSEOP_NAME '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NAME);} + NameString + ',' DataObject + ')' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);} + | PARSEOP_NAME '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + NAndTerm : PARSEOP_NAND '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NAND);} TermArg @@ -1369,6 +1288,10 @@ NAndTerm error ')' {$$ = AslDoError(); yyclearin;} ; +NoOpTerm + : PARSEOP_NOOP {$$ = TrCreateNode (PARSEOP_NOOP, 0);} + ; + NOrTerm : PARSEOP_NOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NOR);} TermArg @@ -1379,6 +1302,15 @@ NOrTerm error ')' {$$ = AslDoError(); yyclearin;} ; +NotifyTerm + : PARSEOP_NOTIFY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NOTIFY);} + SuperName + TermArgItem + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_NOTIFY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + NotTerm : PARSEOP_NOT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);} TermArg @@ -1396,6 +1328,30 @@ ObjectTypeTerm error ')' {$$ = AslDoError(); yyclearin;} ; +OffsetTerm + : PARSEOP_OFFSET '(' + AmlPackageLengthTerm + ')' {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);} + | PARSEOP_OFFSET '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +OpRegionTerm + : PARSEOP_OPERATIONREGION '(' {$<n>$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);} + NameString + ',' OpRegionSpaceIdTerm + TermArgItem + TermArgItem + ')' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);} + | PARSEOP_OPERATIONREGION '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +OpRegionSpaceIdTerm + : RegionSpaceKeyword {} + | ByteConst {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} + ; + OrTerm : PARSEOP_OR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} TermArg @@ -1406,6 +1362,63 @@ OrTerm error ')' {$$ = AslDoError(); yyclearin;} ; +PackageTerm + : PARSEOP_PACKAGE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);} + VarPackageLengthTerm + ')' '{' + PackageList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_PACKAGE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +PowerResTerm + : PARSEOP_POWERRESOURCE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);} + NameString + ',' ByteConstExpr + ',' WordConstExpr + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);} + | PARSEOP_POWERRESOURCE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +PrintfTerm + : PARSEOP_PRINTF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_PRINTF);} + StringData + PrintfArgList + ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} + | PARSEOP_PRINTF '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +PrintfArgList + : {$$ = NULL;} + | TermArg {$$ = $1;} + | PrintfArgList ',' + TermArg {$$ = TrLinkPeerNode ($1, $3);} + ; + +ProcessorTerm + : PARSEOP_PROCESSOR '(' {$<n>$ = TrCreateLeafNode (PARSEOP_PROCESSOR);} + NameString + ',' ByteConstExpr + OptionalDWordConstExpr + OptionalByteConstExpr + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);} + | PARSEOP_PROCESSOR '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +RawDataBufferTerm + : PARSEOP_DATABUFFER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DATABUFFER);} + OptionalWordConst + ')' '{' + ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_DATABUFFER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + /* * In RefOf, the node isn't really a target, but we can't keep track of it after * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.) @@ -1418,6 +1431,40 @@ RefOfTerm error ')' {$$ = AslDoError(); yyclearin;} ; +ReleaseTerm + : PARSEOP_RELEASE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RELEASE);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_RELEASE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ResetTerm + : PARSEOP_RESET '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RESET);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_RESET '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ReturnTerm + : PARSEOP_RETURN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RETURN);} + OptionalReturnArg + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));} + | PARSEOP_RETURN '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ScopeTerm + : PARSEOP_SCOPE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SCOPE);} + NameString + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_SCOPE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + ShiftLeftTerm : PARSEOP_SHIFTLEFT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} TermArg @@ -1438,6 +1485,14 @@ ShiftRightTerm error ')' {$$ = AslDoError(); yyclearin;} ; +SignalTerm + : PARSEOP_SIGNAL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SIGNAL);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_SIGNAL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + SizeOfTerm : PARSEOP_SIZEOF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SIZEOF);} SuperName @@ -1446,6 +1501,22 @@ SizeOfTerm error ')' {$$ = AslDoError(); yyclearin;} ; +SleepTerm + : PARSEOP_SLEEP '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SLEEP);} + TermArg + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_SLEEP '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +StallTerm + : PARSEOP_STALL '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STALL);} + TermArg + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_STALL '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + StoreTerm : PARSEOP_STORE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STORE);} TermArg @@ -1464,6 +1535,24 @@ SubtractTerm | PARSEOP_SUBTRACT '(' error ')' {$$ = AslDoError(); yyclearin;} ; +SwitchTerm + : PARSEOP_SWITCH '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SWITCH);} + TermArg + ')' '{' + CaseDefaultTermList '}' + {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_SWITCH '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ThermalZoneTerm + : PARSEOP_THERMALZONE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_THERMALZONE);} + NameString + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);} + | PARSEOP_THERMALZONE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; TimerTerm : PARSEOP_TIMER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_TIMER);} @@ -1518,35 +1607,12 @@ ToIntegerTerm error ')' {$$ = AslDoError(); yyclearin;} ; -PldKeyword - : PARSEOP_PLD_REVISION {$$ = TrCreateLeafNode (PARSEOP_PLD_REVISION);} - | PARSEOP_PLD_IGNORECOLOR {$$ = TrCreateLeafNode (PARSEOP_PLD_IGNORECOLOR);} - | PARSEOP_PLD_RED {$$ = TrCreateLeafNode (PARSEOP_PLD_RED);} - | PARSEOP_PLD_GREEN {$$ = TrCreateLeafNode (PARSEOP_PLD_GREEN);} - | PARSEOP_PLD_BLUE {$$ = TrCreateLeafNode (PARSEOP_PLD_BLUE);} - | PARSEOP_PLD_WIDTH {$$ = TrCreateLeafNode (PARSEOP_PLD_WIDTH);} - | PARSEOP_PLD_HEIGHT {$$ = TrCreateLeafNode (PARSEOP_PLD_HEIGHT);} - | PARSEOP_PLD_USERVISIBLE {$$ = TrCreateLeafNode (PARSEOP_PLD_USERVISIBLE);} - | PARSEOP_PLD_DOCK {$$ = TrCreateLeafNode (PARSEOP_PLD_DOCK);} - | PARSEOP_PLD_LID {$$ = TrCreateLeafNode (PARSEOP_PLD_LID);} - | PARSEOP_PLD_PANEL {$$ = TrCreateLeafNode (PARSEOP_PLD_PANEL);} - | PARSEOP_PLD_VERTICALPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_VERTICALPOSITION);} - | PARSEOP_PLD_HORIZONTALPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_HORIZONTALPOSITION);} - | PARSEOP_PLD_SHAPE {$$ = TrCreateLeafNode (PARSEOP_PLD_SHAPE);} - | PARSEOP_PLD_GROUPORIENTATION {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPORIENTATION);} - | PARSEOP_PLD_GROUPTOKEN {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPTOKEN);} - | PARSEOP_PLD_GROUPPOSITION {$$ = TrCreateLeafNode (PARSEOP_PLD_GROUPPOSITION);} - | PARSEOP_PLD_BAY {$$ = TrCreateLeafNode (PARSEOP_PLD_BAY);} - | PARSEOP_PLD_EJECTABLE {$$ = TrCreateLeafNode (PARSEOP_PLD_EJECTABLE);} - | PARSEOP_PLD_EJECTREQUIRED {$$ = TrCreateLeafNode (PARSEOP_PLD_EJECTREQUIRED);} - | PARSEOP_PLD_CABINETNUMBER {$$ = TrCreateLeafNode (PARSEOP_PLD_CABINETNUMBER);} - | PARSEOP_PLD_CARDCAGENUMBER {$$ = TrCreateLeafNode (PARSEOP_PLD_CARDCAGENUMBER);} - | PARSEOP_PLD_REFERENCE {$$ = TrCreateLeafNode (PARSEOP_PLD_REFERENCE);} - | PARSEOP_PLD_ROTATION {$$ = TrCreateLeafNode (PARSEOP_PLD_ROTATION);} - | PARSEOP_PLD_ORDER {$$ = TrCreateLeafNode (PARSEOP_PLD_ORDER);} - | PARSEOP_PLD_RESERVED {$$ = TrCreateLeafNode (PARSEOP_PLD_RESERVED);} - | PARSEOP_PLD_VERTICALOFFSET {$$ = TrCreateLeafNode (PARSEOP_PLD_VERTICALOFFSET);} - | PARSEOP_PLD_HORIZONTALOFFSET {$$ = TrCreateLeafNode (PARSEOP_PLD_HORIZONTALOFFSET);} +ToPLDTerm + : PARSEOP_TOPLD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_TOPLD);} + PldKeywordList + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_TOPLD '(' + error ')' {$$ = AslDoError(); yyclearin;} ; PldKeywordList @@ -1564,39 +1630,6 @@ PldKeywordList PARSEOP_EXP_EQUALS String {$$ = TrLinkPeerNode ($1,TrLinkChildren ($3,1,$5));} ; -ToPLDTerm - : PARSEOP_TOPLD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_TOPLD);} - PldKeywordList - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_TOPLD '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -PrintfArgList - : {$$ = NULL;} - | TermArg {$$ = $1;} - | PrintfArgList ',' - TermArg {$$ = TrLinkPeerNode ($1, $3);} - ; - -PrintfTerm - : PARSEOP_PRINTF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_PRINTF);} - StringData - PrintfArgList - ')' {$$ = TrLinkChildren ($<n>3,2,$4,$5);} - | PARSEOP_PRINTF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FprintfTerm - : PARSEOP_FPRINTF '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FPRINTF);} - TermArg ',' - StringData - PrintfArgList - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} - | PARSEOP_FPRINTF '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; ToStringTerm : PARSEOP_TOSTRING '(' {$<n>$ = TrCreateLeafNode (PARSEOP_TOSTRING);} @@ -1615,6 +1648,22 @@ ToUUIDTerm error ')' {$$ = AslDoError(); yyclearin;} ; +UnicodeTerm + : PARSEOP_UNICODE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UNICODE);} + StringData + ')' {$$ = TrLinkChildren ($<n>3,2,0,$4);} + | PARSEOP_UNICODE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +UnloadTerm + : PARSEOP_UNLOAD '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UNLOAD);} + SuperName + ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_UNLOAD '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + WaitTerm : PARSEOP_WAIT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WAIT);} SuperName @@ -1634,1105 +1683,21 @@ XOrTerm error ')' {$$ = AslDoError(); yyclearin;} ; - -/******* Keywords *************************************************************/ - - -AccessAttribKeyword - : PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK);} - | PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK_CALL);} - | PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BYTE);} - | PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_QUICK );} - | PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);} - | PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);} - | PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);} - | PARSEOP_ACCESSATTRIB_MULTIBYTE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);} - ByteConst - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_BYTES '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);} - ByteConst - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_ACCESSATTRIB_RAW_PROCESS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);} - ByteConst - ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - ; - -AccessTypeKeyword - : PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_ANY);} - | PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BYTE);} - | PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_WORD);} - | PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_DWORD);} - | PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_QWORD);} - | PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BUF);} - ; - -AddressingModeKeyword - : PARSEOP_ADDRESSINGMODE_7BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_7BIT);} - | PARSEOP_ADDRESSINGMODE_10BIT {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_10BIT);} - ; - -AddressKeyword - : PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_MEMORY);} - | PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_RESERVED);} - | PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_NVS);} - | PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_ACPI);} - ; - -AddressSpaceKeyword - : ByteConst {$$ = UtCheckIntegerRange ($1, 0x0A, 0xFF);} - | RegionSpaceKeyword {} - ; - -BitsPerByteKeyword - : PARSEOP_BITSPERBYTE_FIVE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_FIVE);} - | PARSEOP_BITSPERBYTE_SIX {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SIX);} - | PARSEOP_BITSPERBYTE_SEVEN {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SEVEN);} - | PARSEOP_BITSPERBYTE_EIGHT {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_EIGHT);} - | PARSEOP_BITSPERBYTE_NINE {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_NINE);} - ; - -ClockPhaseKeyword - : PARSEOP_CLOCKPHASE_FIRST {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_FIRST);} - | PARSEOP_CLOCKPHASE_SECOND {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_SECOND);} - ; - -ClockPolarityKeyword - : PARSEOP_CLOCKPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_LOW);} - | PARSEOP_CLOCKPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_HIGH);} - ; - -DecodeKeyword - : PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_POS);} - | PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_SUB);} - ; - -DevicePolarityKeyword - : PARSEOP_DEVICEPOLARITY_LOW {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_LOW);} - | PARSEOP_DEVICEPOLARITY_HIGH {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_HIGH);} - ; - -DMATypeKeyword - : PARSEOP_DMATYPE_A {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_A);} - | PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_COMPATIBILITY);} - | PARSEOP_DMATYPE_B {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_B);} - | PARSEOP_DMATYPE_F {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);} - ; - -EndianKeyword - : PARSEOP_ENDIAN_LITTLE {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_LITTLE);} - | PARSEOP_ENDIAN_BIG {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_BIG);} - ; - -FlowControlKeyword - : PARSEOP_FLOWCONTROL_HW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_HW);} - | PARSEOP_FLOWCONTROL_NONE {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_NONE);} - | PARSEOP_FLOWCONTROL_SW {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_SW);} - ; - -InterruptLevel - : PARSEOP_INTLEVEL_ACTIVEBOTH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEBOTH);} - | PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEHIGH);} - | PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVELOW);} - ; - -InterruptTypeKeyword - : PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_EDGE);} - | PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_LEVEL);} - ; - -IODecodeKeyword - : PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_16);} - | PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_10);} - ; - -IoRestrictionKeyword - : PARSEOP_IORESTRICT_IN {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_IN);} - | PARSEOP_IORESTRICT_OUT {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_OUT);} - | PARSEOP_IORESTRICT_NONE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_NONE);} - | PARSEOP_IORESTRICT_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_PRESERVE);} - ; - -LockRuleKeyword - : PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_LOCK);} - | PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_NOLOCK);} - ; - -MatchOpKeyword - : PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);} - | PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);} - | PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLE);} - | PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLT);} - | PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGE);} - | PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGT);} - ; - -MaxKeyword - : PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_FIXED);} - | PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_NOTFIXED);} - ; - -MemTypeKeyword - : PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_CACHEABLE);} - | PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_WRITECOMBINING);} - | PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_PREFETCHABLE);} - | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);} - ; - -MinKeyword - : PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_FIXED);} - | PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_NOTFIXED);} - ; - -ObjectTypeKeyword - : PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} - | PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_INT);} - | PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_STR);} - | PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BUF);} - | PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PKG);} - | PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_FLD);} - | PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DEV);} - | PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_EVT);} - | PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTH);} - | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);} - | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);} - | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);} - | PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PRO);} - | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);} - | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);} - | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);} - ; - -ParityTypeKeyword - : PARSEOP_PARITYTYPE_SPACE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_SPACE);} - | PARSEOP_PARITYTYPE_MARK {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_MARK);} - | PARSEOP_PARITYTYPE_ODD {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_ODD);} - | PARSEOP_PARITYTYPE_EVEN {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_EVEN);} - | PARSEOP_PARITYTYPE_NONE {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_NONE);} - ; - -PinConfigByte - : PinConfigKeyword {$$ = $1;} - | ByteConstExpr {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);} - ; - -PinConfigKeyword - : PARSEOP_PIN_NOPULL {$$ = TrCreateLeafNode (PARSEOP_PIN_NOPULL);} - | PARSEOP_PIN_PULLDOWN {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDOWN);} - | PARSEOP_PIN_PULLUP {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLUP);} - | PARSEOP_PIN_PULLDEFAULT {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDEFAULT);} - ; - -RangeTypeKeyword - : PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ISAONLY);} - | PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_NONISAONLY);} - | PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ENTIRE);} - ; - -RegionSpaceKeyword - : PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IO);} - | PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_MEM);} - | PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCI);} - | PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_EC);} - | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);} - | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);} - | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);} - | PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IPMI);} - | PARSEOP_REGIONSPACE_GPIO {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GPIO);} - | PARSEOP_REGIONSPACE_GSBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GSBUS);} - | PARSEOP_REGIONSPACE_PCC {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCC);} - | PARSEOP_REGIONSPACE_FFIXEDHW {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_FFIXEDHW);} - ; - -ResourceTypeKeyword - : PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_PRODUCER);} - ; - -SerializeRuleKeyword - : PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_SERIAL);} - | PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL);} - ; - -ShareTypeKeyword - : PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHARED);} - | PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVE);} - | PARSEOP_SHARETYPE_SHAREDWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHAREDWAKE);} - | PARSEOP_SHARETYPE_EXCLUSIVEWAKE {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);} - ; - -SlaveModeKeyword - : PARSEOP_SLAVEMODE_CONTROLLERINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_CONTROLLERINIT);} - | PARSEOP_SLAVEMODE_DEVICEINIT {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_DEVICEINIT);} - ; - -StopBitsKeyword - : PARSEOP_STOPBITS_TWO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_TWO);} - | PARSEOP_STOPBITS_ONEPLUSHALF {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONEPLUSHALF);} - | PARSEOP_STOPBITS_ONE {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONE);} - | PARSEOP_STOPBITS_ZERO {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ZERO);} - ; - -TranslationKeyword - : PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_SPARSE);} - | PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_DENSE);} - ; - -TypeKeyword - : PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafNode (PARSEOP_TYPE_TRANSLATION);} - | PARSEOP_TYPE_STATIC {$$ = TrCreateLeafNode (PARSEOP_TYPE_STATIC);} - ; - -UpdateRuleKeyword - : PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_PRESERVE);} - | PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ONES);} - | PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ZEROS);} - ; - -WireModeKeyword - : PARSEOP_WIREMODE_FOUR {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_FOUR);} - | PARSEOP_WIREMODE_THREE {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_THREE);} - ; - -XferSizeKeyword - : PARSEOP_XFERSIZE_8 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_8, 0);} - | PARSEOP_XFERSIZE_16 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_16, 1);} - | PARSEOP_XFERSIZE_32 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | PARSEOP_XFERSIZE_64 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_64, 3);} - | PARSEOP_XFERSIZE_128 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_128, 4);} - | PARSEOP_XFERSIZE_256 {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_256, 5);} - ; - -XferTypeKeyword - : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);} - | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);} - | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_16);} - ; - - -/******* Miscellaneous Types **************************************************/ - - -SuperName - : NameString {} - | ArgTerm {} - | LocalTerm {} - | DebugTerm {} - | Type6Opcode {} - -/* For ObjectType: SuperName except for MethodInvocationTerm */ - -ObjectTypeName - : NameString {} - | ArgTerm {} - | LocalTerm {} - | DebugTerm {} - | RefOfTerm {} - | DerefOfTerm {} - | IndexTerm {} - -/* | MethodInvocationTerm {} */ /* Caused reduce/reduce with Type6Opcode->MethodInvocationTerm */ - ; - -ArgTerm - : PARSEOP_ARG0 {$$ = TrCreateLeafNode (PARSEOP_ARG0);} - | PARSEOP_ARG1 {$$ = TrCreateLeafNode (PARSEOP_ARG1);} - | PARSEOP_ARG2 {$$ = TrCreateLeafNode (PARSEOP_ARG2);} - | PARSEOP_ARG3 {$$ = TrCreateLeafNode (PARSEOP_ARG3);} - | PARSEOP_ARG4 {$$ = TrCreateLeafNode (PARSEOP_ARG4);} - | PARSEOP_ARG5 {$$ = TrCreateLeafNode (PARSEOP_ARG5);} - | PARSEOP_ARG6 {$$ = TrCreateLeafNode (PARSEOP_ARG6);} - ; - -LocalTerm - : PARSEOP_LOCAL0 {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);} - | PARSEOP_LOCAL1 {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);} - | PARSEOP_LOCAL2 {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);} - | PARSEOP_LOCAL3 {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);} - | PARSEOP_LOCAL4 {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);} - | PARSEOP_LOCAL5 {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);} - | PARSEOP_LOCAL6 {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);} - | PARSEOP_LOCAL7 {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);} - ; - -DebugTerm - : PARSEOP_DEBUG {$$ = TrCreateLeafNode (PARSEOP_DEBUG);} - ; - - -ByteConst - : Integer {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} - ; - -WordConst - : Integer {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} - ; - -DWordConst - : Integer {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} - ; - -QWordConst - : Integer {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} - ; - -Integer - : PARSEOP_INTEGER {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);} - ; - -String - : PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);} - ; - -ConstTerm - : ConstExprTerm {} - | PARSEOP_REVISION {$$ = TrCreateLeafNode (PARSEOP_REVISION);} - ; - -ConstExprTerm - : PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);} - | PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);} - | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);} - | PARSEOP___DATE__ {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);} - | PARSEOP___FILE__ {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);} - | PARSEOP___LINE__ {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);} - | PARSEOP___PATH__ {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);} - ; - -/* - * The NODE_COMPILE_TIME_CONST flag in the following constant expressions - * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes - * to simple integers. It is an error if these types of expressions cannot be - * reduced, since the AML grammar for ****ConstExpr requires a simple constant. - * Note: The required byte length of the constant is passed through to the - * constant folding code in the node AmlLength field. - */ -ByteConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} - | ByteConst {} - ; - -WordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} - | WordConst {} - ; - -DWordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} - | DWordConst {} - ; - -QWordConstExpr - : Type3Opcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} - | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} - | ConstExprTerm {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} - | QWordConst {} - ; - -/* OptionalCount must appear before ByteList or an incorrect reduction will result */ - -OptionalCount - : {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ - | ',' {$$ = TrCreateLeafNode (PARSEOP_ONES);} /* Placeholder is a OnesOp object */ - | ',' TermArg {$$ = $2;} - ; - -BufferTerm - : PARSEOP_BUFFER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_BUFFER);} - OptionalTermArg - ')' '{' - BufferTermData '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_BUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -BufferTermData - : ByteList {} - | StringData {} - ; - -ByteList - : {$$ = NULL;} - | ByteConstExpr - | ByteList ',' /* Allows a trailing comma at list end */ - | ByteList ',' - ByteConstExpr {$$ = TrLinkPeerNode ($1,$3);} - ; - -DataBufferTerm - : PARSEOP_DATABUFFER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DATABUFFER);} - OptionalWordConst - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_DATABUFFER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordList - : {$$ = NULL;} - | DWordConstExpr - | DWordList ',' /* Allows a trailing comma at list end */ - | DWordList ',' - DWordConstExpr {$$ = TrLinkPeerNode ($1,$3);} - ; - -PackageTerm - : PARSEOP_PACKAGE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);} - VarPackageLengthTerm - ')' '{' - PackageList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_PACKAGE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -PackageList - : {$$ = NULL;} - | PackageElement - | PackageList ',' /* Allows a trailing comma at list end */ - | PackageList ',' - PackageElement {$$ = TrLinkPeerNode ($1,$3);} - ; - -PackageElement - : DataObject {} - | NameString {} - ; - -VarPackageLengthTerm - : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | TermArg {$$ = $1;} - ; - - -/******* Macros ***********************************************/ - - -EISAIDTerm - : PARSEOP_EISAID '(' - StringData ')' {$$ = TrUpdateNode (PARSEOP_EISAID, $3);} - | PARSEOP_EISAID '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -UnicodeTerm - : PARSEOP_UNICODE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UNICODE);} - StringData - ')' {$$ = TrLinkChildren ($<n>3,2,0,$4);} - | PARSEOP_UNICODE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -/******* Resources and Memory ***********************************************/ - - -/* - * Note: Create two default nodes to allow conversion to a Buffer AML opcode - * Also, insert the EndTag at the end of the template. - */ -ResourceTemplateTerm - : PARSEOP_RESOURCETEMPLATE '(' ')' - '{' - ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4, - TrCreateLeafNode (PARSEOP_DEFAULT_ARG), - TrCreateLeafNode (PARSEOP_DEFAULT_ARG), - $5, - TrCreateLeafNode (PARSEOP_ENDTAG));} - ; - -ResourceMacroList - : {$$ = NULL;} - | ResourceMacroList - ResourceMacroTerm {$$ = TrLinkPeerNode ($1,$2);} - ; - -ResourceMacroTerm - : DMATerm {} - | DWordIOTerm {} - | DWordMemoryTerm {} - | DWordSpaceTerm {} - | EndDependentFnTerm {} - | ExtendedIOTerm {} - | ExtendedMemoryTerm {} - | ExtendedSpaceTerm {} - | FixedDmaTerm {} - | FixedIOTerm {} - | GpioIntTerm {} - | GpioIoTerm {} - | I2cSerialBusTerm {} - | InterruptTerm {} - | IOTerm {} - | IRQNoFlagsTerm {} - | IRQTerm {} - | Memory24Term {} - | Memory32FixedTerm {} - | Memory32Term {} - | QWordIOTerm {} - | QWordMemoryTerm {} - | QWordSpaceTerm {} - | RegisterTerm {} - | SpiSerialBusTerm {} - | StartDependentFnNoPriTerm {} - | StartDependentFnTerm {} - | UartSerialBusTerm {} - | VendorLongTerm {} - | VendorShortTerm {} - | WordBusNumberTerm {} - | WordIOTerm {} - | WordSpaceTerm {} - ; - -DMATerm - : PARSEOP_DMA '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DMA);} - DMATypeKeyword - OptionalBusMasterKeyword - ',' XferTypeKeyword - OptionalNameString_Last - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$5,$7,$8,$11);} - | PARSEOP_DMA '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordIOTerm - : PARSEOP_DWORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_DWORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordMemoryTerm - : PARSEOP_DWORDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_DWORDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -DWordSpaceTerm - : PARSEOP_DWORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_DWORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - - -EndDependentFnTerm - : PARSEOP_ENDDEPENDENTFN '(' - ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} - | PARSEOP_ENDDEPENDENTFN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedIOTerm - : PARSEOP_EXTENDEDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} - | PARSEOP_EXTENDEDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedMemoryTerm - : PARSEOP_EXTENDEDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} - | PARSEOP_EXTENDEDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -ExtendedSpaceTerm - : PARSEOP_EXTENDEDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalQWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,13,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} - | PARSEOP_EXTENDEDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FixedDmaTerm - : PARSEOP_FIXEDDMA '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} - WordConstExpr /* 04: DMA RequestLines */ - ',' WordConstExpr /* 06: DMA Channels */ - OptionalXferSize /* 07: DMA TransferSize */ - OptionalNameString /* 08: DescriptorName */ - ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$7,$8);} - | PARSEOP_FIXEDDMA '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -FixedIOTerm - : PARSEOP_FIXEDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} - WordConstExpr - ',' ByteConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);} - | PARSEOP_FIXEDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -GpioIntTerm - : PARSEOP_GPIO_INT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} - InterruptTypeKeyword /* 04: InterruptType */ - ',' InterruptLevel /* 06: InterruptLevel */ - OptionalShareType /* 07: SharedType */ - ',' PinConfigByte /* 09: PinConfig */ - OptionalWordConstExpr /* 10: DebounceTimeout */ - ',' StringData /* 12: ResourceSource */ - OptionalByteConstExpr /* 13: ResourceSourceIndex */ - OptionalResourceType /* 14: ResourceType */ - OptionalNameString /* 15: DescriptorName */ - OptionalBuffer_Last /* 16: VendorData */ - ')' '{' - DWordConstExpr '}' {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);} - | PARSEOP_GPIO_INT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -GpioIoTerm - : PARSEOP_GPIO_IO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} - OptionalShareType_First /* 04: SharedType */ - ',' PinConfigByte /* 06: PinConfig */ - OptionalWordConstExpr /* 07: DebounceTimeout */ - OptionalWordConstExpr /* 08: DriveStrength */ - OptionalIoRestriction /* 09: IoRestriction */ - ',' StringData /* 11: ResourceSource */ - OptionalByteConstExpr /* 12: ResourceSourceIndex */ - OptionalResourceType /* 13: ResourceType */ - OptionalNameString /* 14: DescriptorName */ - OptionalBuffer_Last /* 15: VendorData */ - ')' '{' - DWordList '}' {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);} - | PARSEOP_GPIO_IO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -I2cSerialBusTerm - : PARSEOP_I2C_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} - WordConstExpr /* 04: SlaveAddress */ - OptionalSlaveMode /* 05: SlaveMode */ - ',' DWordConstExpr /* 07: ConnectionSpeed */ - OptionalAddressingMode /* 08: AddressingMode */ - ',' StringData /* 10: ResourceSource */ - OptionalByteConstExpr /* 11: ResourceSourceIndex */ - OptionalResourceType /* 12: ResourceType */ - OptionalNameString /* 13: DescriptorName */ - OptionalBuffer_Last /* 14: VendorData */ - ')' {$$ = TrLinkChildren ($<n>3,9,$4,$5,$7,$8,$10,$11,$12,$13,$14);} - | PARSEOP_I2C_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -InterruptTerm - : PARSEOP_INTERRUPT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INTERRUPT);} - OptionalResourceType_First - ',' InterruptTypeKeyword - ',' InterruptLevel - OptionalShareType - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' '{' - DWordList '}' {$$ = TrLinkChildren ($<n>3,8,$4,$6,$8,$9,$10,$11,$12,$15);} - | PARSEOP_INTERRUPT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IOTerm - : PARSEOP_IO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IO);} - IODecodeKeyword - ',' WordConstExpr - ',' WordConstExpr - ',' ByteConstExpr - ',' ByteConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_IO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IRQNoFlagsTerm - : PARSEOP_IRQNOFLAGS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_IRQNOFLAGS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -IRQTerm - : PARSEOP_IRQ '(' {$<n>$ = TrCreateLeafNode (PARSEOP_IRQ);} - InterruptTypeKeyword - ',' InterruptLevel - OptionalShareType - OptionalNameString_Last - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$7,$8,$11);} - | PARSEOP_IRQ '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory24Term - : PARSEOP_MEMORY24 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY24);} - OptionalReadWriteKeyword - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY24 '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory32FixedTerm - : PARSEOP_MEMORY32FIXED '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} - OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$8,$9);} - | PARSEOP_MEMORY32FIXED '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -Memory32Term - : PARSEOP_MEMORY32 '(' {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32);} - OptionalReadWriteKeyword - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - ',' DWordConstExpr - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);} - | PARSEOP_MEMORY32 '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordIOTerm - : PARSEOP_QWORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_QWORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordMemoryTerm - : PARSEOP_QWORDMEMORY '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);} - OptionalResourceType_First - OptionalDecodeType - OptionalMinType - OptionalMaxType - OptionalMemType - ',' OptionalReadWriteKeyword - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalAddressRange - OptionalType_Last - ')' {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);} - | PARSEOP_QWORDMEMORY '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -QWordSpaceTerm - : PARSEOP_QWORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - ',' QWordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_QWORDSPACE '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -RegisterTerm - : PARSEOP_REGISTER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_REGISTER);} - AddressSpaceKeyword - ',' ByteConstExpr - ',' ByteConstExpr - ',' QWordConstExpr - OptionalAccessSize - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$11,$12);} - | PARSEOP_REGISTER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -SpiSerialBusTerm - : PARSEOP_SPI_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} - WordConstExpr /* 04: DeviceSelection */ - OptionalDevicePolarity /* 05: DevicePolarity */ - OptionalWireMode /* 06: WireMode */ - ',' ByteConstExpr /* 08: DataBitLength */ - OptionalSlaveMode /* 09: SlaveMode */ - ',' DWordConstExpr /* 11: ConnectionSpeed */ - ',' ClockPolarityKeyword /* 13: ClockPolarity */ - ',' ClockPhaseKeyword /* 15: ClockPhase */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalBuffer_Last /* 21: VendorData */ - ')' {$$ = TrLinkChildren ($<n>3,13,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20,$21);} - | PARSEOP_SPI_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -StartDependentFnNoPriTerm - : PARSEOP_STARTDEPENDENTFN_NOPRI '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);} - ')' '{' - ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,1,$6);} - | PARSEOP_STARTDEPENDENTFN_NOPRI '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -StartDependentFnTerm - : PARSEOP_STARTDEPENDENTFN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);} - ByteConstExpr - ',' ByteConstExpr - ')' '{' - ResourceMacroList '}' {$$ = TrLinkChildren ($<n>3,3,$4,$6,$9);} - | PARSEOP_STARTDEPENDENTFN '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -UartSerialBusTerm - : PARSEOP_UART_SERIALBUS '(' {$<n>$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} - DWordConstExpr /* 04: ConnectionSpeed */ - OptionalBitsPerByte /* 05: BitsPerByte */ - OptionalStopBits /* 06: StopBits */ - ',' ByteConstExpr /* 08: LinesInUse */ - OptionalEndian /* 09: Endianess */ - OptionalParityType /* 10: Parity */ - OptionalFlowControl /* 11: FlowControl */ - ',' WordConstExpr /* 13: Rx BufferSize */ - ',' WordConstExpr /* 15: Tx BufferSize */ - ',' StringData /* 17: ResourceSource */ - OptionalByteConstExpr /* 18: ResourceSourceIndex */ - OptionalResourceType /* 19: ResourceType */ - OptionalNameString /* 20: DescriptorName */ - OptionalBuffer_Last /* 21: VendorData */ - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20,$21);} - | PARSEOP_UART_SERIALBUS '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -VendorLongTerm - : PARSEOP_VENDORLONG '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORLONG);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_VENDORLONG '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -VendorShortTerm - : PARSEOP_VENDORSHORT '(' {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);} - OptionalNameString_First - ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_VENDORSHORT '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordBusNumberTerm - : PARSEOP_WORDBUSNUMBER '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,12,$4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);} - | PARSEOP_WORDBUSNUMBER '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordIOTerm - : PARSEOP_WORDIO '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDIO);} - OptionalResourceType_First - OptionalMinType - OptionalMaxType - OptionalDecodeType - OptionalRangeType - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString - OptionalType - OptionalTranslationType_Last - ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);} - | PARSEOP_WORDIO '(' - error ')' {$$ = AslDoError(); yyclearin;} - ; - -WordSpaceTerm - : PARSEOP_WORDSPACE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} - ByteConstExpr {UtCheckIntegerRange ($4, 0xC0, 0xFF);} - OptionalResourceType - OptionalDecodeType - OptionalMinType - OptionalMaxType - ',' ByteConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - ',' WordConstExpr - OptionalByteConstExpr - OptionalStringData - OptionalNameString_Last - ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} - | PARSEOP_WORDSPACE '(' +WhileTerm + : PARSEOP_WHILE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_WHILE);} + TermArg + ')' '{' TermList '}' + {$$ = TrLinkChildren ($<n>3,2,$4,$7);} + | PARSEOP_WHILE '(' error ')' {$$ = AslDoError(); yyclearin;} ; -/******* Object References ***********************************************/ - -/* Allow IO, DMA, IRQ Resource macro names to also be used as identifiers */ - -NameString - : NameSeg {} - | PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) AslCompilerlval.s);} - | PARSEOP_IO {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");} - | PARSEOP_DMA {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");} - | PARSEOP_IRQ {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");} - ; - -NameSeg - : PARSEOP_NAMESEG {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) AslCompilerlval.s);} - ; - - -/******* Helper rules ****************************************************/ - +/******************************************************************************* + * + * ASL Helper Terms + * + ******************************************************************************/ AmlPackageLengthTerm : Integer {$$ = TrUpdateNode (PARSEOP_PACKAGE_LENGTH,(ACPI_PARSE_OBJECT *) $1);} @@ -2748,166 +1713,12 @@ TermArgItem | ',' error {$$ = AslDoError (); yyclearin;} ; -OptionalBusMasterKeyword - : ',' {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} - | ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} - | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);} - ; - -OptionalAccessAttribTerm - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ByteConstExpr {$$ = $2;} - | ',' AccessAttribKeyword {$$ = $2;} - ; - -OptionalAccessSize - : {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalAddressingMode - : ',' {$$ = NULL;} - | ',' AddressingModeKeyword {$$ = $2;} - ; - -OptionalAddressRange - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' AddressKeyword {$$ = $2;} - ; - -OptionalBitsPerByte - : ',' {$$ = NULL;} - | ',' BitsPerByteKeyword {$$ = $2;} - ; - -OptionalBuffer_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' DataBufferTerm {$$ = $2;} - ; - -OptionalByteConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ByteConstExpr {$$ = $2;} - ; - -OptionalDecodeType - : ',' {$$ = NULL;} - | ',' DecodeKeyword {$$ = $2;} - ; - -OptionalDevicePolarity - : ',' {$$ = NULL;} - | ',' DevicePolarityKeyword {$$ = $2;} - ; - -OptionalDWordConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' DWordConstExpr {$$ = $2;} - ; - -OptionalEndian - : ',' {$$ = NULL;} - | ',' EndianKeyword {$$ = $2;} - ; - -OptionalFlowControl - : ',' {$$ = NULL;} - | ',' FlowControlKeyword {$$ = $2;} - ; - -OptionalIoRestriction - : ',' {$$ = NULL;} - | ',' IoRestrictionKeyword {$$ = $2;} - ; - -OptionalListString - : {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */ - | ',' TermArg {$$ = $2;} - ; - -OptionalMaxType - : ',' {$$ = NULL;} - | ',' MaxKeyword {$$ = $2;} - ; - -OptionalMemType - : ',' {$$ = NULL;} - | ',' MemTypeKeyword {$$ = $2;} - ; - -OptionalMinType - : ',' {$$ = NULL;} - | ',' MinKeyword {$$ = $2;} - ; - -OptionalNameString - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' NameString {$$ = $2;} - ; - -OptionalNameString_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' NameString {$$ = $2;} - ; - -OptionalNameString_First - : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} - | NameString {$$ = $1;} - ; - -OptionalObjectTypeKeyword - : {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);} - | ',' ObjectTypeKeyword {$$ = $2;} - ; - -OptionalParityType - : ',' {$$ = NULL;} - | ',' ParityTypeKeyword {$$ = $2;} - ; - -OptionalQWordConstExpr - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' QWordConstExpr {$$ = $2;} - ; - -OptionalRangeType - : ',' {$$ = NULL;} - | ',' RangeTypeKeyword {$$ = $2;} - ; - -OptionalReadWriteKeyword - : {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} - | PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} - | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);} - ; - OptionalReference : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ | ',' {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ | ',' TermArg {$$ = $2;} ; -OptionalResourceType_First - : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ResourceTypeKeyword {$$ = $1;} - ; - -OptionalResourceType - : {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ',' {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);} - | ',' ResourceTypeKeyword {$$ = $2;} - ; - OptionalReturnArg : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */ | TermArg {$$ = $1;} @@ -2919,73 +1730,17 @@ OptionalSerializeRuleKeyword | ',' SerializeRuleKeyword {$$ = $2;} ; -OptionalSlaveMode - : ',' {$$ = NULL;} - | ',' SlaveModeKeyword {$$ = $2;} - ; - -OptionalShareType - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' ShareTypeKeyword {$$ = $2;} - ; - -OptionalShareType_First - : {$$ = NULL;} - | ShareTypeKeyword {$$ = $1;} - ; - -OptionalStopBits - : ',' {$$ = NULL;} - | ',' StopBitsKeyword {$$ = $2;} - ; - -OptionalStringData - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' StringData {$$ = $2;} - ; - OptionalTermArg - : {$$ = NULL;} + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} | TermArg {$$ = $1;} ; -OptionalType +OptionalBufferLength : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TypeKeyword {$$ = $2;} - ; - -OptionalType_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TypeKeyword {$$ = $2;} - ; - -OptionalTranslationType_Last - : {$$ = NULL;} - | ',' {$$ = NULL;} - | ',' TranslationKeyword {$$ = $2;} - ; - -OptionalWireMode - : ',' {$$ = NULL;} - | ',' WireModeKeyword {$$ = $2;} + | TermArg {$$ = $1;} ; OptionalWordConst : {$$ = NULL;} | WordConst {$$ = $1;} ; - -OptionalWordConstExpr - : ',' {$$ = NULL;} - | ',' WordConstExpr {$$ = $2;} - ; - -OptionalXferSize - : {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} - | ',' XferSizeKeyword {$$ = $2;} - ; diff --git a/sys/contrib/dev/acpica/compiler/aslstartup.c b/sys/contrib/dev/acpica/compiler/aslstartup.c index 85e2f88..cd3bb94 100644 --- a/sys/contrib/dev/acpica/compiler/aslstartup.c +++ b/sys/contrib/dev/acpica/compiler/aslstartup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -144,62 +144,63 @@ AslDetectSourceFileType ( ASL_FILE_INFO *Info) { char *FileChar; - UINT8 Type; + UINT8 Type = ASL_INPUT_TYPE_ASCII_DATA; /* default */ ACPI_STATUS Status; - /* Check for a valid binary ACPI table */ + /* Check for 100% ASCII source file (comments are ignored) */ - Status = FlCheckForAcpiTable (Info->Handle); + Status = FlIsFileAsciiSource (Info->Filename, FALSE); if (ACPI_SUCCESS (Status)) { - Type = ASL_INPUT_TYPE_ACPI_TABLE; - goto Cleanup; - } + /* + * File contains ASCII source code. Determine if this is an ASL + * file or an ACPI data table file. + */ + while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle)) + { + /* Uppercase the buffer for caseless compare */ - /* Check for 100% ASCII source file (comments are ignored) */ + FileChar = Gbl_CurrentLineBuffer; + while (*FileChar) + { + *FileChar = (char) toupper ((int) *FileChar); + FileChar++; + } - Status = FlCheckForAscii (Info->Filename, TRUE); - if (ACPI_FAILURE (Status)) - { - printf ("Invalid characters in input file - %s\n", Info->Filename); + /* Presence of "DefinitionBlock" indicates actual ASL code */ - if (!Gbl_IgnoreErrors) - { - Type = ASL_INPUT_TYPE_BINARY; - goto Cleanup; + if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK")) + { + /* Appears to be an ASL file */ + + Type = ASL_INPUT_TYPE_ASCII_ASL; + goto Cleanup; + } } - } - /* - * File is ASCII. Determine if this is an ASL file or an ACPI data - * table file. - */ - while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle)) - { - /* Uppercase the buffer for caseless compare */ + /* Appears to be an ASCII data table source file */ - FileChar = Gbl_CurrentLineBuffer; - while (*FileChar) - { - *FileChar = (char) toupper ((int) *FileChar); - FileChar++; - } + Type = ASL_INPUT_TYPE_ASCII_DATA; + goto Cleanup; + } - /* Presence of "DefinitionBlock" indicates actual ASL code */ + /* We have some sort of binary table, check for valid ACPI table */ - if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK")) - { - /* Appears to be an ASL file */ + fseek (Info->Handle, 0, SEEK_SET); - Type = ASL_INPUT_TYPE_ASCII_ASL; - goto Cleanup; - } + Status = AcValidateTableHeader (Info->Handle, 0); + if (ACPI_SUCCESS (Status)) + { + fprintf (stderr, + "Binary file appears to be a valid ACPI table, disassembling\n"); + + Type = ASL_INPUT_TYPE_BINARY_ACPI_TABLE; + goto Cleanup; } - /* Not an ASL source file, default to a data table source file */ + Type = ASL_INPUT_TYPE_BINARY; - Type = ASL_INPUT_TYPE_ASCII_DATA; Cleanup: @@ -246,9 +247,14 @@ AslDoDisassembly ( return (Status); } + /* Handle additional output files for disassembler */ + + Gbl_FileType = ASL_INPUT_TYPE_BINARY_ACPI_TABLE; + Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); + /* This is where the disassembly happens */ - AcpiGbl_DbOpt_Disasm = TRUE; + AcpiGbl_DmOpt_Disasm = TRUE; Status = AdAmlDisassemble (AslToFile, Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_OutputFilenamePrefix, &Gbl_Files[ASL_FILE_INPUT].Filename); @@ -261,13 +267,6 @@ AslDoDisassembly ( AcpiDmUnresolvedWarning (0); -#if 0 - /* TBD: Handle additional output files for disassembler */ - - Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); - NsDisplayNamespace (); -#endif - /* Shutdown compiler and ACPICA subsystem */ AeClearErrorLog (); @@ -359,6 +358,8 @@ AslDoOneFile ( return (AE_ERROR); } + Gbl_OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT); + /* Determine input file type */ Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]); @@ -454,7 +455,7 @@ AslDoOneFile ( /* * Binary ACPI table was auto-detected, disassemble it */ - case ASL_INPUT_TYPE_ACPI_TABLE: + case ASL_INPUT_TYPE_BINARY_ACPI_TABLE: /* We have what appears to be an ACPI table, disassemble it */ diff --git a/sys/contrib/dev/acpica/compiler/aslstubs.c b/sys/contrib/dev/acpica/compiler/aslstubs.c index 2259255..2d8d21c 100644 --- a/sys/contrib/dev/acpica/compiler/aslstubs.c +++ b/sys/contrib/dev/acpica/compiler/aslstubs.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -64,6 +64,13 @@ AcpiNsExecModuleCodeList ( } ACPI_STATUS +AcpiNsInitializeObjects ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS AcpiHwReadPort ( ACPI_IO_ADDRESS Address, UINT32 *Value, @@ -120,6 +127,13 @@ AcpiDsStoreObjectToLocal ( } ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue) @@ -165,15 +179,6 @@ AcpiEvInitializeRegion ( return (AE_OK); } -void -AcpiExDoDebugObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - UINT32 Level, - UINT32 Index) -{ - return; -} - ACPI_STATUS AcpiExReadDataFromField ( ACPI_WALK_STATE *WalkState, @@ -216,6 +221,60 @@ AcpiExLoadOp ( return (AE_SUPPORT); } +void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index) +{ + return; +} + +void +AcpiExStartTraceMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + return; +} + +void +AcpiExStopTraceMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + return; +} + +void +AcpiExStartTraceOpcode ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + return; +} + +void +AcpiExStopTraceOpcode ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) + +{ + return; +} + +void +AcpiExTracePoint ( + ACPI_TRACE_EVENT_TYPE Type, + BOOLEAN Begin, + UINT8 *Aml, + char *Pathname) +{ + return; +} + ACPI_STATUS AcpiTbFindTable ( char *Signature, @@ -225,3 +284,45 @@ AcpiTbFindTable ( { return (AE_SUPPORT); } + +ACPI_STATUS +AcpiNsLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *Node) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc) +{ + return (AE_OK); +} + +void +AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_WALK_STATE *WalkState) +{ + return; +} + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_THREAD_STATE *Thread, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState) +{ + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.l b/sys/contrib/dev/acpica/compiler/aslsupport.l index b3149cf..deb9e9a 100644 --- a/sys/contrib/dev/acpica/compiler/aslsupport.l +++ b/sys/contrib/dev/acpica/compiler/aslsupport.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -113,6 +113,7 @@ AslDoLineDirective ( char *Filename; UINT32 i; + Gbl_HasIncludeFiles = TRUE; /* Eat the entire line that contains the #line directive */ @@ -195,9 +196,13 @@ AslPopInputFileStack ( ASL_FILE_NODE *Fnode; + Gbl_PreviousIncludeFilename = Gbl_Files[ASL_FILE_INPUT].Filename; Fnode = Gbl_IncludeFileStack; DbgPrint (ASL_PARSE_OUTPUT, - "\nPop InputFile Stack, Fnode %p\n\n", Fnode); + "\nPop InputFile Stack, Fnode %p\n", Fnode); + + DbgPrint (ASL_PARSE_OUTPUT, + "Include: Closing \"%s\"\n\n", Gbl_Files[ASL_FILE_INPUT].Filename); if (!Fnode) { @@ -713,7 +718,7 @@ DoCharacter: * string and resume processing of the next character */ ConvertBuffer[i] = 0; - Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8); + Digit = (UINT8) strtoul (ConvertBuffer, NULL, 8); /* Check for NULL or non-ascii character (ignore if so) */ @@ -749,7 +754,7 @@ DoCharacter: /* Up to two hex digits allowed */ - if (!ACPI_IS_XDIGIT (StringChar) || + if (!isxdigit (StringChar) || (i > 1)) { /* @@ -757,7 +762,7 @@ DoCharacter: * string and resume processing of the next character */ ConvertBuffer[i] = 0; - Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16); + Digit = (UINT8) strtoul (ConvertBuffer, NULL, 16); /* Check for NULL or non-ascii character (ignore if so) */ @@ -830,7 +835,7 @@ CompletedString: return (FALSE); } - ACPI_STRCPY (CleanString, MsgBuffer); + strcpy (CleanString, MsgBuffer); AslCompilerlval.s = CleanString; return (TRUE); diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.y b/sys/contrib/dev/acpica/compiler/aslsupport.y index ba81b7d..cd2605b 100644 --- a/sys/contrib/dev/acpica/compiler/aslsupport.y +++ b/sys/contrib/dev/acpica/compiler/aslsupport.y @@ -6,7 +6,7 @@ NoEcho(' *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/asltokens.y b/sys/contrib/dev/acpica/compiler/asltokens.y index 511fa9b..429fa42 100644 --- a/sys/contrib/dev/acpica/compiler/asltokens.y +++ b/sys/contrib/dev/acpica/compiler/asltokens.y @@ -6,7 +6,7 @@ NoEcho(' *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,7 +124,7 @@ NoEcho(' %token <i> PARSEOP_DECREMENT %token <i> PARSEOP_DEFAULT %token <i> PARSEOP_DEFAULT_ARG -%token <i> PARSEOP_DEFINITIONBLOCK +%token <i> PARSEOP_DEFINITION_BLOCK %token <i> PARSEOP_DEREFOF %token <i> PARSEOP_DEVICE %token <i> PARSEOP_DEVICEPOLARITY_HIGH @@ -166,6 +166,7 @@ NoEcho(' %token <i> PARSEOP_GPIO_INT %token <i> PARSEOP_GPIO_IO %token <i> PARSEOP_I2C_SERIALBUS +%token <i> PARSEOP_I2C_SERIALBUS_V2 %token <i> PARSEOP_IF %token <i> PARSEOP_INCLUDE %token <i> PARSEOP_INCLUDE_END @@ -323,6 +324,7 @@ NoEcho(' %token <i> PARSEOP_SLAVEMODE_DEVICEINIT %token <i> PARSEOP_SLEEP %token <i> PARSEOP_SPI_SERIALBUS +%token <i> PARSEOP_SPI_SERIALBUS_V2 %token <i> PARSEOP_STALL %token <i> PARSEOP_STARTDEPENDENTFN %token <i> PARSEOP_STARTDEPENDENTFN_NOPRI @@ -348,6 +350,7 @@ NoEcho(' %token <i> PARSEOP_TYPE_STATIC %token <i> PARSEOP_TYPE_TRANSLATION %token <i> PARSEOP_UART_SERIALBUS +%token <i> PARSEOP_UART_SERIALBUS_V2 %token <i> PARSEOP_UNICODE %token <i> PARSEOP_UNLOAD %token <i> PARSEOP_UPDATERULE_ONES @@ -452,12 +455,24 @@ NoEcho(' %left <i> PARSEOP_EXP_INCREMENT PARSEOP_EXP_DECREMENT +/* Brackets for Index() support */ + +%left <i> PARSEOP_EXP_INDEX_LEFT +%right <i> PARSEOP_EXP_INDEX_RIGHT + +/* Macros */ + %token <i> PARSEOP_PRINTF %token <i> PARSEOP_FPRINTF +%token <i> PARSEOP_FOR + /* Specific parentheses tokens are not used at this time */ /* PARSEOP_EXP_PAREN_OPEN */ /* PARSEOP_EXP_PAREN_CLOSE */ + +%token <i> PARSEOP_ASL_CODE + /* * Special functions. These should probably stay at the end of this * table. diff --git a/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c index c46801b..cc87390 100644 --- a/sys/contrib/dev/acpica/compiler/asltransform.c +++ b/sys/contrib/dev/acpica/compiler/asltransform.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,7 +111,7 @@ TrAmlGetNextTempName ( char *TempName; - if (*TempCount >= (10+26)) /* 0-35 valid: 0-9 and A-Z for TempName[3] */ + if (*TempCount >= (10 + 26)) /* 0-35 valid: 0-9 and A-Z for TempName[3] */ { /* Too many temps */ @@ -129,6 +129,7 @@ TrAmlGetNextTempName ( { TempName[3] = (char) (*TempCount + ('A' - 10)); } + (*TempCount)++; /* First three characters are always "_T_" */ @@ -217,7 +218,7 @@ TrAmlSetSubtreeParent ( while (Next) { Next->Asl.Parent = Parent; - Next = Next->Asl.Next; + Next = Next->Asl.Next; } } @@ -242,13 +243,13 @@ TrAmlInsertPeer ( { NewPeer->Asl.Next = Op->Asl.Next; - Op->Asl.Next = NewPeer; + Op->Asl.Next = NewPeer; } /******************************************************************************* * - * FUNCTION: TrAmlTransformWalk + * FUNCTION: TrAmlTransformWalkBegin * * PARAMETERS: ASL_WALK_CALLBACK * @@ -260,7 +261,7 @@ TrAmlInsertPeer ( ******************************************************************************/ ACPI_STATUS -TrAmlTransformWalk ( +TrAmlTransformWalkBegin ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) @@ -273,6 +274,38 @@ TrAmlTransformWalk ( /******************************************************************************* * + * FUNCTION: TrAmlTransformWalkEnd + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: None + * + * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML + * operands. + * + ******************************************************************************/ + +ACPI_STATUS +TrAmlTransformWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + + /* Save possible Externals list in the DefintionBlock Op */ + + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) + { + Op->Asl.Value.Arg = Gbl_ExternalsListHead; + Gbl_ExternalsListHead = NULL; + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: TrTransformSubtree * * PARAMETERS: Op - The parent parse node @@ -297,7 +330,7 @@ TrTransformSubtree ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_DEFINITION_BLOCK: TrDoDefinitionBlock (Op); break; @@ -315,6 +348,15 @@ TrTransformSubtree ( Gbl_TempCount = 0; break; + case PARSEOP_EXTERNAL: + + if (Gbl_DoExternals == TRUE) + { + ExDoExternal (Op); + } + + break; + default: /* Nothing to do here for other opcodes */ @@ -346,6 +388,10 @@ TrDoDefinitionBlock ( UINT32 i; + /* Reset external list when starting a definition block */ + + Gbl_ExternalsListHead = NULL; + Next = Op->Asl.Child; for (i = 0; i < 5; i++) { @@ -448,7 +494,7 @@ TrDoSwitch ( { /* Add an ELSE to complete the previous CASE */ - NewOp = TrCreateLeafNode (PARSEOP_ELSE); + NewOp = TrCreateLeafNode (PARSEOP_ELSE); NewOp->Asl.Parent = Conditional->Asl.Parent; TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent); @@ -458,9 +504,9 @@ TrDoSwitch ( CurrentParentNode = NewOp; } - CaseOp = Next; + CaseOp = Next; Conditional = CaseOp; - CaseBlock = CaseOp->Asl.Child->Asl.Next; + CaseBlock = CaseOp->Asl.Child->Asl.Next; Conditional->Asl.Child->Asl.Next = NULL; Predicate = CaseOp->Asl.Child; @@ -537,7 +583,7 @@ TrDoSwitch ( * CaseOp->Child->Peer is the beginning of the case block */ NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, - (UINT64) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); NewOp->Asl.Next = Predicate; TrAmlInitLineNumbers (NewOp, Predicate); @@ -600,7 +646,7 @@ TrDoSwitch ( /* Unknown peer opcode */ AcpiOsPrintf ("Unknown parse opcode for switch statement: %s (%u)\n", - Next->Asl.ParseOpName, Next->Asl.ParseOpcode); + Next->Asl.ParseOpName, Next->Asl.ParseOpcode); } } @@ -645,7 +691,7 @@ TrDoSwitch ( Next = StartNode; while ((Next->Asl.ParseOpcode != PARSEOP_METHOD) && - (Next->Asl.ParseOpcode != PARSEOP_DEFINITIONBLOCK)) + (Next->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK)) { Next = Next->Asl.Parent; } @@ -668,7 +714,8 @@ TrDoSwitch ( */ if (Next->Asl.ParseOpcode != PARSEOP_SERIALIZERULE_SERIAL) { - AslError (ASL_REMARK, ASL_MSG_SERIALIZED, MethodOp, "Due to use of Switch operator"); + AslError (ASL_REMARK, ASL_MSG_SERIALIZED, MethodOp, + "Due to use of Switch operator"); Next->Asl.ParseOpcode = PARSEOP_SERIALIZERULE_SERIAL; } @@ -682,7 +729,7 @@ TrDoSwitch ( /* Create the NameSeg child for the Name node */ NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESEG, - (UINT64) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); TrAmlInitLineNumbers (NewOp2, NewOp); NewOp2->Asl.CompileFlags |= NODE_IS_NAME_DECLARATION; NewOp->Asl.Child = NewOp2; @@ -694,25 +741,25 @@ TrDoSwitch ( case ACPI_BTYPE_INTEGER: NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO, - (UINT64) 0); + (UINT64) 0); TrAmlInitLineNumbers (NewOp2->Asl.Next, NewOp); break; case ACPI_BTYPE_STRING: NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, - (UINT64) ACPI_TO_INTEGER ("")); + (UINT64) ACPI_TO_INTEGER ("")); TrAmlInitLineNumbers (NewOp2->Asl.Next, NewOp); break; case ACPI_BTYPE_BUFFER: (void) TrLinkPeerNode (NewOp2, TrCreateValuedLeafNode (PARSEOP_BUFFER, - (UINT64) 0)); + (UINT64) 0)); Next = NewOp2->Asl.Next; TrAmlInitLineNumbers (Next, NewOp2); (void) TrLinkChildren (Next, 1, TrCreateValuedLeafNode (PARSEOP_ZERO, - (UINT64) 1)); + (UINT64) 1)); TrAmlInitLineNumbers (Next->Asl.Child, Next); BufferOp = TrCreateValuedLeafNode (PARSEOP_DEFAULT_ARG, (UINT64) 0); @@ -755,7 +802,7 @@ TrDoSwitch ( Predicate->Asl.Parent = StoreOp; NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESEG, - (UINT64) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); TrAmlInitLineNumbers (NewOp, StoreOp); NewOp->Asl.Parent = StoreOp; Predicate->Asl.Next = NewOp; diff --git a/sys/contrib/dev/acpica/compiler/asltree.c b/sys/contrib/dev/acpica/compiler/asltree.c index 68d8072..d2f128e 100644 --- a/sys/contrib/dev/acpica/compiler/asltree.c +++ b/sys/contrib/dev/acpica/compiler/asltree.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,6 +58,29 @@ TrGetNextNode ( /******************************************************************************* * + * FUNCTION: TrSetParent + * + * PARAMETERS: Op - To be set to new parent + * ParentOp - The parent + * + * RETURN: None, sets Op parent directly + * + * DESCRIPTION: Change the parent of a parse op. + * + ******************************************************************************/ + +void +TrSetParent ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *ParentOp) +{ + + Op->Asl.Parent = ParentOp; +} + + +/******************************************************************************* + * * FUNCTION: TrGetNextNode * * PARAMETERS: None @@ -157,10 +180,30 @@ TrReleaseNode ( /******************************************************************************* * + * FUNCTION: TrSetCurrentFilename + * + * PARAMETERS: Op - An existing parse node + * + * RETURN: None + * + * DESCRIPTION: Save the include file filename. Used for debug output only. + * + ******************************************************************************/ + +void +TrSetCurrentFilename ( + ACPI_PARSE_OBJECT *Op) +{ + Op->Asl.Filename = Gbl_PreviousIncludeFilename; +} + + +/******************************************************************************* + * * FUNCTION: TrUpdateNode * * PARAMETERS: ParseOpcode - New opcode to be assigned to the node - * Op - An existing parse node + * Op - An existing parse node * * RETURN: The updated node * @@ -340,6 +383,11 @@ TrPrintNodeCompileFlags ( FlagName = "NODE_METHOD_TYPED"; break; + case NODE_COULD_NOT_REDUCE: + + FlagName = "NODE_COULD_NOT_REDUCE"; + break; + case NODE_COMPILE_TIME_CONST: FlagName = "NODE_COMPILE_TIME_CONST"; @@ -489,7 +537,7 @@ TrSetEndLineNumber ( return; } - Op->Asl.EndLine = Gbl_CurrentLineNumber; + Op->Asl.EndLine = Gbl_CurrentLineNumber; Op->Asl.EndLogicalLine = Gbl_LogicalLineNumber; } @@ -538,6 +586,7 @@ TrCreateAssignmentNode ( case PARSEOP_ADD: case PARSEOP_AND: case PARSEOP_DIVIDE: + case PARSEOP_INDEX: case PARSEOP_MOD: case PARSEOP_MULTIPLY: case PARSEOP_NOT: @@ -752,7 +801,8 @@ TrCreateConstantLeafNode ( } DbgPrint (ASL_PARSE_OUTPUT, - "\nCreateConstantLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X \n", + "\nCreateConstantLeafNode Ln/Col %u/%u NewNode %p " + "Op %s Value %8.8X%8.8X \n", Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode), ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); return (Op); @@ -859,7 +909,8 @@ TrCreateValuedLeafNode ( Op = TrAllocateNode (ParseOpcode); DbgPrint (ASL_PARSE_OUTPUT, - "\nCreateValuedLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X ", + "\nCreateValuedLeafNode Ln/Col %u/%u NewNode %p " + "Op %s Value %8.8X%8.8X ", Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName(ParseOpcode), ACPI_FORMAT_UINT64 (Value)); Op->Asl.Value.Integer = Value; @@ -945,15 +996,22 @@ TrCreateNode ( DbgPrint (ASL_PARSE_OUTPUT, "\nCreateNode Ln/Col %u/%u NewParent %p Child %u Op %s ", - Op->Asl.LineNumber, Op->Asl.Column, Op, NumChildren, UtGetOpName(ParseOpcode)); + Op->Asl.LineNumber, Op->Asl.Column, Op, + NumChildren, UtGetOpName(ParseOpcode)); /* Some extra debug output based on the parse opcode */ switch (ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_ASL_CODE: + + Gbl_ParseTreeRoot = Op; + Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->"); + break; + + case PARSEOP_DEFINITION_BLOCK: - RootNode = Op; DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->"); break; @@ -1074,9 +1132,15 @@ TrLinkChildren ( switch (Op->Asl.ParseOpcode) { - case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_ASL_CODE: + + Gbl_ParseTreeRoot = Op; + Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->"); + break; + + case PARSEOP_DEFINITION_BLOCK: - RootNode = Op; DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->"); break; @@ -1154,6 +1218,7 @@ TrLinkChildren ( Child = Child->Asl.Next; Child->Asl.Parent = Op; } + PrevChild = Child; } @@ -1375,7 +1440,7 @@ TrWalkParseTree ( ACPI_STATUS Status; - if (!RootNode) + if (!Gbl_ParseTreeRoot) { return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h index 4bd24da..411faed 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.h +++ b/sys/contrib/dev/acpica/compiler/asltypes.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,7 +66,7 @@ #define NODE_METHOD_SOME_NO_RETVAL 0x00000200 #define NODE_RESULT_NOT_USED 0x00000400 #define NODE_METHOD_TYPED 0x00000800 -#define NODE_UNUSED_FLAG 0x00001000 +#define NODE_COULD_NOT_REDUCE 0x00001000 #define NODE_COMPILE_TIME_CONST 0x00002000 #define NODE_IS_TERM_ARG 0x00004000 #define NODE_WAS_ONES_OP 0x00008000 @@ -81,6 +81,7 @@ typedef struct asl_method_info { ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *CurrentOp; struct asl_method_info *Next; UINT32 ValidArgTypes[ACPI_METHOD_NUM_ARGS]; UINT32 ValidReturnTypes; @@ -148,32 +149,57 @@ typedef struct asl_file_status /* * File types. Note: Any changes to this table must also be reflected * in the Gbl_Files array. + * + * Corresponding filename suffixes are in comments + * + * NOTE: Don't move the first 4 file types */ typedef enum { ASL_FILE_STDOUT = 0, ASL_FILE_STDERR, - ASL_FILE_INPUT, - ASL_FILE_AML_OUTPUT, /* Don't move these first 4 file types */ - ASL_FILE_SOURCE_OUTPUT, - ASL_FILE_PREPROCESSOR, - ASL_FILE_LISTING_OUTPUT, - ASL_FILE_HEX_OUTPUT, - ASL_FILE_NAMESPACE_OUTPUT, - ASL_FILE_DEBUG_OUTPUT, - ASL_FILE_ASM_SOURCE_OUTPUT, - ASL_FILE_C_SOURCE_OUTPUT, - ASL_FILE_ASM_INCLUDE_OUTPUT, - ASL_FILE_C_INCLUDE_OUTPUT, - ASL_FILE_C_OFFSET_OUTPUT, - ASL_FILE_MAP_OUTPUT + ASL_FILE_INPUT, /* .asl */ + ASL_FILE_AML_OUTPUT, /* .aml */ + ASL_FILE_SOURCE_OUTPUT, /* .src */ + ASL_FILE_PREPROCESSOR, /* .pre */ + ASL_FILE_PREPROCESSOR_USER, /* .i */ + ASL_FILE_LISTING_OUTPUT, /* .lst */ + ASL_FILE_HEX_OUTPUT, /* .hex */ + ASL_FILE_NAMESPACE_OUTPUT, /* .nsp */ + ASL_FILE_DEBUG_OUTPUT, /* .txt */ + ASL_FILE_ASM_SOURCE_OUTPUT, /* .asm */ + ASL_FILE_C_SOURCE_OUTPUT, /* .c */ + ASL_FILE_ASM_INCLUDE_OUTPUT,/* .inc */ + ASL_FILE_C_INCLUDE_OUTPUT, /* .h */ + ASL_FILE_C_OFFSET_OUTPUT, /* .offset.h */ + ASL_FILE_MAP_OUTPUT, /* .map */ + ASL_FILE_XREF_OUTPUT /* .xrf */ } ASL_FILE_TYPES; -#define ASL_MAX_FILE_TYPE 15 +#define ASL_MAX_FILE_TYPE 17 #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) +/* Name suffixes used to create filenames for output files */ + +#define FILE_SUFFIX_ASL_CODE "asl" +#define FILE_SUFFIX_AML_CODE "aml" +#define FILE_SUFFIX_SOURCE "src" +#define FILE_SUFFIX_PREPROCESSOR "pre" +#define FILE_SUFFIX_PREPROC_USER "i" +#define FILE_SUFFIX_LISTING "lst" +#define FILE_SUFFIX_HEX_DUMP "hex" +#define FILE_SUFFIX_NAMESPACE "nsp" +#define FILE_SUFFIX_DEBUG "txt" +#define FILE_SUFFIX_ASM_SOURCE "asm" +#define FILE_SUFFIX_C_SOURCE "c" +#define FILE_SUFFIX_ASM_INCLUDE "inc" +#define FILE_SUFFIX_C_INCLUDE "h" +#define FILE_SUFFIX_C_OFFSET "offset.h" +#define FILE_SUFFIX_MAP "map" +#define FILE_SUFFIX_XREF "xrf" + /* Cache block structure for ParseOps and Strings */ @@ -278,5 +304,36 @@ typedef struct acpi_serial_info } ACPI_SERIAL_INFO; +typedef struct asl_method_local +{ + ACPI_PARSE_OBJECT *Op; + UINT8 Flags; + +} ASL_METHOD_LOCAL; + +/* Values for Flags field above */ + +#define ASL_LOCAL_INITIALIZED (1) +#define ASL_LOCAL_REFERENCED (1<<1) +#define ASL_ARG_IS_LOCAL (1<<2) +#define ASL_ARG_INITIALIZED (1<<3) +#define ASL_ARG_REFERENCED (1<<4) + +/* Info used to track method counts for cross reference output file */ + +typedef struct asl_xref_info +{ + UINT32 ThisMethodInvocations; + UINT32 TotalPredefinedMethods; + UINT32 TotalUserMethods; + UINT32 TotalUnreferenceUserMethods; + UINT32 ThisObjectReferences; + UINT32 TotalObjects; + UINT32 TotalUnreferencedObjects; + ACPI_PARSE_OBJECT *MethodOp; + ACPI_PARSE_OBJECT *CurrentMethodOp; + +} ASL_XREF_INFO; + #endif /* __ASLTYPES_H */ diff --git a/sys/contrib/dev/acpica/compiler/asltypes.y b/sys/contrib/dev/acpica/compiler/asltypes.y index 650b856..1faecb4 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.y +++ b/sys/contrib/dev/acpica/compiler/asltypes.y @@ -6,7 +6,7 @@ NoEcho(' *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,17 +51,17 @@ NoEcho(' *****************************************************************************/ %type <n> ArgList -%type <n> ASLCode +%type <n> AslCode %type <n> BufferData %type <n> BufferTermData %type <n> CompilerDirective %type <n> DataObject %type <n> DefinitionBlockTerm +%type <n> DefinitionBlockList %type <n> IntegerData %type <n> NamedObject %type <n> NameSpaceModifier %type <n> Object -%type <n> ObjectList %type <n> PackageData %type <n> ParameterTypePackage %type <n> ParameterTypePackageList @@ -136,7 +136,7 @@ NoEcho(' %type <n> DefaultTerm %type <n> ElseTerm %type <n> FatalTerm -%type <n> IfElseTerm +%type <n> ElseIfTerm %type <n> IfTerm %type <n> LoadTerm %type <n> NoOpTerm @@ -188,6 +188,7 @@ NoEcho(' %type <n> NotTerm %type <n> ObjectTypeTerm %type <n> OrTerm +%type <n> RawDataBufferTerm %type <n> RefOfTerm %type <n> ShiftLeftTerm %type <n> ShiftRightTerm @@ -293,11 +294,11 @@ NoEcho(' %type <n> PrintfArgList %type <n> PrintfTerm %type <n> FprintfTerm +%type <n> ForTerm /* Resource Descriptors */ %type <n> ConnectionTerm -%type <n> DataBufferTerm %type <n> DMATerm %type <n> DWordIOTerm %type <n> DWordMemoryTerm @@ -311,6 +312,7 @@ NoEcho(' %type <n> GpioIntTerm %type <n> GpioIoTerm %type <n> I2cSerialBusTerm +%type <n> I2cSerialBusTermV2 %type <n> InterruptTerm %type <n> IOTerm %type <n> IRQNoFlagsTerm @@ -325,9 +327,11 @@ NoEcho(' %type <n> QWordSpaceTerm %type <n> RegisterTerm %type <n> SpiSerialBusTerm +%type <n> SpiSerialBusTermV2 %type <n> StartDependentFnNoPriTerm %type <n> StartDependentFnTerm %type <n> UartSerialBusTerm +%type <n> UartSerialBusTermV2 %type <n> VendorLongTerm %type <n> VendorShortTerm %type <n> WordBusNumberTerm @@ -346,6 +350,7 @@ NoEcho(' %type <n> OptionalAddressRange %type <n> OptionalBitsPerByte %type <n> OptionalBuffer_Last +%type <n> OptionalBufferLength %type <n> OptionalByteConstExpr %type <n> OptionalCount %type <n> OptionalDecodeType @@ -365,6 +370,7 @@ NoEcho(' %type <n> OptionalParameterTypePackage %type <n> OptionalParameterTypesPackage %type <n> OptionalParityType +%type <n> OptionalPredicate %type <n> OptionalQWordConstExpr %type <n> OptionalRangeType %type <n> OptionalReference @@ -391,3 +397,4 @@ NoEcho(' */ %type <n> Expression %type <n> EqualsTerm +%type <n> IndexExpTerm diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c index dadd6b1..b3dc354 100644 --- a/sys/contrib/dev/acpica/compiler/aslutils.c +++ b/sys/contrib/dev/acpica/compiler/aslutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,8 @@ #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acapps.h> +#include <sys/stat.h> + #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslutils") @@ -67,6 +69,67 @@ UtAttachNameseg ( /******************************************************************************* * + * FUNCTION: UtIsBigEndianMachine + * + * PARAMETERS: None + * + * RETURN: TRUE if machine is big endian + * FALSE if machine is little endian + * + * DESCRIPTION: Detect whether machine is little endian or big endian. + * + ******************************************************************************/ + +UINT8 +UtIsBigEndianMachine ( + void) +{ + union { + UINT32 Integer; + UINT8 Bytes[4]; + } Overlay = {0xFF000000}; + + + return (Overlay.Bytes[0]); /* Returns 0xFF (TRUE) for big endian */ +} + + +/****************************************************************************** + * + * FUNCTION: UtQueryForOverwrite + * + * PARAMETERS: Pathname - Output filename + * + * RETURN: TRUE if file does not exist or overwrite is authorized + * + * DESCRIPTION: Query for file overwrite if it already exists. + * + ******************************************************************************/ + +BOOLEAN +UtQueryForOverwrite ( + char *Pathname) +{ + struct stat StatInfo; + + + if (!stat (Pathname, &StatInfo)) + { + fprintf (stderr, "Target file \"%s\" already exists, overwrite? [y|n] ", + Pathname); + + if (getchar () != 'y') + { + return (FALSE); + } + } + + return (TRUE); +} + + +/******************************************************************************* + * * FUNCTION: UtDisplaySupportedTables * * PARAMETERS: None @@ -199,7 +262,6 @@ UtBeginEvent ( AslGbl_Events[AslGbl_NextEvent].StartTime = AcpiOsGetTimer (); AslGbl_Events[AslGbl_NextEvent].EventName = Name; AslGbl_Events[AslGbl_NextEvent].Valid = TRUE; - return (AslGbl_NextEvent++); } @@ -234,63 +296,6 @@ UtEndEvent ( /******************************************************************************* * - * FUNCTION: UtConvertByteToHex - * - * PARAMETERS: RawByte - Binary data - * Buffer - Pointer to where the hex bytes will be - * stored - * - * RETURN: Ascii hex byte is stored in Buffer. - * - * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed - * with "0x" - * - ******************************************************************************/ - -void -UtConvertByteToHex ( - UINT8 RawByte, - UINT8 *Buffer) -{ - - Buffer[0] = '0'; - Buffer[1] = 'x'; - - Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); - Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); -} - - -/******************************************************************************* - * - * FUNCTION: UtConvertByteToAsmHex - * - * PARAMETERS: RawByte - Binary data - * Buffer - Pointer to where the hex bytes will be - * stored - * - * RETURN: Ascii hex byte is stored in Buffer. - * - * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed - * with '0', and a trailing 'h' is added. - * - ******************************************************************************/ - -void -UtConvertByteToAsmHex ( - UINT8 RawByte, - UINT8 *Buffer) -{ - - Buffer[0] = '0'; - Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); - Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); - Buffer[3] = 'h'; -} - - -/******************************************************************************* - * * FUNCTION: DbgPrint * * PARAMETERS: Type - Type of output @@ -333,43 +338,6 @@ DbgPrint ( /******************************************************************************* * - * FUNCTION: UtPrintFormattedName - * - * PARAMETERS: ParseOpcode - Parser keyword ID - * Level - Indentation level - * - * RETURN: None - * - * DESCRIPTION: Print the ascii name of the parse opcode. - * - ******************************************************************************/ - -#define TEXT_OFFSET 10 - -void -UtPrintFormattedName ( - UINT16 ParseOpcode, - UINT32 Level) -{ - - if (Level) - { - DbgPrint (ASL_TREE_OUTPUT, - "%*s", (3 * Level), " "); - } - DbgPrint (ASL_TREE_OUTPUT, - " %-20.20s", UtGetOpName (ParseOpcode)); - - if (Level < TEXT_OFFSET) - { - DbgPrint (ASL_TREE_OUTPUT, - "%*s", (TEXT_OFFSET - Level) * 3, " "); - } -} - - -/******************************************************************************* - * * FUNCTION: UtSetParseOpName * * PARAMETERS: Op - Parse op to be named. @@ -441,17 +409,22 @@ UtDisplaySummary ( "%-14s %s - %u lines, %u bytes, %u keywords\n", "ASL Input:", Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, - Gbl_InputByteCount, TotalKeywords); + Gbl_OriginalInputFileSize, TotalKeywords); /* AML summary */ if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors)) { - FlPrintFile (FileId, - "%-14s %s - %u bytes, %u named objects, %u executable opcodes\n", - "AML Output:", - Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength, - TotalNamedObjects, TotalExecutableOpcodes); + if (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) + { + FlPrintFile (FileId, + "%-14s %s - %u bytes, %u named objects, " + "%u executable opcodes\n", + "AML Output:", + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, + FlGetFileSize (ASL_FILE_AML_OUTPUT), + TotalNamedObjects, TotalExecutableOpcodes); + } } } @@ -471,9 +444,9 @@ UtDisplaySummary ( continue; } - /* .I is a temp file unless specifically requested */ + /* .PRE is the preprocessor intermediate file */ - if ((i == ASL_FILE_PREPROCESSOR) && (!Gbl_PreprocessorOutputFlag)) + if ((i == ASL_FILE_PREPROCESSOR) && (!Gbl_KeepPreprocessorTempFile)) { continue; } @@ -803,6 +776,7 @@ UtPadNameWithUnderscores ( { *PaddedNameSeg = '_'; } + PaddedNameSeg++; } } @@ -932,7 +906,9 @@ UtDoConstant ( char ErrBuf[64]; - Status = UtStrtoul64 (String, 0, &Converted); + Status = AcpiUtStrtoul64 (String, ACPI_ANY_BASE, + ACPI_MAX64_BYTE_WIDTH, &Converted); + if (ACPI_FAILURE (Status)) { sprintf (ErrBuf, "%s %s\n", "Conversion error:", @@ -944,198 +920,62 @@ UtDoConstant ( } -/* TBD: use version in ACPICA main code base? */ +#ifdef _OBSOLETE_FUNCTIONS +/* Removed 01/2016 */ /******************************************************************************* * - * FUNCTION: UtStrtoul64 + * FUNCTION: UtConvertByteToHex * - * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte - * is returned - * Base - Radix of the string + * PARAMETERS: RawByte - Binary data + * Buffer - Pointer to where the hex bytes will be + * stored * - * RETURN: Converted value + * RETURN: Ascii hex byte is stored in Buffer. * - * DESCRIPTION: Convert a string into an unsigned value. + * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed + * with "0x" * ******************************************************************************/ -ACPI_STATUS -UtStrtoul64 ( - char *String, - UINT32 Base, - UINT64 *RetInteger) +void +UtConvertByteToHex ( + UINT8 RawByte, + UINT8 *Buffer) { - UINT32 Index; - UINT32 Sign; - UINT64 ReturnValue = 0; - ACPI_STATUS Status = AE_OK; - - - *RetInteger = 0; - - switch (Base) - { - case 0: - case 8: - case 10: - case 16: - - break; - - default: - /* - * The specified Base parameter is not in the domain of - * this function: - */ - return (AE_BAD_PARAMETER); - } - /* Skip over any white space in the buffer: */ - - while (isspace ((int) *String) || *String == '\t') - { - ++String; - } - - /* - * The buffer may contain an optional plus or minus sign. - * If it does, then skip over it but remember what is was: - */ - if (*String == '-') - { - Sign = NEGATIVE; - ++String; - } - else if (*String == '+') - { - ++String; - Sign = POSITIVE; - } - else - { - Sign = POSITIVE; - } - - /* - * If the input parameter Base is zero, then we need to - * determine if it is octal, decimal, or hexadecimal: - */ - if (Base == 0) - { - if (*String == '0') - { - if (tolower ((int) *(++String)) == 'x') - { - Base = 16; - ++String; - } - else - { - Base = 8; - } - } - else - { - Base = 10; - } - } - - /* - * For octal and hexadecimal bases, skip over the leading - * 0 or 0x, if they are present. - */ - if (Base == 8 && *String == '0') - { - String++; - } - - if (Base == 16 && - *String == '0' && - tolower ((int) *(++String)) == 'x') - { - String++; - } - - /* Main loop: convert the string to an unsigned long */ - - while (*String) - { - if (isdigit ((int) *String)) - { - Index = ((UINT8) *String) - '0'; - } - else - { - Index = (UINT8) toupper ((int) *String); - if (isupper ((int) Index)) - { - Index = Index - 'A' + 10; - } - else - { - goto ErrorExit; - } - } - - if (Index >= Base) - { - goto ErrorExit; - } - - /* Check to see if value is out of range: */ - - if (ReturnValue > ((ACPI_UINT64_MAX - (UINT64) Index) / - (UINT64) Base)) - { - goto ErrorExit; - } - else - { - ReturnValue *= Base; - ReturnValue += Index; - } - - ++String; - } - - - /* If a minus sign was present, then "the conversion is negated": */ - - if (Sign == NEGATIVE) - { - ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; - } - - *RetInteger = ReturnValue; - return (Status); - - -ErrorExit: - switch (Base) - { - case 8: - - Status = AE_BAD_OCTAL_CONSTANT; - break; - - case 10: - - Status = AE_BAD_DECIMAL_CONSTANT; - break; - - case 16: + Buffer[0] = '0'; + Buffer[1] = 'x'; - Status = AE_BAD_HEX_CONSTANT; - break; + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); +} - default: - /* Base validated above */ +/******************************************************************************* + * + * FUNCTION: UtConvertByteToAsmHex + * + * PARAMETERS: RawByte - Binary data + * Buffer - Pointer to where the hex bytes will be + * stored + * + * RETURN: Ascii hex byte is stored in Buffer. + * + * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed + * with '0', and a trailing 'h' is added. + * + ******************************************************************************/ - break; - } +void +UtConvertByteToAsmHex ( + UINT8 RawByte, + UINT8 *Buffer) +{ - return (Status); + Buffer[0] = '0'; + Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); + Buffer[3] = 'h'; } +#endif /* OBSOLETE_FUNCTIONS */ diff --git a/sys/contrib/dev/acpica/compiler/asluuid.c b/sys/contrib/dev/acpica/compiler/asluuid.c index 4e345e9..a26fdfa 100644 --- a/sys/contrib/dev/acpica/compiler/asluuid.c +++ b/sys/contrib/dev/acpica/compiler/asluuid.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ ACPI_MODULE_NAME ("asluuid") -extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; +extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; /******************************************************************************* @@ -69,7 +69,7 @@ AuValidateUuid ( UINT32 i; - if (!InString || (ACPI_STRLEN (InString) != UUID_STRING_LENGTH)) + if (!InString || (strlen (InString) != UUID_STRING_LENGTH)) { return (AE_BAD_PARAMETER); } @@ -90,11 +90,10 @@ AuValidateUuid ( return (AE_BAD_PARAMETER); } } - - /* All other positions must contain hex digits */ - else { + /* All other positions must contain hex digits */ + if (!isxdigit ((int) InString[i])) { return (AE_BAD_PARAMETER); diff --git a/sys/contrib/dev/acpica/compiler/aslwalks.c b/sys/contrib/dev/acpica/compiler/aslwalks.c index c59895d..dbafaf6 100644 --- a/sys/contrib/dev/acpica/compiler/aslwalks.c +++ b/sys/contrib/dev/acpica/compiler/aslwalks.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,13 @@ ACPI_MODULE_NAME ("aslwalks") +/* Local prototypes */ + +static void +AnAnalyzeStoreOperator ( + ACPI_PARSE_OBJECT *Op); + + /******************************************************************************* * * FUNCTION: AnMethodTypingWalkEnd @@ -73,7 +80,7 @@ AnMethodTypingWalkEnd ( UINT32 Level, void *Context) { - UINT32 ThisNodeBtype; + UINT32 ThisOpBtype; switch (Op->Asl.ParseOpcode) @@ -88,18 +95,21 @@ AnMethodTypingWalkEnd ( if ((Op->Asl.Child) && (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) { - ThisNodeBtype = AnGetBtype (Op->Asl.Child); + ThisOpBtype = AnGetBtype (Op->Asl.Child); if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) && - (ThisNodeBtype == (ACPI_UINT32_MAX -1))) + (ThisOpBtype == (ACPI_UINT32_MAX -1))) { /* * The called method is untyped at this time (typically a * forward reference). * - * Check for a recursive method call first. + * Check for a recursive method call first. Note: the + * Child->Node will be null if the method has not been + * resolved. */ - if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op) + if (Op->Asl.Child->Asl.Node && + (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)) { /* We must type the method here */ @@ -107,7 +117,7 @@ AnMethodTypingWalkEnd ( ASL_WALK_VISIT_UPWARD, NULL, AnMethodTypingWalkEnd, NULL); - ThisNodeBtype = AnGetBtype (Op->Asl.Child); + ThisOpBtype = AnGetBtype (Op->Asl.Child); } } @@ -115,7 +125,7 @@ AnMethodTypingWalkEnd ( if (Op->Asl.ParentMethod) { - Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisNodeBtype; + Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisOpBtype; } } break; @@ -186,9 +196,9 @@ AnOperandTypecheckWalkEnd ( return (AE_OK); } - ArgOp = Op->Asl.Child; + ArgOp = Op->Asl.Child; + OpcodeClass = OpInfo->Class; RuntimeArgTypes = OpInfo->RuntimeArgs; - OpcodeClass = OpInfo->Class; #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE /* @@ -247,6 +257,7 @@ AnOperandTypecheckWalkEnd ( { return (AE_OK); } + AnCheckMethodReturnValue (Op, OpInfo, ArgOp, RequiredBtypes, ThisNodeBtype); } @@ -271,6 +282,70 @@ AnOperandTypecheckWalkEnd ( return (AE_OK); } + /* + * Special handling for certain opcodes. + */ + switch (Op->Asl.AmlOpcode) + { + /* BankField has one TermArg */ + + case AML_BANK_FIELD_OP: + + OpcodeClass = AML_CLASS_EXECUTE; + ArgOp = ArgOp->Asl.Next; + ArgOp = ArgOp->Asl.Next; + break; + + /* Operation Region has 2 TermArgs */ + + case AML_REGION_OP: + + OpcodeClass = AML_CLASS_EXECUTE; + ArgOp = ArgOp->Asl.Next; + ArgOp = ArgOp->Asl.Next; + break; + + /* DataTableRegion has 3 TermArgs */ + + case AML_DATA_REGION_OP: + + OpcodeClass = AML_CLASS_EXECUTE; + ArgOp = ArgOp->Asl.Next; + break; + + /* Buffers/Packages have a length that is a TermArg */ + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + /* If length is a constant, we are done */ + + if ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) || + (ArgOp->Asl.ParseOpcode == PARSEOP_RAW_DATA)) + { + return (AE_OK); + } + break; + + /* Store can write any object to the Debug object */ + + case AML_STORE_OP: + /* + * If this is a Store() to the Debug object, we don't need + * to perform any further validation -- because a Store of + * any object to Debug is permitted and supported. + */ + if (ArgOp->Asl.Next->Asl.AmlOpcode == AML_DEBUG_OP) + { + return (AE_OK); + } + break; + + default: + break; + } + switch (OpcodeClass) { case AML_CLASS_EXECUTE: @@ -278,15 +353,6 @@ AnOperandTypecheckWalkEnd ( case AML_CLASS_CONTROL: case AML_CLASS_RETURN_VALUE: - /* TBD: Change class or fix typechecking for these */ - - if ((Op->Asl.AmlOpcode == AML_BUFFER_OP) || - (Op->Asl.AmlOpcode == AML_PACKAGE_OP) || - (Op->Asl.AmlOpcode == AML_VAR_PACKAGE_OP)) - { - break; - } - /* Reverse the runtime argument list */ RuntimeArgTypes2 = 0; @@ -297,8 +363,12 @@ AnOperandTypecheckWalkEnd ( INCREMENT_ARG_LIST (RuntimeArgTypes); } + /* Typecheck each argument */ + while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2))) { + /* Get the required type(s) for the argument */ + RequiredBtypes = AnMapArgTypeToBtype (ArgType); if (!ArgOp) @@ -308,6 +378,8 @@ AnOperandTypecheckWalkEnd ( AslAbort (); } + /* Get the actual type of the argument */ + ThisNodeBtype = AnGetBtype (ArgOp); if (ThisNodeBtype == ACPI_UINT32_MAX) { @@ -328,6 +400,10 @@ AnOperandTypecheckWalkEnd ( break; } + /* Fallthrough */ + + case ARGI_STORE_TARGET: + if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) { /* @@ -339,25 +415,22 @@ AnOperandTypecheckWalkEnd ( if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) || (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE)) { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, ArgOp, NULL); + AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, + ArgOp, NULL); } else { - AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, NULL); + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, + ArgOp, NULL); } - break; } - - if ((ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) || - (ArgOp->Asl.ParseOpcode == PARSEOP_DEREFOF)) - { - break; - } - - ThisNodeBtype = RequiredBtypes; break; +#ifdef __FUTURE_IMPLEMENTATION +/* + * Possible future typechecking support + */ case ARGI_REFERENCE: /* References */ case ARGI_INTEGER_REF: case ARGI_OBJECT_REF: @@ -388,8 +461,8 @@ AnOperandTypecheckWalkEnd ( case PARSEOP_ARG5: case PARSEOP_ARG6: - /* Hard to analyze argument types, sow we won't */ - /* For now, just treat any arg as a typematch */ + /* Hard to analyze argument types, so we won't */ + /* for now. Just treat any arg as a typematch */ /* ThisNodeBtype = RequiredBtypes; */ break; @@ -400,10 +473,9 @@ AnOperandTypecheckWalkEnd ( default: break; - } break; - +#endif case ARGI_INTEGER: default: @@ -411,6 +483,8 @@ AnOperandTypecheckWalkEnd ( } + /* Check for a type mismatch (required versus actual) */ + CommonBtypes = ThisNodeBtype & RequiredBtypes; if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) @@ -438,9 +512,10 @@ AnOperandTypecheckWalkEnd ( AnFormatBtype (StringBuffer2, RequiredBtypes); sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]", - StringBuffer, OpInfo->Name, StringBuffer2); + StringBuffer, OpInfo->Name, StringBuffer2); - AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, + ArgOp, MsgBuffer); } NextArgument: @@ -477,14 +552,15 @@ AnOtherSemanticAnalysisWalkBegin ( UINT32 Level, void *Context) { - ACPI_PARSE_OBJECT *ArgNode; - ACPI_PARSE_OBJECT *PrevArgNode = NULL; + ACPI_PARSE_OBJECT *ArgOp; + ACPI_PARSE_OBJECT *PrevArgOp = NULL; const ACPI_OPCODE_INFO *OpInfo; ACPI_NAMESPACE_NODE *Node; OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + /* * Determine if an execution class operator actually does something by * checking if it has a target and/or the function return value is used. @@ -497,30 +573,31 @@ AnOtherSemanticAnalysisWalkBegin ( if (OpInfo->Flags & AML_HAS_TARGET) { /* - * Find the target node, it is always the last child. If the traget + * Find the target node, it is always the last child. If the target * is not specified in the ASL, a default node of type Zero was * created by the parser. */ - ArgNode = Op->Asl.Child; - while (ArgNode->Asl.Next) + ArgOp = Op->Asl.Child; + while (ArgOp->Asl.Next) { - PrevArgNode = ArgNode; - ArgNode = ArgNode->Asl.Next; + PrevArgOp = ArgOp; + ArgOp = ArgOp->Asl.Next; } /* Divide() is the only weird case, it has two targets */ if (Op->Asl.AmlOpcode == AML_DIVIDE_OP) { - if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) && - (PrevArgNode) && - (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO)) + if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) && + (PrevArgOp) && + (PrevArgOp->Asl.ParseOpcode == PARSEOP_ZERO)) { AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); } } - else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) + + else if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) { AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); @@ -555,6 +632,15 @@ AnOtherSemanticAnalysisWalkBegin ( */ switch (Op->Asl.ParseOpcode) { + case PARSEOP_STORE: + + if (Gbl_DoTypechecking) + { + AnAnalyzeStoreOperator (Op); + } + break; + + case PARSEOP_ACQUIRE: case PARSEOP_WAIT: /* @@ -566,16 +652,16 @@ AnOtherSemanticAnalysisWalkBegin ( /* First child is the namepath, 2nd child is timeout */ - ArgNode = Op->Asl.Child; - ArgNode = ArgNode->Asl.Next; + ArgOp = Op->Asl.Child; + ArgOp = ArgOp->Asl.Next; /* * Check for the WAIT_FOREVER case - defined by the ACPI spec to be * 0xFFFF or greater */ - if (((ArgNode->Asl.ParseOpcode == PARSEOP_WORDCONST) || - (ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER)) && - (ArgNode->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) + if (((ArgOp->Asl.ParseOpcode == PARSEOP_WORDCONST) || + (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)) && + (ArgOp->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) { break; } @@ -586,7 +672,7 @@ AnOtherSemanticAnalysisWalkBegin ( */ if (!AnIsResultUsed (Op)) { - AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode, + AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgOp, Op->Asl.ExternalName); } break; @@ -595,15 +681,15 @@ AnOtherSemanticAnalysisWalkBegin ( /* * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand */ - ArgNode = Op->Asl.Child; - ArgNode = ArgNode->Asl.Next; - ArgNode = ArgNode->Asl.Next; + ArgOp = Op->Asl.Child; + ArgOp = ArgOp->Asl.Next; + ArgOp = ArgOp->Asl.Next; - if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) || - ((ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER) && - (ArgNode->Asl.Value.Integer == 0))) + if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) || + ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) && + (ArgOp->Asl.Value.Integer == 0))) { - AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgNode, NULL); + AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgOp, NULL); } break; @@ -612,24 +698,24 @@ AnOtherSemanticAnalysisWalkBegin ( * Ensure that the referenced operation region has the correct SPACE_ID. * From the grammar/parser, we know the parent is a FIELD definition. */ - ArgNode = Op->Asl.Parent; /* Field definition */ - ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ - Node = ArgNode->Asl.Node; /* OpRegion namespace node */ + ArgOp = Op->Asl.Parent; /* Field definition */ + ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ + Node = ArgOp->Asl.Node; /* OpRegion namespace node */ if (!Node) { break; } - ArgNode = Node->Op; /* OpRegion definition */ - ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ - ArgNode = ArgNode->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ + ArgOp = Node->Op; /* OpRegion definition */ + ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ + ArgOp = ArgOp->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ /* * The Connection() operator is only valid for the following operation * region SpaceIds: GeneralPurposeIo and GenericSerialBus. */ - if ((ArgNode->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && - (ArgNode->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) + if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && + (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) { AslError (ASL_ERROR, ASL_MSG_CONNECTION_INVALID, Op, NULL); } @@ -640,46 +726,46 @@ AnOtherSemanticAnalysisWalkBegin ( * Ensure that fields for GeneralPurposeIo and GenericSerialBus * contain at least one Connection() operator */ - ArgNode = Op->Asl.Child; /* 1st child is the OpRegion Name */ - Node = ArgNode->Asl.Node; /* OpRegion namespace node */ + ArgOp = Op->Asl.Child; /* 1st child is the OpRegion Name */ + Node = ArgOp->Asl.Node; /* OpRegion namespace node */ if (!Node) { break; } - ArgNode = Node->Op; /* OpRegion definition */ - ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ - ArgNode = ArgNode->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ + ArgOp = Node->Op; /* OpRegion definition */ + ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */ + ArgOp = ArgOp->Asl.Next; /* Next peer is the SPACE_ID (what we want) */ /* We are only interested in GeneralPurposeIo and GenericSerialBus */ - if ((ArgNode->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && - (ArgNode->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) + if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) && + (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS)) { break; } - ArgNode = Op->Asl.Child; /* 1st child is the OpRegion Name */ - ArgNode = ArgNode->Asl.Next; /* AccessType */ - ArgNode = ArgNode->Asl.Next; /* LockRule */ - ArgNode = ArgNode->Asl.Next; /* UpdateRule */ - ArgNode = ArgNode->Asl.Next; /* Start of FieldUnitList */ + ArgOp = Op->Asl.Child; /* 1st child is the OpRegion Name */ + ArgOp = ArgOp->Asl.Next; /* AccessType */ + ArgOp = ArgOp->Asl.Next; /* LockRule */ + ArgOp = ArgOp->Asl.Next; /* UpdateRule */ + ArgOp = ArgOp->Asl.Next; /* Start of FieldUnitList */ /* Walk the FieldUnitList */ - while (ArgNode) + while (ArgOp) { - if (ArgNode->Asl.ParseOpcode == PARSEOP_CONNECTION) + if (ArgOp->Asl.ParseOpcode == PARSEOP_CONNECTION) { break; } - else if (ArgNode->Asl.ParseOpcode == PARSEOP_NAMESEG) + else if (ArgOp->Asl.ParseOpcode == PARSEOP_NAMESEG) { - AslError (ASL_ERROR, ASL_MSG_CONNECTION_MISSING, ArgNode, NULL); + AslError (ASL_ERROR, ASL_MSG_CONNECTION_MISSING, ArgOp, NULL); break; } - ArgNode = ArgNode->Asl.Next; + ArgOp = ArgOp->Asl.Next; } break; @@ -690,3 +776,202 @@ AnOtherSemanticAnalysisWalkBegin ( return (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AnAnalyzeStoreOperator + * + * PARAMETERS: Op - Store() operator + * + * RETURN: None + * + * DESCRIPTION: Analyze a store operator. Mostly for stores to/from package + * objects where there are more restrictions than other data + * types. + * + ******************************************************************************/ + +static void +AnAnalyzeStoreOperator ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_NAMESPACE_NODE *SourceNode; + ACPI_NAMESPACE_NODE *TargetNode; + ACPI_PARSE_OBJECT *SourceOperandOp; + ACPI_PARSE_OBJECT *TargetOperandOp; + UINT32 SourceOperandBtype; + UINT32 TargetOperandBtype; + + + /* Extract the two operands for STORE */ + + SourceOperandOp = Op->Asl.Child; + TargetOperandOp = SourceOperandOp->Asl.Next; + + /* + * Ignore these Source operand opcodes, they cannot be typechecked, + * the actual result is unknown here. + */ + switch (SourceOperandOp->Asl.ParseOpcode) + { + /* For these, type of the returned value is unknown at compile time */ + + case PARSEOP_DEREFOF: + case PARSEOP_METHODCALL: + case PARSEOP_STORE: + case PARSEOP_COPYOBJECT: + + return; + + case PARSEOP_INDEX: + case PARSEOP_REFOF: + + if (!Gbl_EnableReferenceTypechecking) + { + return; + } + + /* + * These opcodes always return an object reference, and thus + * the result can only be stored to a Local, Arg, or Debug. + */ + if (TargetOperandOp->Asl.AmlOpcode == AML_DEBUG_OP) + { + return; + } + + if ((TargetOperandOp->Asl.AmlOpcode < AML_LOCAL0) || + (TargetOperandOp->Asl.AmlOpcode > AML_ARG6)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp, + "Source [Reference], Target must be [Local/Arg/Debug]"); + } + return; + + default: + break; + } + + /* + * Ignore these Target operand opcodes, they cannot be typechecked + */ + switch (TargetOperandOp->Asl.ParseOpcode) + { + case PARSEOP_DEBUG: + case PARSEOP_DEREFOF: + case PARSEOP_REFOF: + case PARSEOP_INDEX: + + return; + + case PARSEOP_METHODCALL: + /* + * A target is not allowed to be a method call. + * It is not supported by the ACPICA interpreter, nor is it + * supported by the MS ASL compiler or the MS interpreter. + * Although legal syntax up until ACPI 6.1, support for this + * will be removed for ACPI 6.2 (02/2016) + */ + AslError (ASL_ERROR, ASL_MSG_SYNTAX, + TargetOperandOp, "Illegal method invocation as a target operand"); + return; + + default: + break; + } + + /* + * Ignore typecheck for External() operands of type "UnknownObj", + * we don't know the actual type (source or target). + */ + SourceNode = SourceOperandOp->Asl.Node; + if (SourceNode && + (SourceNode->Flags & ANOBJ_IS_EXTERNAL) && + (SourceNode->Type == ACPI_TYPE_ANY)) + { + return; + } + + TargetNode = TargetOperandOp->Asl.Node; + if (TargetNode && + (TargetNode->Flags & ANOBJ_IS_EXTERNAL) && + (TargetNode->Type == ACPI_TYPE_ANY)) + { + return; + } + + /* + * A NULL node with a namepath AML opcode indicates non-existent + * name. Just return, the error message is generated elsewhere. + */ + if ((!SourceNode && (SourceOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)) || + (!TargetNode && (TargetOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP))) + { + return; + } + + /* + * Simple check for source same as target via NS node. + * -- Could be expanded to locals and args. + */ + if (SourceNode && TargetNode) + { + if (SourceNode == TargetNode) + { + AslError (ASL_WARNING, ASL_MSG_DUPLICATE_ITEM, + TargetOperandOp, "Source is the same as Target"); + return; + } + } + + /* Ignore typecheck if either source or target is a local or arg */ + + if ((SourceOperandOp->Asl.AmlOpcode >= AML_LOCAL0) && + (SourceOperandOp->Asl.AmlOpcode <= AML_ARG6)) + { + return; /* Cannot type a local/arg at compile time */ + } + + if ((TargetOperandOp->Asl.AmlOpcode >= AML_LOCAL0) && + (TargetOperandOp->Asl.AmlOpcode <= AML_ARG6)) + { + return; /* Cannot type a local/arg at compile time */ + } + + /* + * Package objects are a special case because they cannot by implicitly + * converted to/from anything. Check for these two illegal cases: + * + * Store (non-package, package) + * Store (package, non-package) + */ + SourceOperandBtype = AnGetBtype (SourceOperandOp); + TargetOperandBtype = AnGetBtype (TargetOperandOp); + + /* Check source first for (package, non-package) case */ + + if (SourceOperandBtype & ACPI_BTYPE_PACKAGE) + { + /* If Source is PACKAGE-->Target must be PACKAGE */ + + if (!(TargetOperandBtype & ACPI_BTYPE_PACKAGE)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp, + "Source is [Package], Target must be a package also"); + } + } + + /* Else check target for (non-package, package) case */ + + else if (TargetOperandBtype & ACPI_BTYPE_PACKAGE) + { + /* If Target is PACKAGE, Source must be PACKAGE */ + + if (!(SourceOperandBtype & ACPI_BTYPE_PACKAGE)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, SourceOperandOp, + "Target is [Package], Source must be a package also"); + } + } +} diff --git a/sys/contrib/dev/acpica/compiler/aslxref.c b/sys/contrib/dev/acpica/compiler/aslxref.c index cda7ccf..b09572e 100644 --- a/sys/contrib/dev/acpica/compiler/aslxref.c +++ b/sys/contrib/dev/acpica/compiler/aslxref.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,6 +66,10 @@ XfNamespaceLocateEnd ( UINT32 Level, void *Context); +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op); + static BOOLEAN XfObjectExists ( char *Name); @@ -129,8 +133,6 @@ XfCrossReferenceNamespace ( ACPI_WALK_STATE *WalkState; - DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n"); - /* * Create a new walk state for use when looking up names * within the namespace (Passed as context to the callbacks) @@ -143,8 +145,8 @@ XfCrossReferenceNamespace ( /* Walk the entire parse tree */ - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin, - XfNamespaceLocateEnd, WalkState); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + XfNamespaceLocateBegin, XfNamespaceLocateEnd, WalkState); ACPI_FREE (WalkState); return (AE_OK); @@ -173,8 +175,8 @@ XfObjectExists ( /* Walk entire namespace from the supplied root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, XfCompareOneNamespaceObject, NULL, - Name, NULL); + ACPI_UINT32_MAX, FALSE, XfCompareOneNamespaceObject, NULL, + Name, NULL); if (Status == AE_CTRL_TRUE) { /* At least one instance of the name was found */ @@ -280,59 +282,16 @@ XfCheckFieldRange ( } -#ifdef __UNDER_DEVELOPMENT -/******************************************************************************* - * - * FUNCTION: XfIsObjectParental - * - * PARAMETERS: ChildOp - Op to be checked - * PossibleParentOp - Determine if this op is in the family - * - * RETURN: TRUE if ChildOp is a descendent of PossibleParentOp - * - * DESCRIPTION: Determine if an Op is a descendent of another Op. Used to - * detect if a method is declared within another method. - * - ******************************************************************************/ - -static BOOLEAN -XfIsObjectParental ( - ACPI_PARSE_OBJECT *ChildOp, - ACPI_PARSE_OBJECT *PossibleParentOp) -{ - ACPI_PARSE_OBJECT *ParentOp; - - - /* Search upwards through the tree for possible parent */ - - ParentOp = ChildOp; - while (ParentOp) - { - if (ParentOp == PossibleParentOp) - { - return (TRUE); - } - - ParentOp = ParentOp->Asl.Parent; - } - - return (FALSE); -} - - /******************************************************************************* * * FUNCTION: XfGetParentMethod * - * PARAMETERS: Op - Op to be checked + * PARAMETERS: Op - Parse Op to be checked * - * RETURN: Op for parent method. NULL if object is not within a method. - * - * DESCRIPTION: Determine if an object is within a control method. Used to - * implement special rules for named references from within a - * control method. + * RETURN: Control method Op if found. NULL otherwise * - * NOTE: It would be better to have the parser set a flag in the Op if possible. + * DESCRIPTION: Find the control method parent of a parse op. Returns NULL if + * the input Op is not within a control method. * ******************************************************************************/ @@ -340,120 +299,22 @@ static ACPI_PARSE_OBJECT * XfGetParentMethod ( ACPI_PARSE_OBJECT *Op) { - ACPI_PARSE_OBJECT *ParentOp; - - - if (!Op) - { - return (NULL); - } - - if (Op->Asl.ParseOpcode == PARSEOP_METHOD) - { - return (NULL); - } - - /* Walk upwards through the parse tree, up to the root if necessary */ - - ParentOp = Op; - while (ParentOp) - { - if (ParentOp->Asl.ParseOpcode == PARSEOP_METHOD) - { - return (ParentOp); - } - - ParentOp = ParentOp->Asl.Parent; - } - - /* Object is not within a method */ - - return (NULL); -} - - -/******************************************************************************* - * - * FUNCTION: XfCheckIllegalReference - * - * PARAMETERS: Op - Op referring to the target - * TargetNode - Target of the reference - * - * RETURN: None. Emits error message for an illegal reference - * - * DESCRIPTION: Determine if a named reference is legal. A "named" reference - * is something like: Store(ABCD, ...), where ABCD is an AML - * Nameseg or Namepath. - * - * NOTE: Caller must ensure that the name Op is in fact a reference, and not - * an actual name declaration (creation of a named object). - * - ******************************************************************************/ - -static void -XfCheckIllegalReference ( - ACPI_PARSE_OBJECT *Op, - ACPI_NAMESPACE_NODE *TargetNode) -{ - ACPI_PARSE_OBJECT *MethodOp1; - ACPI_PARSE_OBJECT *MethodOp2; - ACPI_PARSE_OBJECT *TargetOp; - - - /* - * Check for an illegal reference to a named object: - * - * 1) References from one control method to another, non-parent - * method are not allowed, they will fail at runtime. - * - * 2) Forward references within a control method are not allowed. - * AML interpreters use a one-pass parse of control methods - * so these forward references will fail at runtime. - */ - TargetOp = TargetNode->Op; - - MethodOp1 = XfGetParentMethod (Op); - MethodOp2 = XfGetParentMethod (TargetOp); - - /* Are both objects within control method(s)? */ - - if (!MethodOp1 || !MethodOp2) - { - return; - } + ACPI_PARSE_OBJECT *NextOp; - /* Objects not in the same method? */ - if (MethodOp1 != MethodOp2) + NextOp = Op->Asl.Parent; + while (NextOp) { - /* - * 1) Cross-method named reference - * - * This is OK if and only if the target reference is within in a - * method that is a parent of current method - */ - if (!XfIsObjectParental (MethodOp1, MethodOp2)) + if (NextOp->Asl.AmlOpcode == AML_METHOD_OP) { - AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op, - Op->Asl.ExternalName); + return (NextOp); } - } - /* - * 2) Both reference and target are in the same method. Check if this is - * an (illegal) forward reference by examining the exact source code - * location of each (the referenced object and the object declaration). - * This is a bit nasty, yet effective. - */ - else if (Op->Asl.LogicalByteOffset < TargetOp->Asl.LogicalByteOffset) - { - AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op, - Op->Asl.ExternalName); + NextOp = NextOp->Asl.Parent; } + return (NULL); /* No parent method found */ } -#endif - /******************************************************************************* * @@ -496,10 +357,67 @@ XfNamespaceLocateBegin ( UINT8 Message = 0; const ACPI_OPCODE_INFO *OpInfo; UINT32 Flags; + ASL_METHOD_LOCAL *MethodLocals = NULL; + ASL_METHOD_LOCAL *MethodArgs = NULL; + int RegisterNumber; + UINT32 i; ACPI_FUNCTION_TRACE_PTR (XfNamespaceLocateBegin, Op); + + if ((Op->Asl.AmlOpcode == AML_METHOD_OP) && Op->Asl.Node) + { + Node = Op->Asl.Node; + + /* Support for method LocalX/ArgX analysis */ + + if (!Node->MethodLocals) + { + /* Create local/arg info blocks */ + + MethodLocals = UtLocalCalloc ( + sizeof (ASL_METHOD_LOCAL) * ACPI_METHOD_NUM_LOCALS); + Node->MethodLocals = MethodLocals; + + MethodArgs = UtLocalCalloc ( + sizeof (ASL_METHOD_LOCAL) * ACPI_METHOD_NUM_ARGS); + Node->MethodArgs = MethodArgs; + + /* + * Get the method argument count + * First, get the name node + */ + NextOp = Op->Asl.Child; + + /* Get the NumArguments node */ + + NextOp = NextOp->Asl.Next; + Node->ArgCount = (UINT8) + (((UINT8) NextOp->Asl.Value.Integer) & 0x07); + + /* We will track all posible ArgXs */ + + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + if (i < Node->ArgCount) + { + /* Real Args are always "initialized" */ + + MethodArgs[i].Flags = ASL_ARG_INITIALIZED; + } + else + { + /* Other ArgXs can be used as locals */ + + MethodArgs[i].Flags = ASL_ARG_IS_LOCAL; + } + + MethodArgs[i].Op = Op; + } + } + } + /* * If this node is the actual declaration of a name * [such as the XXXX name in "Method (XXXX)"], @@ -512,10 +430,88 @@ XfNamespaceLocateBegin ( return_ACPI_STATUS (AE_OK); } - /* We are only interested in opcodes that have an associated name */ - OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + /* Check method LocalX variables */ + + if (OpInfo->Type == AML_TYPE_LOCAL_VARIABLE) + { + /* Find parent method Op */ + + NextOp = XfGetParentMethod (Op); + if (!NextOp) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get method node */ + + Node = NextOp->Asl.Node; + + RegisterNumber = Op->Asl.AmlOpcode & 0x0007; /* 0x60 through 0x67 */ + MethodLocals = Node->MethodLocals; + + if (Op->Asl.CompileFlags & NODE_IS_TARGET) + { + /* Local is being initialized */ + + MethodLocals[RegisterNumber].Flags |= ASL_LOCAL_INITIALIZED; + MethodLocals[RegisterNumber].Op = Op; + + return_ACPI_STATUS (AE_OK); + } + + /* Mark this Local as referenced */ + + MethodLocals[RegisterNumber].Flags |= ASL_LOCAL_REFERENCED; + MethodLocals[RegisterNumber].Op = Op; + + return_ACPI_STATUS (AE_OK); + } + + /* Check method ArgX variables */ + + if (OpInfo->Type == AML_TYPE_METHOD_ARGUMENT) + { + /* Find parent method Op */ + + NextOp = XfGetParentMethod (Op); + if (!NextOp) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get method node */ + + Node = NextOp->Asl.Node; + + /* Get Arg # */ + + RegisterNumber = Op->Asl.AmlOpcode - AML_ARG0; /* 0x68 through 0x6F */ + MethodArgs = Node->MethodArgs; + + if (Op->Asl.CompileFlags & NODE_IS_TARGET) + { + /* Arg is being initialized */ + + MethodArgs[RegisterNumber].Flags |= ASL_ARG_INITIALIZED; + MethodArgs[RegisterNumber].Op = Op; + + return_ACPI_STATUS (AE_OK); + } + + /* Mark this Arg as referenced */ + + MethodArgs[RegisterNumber].Flags |= ASL_ARG_REFERENCED; + MethodArgs[RegisterNumber].Op = Op; + + return_ACPI_STATUS (AE_OK); + } + + /* + * After method ArgX and LocalX, we are only interested in opcodes + * that have an associated name + */ if ((!(OpInfo->Flags & AML_NAMED)) && (!(OpInfo->Flags & AML_CREATE)) && (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && @@ -577,6 +573,7 @@ XfNamespaceLocateBegin ( { NextOp = NextOp->Asl.Next; } + Path = NextOp->Asl.Value.String; } else @@ -598,7 +595,7 @@ XfNamespaceLocateBegin ( Gbl_NsLookupCount++; Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -780,7 +777,8 @@ XfNamespaceLocateBegin ( if (Message) { - sprintf (MsgBuffer, "Size mismatch, Tag: %u bit%s, Field: %u bit%s", + sprintf (MsgBuffer, + "Size mismatch, Tag: %u bit%s, Field: %u bit%s", TagBitLength, (TagBitLength > 1) ? "s" : "", FieldBitLength, (FieldBitLength > 1) ? "s" : ""); @@ -849,7 +847,7 @@ XfNamespaceLocateBegin ( if (Node->Type != ACPI_TYPE_METHOD) { sprintf (MsgBuffer, "%s is a %s", - Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); + Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer); return_ACPI_STATUS (AE_OK); @@ -872,7 +870,7 @@ XfNamespaceLocateBegin ( UtSetParseOpName (Op); PassedArgs = 0; - NextOp = Op->Asl.Child; + NextOp = Op->Asl.Child; while (NextOp) { @@ -880,7 +878,8 @@ XfNamespaceLocateBegin ( NextOp = NextOp->Asl.Next; } - if (Node->Value != ASL_EXTERNAL_METHOD) + if (Node->Value != ASL_EXTERNAL_METHOD && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) { /* * Check the parsed arguments with the number expected by the @@ -978,7 +977,8 @@ XfNamespaceLocateBegin ( case ACPI_ADR_SPACE_CMOS: case ACPI_ADR_SPACE_GPIO: - if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE) + if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != + AML_FIELD_ACCESS_BYTE) { AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL); } @@ -988,7 +988,8 @@ XfNamespaceLocateBegin ( case ACPI_ADR_SPACE_IPMI: case ACPI_ADR_SPACE_GSBUS: - if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER) + if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != + AML_FIELD_ACCESS_BUFFER) { AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL); } @@ -1016,10 +1017,10 @@ XfNamespaceLocateBegin ( if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child) { XfCheckFieldRange (Op, - Op->Asl.Parent->Asl.ExtraValue, - Op->Asl.ExtraValue, - (UINT32) Op->Asl.Child->Asl.Value.Integer, - Op->Asl.Child->Asl.ExtraValue); + Op->Asl.Parent->Asl.ExtraValue, + Op->Asl.ExtraValue, + (UINT32) Op->Asl.Child->Asl.Value.Integer, + Op->Asl.Child->Asl.ExtraValue); } } } @@ -1094,3 +1095,178 @@ XfNamespaceLocateEnd ( return_ACPI_STATUS (AE_OK); } + + +#ifdef __UNDER_DEVELOPMENT +/******************************************************************************* + * + * FUNCTION: XfIsObjectParental + * + * PARAMETERS: ChildOp - Op to be checked + * PossibleParentOp - Determine if this op is in the family + * + * RETURN: TRUE if ChildOp is a descendent of PossibleParentOp + * + * DESCRIPTION: Determine if an Op is a descendent of another Op. Used to + * detect if a method is declared within another method. + * + ******************************************************************************/ + +static BOOLEAN +XfIsObjectParental ( + ACPI_PARSE_OBJECT *ChildOp, + ACPI_PARSE_OBJECT *PossibleParentOp) +{ + ACPI_PARSE_OBJECT *ParentOp; + + + /* Search upwards through the tree for possible parent */ + + ParentOp = ChildOp; + while (ParentOp) + { + if (ParentOp == PossibleParentOp) + { + return (TRUE); + } + + ParentOp = ParentOp->Asl.Parent; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: XfGetParentMethod + * + * PARAMETERS: Op - Op to be checked + * + * RETURN: Op for parent method. NULL if object is not within a method. + * + * DESCRIPTION: Determine if an object is within a control method. Used to + * implement special rules for named references from within a + * control method. + * + * NOTE: It would be better to have the parser set a flag in the Op if possible. + * + ******************************************************************************/ + +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *ParentOp; + + + if (!Op) + { + return (NULL); + } + + if (Op->Asl.ParseOpcode == PARSEOP_METHOD) + { + return (NULL); + } + + /* Walk upwards through the parse tree, up to the root if necessary */ + + ParentOp = Op; + while (ParentOp) + { + if (ParentOp->Asl.ParseOpcode == PARSEOP_METHOD) + { + return (ParentOp); + } + + ParentOp = ParentOp->Asl.Parent; + } + + /* Object is not within a method */ + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: XfCheckIllegalReference + * + * PARAMETERS: Op - Op referring to the target + * TargetNode - Target of the reference + * + * RETURN: None. Emits error message for an illegal reference + * + * DESCRIPTION: Determine if a named reference is legal. A "named" reference + * is something like: Store(ABCD, ...), where ABCD is an AML + * Nameseg or Namepath. + * + * NOTE: Caller must ensure that the name Op is in fact a reference, and not + * an actual name declaration (creation of a named object). + * + ******************************************************************************/ + +static void +XfCheckIllegalReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *TargetNode) +{ + ACPI_PARSE_OBJECT *MethodOp1; + ACPI_PARSE_OBJECT *MethodOp2; + ACPI_PARSE_OBJECT *TargetOp; + + + /* + * Check for an illegal reference to a named object: + * + * 1) References from one control method to another, non-parent + * method are not allowed, they will fail at runtime. + * + * 2) Forward references within a control method are not allowed. + * AML interpreters use a one-pass parse of control methods + * so these forward references will fail at runtime. + */ + TargetOp = TargetNode->Op; + + MethodOp1 = XfGetParentMethod (Op); + MethodOp2 = XfGetParentMethod (TargetOp); + + /* Are both objects within control method(s)? */ + + if (!MethodOp1 || !MethodOp2) + { + return; + } + + /* Objects not in the same method? */ + + if (MethodOp1 != MethodOp2) + { + /* + * 1) Cross-method named reference + * + * This is OK if and only if the target reference is within in a + * method that is a parent of current method + */ + if (!XfIsObjectParental (MethodOp1, MethodOp2)) + { + AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op, + Op->Asl.ExternalName); + } + } + + /* + * 2) Both reference and target are in the same method. Check if this is + * an (illegal) forward reference by examining the exact source code + * location of each (the referenced object and the object declaration). + * This is a bit nasty, yet effective. + */ + else if (Op->Asl.LogicalByteOffset < TargetOp->Asl.LogicalByteOffset) + { + AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op, + Op->Asl.ExternalName); + } + +} +#endif diff --git a/sys/contrib/dev/acpica/compiler/aslxrefout.c b/sys/contrib/dev/acpica/compiler/aslxrefout.c new file mode 100644 index 0000000..7408ffe --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslxrefout.c @@ -0,0 +1,814 @@ +/****************************************************************************** + * + * Module Name: aslxrefout.c - support for optional cross-reference file + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include "aslcompiler.y.h" +#include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/include/acparser.h> +#include <contrib/dev/acpica/include/amlcode.h> + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslxrefout") + + +/* Local prototypes */ + +static ACPI_STATUS +OtXrefWalkPart2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +OtXrefWalkPart3 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +OtXrefAnalysisWalkPart1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + + +static ACPI_STATUS +OtXrefAnalysisWalkPart2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +OtXrefAnalysisWalkPart3 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + + +/******************************************************************************* + * + * FUNCTION: OtPrintHeaders + * + * PARAMETERS: Message - Main header message + * + * RETURN: None + * + * DESCRIPTION: Emits the main header message along with field descriptions + * + ******************************************************************************/ + +void +OtPrintHeaders ( + char *Message) +{ + UINT32 Length; + + + Length = strlen (Message); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\n%s\n", Message); + while (Length) + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, "-"); + Length--; + } + + FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\nLineno %-40s Description\n", + "Full Pathname"); +} + + +/******************************************************************************* + * + * FUNCTION: OtCreateXrefFile + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION Main entry point for parts 2 and 3 of the cross-reference + * file. + * + ******************************************************************************/ + +void +OtCreateXrefFile ( + void) +{ + ASL_XREF_INFO XrefInfo; + + + /* Build cross-reference output file if requested */ + + if (!Gbl_CrossReferenceOutput) + { + return; + } + + memset (&XrefInfo, 0, sizeof (ASL_XREF_INFO)); + + /* Cross-reference output file, part 2 (Method invocations) */ + + OtPrintHeaders ("Part 2: Method Reference Map " + "(Invocations of each user-defined control method)"); + + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + OtXrefWalkPart2, NULL, &XrefInfo); + + /* Cross-reference output file, part 3 (All other object refs) */ + + OtPrintHeaders ("Part 3: Full Object Reference Map " + "(Methods that reference each object in namespace"); + + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + OtXrefWalkPart3, NULL, &XrefInfo); + + /* Cross-reference summary */ + + FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\nObject Summary\n"); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\nTotal methods: %u\n", + XrefInfo.TotalPredefinedMethods + XrefInfo.TotalUserMethods); + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "Total predefined methods: %u\n", + XrefInfo.TotalPredefinedMethods); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\nTotal user methods: %u\n", + XrefInfo.TotalUserMethods); + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "Total unreferenced user methods %u\n", + XrefInfo.TotalUnreferenceUserMethods); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\nTotal defined objects: %u\n", + XrefInfo.TotalObjects); + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "Total unreferenced objects: %u\n", + XrefInfo.TotalUnreferencedObjects); +} + + +/* + * Part 1 of the cross reference file. This part emits the namespace objects + * that are referenced by each control method in the namespace. + * + * Part 2 and 3 are below part 1. + */ + +/******************************************************************************* + * + * FUNCTION: OtXrefWalkPart1 + * + * PARAMETERS: Op - Current parse Op + * Level - Current tree nesting level + * MethodInfo - Info block for the current method + * + * + * RETURN: None + * + * DESCRIPTION: Entry point for the creation of the method call reference map. + * For each control method in the namespace, all other methods + * that invoke the method are listed. Predefined names/methods + * that start with an underscore are ignored, because these are + * essentially external/public interfaces. + + * DESCRIPTION: Entry point for the creation of the object reference map. + * For each control method in the namespace, all objects that + * are referenced by the method are listed. + * + * Called during a normal namespace walk, once per namespace + * object. (MtMethodAnalysisWalkBegin) + * + ******************************************************************************/ + +void +OtXrefWalkPart1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + ASL_METHOD_INFO *MethodInfo) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *FieldOp; + char *ParentPath; + UINT32 Length; + ACPI_STATUS Status; + + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_NAMESEG: + case PARSEOP_NAMESTRING: + case PARSEOP_METHODCALL: + + if (!MethodInfo || + (MethodInfo->Op->Asl.Child == Op) || + !Op->Asl.Node) + { + break; + } + + MethodInfo->CurrentOp = Op; + Node = Op->Asl.Node; + + /* Find all objects referenced by this method */ + + Status = TrWalkParseTree (MethodInfo->Op, ASL_WALK_VISIT_DOWNWARD, + OtXrefAnalysisWalkPart1, NULL, MethodInfo); + + if (Status == AE_CTRL_TERMINATE) + { + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " %-40s %s", + ParentPath, AcpiUtGetTypeName (Node->Type)); + ACPI_FREE (ParentPath); + + switch (Node->Type) + { + /* Handle externals */ + + case ACPI_TYPE_ANY: + case ACPI_TYPE_FIELD_UNIT: + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " <External Object>"); + break; + + case ACPI_TYPE_INTEGER: + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " %8.8X%8.8X", + ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); + break; + + case ACPI_TYPE_METHOD: + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " Invocation (%u args)", + Node->ArgCount); + break; + + case ACPI_TYPE_BUFFER_FIELD: + + NextOp = Node->Op; /* Create Buffer Field Op */ + switch (NextOp->Asl.ParseOpcode) + { + case PARSEOP_CREATEBITFIELD: + Length = 1; + break; + + case PARSEOP_CREATEBYTEFIELD: + Length = 8; + break; + + case PARSEOP_CREATEWORDFIELD: + Length = 16; + break; + + case PARSEOP_CREATEDWORDFIELD: + Length = 32; + break; + + case PARSEOP_CREATEQWORDFIELD: + Length = 64; + break; + + default: + Length = 0; + break; + } + + NextOp = NextOp->Asl.Child; /* Buffer name */ + + if (!NextOp->Asl.ExternalName) + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, " in Arg/Local"); + } + else + { + ParentPath = AcpiNsGetNormalizedPathname ( + NextOp->Asl.Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%.2u bit) in Buffer %s", + Length, ParentPath); + ACPI_FREE (ParentPath); + } + break; + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + NextOp = Node->Op; + FieldOp = NextOp->Asl.Parent; + NextOp = FieldOp->Asl.Child; + + ParentPath = AcpiNsGetNormalizedPathname ( + NextOp->Asl.Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%.2u bit) in Region %s", + (UINT32) Node->Op->Asl.Child->Asl.Value.Integer, + ParentPath); + ACPI_FREE (ParentPath); + + if (FieldOp->Asl.ParseOpcode == PARSEOP_FIELD) + { + Node = NextOp->Asl.Node; /* Region node */ + NextOp = Node->Op; /* PARSEOP_REGION */ + NextOp = NextOp->Asl.Child; /* Region name */ + NextOp = NextOp->Asl.Next; + + /* Get region space/addr/len? */ + + FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%s)", + AcpiUtGetRegionName ((UINT8) + NextOp->Asl.Value.Integer)); + } + break; + + default: + break; + } + + FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n"); + } + break; + + case PARSEOP_METHOD: + + ParentPath = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\n[%5u] %-40s %s Declaration (%u args)\n", + Op->Asl.LogicalLineNumber, ParentPath, + AcpiUtGetTypeName (Op->Asl.Node->Type), Op->Asl.Node->ArgCount); + + ACPI_FREE (ParentPath); + break; + + default: + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: OtXrefAnalysisWalkPart1 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Secondary walk for cross-reference part 1. + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefAnalysisWalkPart1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_METHOD_INFO *MethodInfo = (ASL_METHOD_INFO *) Context; + ACPI_PARSE_OBJECT *Next; + + + /* Only interested in name string Ops -- ignore all others */ + + if ((Op->Asl.ParseOpcode != PARSEOP_NAMESEG) && + (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && + (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) + { + return (AE_OK); + } + + /* No node means a locally declared object -- ignore */ + + if (!Op->Asl.Node) + { + return (AE_OK); + } + + /* When we encounter the source Op, we are done */ + + Next = MethodInfo->CurrentOp; + if (Next == Op) + { + return (AE_CTRL_TERMINATE); + } + + /* If we have a name match, this Op is a duplicate */ + + if ((Next->Asl.ParseOpcode == PARSEOP_NAMESEG) || + (Next->Asl.ParseOpcode == PARSEOP_NAMESTRING) || + (Next->Asl.ParseOpcode == PARSEOP_METHODCALL)) + { + if (!strcmp (Op->Asl.ExternalName, Next->Asl.ExternalName)) + { + return (AE_ALREADY_EXISTS); + } + } + + return (AE_OK); +} + + +/* + * Part 2 of the cross reference file. This part emits the names of each + * non-predefined method in the namespace (user methods), along with the + * names of each control method that references that method. + */ + +/******************************************************************************* + * + * FUNCTION: OtXrefWalkPart2 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: For each control method in the namespace, we will re-walk the + * namespace to find each and every invocation of that control + * method. Brute force, but does not matter, even for large + * namespaces. Ignore predefined names (start with underscore). + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefWalkPart2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; + ACPI_NAMESPACE_NODE *Node; + char *ParentPath; + + + /* Looking for Method Declaration Ops only */ + + if (!Op->Asl.Node || + (Op->Asl.ParseOpcode != PARSEOP_METHOD)) + { + return (AE_OK); + } + + /* Ignore predefined names */ + + if (Op->Asl.Node->Name.Ascii[0] == '_') + { + XrefInfo->TotalPredefinedMethods++; + return (AE_OK); + } + + Node = Op->Asl.Node; + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\n[%5u] %-40s %s Declaration (%u args)\n", + Op->Asl.LogicalLineNumber, ParentPath, + AcpiUtGetTypeName (Node->Type), Node->ArgCount); + + XrefInfo->TotalUserMethods++; + XrefInfo->ThisMethodInvocations = 0; + XrefInfo->MethodOp = Op; + + (void) TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + OtXrefAnalysisWalkPart2, NULL, XrefInfo); + + if (!XrefInfo->ThisMethodInvocations) + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, + " Zero invocations of this method in this module\n"); + XrefInfo->TotalUnreferenceUserMethods++; + } + else + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, + " %u invocations of method %s in this module\n", + XrefInfo->ThisMethodInvocations, ParentPath); + } + + ACPI_FREE (ParentPath); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: OtXrefAnalysisWalkPart2 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: For every Op that is a method invocation, emit a reference + * line if the Op is invoking the target method. + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefAnalysisWalkPart2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; + ACPI_PARSE_OBJECT *CallerOp; + char *CallerFullPathname; + + + /* Looking for MethodCall Ops only */ + + if (!Op->Asl.Node || + (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) + { + return (AE_OK); + } + + /* If not a match to the target method, we are done */ + + if (Op->Asl.Node != XrefInfo->MethodOp->Asl.Node) + { + return (AE_CTRL_DEPTH); + } + + /* Find parent method to get method caller namepath */ + + CallerOp = Op->Asl.Parent; + while (CallerOp && + (CallerOp->Asl.ParseOpcode != PARSEOP_METHOD)) + { + CallerOp = CallerOp->Asl.Parent; + } + + /* There is no parent method for External() statements */ + + if (!CallerOp) + { + return (AE_OK); + } + + CallerFullPathname = AcpiNsGetNormalizedPathname ( + CallerOp->Asl.Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "[%5u] %-40s Invocation path: %s\n", + Op->Asl.LogicalLineNumber, CallerFullPathname, + Op->Asl.ExternalName); + + ACPI_FREE (CallerFullPathname); + XrefInfo->ThisMethodInvocations++; + return (AE_OK); +} + + +/* + * Part 3 of the cross reference file. This part emits the names of each + * non-predefined method in the namespace (user methods), along with the + * names of each control method that references that method. + */ + +/******************************************************************************* + * + * FUNCTION: OtXrefWalkPart3 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Cross-reference part 3. references to objects other than + * control methods. + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefWalkPart3 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; + ACPI_NAMESPACE_NODE *Node; + char *ParentPath; + const ACPI_OPCODE_INFO *OpInfo; + + + /* Ignore method declarations */ + + if (!Op->Asl.Node || + (Op->Asl.ParseOpcode == PARSEOP_METHOD)) + { + return (AE_OK); + } + + OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + if (!(OpInfo->Class & AML_CLASS_NAMED_OBJECT)) + { + return (AE_OK); + } + + /* Only care about named object creation opcodes */ + + if ((Op->Asl.ParseOpcode != PARSEOP_NAME) && + (Op->Asl.ParseOpcode != PARSEOP_DEVICE) && + (Op->Asl.ParseOpcode != PARSEOP_MUTEX) && + (Op->Asl.ParseOpcode != PARSEOP_OPERATIONREGION) && + (Op->Asl.ParseOpcode != PARSEOP_FIELD) && + (Op->Asl.ParseOpcode != PARSEOP_EVENT)) + { + return (AE_OK); + } + + /* Ignore predefined names */ + + if (Op->Asl.Node->Name.Ascii[0] == '_') + { + return (AE_OK); + } + + Node = Op->Asl.Node; + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "\n[%5u] %-40s %s Declaration\n", + Op->Asl.LogicalLineNumber, ParentPath, + AcpiUtGetTypeName (Node->Type)); + ACPI_FREE (ParentPath); + + XrefInfo->MethodOp = Op; + XrefInfo->ThisObjectReferences = 0; + XrefInfo->TotalObjects = 0; + + (void) TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + OtXrefAnalysisWalkPart3, NULL, XrefInfo); + + if (!XrefInfo->ThisObjectReferences) + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, + " Zero references to this object in this module\n"); + XrefInfo->TotalUnreferencedObjects++; + } + else + { + FlPrintFile (ASL_FILE_XREF_OUTPUT, + " %u references to this object in this module\n", + XrefInfo->ThisObjectReferences, ParentPath); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: OtXrefAnalysisWalkPart3 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Secondary walk for cross-reference part 3. + * + ******************************************************************************/ + +static ACPI_STATUS +OtXrefAnalysisWalkPart3 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; + char *CallerFullPathname = NULL; + ACPI_PARSE_OBJECT *CallerOp; + const char *Operator; + + + if (!Op->Asl.Node) + { + return (AE_OK); + } + + XrefInfo->TotalObjects++; + + /* Ignore Op that actually defined the object */ + + if (Op == XrefInfo->MethodOp) + { + return (AE_OK); + } + + /* Only interested in Ops that reference the target node */ + + if (Op->Asl.Node != XrefInfo->MethodOp->Asl.Node) + { + return (AE_OK); + } + + /* Find parent "open scope" object to get method caller namepath */ + + CallerOp = Op->Asl.Parent; + while (CallerOp && + (CallerOp->Asl.ParseOpcode != PARSEOP_NAME) && + (CallerOp->Asl.ParseOpcode != PARSEOP_METHOD) && + (CallerOp->Asl.ParseOpcode != PARSEOP_DEVICE) && + (CallerOp->Asl.ParseOpcode != PARSEOP_POWERRESOURCE) && + (CallerOp->Asl.ParseOpcode != PARSEOP_PROCESSOR) && + (CallerOp->Asl.ParseOpcode != PARSEOP_THERMALZONE)) + { + CallerOp = CallerOp->Asl.Parent; + } + + if (CallerOp == XrefInfo->CurrentMethodOp) + { + return (AE_OK); + } + + /* Null CallerOp means the caller is at the namespace root */ + + if (CallerOp) + { + CallerFullPathname = AcpiNsGetNormalizedPathname ( + CallerOp->Asl.Node, TRUE); + } + + /* There are some special cases for the oddball operators */ + + if (Op->Asl.ParseOpcode == PARSEOP_SCOPE) + { + Operator = "Scope"; + } + else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_ALIAS) + { + Operator = "Alias"; + } + else if (!CallerOp) + { + Operator = "ModLevel"; + } + else + { + Operator = AcpiUtGetTypeName (CallerOp->Asl.Node->Type); + } + + FlPrintFile (ASL_FILE_XREF_OUTPUT, + "[%5u] %-40s %-8s via path: %s, Operator: %s\n", + Op->Asl.LogicalLineNumber, + CallerFullPathname ? CallerFullPathname : "<root>", + Operator, + Op->Asl.ExternalName, + Op->Asl.Parent->Asl.ParseOpName); + + if (!CallerOp) + { + CallerOp = ACPI_TO_POINTER (0xFFFFFFFF); + } + + if (CallerFullPathname) + { + ACPI_FREE (CallerFullPathname); + } + + XrefInfo->CurrentMethodOp = CallerOp; + XrefInfo->ThisObjectReferences++; + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/dtcompile.c b/sys/contrib/dev/acpica/compiler/dtcompile.c index 20da143..56da8d3 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompile.c +++ b/sys/contrib/dev/acpica/compiler/dtcompile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -302,7 +302,7 @@ DtCompileDataTable ( return (AE_ERROR); } - Gbl_Signature = UtStringCacheCalloc (ACPI_STRLEN (Signature) + 1); + Gbl_Signature = UtStringCacheCalloc (strlen (Signature) + 1); strcpy (Gbl_Signature, Signature); /* @@ -345,7 +345,7 @@ DtCompileDataTable ( DtInsertCompilerIds (*FieldList); Status = DtCompileTable (FieldList, AcpiDmTableInfoHeader, - &Gbl_RootTable, TRUE); + &Gbl_RootTable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -358,6 +358,8 @@ DtCompileDataTable ( TableData = AcpiDmGetTableData (Signature); if (!TableData || Gbl_CompileGeneric) { + /* Unknown table signature and/or force generic compile */ + DtCompileGeneric ((void **) FieldList, NULL, NULL); goto FinishHeader; } @@ -380,7 +382,7 @@ DtCompileDataTable ( Subtable = NULL; Status = DtCompileTable (FieldList, TableData->TableInfo, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -454,7 +456,7 @@ DtCompileTable ( /* Ignore optional subtable if name does not match */ if ((Info->Flags & DT_OPTIONAL) && - ACPI_STRCMP ((*Field)->Name, Info->Name)) + strcmp ((*Field)->Name, Info->Name)) { *RetSubtable = NULL; return (AE_OK); @@ -591,7 +593,7 @@ DtCompileTable ( DtSetSubtableLength (InlineSubtable); - ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); + memcpy (Buffer, InlineSubtable->Buffer, FieldLength); LocalField = *Field; break; @@ -637,6 +639,57 @@ Error: /****************************************************************************** * + * FUNCTION: DtCompileTwoSubtables + * + * PARAMETERS: List - Current field list pointer + * TableInfo1 - Info table 1 + * TableInfo1 - Info table 2 + * + * RETURN: Status + * + * DESCRIPTION: Compile tables with a header and one or more same subtables. + * Include CPEP, EINJ, ERST, MCFG, MSCT, WDAT + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileTwoSubtables ( + void **List, + ACPI_DMTABLE_INFO *TableInfo1, + ACPI_DMTABLE_INFO *TableInfo2) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + + + Status = DtCompileTable (PFieldList, TableInfo1, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, TableInfo2, &Subtable, FALSE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: DtCompilePadding * * PARAMETERS: Length - Padding field size diff --git a/sys/contrib/dev/acpica/compiler/dtcompiler.h b/sys/contrib/dev/acpica/compiler/dtcompiler.h index 201b2db..ca7fb59 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompiler.h +++ b/sys/contrib/dev/acpica/compiler/dtcompiler.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -172,6 +172,12 @@ DtCompileTable ( BOOLEAN Required); ACPI_STATUS +DtCompileTwoSubtables ( + void **List, + ACPI_DMTABLE_INFO *TableInfo1, + ACPI_DMTABLE_INFO *TableInfo2); + +ACPI_STATUS DtCompilePadding ( UINT32 Length, DT_SUBTABLE **RetSubtable); @@ -181,7 +187,13 @@ DtCompilePadding ( UINT32 DtGetNextLine ( - FILE *Handle); + FILE *Handle, + UINT32 Flags); + +/* Flags for DtGetNextLine */ + +#define DT_ALLOW_MULTILINE_QUOTES 0x01 + DT_FIELD * DtScanFile ( @@ -531,6 +543,10 @@ DtCompileStao ( void **PFieldList); ACPI_STATUS +DtCompileTcpa ( + void **PFieldList); + +ACPI_STATUS DtCompileUefi ( void **PFieldList); diff --git a/sys/contrib/dev/acpica/compiler/dtexpress.c b/sys/contrib/dev/acpica/compiler/dtexpress.c index 90054c9..b9da670 100644 --- a/sys/contrib/dev/acpica/compiler/dtexpress.c +++ b/sys/contrib/dev/acpica/compiler/dtexpress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -147,6 +147,7 @@ DtDoOperator ( Gbl_CurrentField, NULL); return (0); } + Result = LeftValue / RightValue; break; @@ -158,6 +159,7 @@ DtDoOperator ( Gbl_CurrentField, NULL); return (0); } + Result = LeftValue % RightValue; break; @@ -413,10 +415,11 @@ DtLookupLabel ( LabelField = Gbl_LabelList; while (LabelField) { - if (!ACPI_STRCMP (Name, LabelField->Value)) + if (!strcmp (Name, LabelField->Value)) { return (LabelField); } + LabelField = LabelField->NextLabel; } diff --git a/sys/contrib/dev/acpica/compiler/dtfield.c b/sys/contrib/dev/acpica/compiler/dtfield.c index 3b191ab..8448206 100644 --- a/sys/contrib/dev/acpica/compiler/dtfield.c +++ b/sys/contrib/dev/acpica/compiler/dtfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,6 +99,7 @@ DtCompileOneField ( { ACPI_STATUS Status; + switch (Type) { case DT_FIELD_TYPE_INTEGER: @@ -166,7 +167,7 @@ DtCompileString ( UINT32 Length; - Length = ACPI_STRLEN (Field->Value); + Length = strlen (Field->Value); /* Check if the string is too long for the field */ @@ -177,7 +178,7 @@ DtCompileString ( Length = ByteLength; } - ACPI_MEMCPY (Buffer, Field->Value, Length); + memcpy (Buffer, Field->Value, Length); } @@ -212,7 +213,7 @@ DtCompileUnicode ( AsciiString = Field->Value; UnicodeString = (UINT16 *) Buffer; - Count = ACPI_STRLEN (AsciiString) + 1; + Count = strlen (AsciiString) + 1; /* Convert to Unicode string (including null terminator) */ @@ -318,7 +319,7 @@ DtCompileInteger ( /* TBD: Should use a flag rather than compare "Reserved" */ - if (!ACPI_STRCMP (Field->Name, "Reserved")) + if (!strcmp (Field->Name, "Reserved")) { if (Flags & DT_NON_ZERO) { @@ -359,7 +360,7 @@ DtCompileInteger ( DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer); } - ACPI_MEMCPY (Buffer, &Value, ByteLength); + memcpy (Buffer, &Value, ByteLength); return; } @@ -391,7 +392,7 @@ DtNormalizeBuffer ( char c; - NewBuffer = UtLocalCalloc (ACPI_STRLEN (Buffer) + 1); + NewBuffer = UtLocalCalloc (strlen (Buffer) + 1); TmpBuffer = NewBuffer; while ((c = *Buffer++)) diff --git a/sys/contrib/dev/acpica/compiler/dtio.c b/sys/contrib/dev/acpica/compiler/dtio.c index 4b05bd0..d43b57e 100644 --- a/sys/contrib/dev/acpica/compiler/dtio.c +++ b/sys/contrib/dev/acpica/compiler/dtio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -102,7 +102,7 @@ DtDumpSubtableTree ( #define DT_MERGE_LINES 6 #define DT_ESCAPE_SEQUENCE 7 -static UINT32 Gbl_NextLineOffset; +static UINT32 Gbl_NextLineOffset; /****************************************************************************** @@ -129,7 +129,7 @@ DtTrim ( /* Skip lines that start with a space */ - if (!ACPI_STRCMP (String, " ")) + if (!strcmp (String, " ")) { ReturnString = UtStringCacheCalloc (1); return (ReturnString); @@ -138,7 +138,7 @@ DtTrim ( /* Setup pointers to start and end of input string */ Start = String; - End = String + ACPI_STRLEN (String) - 1; + End = String + strlen (String) - 1; /* Find first non-whitespace character */ @@ -180,9 +180,9 @@ DtTrim ( Length = ACPI_PTR_DIFF (End, Start) + 1; ReturnString = UtStringCacheCalloc (Length + 1); - if (ACPI_STRLEN (Start)) + if (strlen (Start)) { - ACPI_STRNCPY (ReturnString, Start, Length); + strncpy (ReturnString, Start, Length); } ReturnString[Length] = 0; @@ -313,7 +313,7 @@ DtParseLine ( Length = ACPI_PTR_DIFF (End, Start); TmpName = UtLocalCalloc (Length + 1); - ACPI_STRNCPY (TmpName, Start, Length); + strncpy (TmpName, Start, Length); Name = DtTrim (TmpName); ACPI_FREE (TmpName); @@ -354,13 +354,14 @@ DtParseLine ( End--; break; } + End++; } Length = ACPI_PTR_DIFF (End, Start); TmpValue = UtLocalCalloc (Length + 1); - ACPI_STRNCPY (TmpValue, Start, Length); + strncpy (TmpValue, Start, Length); Value = DtTrim (TmpValue); ACPI_FREE (TmpValue); @@ -406,7 +407,8 @@ DtParseLine ( UINT32 DtGetNextLine ( - FILE *Handle) + FILE *Handle, + UINT32 Flags) { BOOLEAN LineNotAllBlanks = FALSE; UINT32 State = DT_NORMAL_TEXT; @@ -415,7 +417,7 @@ DtGetNextLine ( int c; - ACPI_MEMSET (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize); + memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize); for (i = 0; ;) { /* @@ -550,9 +552,13 @@ DtGetNextLine ( case '\n': - AcpiOsPrintf ("ERROR at line %u: Unterminated quoted string\n", - Gbl_CurrentLineNumber++); - State = DT_NORMAL_TEXT; + if (!(Flags & DT_ALLOW_MULTILINE_QUOTES)) + { + AcpiOsPrintf ( + "ERROR at line %u: Unterminated quoted string\n", + Gbl_CurrentLineNumber++); + State = DT_NORMAL_TEXT; + } break; default: /* Get next character */ @@ -746,12 +752,13 @@ DtScanFile ( /* Scan line-by-line */ - while ((Offset = DtGetNextLine (Handle)) != ASL_EOF) + while ((Offset = DtGetNextLine (Handle, 0)) != ASL_EOF) { ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s", Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer)); - Status = DtParseLine (Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber, Offset); + Status = DtParseLine (Gbl_CurrentLineBuffer, + Gbl_CurrentLineNumber, Offset); if (Status == AE_NOT_FOUND) { break; @@ -897,7 +904,7 @@ DtDumpBuffer ( } BufChar = Buffer[(ACPI_SIZE) i + j]; - if (ACPI_IS_PRINT (BufChar)) + if (isprint (BufChar)) { FlPrintFile (FileId, "%c", BufChar); } @@ -942,6 +949,7 @@ DtDumpFieldList ( DbgPrint (ASL_DEBUG_OUTPUT, "\nField List:\n" "LineNo ByteOff NameCol Column TableOff " "Flags %32s : %s\n\n", "Name", "Value"); + while (Field) { DbgPrint (ASL_DEBUG_OUTPUT, @@ -1088,6 +1096,7 @@ DtWriteFieldToListing ( FlPrintFile (ASL_FILE_LISTING_OUTPUT, "...Additional data, length 0x%X\n", strlen (Field->Value)); } + FlPrintFile (ASL_FILE_LISTING_OUTPUT, "\n"); /* Dump the hex data that will be output for this field */ diff --git a/sys/contrib/dev/acpica/compiler/dtparser.l b/sys/contrib/dev/acpica/compiler/dtparser.l index c6c29ae..9f62bed 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.l +++ b/sys/contrib/dev/acpica/compiler/dtparser.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/dtparser.y b/sys/contrib/dev/acpica/compiler/dtparser.y index 0271d78..fe29e38 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.y +++ b/sys/contrib/dev/acpica/compiler/dtparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,13 @@ #define _COMPONENT DT_COMPILER ACPI_MODULE_NAME ("dtparser") +void * AslLocalAllocate (unsigned int Size); + +/* Bison/yacc configuration */ + +#undef alloca +#define alloca AslLocalAllocate + int DtParserlex (void); int DtParserparse (void); void DtParsererror (char const *msg); @@ -162,15 +169,15 @@ Expression /* Default base for a non-prefixed integer is 16 */ - | EXPOP_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);} + | EXPOP_NUMBER { AcpiUtStrtoul64 (DtParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} /* Standard hex number (0x1234) */ - | EXPOP_HEX_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);} + | EXPOP_HEX_NUMBER { AcpiUtStrtoul64 (DtParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} - /* TBD: Decimal number with prefix (0d1234) - Not supported by UtStrtoul64 at this time */ + /* TBD: Decimal number with prefix (0d1234) - Not supported by strtoul64 at this time */ - | EXPOP_DECIMAL_NUMBER { UtStrtoul64 (DtParsertext, 10, &$$);} + | EXPOP_DECIMAL_NUMBER { AcpiUtStrtoul64 (DtParsertext, 10, ACPI_MAX64_BYTE_WIDTH, &$$);} ; %% diff --git a/sys/contrib/dev/acpica/compiler/dtsubtable.c b/sys/contrib/dev/acpica/compiler/dtsubtable.c index 1152656..49ae8d5 100644 --- a/sys/contrib/dev/acpica/compiler/dtsubtable.c +++ b/sys/contrib/dev/acpica/compiler/dtsubtable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -80,7 +80,7 @@ DtCreateSubtable ( String = UtStringCacheCalloc (Length); Subtable->Buffer = ACPI_CAST_PTR (UINT8, String); - ACPI_MEMCPY (Subtable->Buffer, Buffer, Length); + memcpy (Subtable->Buffer, Buffer, Length); Subtable->Length = Length; Subtable->TotalLength = Length; @@ -379,6 +379,6 @@ DtSetSubtableLength ( return; } - ACPI_MEMCPY (Subtable->LengthField, &Subtable->TotalLength, + memcpy (Subtable->LengthField, &Subtable->TotalLength, Subtable->SizeOfLengthField); } diff --git a/sys/contrib/dev/acpica/compiler/dttable.c b/sys/contrib/dev/acpica/compiler/dttable.c index bae80ad..dc55449 100644 --- a/sys/contrib/dev/acpica/compiler/dttable.c +++ b/sys/contrib/dev/acpica/compiler/dttable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,7 @@ * POSSIBILITY OF SUCH DAMAGES. */ -/* Compile all complex data tables */ +/* Compile routines for the basic ACPI tables */ #include <contrib/dev/acpica/compiler/aslcompiler.h> #include <contrib/dev/acpica/compiler/dtcompiler.h> @@ -50,123 +50,6 @@ ACPI_MODULE_NAME ("dttable") -/* TBD: merge these into dmtbinfo.c? */ - -static ACPI_DMTABLE_INFO TableInfoAsfAddress[] = -{ - {ACPI_DMT_BUFFER, 0, "Addresses", 0}, - {ACPI_DMT_EXIT, 0, NULL, 0} -}; - -static ACPI_DMTABLE_INFO TableInfoDmarPciPath[] = -{ - {ACPI_DMT_PCI_PATH, 0, "PCI Path", 0}, - {ACPI_DMT_EXIT, 0, NULL, 0} -}; - - -/* Local prototypes */ - -static ACPI_STATUS -DtCompileTwoSubtables ( - void **List, - ACPI_DMTABLE_INFO *TableInfo1, - ACPI_DMTABLE_INFO *TableInfo2); - - -/****************************************************************************** - * - * FUNCTION: DtCompileTwoSubtables - * - * PARAMETERS: List - Current field list pointer - * TableInfo1 - Info table 1 - * TableInfo1 - Info table 2 - * - * RETURN: Status - * - * DESCRIPTION: Compile tables with a header and one or more same subtables. - * Include CPEP, EINJ, ERST, MCFG, MSCT, WDAT - * - *****************************************************************************/ - -static ACPI_STATUS -DtCompileTwoSubtables ( - void **List, - ACPI_DMTABLE_INFO *TableInfo1, - ACPI_DMTABLE_INFO *TableInfo2) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - - - Status = DtCompileTable (PFieldList, TableInfo1, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, TableInfo2, &Subtable, FALSE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileFacs - * - * PARAMETERS: PFieldList - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile FACS. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileFacs ( - DT_FIELD **PFieldList) -{ - DT_SUBTABLE *Subtable; - UINT8 *ReservedBuffer; - ACPI_STATUS Status; - UINT32 ReservedSize; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs, - &Gbl_RootTable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Large FACS reserved area at the end of the table */ - - ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1); - ReservedBuffer = UtLocalCalloc (ReservedSize); - - DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable); - - ACPI_FREE (ReservedBuffer); - DtInsertSubtable (Gbl_RootTable, Subtable); - return (AE_OK); -} - - /****************************************************************************** * * FUNCTION: DtCompileRsdp @@ -192,7 +75,7 @@ DtCompileRsdp ( /* Compile the "common" RSDP (ACPI 1.0) */ Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1, - &Gbl_RootTable, TRUE); + &Gbl_RootTable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -206,7 +89,7 @@ DtCompileRsdp ( /* Compile the "extended" part of the RSDP as a subtable */ Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -227,799 +110,6 @@ DtCompileRsdp ( /****************************************************************************** * - * FUNCTION: DtCompileAsf - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile ASF!. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileAsf ( - void **List) -{ - ACPI_ASF_INFO *AsfTable; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_DMTABLE_INFO *InfoTable; - ACPI_DMTABLE_INFO *DataInfoTable = NULL; - UINT32 DataCount = 0; - ACPI_STATUS Status; - UINT32 i; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoAsfHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - AsfTable = ACPI_CAST_PTR (ACPI_ASF_INFO, Subtable->Buffer); - - switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ - { - case ACPI_ASF_TYPE_INFO: - - InfoTable = AcpiDmTableInfoAsf0; - break; - - case ACPI_ASF_TYPE_ALERT: - - InfoTable = AcpiDmTableInfoAsf1; - break; - - case ACPI_ASF_TYPE_CONTROL: - - InfoTable = AcpiDmTableInfoAsf2; - break; - - case ACPI_ASF_TYPE_BOOT: - - InfoTable = AcpiDmTableInfoAsf3; - break; - - case ACPI_ASF_TYPE_ADDRESS: - - InfoTable = AcpiDmTableInfoAsf4; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ - { - case ACPI_ASF_TYPE_INFO: - - DataInfoTable = NULL; - break; - - case ACPI_ASF_TYPE_ALERT: - - DataInfoTable = AcpiDmTableInfoAsf1a; - DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, - ACPI_SUB_PTR (UINT8, Subtable->Buffer, - sizeof (ACPI_ASF_HEADER)))->Alerts; - break; - - case ACPI_ASF_TYPE_CONTROL: - - DataInfoTable = AcpiDmTableInfoAsf2a; - DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, - ACPI_SUB_PTR (UINT8, Subtable->Buffer, - sizeof (ACPI_ASF_HEADER)))->Controls; - break; - - case ACPI_ASF_TYPE_BOOT: - - DataInfoTable = NULL; - break; - - case ACPI_ASF_TYPE_ADDRESS: - - DataInfoTable = TableInfoAsfAddress; - DataCount = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, - ACPI_SUB_PTR (UINT8, Subtable->Buffer, - sizeof (ACPI_ASF_HEADER)))->Devices; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); - return (AE_ERROR); - } - - if (DataInfoTable) - { - switch (AsfTable->Header.Type & 0x7F) - { - case ACPI_ASF_TYPE_ADDRESS: - - while (DataCount > 0) - { - Status = DtCompileTable (PFieldList, DataInfoTable, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - DataCount = DataCount - Subtable->Length; - } - break; - - default: - - for (i = 0; i < DataCount; i++) - { - Status = DtCompileTable (PFieldList, DataInfoTable, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - } - break; - } - } - - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileCpep - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile CPEP. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileCpep ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoCpep, AcpiDmTableInfoCpep0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileCsrt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile CSRT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileCsrt ( - void **List) -{ - ACPI_STATUS Status = AE_OK; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - UINT32 DescriptorCount; - UINT32 GroupLength; - - - /* Subtables (Resource Groups) */ - - ParentTable = DtPeekSubtable (); - while (*PFieldList) - { - /* Resource group subtable */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Compute the number of resource descriptors */ - - GroupLength = - (ACPI_CAST_PTR (ACPI_CSRT_GROUP, - Subtable->Buffer))->Length - - (ACPI_CAST_PTR (ACPI_CSRT_GROUP, - Subtable->Buffer))->SharedInfoLength - - sizeof (ACPI_CSRT_GROUP); - - DescriptorCount = (GroupLength / - sizeof (ACPI_CSRT_DESCRIPTOR)); - - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - - /* Shared info subtable (One per resource group) */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt1, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - - /* Sub-Subtables (Resource Descriptors) */ - - while (*PFieldList && DescriptorCount) - { - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - if (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (Subtable) - { - DtInsertSubtable (ParentTable, Subtable); - } - } - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - - DescriptorCount--; - } - - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - } - - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileDbg2 - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile DBG2. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileDbg2 ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - UINT32 SubtableCount; - ACPI_DBG2_HEADER *Dbg2Header; - ACPI_DBG2_DEVICE *DeviceInfo; - UINT16 CurrentOffset; - UINT32 i; - - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* Main table fields */ - - Dbg2Header = ACPI_CAST_PTR (ACPI_DBG2_HEADER, Subtable->Buffer); - Dbg2Header->InfoOffset = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF ( - ACPI_ADD_PTR (UINT8, Dbg2Header, sizeof (ACPI_DBG2_HEADER)), Dbg2Header); - - SubtableCount = Dbg2Header->InfoCount; - DtPushSubtable (Subtable); - - /* Process all Device Information subtables (Count = InfoCount) */ - - while (*PFieldList && SubtableCount) - { - /* Subtable: Debug Device Information */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Device, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DeviceInfo = ACPI_CAST_PTR (ACPI_DBG2_DEVICE, Subtable->Buffer); - CurrentOffset = (UINT16) sizeof (ACPI_DBG2_DEVICE); - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - ParentTable = DtPeekSubtable (); - - /* BaseAddressRegister GAS array (Required, size is RegisterCount) */ - - DeviceInfo->BaseAddressOffset = CurrentOffset; - for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Addr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - CurrentOffset += (UINT16) sizeof (ACPI_GENERIC_ADDRESS); - DtInsertSubtable (ParentTable, Subtable); - } - - /* AddressSize array (Required, size = RegisterCount) */ - - DeviceInfo->AddressSizeOffset = CurrentOffset; - for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Size, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - CurrentOffset += (UINT16) sizeof (UINT32); - DtInsertSubtable (ParentTable, Subtable); - } - - /* NamespaceString device identifier (Required, size = NamePathLength) */ - - DeviceInfo->NamepathOffset = CurrentOffset; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Name, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Update the device info header */ - - DeviceInfo->NamepathLength = (UINT16) Subtable->Length; - CurrentOffset += (UINT16) DeviceInfo->NamepathLength; - DtInsertSubtable (ParentTable, Subtable); - - /* OemData - Variable-length data (Optional, size = OemDataLength) */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2OemData, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Update the device info header (zeros if no OEM data present) */ - - DeviceInfo->OemDataOffset = 0; - DeviceInfo->OemDataLength = 0; - - /* Optional subtable (OemData) */ - - if (Subtable && Subtable->Length) - { - DeviceInfo->OemDataOffset = CurrentOffset; - DeviceInfo->OemDataLength = (UINT16) Subtable->Length; - - DtInsertSubtable (ParentTable, Subtable); - } - - SubtableCount--; - DtPopSubtable (); /* Get next Device Information subtable */ - } - - DtPopSubtable (); - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileDmar - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile DMAR. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileDmar ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_DMTABLE_INFO *InfoTable; - ACPI_DMAR_HEADER *DmarHeader; - ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope; - UINT32 DeviceScopeLength; - UINT32 PciPathLength; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - while (*PFieldList) - { - /* DMAR Header */ - - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer); - - switch (DmarHeader->Type) - { - case ACPI_DMAR_TYPE_HARDWARE_UNIT: - - InfoTable = AcpiDmTableInfoDmar0; - break; - - case ACPI_DMAR_TYPE_RESERVED_MEMORY: - - InfoTable = AcpiDmTableInfoDmar1; - break; - - case ACPI_DMAR_TYPE_ROOT_ATS: - - InfoTable = AcpiDmTableInfoDmar2; - break; - - case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: - - InfoTable = AcpiDmTableInfoDmar3; - break; - - case ACPI_DMAR_TYPE_NAMESPACE: - - InfoTable = AcpiDmTableInfoDmar4; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR"); - return (AE_ERROR); - } - - /* DMAR Subtable */ - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* - * Optional Device Scope subtables - */ - if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || - (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE)) - { - /* These types do not support device scopes */ - - DtPopSubtable (); - continue; - } - - DtPushSubtable (Subtable); - DeviceScopeLength = DmarHeader->Length - Subtable->Length - - ParentTable->Length; - while (DeviceScopeLength) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope, - &Subtable, FALSE); - if (Status == AE_NOT_FOUND) - { - break; - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - DmarDeviceScope = ACPI_CAST_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable->Buffer); - - /* Optional PCI Paths */ - - PciPathLength = DmarDeviceScope->Length - Subtable->Length; - while (PciPathLength) - { - Status = DtCompileTable (PFieldList, TableInfoDmarPciPath, - &Subtable, FALSE); - if (Status == AE_NOT_FOUND) - { - DtPopSubtable (); - break; - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - PciPathLength -= Subtable->Length; - } - - DtPopSubtable (); - DeviceScopeLength -= DmarDeviceScope->Length; - } - - DtPopSubtable (); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileDrtm - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile DRTM. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileDrtm ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - UINT32 Count; - /* ACPI_TABLE_DRTM *Drtm; */ - ACPI_DRTM_VTABLE_LIST *DrtmVtl; - ACPI_DRTM_RESOURCE_LIST *DrtmRl; - /* ACPI_DRTM_DPS_ID *DrtmDps; */ - - - ParentTable = DtPeekSubtable (); - - /* Compile DRTM header */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - - /* - * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care - * should be taken to avoid accessing ACPI_TABLE_HADER fields. - */ -#if 0 - Drtm = ACPI_SUB_PTR (ACPI_TABLE_DRTM, - Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); -#endif - /* Compile VTL */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - DrtmVtl = ACPI_CAST_PTR (ACPI_DRTM_VTABLE_LIST, Subtable->Buffer); - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - Count = 0; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - Count++; - } - DrtmVtl->ValidatedTableCount = Count; - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - - /* Compile RL */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - DrtmRl = ACPI_CAST_PTR (ACPI_DRTM_RESOURCE_LIST, Subtable->Buffer); - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - Count = 0; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - Count++; - } - DrtmRl->ResourceCount = Count; - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - - /* Compile DPS */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - /* DrtmDps = ACPI_CAST_PTR (ACPI_DRTM_DPS_ID, Subtable->Buffer);*/ - - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileEinj - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile EINJ. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileEinj ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoEinj, AcpiDmTableInfoEinj0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileErst - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile ERST. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileErst ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoErst, AcpiDmTableInfoEinj0); - return (Status); -} - - -/****************************************************************************** - * * FUNCTION: DtCompileFadt * * PARAMETERS: List - Current field list pointer @@ -1043,7 +133,7 @@ DtCompileFadt ( Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -1058,7 +148,7 @@ DtCompileFadt ( if (Revision == 2) { Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -1069,7 +159,7 @@ DtCompileFadt ( else if (Revision >= 2) { Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -1080,7 +170,7 @@ DtCompileFadt ( if (Revision >= 5) { Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5, - &Subtable, TRUE); + &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); @@ -1092,2362 +182,57 @@ DtCompileFadt ( if (Revision >= 6) { Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - } - } - - return (AE_OK); -} - -/****************************************************************************** - * - * FUNCTION: DtCompileGtdt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile GTDT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileGtdt ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_SUBTABLE_HEADER *GtdtHeader; - ACPI_DMTABLE_INFO *InfoTable; - UINT32 GtCount; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdtHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - GtdtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); - - switch (GtdtHeader->Type) - { - case ACPI_GTDT_TYPE_TIMER_BLOCK: - - InfoTable = AcpiDmTableInfoGtdt0; - break; - - case ACPI_GTDT_TYPE_WATCHDOG: - - InfoTable = AcpiDmTableInfoGtdt1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "GTDT"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* - * Additional GT block subtable data - */ - - switch (GtdtHeader->Type) - { - case ACPI_GTDT_TYPE_TIMER_BLOCK: - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - - GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, - Subtable->Buffer - sizeof(ACPI_GTDT_HEADER)))->TimerCount; - while (GtCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt0a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - - DtInsertSubtable (ParentTable, Subtable); - GtCount--; - } - DtPopSubtable (); - break; - - default: - - break; - } - - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileFpdt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile FPDT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileFpdt ( - void **List) -{ - ACPI_STATUS Status; - ACPI_FPDT_HEADER *FpdtHeader; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_DMTABLE_INFO *InfoTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoFpdtHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - FpdtHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); - - switch (FpdtHeader->Type) - { - case ACPI_FPDT_TYPE_BOOT: - - InfoTable = AcpiDmTableInfoFpdt0; - break; - - case ACPI_FPDT_TYPE_S3PERF: - - InfoTable = AcpiDmTableInfoFpdt1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "FPDT"); - return (AE_ERROR); - break; - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileHest - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile HEST. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileHest ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_DMTABLE_INFO *InfoTable; - UINT16 Type; - UINT32 BankCount; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoHest, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - /* Get subtable type */ - - SubtableStart = *PFieldList; - DtCompileInteger ((UINT8 *) &Type, *PFieldList, 2, 0); - - switch (Type) - { - case ACPI_HEST_TYPE_IA32_CHECK: - - InfoTable = AcpiDmTableInfoHest0; - break; - - case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: - - InfoTable = AcpiDmTableInfoHest1; - break; - - case ACPI_HEST_TYPE_IA32_NMI: - - InfoTable = AcpiDmTableInfoHest2; - break; - - case ACPI_HEST_TYPE_AER_ROOT_PORT: - - InfoTable = AcpiDmTableInfoHest6; - break; - - case ACPI_HEST_TYPE_AER_ENDPOINT: - - InfoTable = AcpiDmTableInfoHest7; - break; - - case ACPI_HEST_TYPE_AER_BRIDGE: - - InfoTable = AcpiDmTableInfoHest8; - break; - - case ACPI_HEST_TYPE_GENERIC_ERROR: - - InfoTable = AcpiDmTableInfoHest9; - break; - - default: - - /* Cannot continue on unknown type */ - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "HEST"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - - /* - * Additional subtable data - IA32 Error Bank(s) - */ - BankCount = 0; - switch (Type) - { - case ACPI_HEST_TYPE_IA32_CHECK: - - BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, - Subtable->Buffer))->NumHardwareBanks; - break; - - case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: - - BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, - Subtable->Buffer))->NumHardwareBanks; - break; - - default: - - break; - } - - while (BankCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoHestBank, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - BankCount--; - } - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileIort - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile IORT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileIort ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_TABLE_IORT *Iort; - ACPI_IORT_NODE *IortNode; - ACPI_IORT_ITS_GROUP *IortItsGroup; - ACPI_IORT_SMMU *IortSmmu; - UINT32 NodeNumber; - UINT32 NodeLength; - UINT32 IdMappingNumber; - UINT32 ItsNumber; - UINT32 ContextIrptNumber; - UINT32 PmuIrptNumber; - UINT32 PaddingLength; - - - ParentTable = DtPeekSubtable (); - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - - /* - * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care - * should be taken to avoid accessing ACPI_TABLE_HADER fields. - */ - Iort = ACPI_SUB_PTR (ACPI_TABLE_IORT, - Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); - - /* - * OptionalPadding - Variable-length data - * (Optional, size = OffsetToNodes - sizeof (ACPI_TABLE_IORT)) - * Optionally allows the generic data types to be used for filling - * this field. - */ - Iort->NodeOffset = sizeof (ACPI_TABLE_IORT); - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortPad, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (Subtable) - { - DtInsertSubtable (ParentTable, Subtable); - Iort->NodeOffset += Subtable->Length; - } - else - { - Status = DtCompileGeneric (ACPI_CAST_PTR (void *, PFieldList), - AcpiDmTableInfoIortHdr[0].Name, &PaddingLength); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - Iort->NodeOffset += PaddingLength; - } - - NodeNumber = 0; - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - IortNode = ACPI_CAST_PTR (ACPI_IORT_NODE, Subtable->Buffer); - NodeLength = ACPI_OFFSET (ACPI_IORT_NODE, NodeData); - - DtPushSubtable (Subtable); - ParentTable = DtPeekSubtable (); - - switch (IortNode->Type) - { - case ACPI_IORT_NODE_ITS_GROUP: - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - IortItsGroup = ACPI_CAST_PTR (ACPI_IORT_ITS_GROUP, Subtable->Buffer); - NodeLength += Subtable->Length; - - ItsNumber = 0; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - ItsNumber++; - } - - IortItsGroup->ItsCount = ItsNumber; - break; - - case ACPI_IORT_NODE_NAMED_COMPONENT: - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - - /* - * Padding - Variable-length data - * Optionally allows the offset of the ID mappings to be used - * for filling this field. - */ - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (Subtable) - { - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - } - else - { - if (NodeLength > IortNode->MappingOffset) - { - return (AE_BAD_DATA); - } - if (NodeLength < IortNode->MappingOffset) - { - Status = DtCompilePadding ( - IortNode->MappingOffset - NodeLength, - &Subtable); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength = IortNode->MappingOffset; - } - } - break; - - case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - break; - - case ACPI_IORT_NODE_SMMU: - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - IortSmmu = ACPI_CAST_PTR (ACPI_IORT_SMMU, Subtable->Buffer); - NodeLength += Subtable->Length; - - /* Compile global interrupt array */ - - IortSmmu->GlobalInterruptOffset = NodeLength; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - - /* Compile context interrupt array */ - - ContextIrptNumber = 0; - IortSmmu->ContextInterruptOffset = NodeLength; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3b, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - ContextIrptNumber++; - } - IortSmmu->ContextInterruptCount = ContextIrptNumber; - - /* Compile PMU interrupt array */ - - PmuIrptNumber = 0; - IortSmmu->PmuInterruptOffset = NodeLength; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3c, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += Subtable->Length; - PmuIrptNumber++; - } - IortSmmu->PmuInterruptCount = PmuIrptNumber; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IORT"); - return (AE_ERROR); - } - - /* Compile Array of ID mappings */ - - IortNode->MappingOffset = NodeLength; - IdMappingNumber = 0; - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortMap, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - break; - } - DtInsertSubtable (ParentTable, Subtable); - NodeLength += sizeof (ACPI_IORT_ID_MAPPING); - IdMappingNumber++; - } - IortNode->MappingCount = IdMappingNumber; - - /* - * Node length can be determined by DT_LENGTH option - * IortNode->Length = NodeLength; - */ - DtPopSubtable (); - ParentTable = DtPeekSubtable (); - NodeNumber++; - } - Iort->NodeCount = NodeNumber; - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileIvrs - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile IVRS. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileIvrs ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_DMTABLE_INFO *InfoTable; - ACPI_IVRS_HEADER *IvrsHeader; - UINT8 EntryType; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrs, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrsHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - IvrsHeader = ACPI_CAST_PTR (ACPI_IVRS_HEADER, Subtable->Buffer); - - switch (IvrsHeader->Type) - { - case ACPI_IVRS_TYPE_HARDWARE: - - InfoTable = AcpiDmTableInfoIvrs0; - break; - - case ACPI_IVRS_TYPE_MEMORY1: - case ACPI_IVRS_TYPE_MEMORY2: - case ACPI_IVRS_TYPE_MEMORY3: - - InfoTable = AcpiDmTableInfoIvrs1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IVRS"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - if (IvrsHeader->Type == ACPI_IVRS_TYPE_HARDWARE) - { - while (*PFieldList && - !ACPI_STRCMP ((*PFieldList)->Name, "Entry Type")) - { - SubtableStart = *PFieldList; - DtCompileInteger (&EntryType, *PFieldList, 1, 0); - - switch (EntryType) - { - /* 4-byte device entries */ - - case ACPI_IVRS_TYPE_PAD4: - case ACPI_IVRS_TYPE_ALL: - case ACPI_IVRS_TYPE_SELECT: - case ACPI_IVRS_TYPE_START: - case ACPI_IVRS_TYPE_END: - - InfoTable = AcpiDmTableInfoIvrs4; - break; - - /* 8-byte entries, type A */ - - case ACPI_IVRS_TYPE_ALIAS_SELECT: - case ACPI_IVRS_TYPE_ALIAS_START: - - InfoTable = AcpiDmTableInfoIvrs8a; - break; - - /* 8-byte entries, type B */ - - case ACPI_IVRS_TYPE_PAD8: - case ACPI_IVRS_TYPE_EXT_SELECT: - case ACPI_IVRS_TYPE_EXT_START: - - InfoTable = AcpiDmTableInfoIvrs8b; - break; - - /* 8-byte entries, type C */ - - case ACPI_IVRS_TYPE_SPECIAL: - - InfoTable = AcpiDmTableInfoIvrs8c; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, - "IVRS Device Entry"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - } - } - - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileLpit - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile LPIT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileLpit ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_DMTABLE_INFO *InfoTable; - ACPI_LPIT_HEADER *LpitHeader; - - - /* Note: Main table consists only of the standard ACPI table header */ - - while (*PFieldList) - { - SubtableStart = *PFieldList; - - /* LPIT Subtable header */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoLpitHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - LpitHeader = ACPI_CAST_PTR (ACPI_LPIT_HEADER, Subtable->Buffer); - - switch (LpitHeader->Type) - { - case ACPI_LPIT_TYPE_NATIVE_CSTATE: - - InfoTable = AcpiDmTableInfoLpit0; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT"); - return (AE_ERROR); - } - - /* LPIT Subtable */ - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileMadt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MADT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMadt ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_SUBTABLE_HEADER *MadtHeader; - ACPI_DMTABLE_INFO *InfoTable; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); - - switch (MadtHeader->Type) - { - case ACPI_MADT_TYPE_LOCAL_APIC: - - InfoTable = AcpiDmTableInfoMadt0; - break; - - case ACPI_MADT_TYPE_IO_APIC: - - InfoTable = AcpiDmTableInfoMadt1; - break; - - case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: - - InfoTable = AcpiDmTableInfoMadt2; - break; - - case ACPI_MADT_TYPE_NMI_SOURCE: - - InfoTable = AcpiDmTableInfoMadt3; - break; - - case ACPI_MADT_TYPE_LOCAL_APIC_NMI: - - InfoTable = AcpiDmTableInfoMadt4; - break; - - case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: - - InfoTable = AcpiDmTableInfoMadt5; - break; - - case ACPI_MADT_TYPE_IO_SAPIC: - - InfoTable = AcpiDmTableInfoMadt6; - break; - - case ACPI_MADT_TYPE_LOCAL_SAPIC: - - InfoTable = AcpiDmTableInfoMadt7; - break; - - case ACPI_MADT_TYPE_INTERRUPT_SOURCE: - - InfoTable = AcpiDmTableInfoMadt8; - break; - - case ACPI_MADT_TYPE_LOCAL_X2APIC: - - InfoTable = AcpiDmTableInfoMadt9; - break; - - case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: - - InfoTable = AcpiDmTableInfoMadt10; - break; - - case ACPI_MADT_TYPE_GENERIC_INTERRUPT: - - InfoTable = AcpiDmTableInfoMadt11; - break; - - case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: - - InfoTable = AcpiDmTableInfoMadt12; - break; - - case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: - - InfoTable = AcpiDmTableInfoMadt13; - break; - - case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: - - InfoTable = AcpiDmTableInfoMadt14; - break; - - case ACPI_MADT_TYPE_GENERIC_TRANSLATOR: - - InfoTable = AcpiDmTableInfoMadt15; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileMcfg - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MCFG. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMcfg ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileMpst - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MPST. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMpst ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - ACPI_MPST_CHANNEL *MpstChannelInfo; - ACPI_MPST_POWER_NODE *MpstPowerNode; - ACPI_MPST_DATA_HDR *MpstDataHeader; - UINT16 SubtableCount; - UINT32 PowerStateCount; - UINT32 ComponentCount; - - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer); - SubtableCount = MpstChannelInfo->PowerNodeCount; - - while (*PFieldList && SubtableCount) - { - /* Subtable: Memory Power Node(s) */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer); - PowerStateCount = MpstPowerNode->NumPowerStates; - ComponentCount = MpstPowerNode->NumPhysicalComponents; - - ParentTable = DtPeekSubtable (); - - /* Sub-subtables - Memory Power State Structure(s) */ - - while (*PFieldList && PowerStateCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A, - &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); } DtInsertSubtable (ParentTable, Subtable); - PowerStateCount--; - } - - /* Sub-subtables - Physical Component ID Structure(s) */ - - while (*PFieldList && ComponentCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - ComponentCount--; - } - - SubtableCount--; - DtPopSubtable (); - } - - /* Subtable: Count of Memory Power State Characteristic structures */ - - DtPopSubtable (); - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer); - SubtableCount = MpstDataHeader->CharacteristicsCount; - - ParentTable = DtPeekSubtable (); - - /* Subtable: Memory Power State Characteristics structure(s) */ - - while (*PFieldList && SubtableCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); } - - DtInsertSubtable (ParentTable, Subtable); - SubtableCount--; } - DtPopSubtable (); return (AE_OK); } /****************************************************************************** * - * FUNCTION: DtCompileMsct - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MSCT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMsct ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileMtmr - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile MTMR. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileMtmr ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoMtmr, AcpiDmTableInfoMtmr0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileNfit - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile NFIT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileNfit ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_NFIT_HEADER *NfitHeader; - ACPI_DMTABLE_INFO *InfoTable; - UINT32 Count; - ACPI_NFIT_INTERLEAVE *Interleave = NULL; - ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL; - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - /* Subtables */ - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer); - - switch (NfitHeader->Type) - { - case ACPI_NFIT_TYPE_SYSTEM_ADDRESS: - - InfoTable = AcpiDmTableInfoNfit0; - break; - - case ACPI_NFIT_TYPE_MEMORY_MAP: - - InfoTable = AcpiDmTableInfoNfit1; - break; - - case ACPI_NFIT_TYPE_INTERLEAVE: - - Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer); - InfoTable = AcpiDmTableInfoNfit2; - break; - - case ACPI_NFIT_TYPE_SMBIOS: - - InfoTable = AcpiDmTableInfoNfit3; - break; - - case ACPI_NFIT_TYPE_CONTROL_REGION: - - InfoTable = AcpiDmTableInfoNfit4; - break; - - case ACPI_NFIT_TYPE_DATA_REGION: - - InfoTable = AcpiDmTableInfoNfit5; - break; - - case ACPI_NFIT_TYPE_FLUSH_ADDRESS: - - Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer); - InfoTable = AcpiDmTableInfoNfit6; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - - switch (NfitHeader->Type) - { - case ACPI_NFIT_TYPE_INTERLEAVE: - - Count = 0; - DtPushSubtable (Subtable); - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a, - &Subtable, FALSE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - DtPopSubtable (); - break; - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - Count++; - } - - Interleave->LineCount = Count; - DtPopSubtable (); - break; - - case ACPI_NFIT_TYPE_SMBIOS: - - if (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (Subtable) - { - DtInsertSubtable (ParentTable, Subtable); - } - } - break; - - case ACPI_NFIT_TYPE_FLUSH_ADDRESS: - - Count = 0; - DtPushSubtable (Subtable); - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a, - &Subtable, FALSE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - if (!Subtable) - { - DtPopSubtable (); - break; - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - Count++; - } - - Hint->HintCount = (UINT16) Count; - DtPopSubtable (); - break; - - default: - break; - } - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompilePcct - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile PCCT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompilePcct ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_SUBTABLE_HEADER *PcctHeader; - ACPI_DMTABLE_INFO *InfoTable; - - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* Subtables */ - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); - - switch (PcctHeader->Type) - { - case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: - - InfoTable = AcpiDmTableInfoPcct0; - break; - - case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: - - InfoTable = AcpiDmTableInfoPcct1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompilePmtt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile PMTT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompilePmtt ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_PMTT_HEADER *PmttHeader; - ACPI_PMTT_CONTROLLER *PmttController; - UINT16 DomainCount; - UINT8 PrevType = ACPI_PMTT_TYPE_SOCKET; - - - /* Main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer); - while (PrevType >= PmttHeader->Type) - { - DtPopSubtable (); - - if (PrevType == ACPI_PMTT_TYPE_SOCKET) - { - break; - } - PrevType--; - } - PrevType = PmttHeader->Type; - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - switch (PmttHeader->Type) - { - case ACPI_PMTT_TYPE_SOCKET: - - /* Subtable: Socket Structure */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - break; - - case ACPI_PMTT_TYPE_CONTROLLER: - - /* Subtable: Memory Controller Structure */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER, - (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER))); - DomainCount = PmttController->DomainCount; - - while (DomainCount) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtInsertSubtable (ParentTable, Subtable); - DomainCount--; - } - break; - - case ACPI_PMTT_TYPE_DIMM: - - /* Subtable: Physical Component Structure */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT"); - return (AE_ERROR); - } - } - - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileRsdt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile RSDT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileRsdt ( - void **List) -{ - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD *FieldList = *(DT_FIELD **) List; - UINT32 Address; - - - ParentTable = DtPeekSubtable (); - - while (FieldList) - { - DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO); - - DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable); - DtInsertSubtable (ParentTable, Subtable); - FieldList = FieldList->Next; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileS3pt + * FUNCTION: DtCompileFacs * * PARAMETERS: PFieldList - Current field list pointer * * RETURN: Status * - * DESCRIPTION: Compile S3PT (Pointed to by FPDT) + * DESCRIPTION: Compile FACS. * *****************************************************************************/ ACPI_STATUS -DtCompileS3pt ( +DtCompileFacs ( DT_FIELD **PFieldList) { - ACPI_STATUS Status; - ACPI_S3PT_HEADER *S3ptHeader; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_DMTABLE_INFO *InfoTable; - DT_FIELD *SubtableStart; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt, - &Gbl_RootTable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DtPushSubtable (Gbl_RootTable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - S3ptHeader = ACPI_CAST_PTR (ACPI_S3PT_HEADER, Subtable->Buffer); - - switch (S3ptHeader->Type) - { - case ACPI_S3PT_TYPE_RESUME: - - InfoTable = AcpiDmTableInfoS3pt0; - break; - - case ACPI_S3PT_TYPE_SUSPEND: - - InfoTable = AcpiDmTableInfoS3pt1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileSlic - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile SLIC. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileSlic ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - - - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileSlit - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile SLIT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileSlit ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *FieldList; - UINT32 Localities; - UINT8 *LocalityBuffer; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer); - LocalityBuffer = UtLocalCalloc (Localities); - - /* Compile each locality buffer */ - - FieldList = *PFieldList; - while (FieldList) - { - DtCompileBuffer (LocalityBuffer, - FieldList->Value, FieldList, Localities); - - DtCreateSubtable (LocalityBuffer, Localities, &Subtable); - DtInsertSubtable (ParentTable, Subtable); - FieldList = FieldList->Next; - } - - ACPI_FREE (LocalityBuffer); - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileSrat - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile SRAT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileSrat ( - void **List) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_SUBTABLE_HEADER *SratHeader; - ACPI_DMTABLE_INFO *InfoTable; - - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - while (*PFieldList) - { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - - SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); - - switch (SratHeader->Type) - { - case ACPI_SRAT_TYPE_CPU_AFFINITY: - - InfoTable = AcpiDmTableInfoSrat0; - break; - - case ACPI_SRAT_TYPE_MEMORY_AFFINITY: - - InfoTable = AcpiDmTableInfoSrat1; - break; - - case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: - - InfoTable = AcpiDmTableInfoSrat2; - break; - - case ACPI_SRAT_TYPE_GICC_AFFINITY: - - InfoTable = AcpiDmTableInfoSrat3; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - DtPopSubtable (); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileStao - * - * PARAMETERS: PFieldList - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile STAO. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileStao ( - void **List) -{ - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_STATUS Status; - - - /* Compile the main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* Compile each ASCII namestring as a subtable */ - - while (*PFieldList) - { - Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtGetGenericTableInfo - * - * PARAMETERS: Name - Generic type name - * - * RETURN: Info entry - * - * DESCRIPTION: Obtain table info for a generic name entry - * - *****************************************************************************/ - -ACPI_DMTABLE_INFO * -DtGetGenericTableInfo ( - char *Name) -{ - ACPI_DMTABLE_INFO *Info; - UINT32 i; - - - if (!Name) - { - return (NULL); - } - - /* Search info table for name match */ - - for (i = 0; ; i++) - { - Info = AcpiDmTableInfoGeneric[i]; - if (Info->Opcode == ACPI_DMT_EXIT) - { - Info = NULL; - break; - } - - /* Use caseless compare for generic keywords */ - - if (!AcpiUtStricmp (Name, Info->Name)) - { - break; - } - } - - return (Info); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileUefi - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile UEFI. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileUefi ( - void **List) -{ - ACPI_STATUS Status; DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - UINT16 *DataOffset; - - - /* Compile the predefined portion of the UEFI table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - DataOffset = (UINT16 *) (Subtable->Buffer + 16); - *DataOffset = sizeof (ACPI_TABLE_UEFI); - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - - /* - * Compile the "generic" portion of the UEFI table. This - * part of the table is not predefined and any of the generic - * operators may be used. - */ - - DtCompileGeneric ((void **) PFieldList, NULL, NULL); - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileVrtc - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile VRTC. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileVrtc ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoVrtc, AcpiDmTableInfoVrtc0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileWdat - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile WDAT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileWdat ( - void **List) -{ - ACPI_STATUS Status; - - - Status = DtCompileTwoSubtables (List, - AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileWpbt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile WPBT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileWpbt ( - void **List) -{ - DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - ACPI_TABLE_WPBT *Table; + UINT8 *ReservedBuffer; ACPI_STATUS Status; - UINT16 Length; - - - /* Compile the main table */ - - Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt, - &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); + UINT32 ReservedSize; - /* Compile the argument list subtable */ - Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0, - &Subtable, TRUE); + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs, + &Gbl_RootTable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); } - /* Extract the length of the Arguments buffer, insert into main table */ - - Length = (UINT16) Subtable->TotalLength; - Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer); - Table->ArgumentsLength = Length; - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileXsdt - * - * PARAMETERS: List - Current field list pointer - * - * RETURN: Status - * - * DESCRIPTION: Compile XSDT. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileXsdt ( - void **List) -{ - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD *FieldList = *(DT_FIELD **) List; - UINT64 Address; - - - ParentTable = DtPeekSubtable (); - - while (FieldList) - { - DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO); - - DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable); - DtInsertSubtable (ParentTable, Subtable); - FieldList = FieldList->Next; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: DtCompileGeneric - * - * PARAMETERS: List - Current field list pointer - * Name - Field name to end generic compiling - * Length - Compiled table length to return - * - * RETURN: Status - * - * DESCRIPTION: Compile generic unknown table. - * - *****************************************************************************/ - -ACPI_STATUS -DtCompileGeneric ( - void **List, - char *Name, - UINT32 *Length) -{ - ACPI_STATUS Status; - DT_SUBTABLE *Subtable; - DT_SUBTABLE *ParentTable; - DT_FIELD **PFieldList = (DT_FIELD **) List; - ACPI_DMTABLE_INFO *Info; - - - ParentTable = DtPeekSubtable (); - - /* - * Compile the "generic" portion of the table. This - * part of the table is not predefined and any of the generic - * operators may be used. - */ - - /* Find any and all labels in the entire generic portion */ - - DtDetectAllLabels (*PFieldList); - - /* Now we can actually compile the parse tree */ - - if (*Length) - { - *Length = 0; - } - while (*PFieldList) - { - if (Name && !ACPI_STRCMP ((*PFieldList)->Name, Name)) - { - break; - } - Info = DtGetGenericTableInfo ((*PFieldList)->Name); - if (!Info) - { - sprintf (MsgBuffer, "Generic data type \"%s\" not found", - (*PFieldList)->Name); - DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, - (*PFieldList), MsgBuffer); - - *PFieldList = (*PFieldList)->Next; - continue; - } + /* Large FACS reserved area at the end of the table */ - Status = DtCompileTable (PFieldList, Info, - &Subtable, TRUE); - if (ACPI_SUCCESS (Status)) - { - DtInsertSubtable (ParentTable, Subtable); - if (Length) - { - *Length += Subtable->Length; - } - } - else - { - *PFieldList = (*PFieldList)->Next; + ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1); + ReservedBuffer = UtLocalCalloc (ReservedSize); - if (Status == AE_NOT_FOUND) - { - sprintf (MsgBuffer, "Generic data type \"%s\" not found", - (*PFieldList)->Name); - DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, - (*PFieldList), MsgBuffer); - } - } - } + DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable); + ACPI_FREE (ReservedBuffer); + DtInsertSubtable (Gbl_RootTable, Subtable); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/dttable1.c b/sys/contrib/dev/acpica/compiler/dttable1.c new file mode 100644 index 0000000..673f256 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/dttable1.c @@ -0,0 +1,1684 @@ +/****************************************************************************** + * + * Module Name: dttable1.c - handling for specific ACPI tables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +/* Compile all complex data tables, signatures starting with A-I */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/compiler/dtcompiler.h> + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dttable1") + + +static ACPI_DMTABLE_INFO TableInfoAsfAddress[] = +{ + {ACPI_DMT_BUFFER, 0, "Addresses", 0}, + {ACPI_DMT_EXIT, 0, NULL, 0} +}; + +static ACPI_DMTABLE_INFO TableInfoDmarPciPath[] = +{ + {ACPI_DMT_PCI_PATH, 0, "PCI Path", 0}, + {ACPI_DMT_EXIT, 0, NULL, 0} +}; + + +/****************************************************************************** + * + * FUNCTION: DtCompileAsf + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile ASF!. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileAsf ( + void **List) +{ + ACPI_ASF_INFO *AsfTable; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_DMTABLE_INFO *DataInfoTable = NULL; + UINT32 DataCount = 0; + ACPI_STATUS Status; + UINT32 i; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoAsfHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + AsfTable = ACPI_CAST_PTR (ACPI_ASF_INFO, Subtable->Buffer); + + switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ + { + case ACPI_ASF_TYPE_INFO: + + InfoTable = AcpiDmTableInfoAsf0; + break; + + case ACPI_ASF_TYPE_ALERT: + + InfoTable = AcpiDmTableInfoAsf1; + break; + + case ACPI_ASF_TYPE_CONTROL: + + InfoTable = AcpiDmTableInfoAsf2; + break; + + case ACPI_ASF_TYPE_BOOT: + + InfoTable = AcpiDmTableInfoAsf3; + break; + + case ACPI_ASF_TYPE_ADDRESS: + + InfoTable = AcpiDmTableInfoAsf4; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ + { + case ACPI_ASF_TYPE_INFO: + + DataInfoTable = NULL; + break; + + case ACPI_ASF_TYPE_ALERT: + + DataInfoTable = AcpiDmTableInfoAsf1a; + DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Alerts; + break; + + case ACPI_ASF_TYPE_CONTROL: + + DataInfoTable = AcpiDmTableInfoAsf2a; + DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Controls; + break; + + case ACPI_ASF_TYPE_BOOT: + + DataInfoTable = NULL; + break; + + case ACPI_ASF_TYPE_ADDRESS: + + DataInfoTable = TableInfoAsfAddress; + DataCount = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Devices; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); + return (AE_ERROR); + } + + if (DataInfoTable) + { + switch (AsfTable->Header.Type & 0x7F) + { + case ACPI_ASF_TYPE_ADDRESS: + + while (DataCount > 0) + { + Status = DtCompileTable (PFieldList, DataInfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DataCount = DataCount - Subtable->Length; + } + break; + + default: + + for (i = 0; i < DataCount; i++) + { + Status = DtCompileTable (PFieldList, DataInfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + break; + } + } + + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileCpep + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile CPEP. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileCpep ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoCpep, AcpiDmTableInfoCpep0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileCsrt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile CSRT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileCsrt ( + void **List) +{ + ACPI_STATUS Status = AE_OK; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT32 DescriptorCount; + UINT32 GroupLength; + + + /* Subtables (Resource Groups) */ + + ParentTable = DtPeekSubtable (); + while (*PFieldList) + { + /* Resource group subtable */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Compute the number of resource descriptors */ + + GroupLength = + (ACPI_CAST_PTR (ACPI_CSRT_GROUP, + Subtable->Buffer))->Length - + (ACPI_CAST_PTR (ACPI_CSRT_GROUP, + Subtable->Buffer))->SharedInfoLength - + sizeof (ACPI_CSRT_GROUP); + + DescriptorCount = (GroupLength / + sizeof (ACPI_CSRT_DESCRIPTOR)); + + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + /* Shared info subtable (One per resource group) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + /* Sub-Subtables (Resource Descriptors) */ + + while (*PFieldList && DescriptorCount) + { + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + if (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (Subtable) + { + DtInsertSubtable (ParentTable, Subtable); + } + } + + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + DescriptorCount--; + } + + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + } + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileDbg2 + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DBG2. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDbg2 ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT32 SubtableCount; + ACPI_DBG2_HEADER *Dbg2Header; + ACPI_DBG2_DEVICE *DeviceInfo; + UINT16 CurrentOffset; + UINT32 i; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Main table fields */ + + Dbg2Header = ACPI_CAST_PTR (ACPI_DBG2_HEADER, Subtable->Buffer); + Dbg2Header->InfoOffset = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF ( + ACPI_ADD_PTR (UINT8, Dbg2Header, sizeof (ACPI_DBG2_HEADER)), Dbg2Header); + + SubtableCount = Dbg2Header->InfoCount; + DtPushSubtable (Subtable); + + /* Process all Device Information subtables (Count = InfoCount) */ + + while (*PFieldList && SubtableCount) + { + /* Subtable: Debug Device Information */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Device, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DeviceInfo = ACPI_CAST_PTR (ACPI_DBG2_DEVICE, Subtable->Buffer); + CurrentOffset = (UINT16) sizeof (ACPI_DBG2_DEVICE); + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + ParentTable = DtPeekSubtable (); + + /* BaseAddressRegister GAS array (Required, size is RegisterCount) */ + + DeviceInfo->BaseAddressOffset = CurrentOffset; + for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Addr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + CurrentOffset += (UINT16) sizeof (ACPI_GENERIC_ADDRESS); + DtInsertSubtable (ParentTable, Subtable); + } + + /* AddressSize array (Required, size = RegisterCount) */ + + DeviceInfo->AddressSizeOffset = CurrentOffset; + for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Size, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + CurrentOffset += (UINT16) sizeof (UINT32); + DtInsertSubtable (ParentTable, Subtable); + } + + /* NamespaceString device identifier (Required, size = NamePathLength) */ + + DeviceInfo->NamepathOffset = CurrentOffset; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Name, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update the device info header */ + + DeviceInfo->NamepathLength = (UINT16) Subtable->Length; + CurrentOffset += (UINT16) DeviceInfo->NamepathLength; + DtInsertSubtable (ParentTable, Subtable); + + /* OemData - Variable-length data (Optional, size = OemDataLength) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2OemData, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update the device info header (zeros if no OEM data present) */ + + DeviceInfo->OemDataOffset = 0; + DeviceInfo->OemDataLength = 0; + + /* Optional subtable (OemData) */ + + if (Subtable && Subtable->Length) + { + DeviceInfo->OemDataOffset = CurrentOffset; + DeviceInfo->OemDataLength = (UINT16) Subtable->Length; + + DtInsertSubtable (ParentTable, Subtable); + } + + SubtableCount--; + DtPopSubtable (); /* Get next Device Information subtable */ + } + + DtPopSubtable (); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileDmar + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DMAR. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDmar ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_DMAR_HEADER *DmarHeader; + ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope; + UINT32 DeviceScopeLength; + UINT32 PciPathLength; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + while (*PFieldList) + { + /* DMAR Header */ + + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer); + + switch (DmarHeader->Type) + { + case ACPI_DMAR_TYPE_HARDWARE_UNIT: + + InfoTable = AcpiDmTableInfoDmar0; + break; + + case ACPI_DMAR_TYPE_RESERVED_MEMORY: + + InfoTable = AcpiDmTableInfoDmar1; + break; + + case ACPI_DMAR_TYPE_ROOT_ATS: + + InfoTable = AcpiDmTableInfoDmar2; + break; + + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: + + InfoTable = AcpiDmTableInfoDmar3; + break; + + case ACPI_DMAR_TYPE_NAMESPACE: + + InfoTable = AcpiDmTableInfoDmar4; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR"); + return (AE_ERROR); + } + + /* DMAR Subtable */ + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Optional Device Scope subtables + */ + if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE)) + { + /* These types do not support device scopes */ + + DtPopSubtable (); + continue; + } + + DtPushSubtable (Subtable); + DeviceScopeLength = DmarHeader->Length - Subtable->Length - + ParentTable->Length; + while (DeviceScopeLength) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope, + &Subtable, FALSE); + if (Status == AE_NOT_FOUND) + { + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + DmarDeviceScope = ACPI_CAST_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable->Buffer); + + /* Optional PCI Paths */ + + PciPathLength = DmarDeviceScope->Length - Subtable->Length; + while (PciPathLength) + { + Status = DtCompileTable (PFieldList, TableInfoDmarPciPath, + &Subtable, FALSE); + if (Status == AE_NOT_FOUND) + { + DtPopSubtable (); + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + PciPathLength -= Subtable->Length; + } + + DtPopSubtable (); + DeviceScopeLength -= DmarDeviceScope->Length; + } + + DtPopSubtable (); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileDrtm + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DRTM. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDrtm ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT32 Count; + /* ACPI_TABLE_DRTM *Drtm; */ + ACPI_DRTM_VTABLE_LIST *DrtmVtl; + ACPI_DRTM_RESOURCE_LIST *DrtmRl; + /* ACPI_DRTM_DPS_ID *DrtmDps; */ + + + ParentTable = DtPeekSubtable (); + + /* Compile DRTM header */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + DtInsertSubtable (ParentTable, Subtable); + + /* + * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care + * should be taken to avoid accessing ACPI_TABLE_HADER fields. + */ +#if 0 + Drtm = ACPI_SUB_PTR (ACPI_TABLE_DRTM, + Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); +#endif + /* Compile VTL */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DrtmVtl = ACPI_CAST_PTR (ACPI_DRTM_VTABLE_LIST, Subtable->Buffer); + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + Count = 0; + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (!Subtable) + { + break; + } + DtInsertSubtable (ParentTable, Subtable); + Count++; + } + + DrtmVtl->ValidatedTableCount = Count; + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + + /* Compile RL */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DrtmRl = ACPI_CAST_PTR (ACPI_DRTM_RESOURCE_LIST, Subtable->Buffer); + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + Count = 0; + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + Count++; + } + + DrtmRl->ResourceCount = Count; + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + + /* Compile DPS */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + DtInsertSubtable (ParentTable, Subtable); + /* DrtmDps = ACPI_CAST_PTR (ACPI_DRTM_DPS_ID, Subtable->Buffer);*/ + + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileEinj + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile EINJ. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileEinj ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoEinj, AcpiDmTableInfoEinj0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileErst + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile ERST. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileErst ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoErst, AcpiDmTableInfoEinj0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileGtdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile GTDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileGtdt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *GtdtHeader; + ACPI_DMTABLE_INFO *InfoTable; + UINT32 GtCount; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + GtdtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + InfoTable = AcpiDmTableInfoGtdt0; + break; + + case ACPI_GTDT_TYPE_WATCHDOG: + + InfoTable = AcpiDmTableInfoGtdt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "GTDT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Additional GT block subtable data + */ + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, + Subtable->Buffer - sizeof(ACPI_GTDT_HEADER)))->TimerCount; + + while (GtCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + GtCount--; + } + + DtPopSubtable (); + break; + + default: + + break; + } + + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileFpdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile FPDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileFpdt ( + void **List) +{ + ACPI_STATUS Status; + ACPI_FPDT_HEADER *FpdtHeader; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_DMTABLE_INFO *InfoTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFpdtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + FpdtHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); + + switch (FpdtHeader->Type) + { + case ACPI_FPDT_TYPE_BOOT: + + InfoTable = AcpiDmTableInfoFpdt0; + break; + + case ACPI_FPDT_TYPE_S3PERF: + + InfoTable = AcpiDmTableInfoFpdt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "FPDT"); + return (AE_ERROR); + break; + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileHest + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile HEST. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileHest ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + UINT16 Type; + UINT32 BankCount; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoHest, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + /* Get subtable type */ + + SubtableStart = *PFieldList; + DtCompileInteger ((UINT8 *) &Type, *PFieldList, 2, 0); + + switch (Type) + { + case ACPI_HEST_TYPE_IA32_CHECK: + + InfoTable = AcpiDmTableInfoHest0; + break; + + case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + + InfoTable = AcpiDmTableInfoHest1; + break; + + case ACPI_HEST_TYPE_IA32_NMI: + + InfoTable = AcpiDmTableInfoHest2; + break; + + case ACPI_HEST_TYPE_AER_ROOT_PORT: + + InfoTable = AcpiDmTableInfoHest6; + break; + + case ACPI_HEST_TYPE_AER_ENDPOINT: + + InfoTable = AcpiDmTableInfoHest7; + break; + + case ACPI_HEST_TYPE_AER_BRIDGE: + + InfoTable = AcpiDmTableInfoHest8; + break; + + case ACPI_HEST_TYPE_GENERIC_ERROR: + + InfoTable = AcpiDmTableInfoHest9; + break; + + default: + + /* Cannot continue on unknown type */ + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "HEST"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + /* + * Additional subtable data - IA32 Error Bank(s) + */ + BankCount = 0; + switch (Type) + { + case ACPI_HEST_TYPE_IA32_CHECK: + + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, + Subtable->Buffer))->NumHardwareBanks; + break; + + case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, + Subtable->Buffer))->NumHardwareBanks; + break; + + default: + + break; + } + + while (BankCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoHestBank, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + BankCount--; + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileIort + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile IORT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileIort ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_TABLE_IORT *Iort; + ACPI_IORT_NODE *IortNode; + ACPI_IORT_ITS_GROUP *IortItsGroup; + ACPI_IORT_SMMU *IortSmmu; + UINT32 NodeNumber; + UINT32 NodeLength; + UINT32 IdMappingNumber; + UINT32 ItsNumber; + UINT32 ContextIrptNumber; + UINT32 PmuIrptNumber; + UINT32 PaddingLength; + + + ParentTable = DtPeekSubtable (); + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + DtInsertSubtable (ParentTable, Subtable); + + /* + * Using ACPI_SUB_PTR, We needn't define a separate structure. Care + * should be taken to avoid accessing ACPI_TABLE_HEADER fields. + */ + Iort = ACPI_SUB_PTR (ACPI_TABLE_IORT, + Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); + + /* + * OptionalPadding - Variable-length data + * (Optional, size = OffsetToNodes - sizeof (ACPI_TABLE_IORT)) + * Optionally allows the generic data types to be used for filling + * this field. + */ + Iort->NodeOffset = sizeof (ACPI_TABLE_IORT); + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortPad, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (Subtable) + { + DtInsertSubtable (ParentTable, Subtable); + Iort->NodeOffset += Subtable->Length; + } + else + { + Status = DtCompileGeneric (ACPI_CAST_PTR (void *, PFieldList), + AcpiDmTableInfoIortHdr[0].Name, &PaddingLength); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + Iort->NodeOffset += PaddingLength; + } + + NodeNumber = 0; + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + IortNode = ACPI_CAST_PTR (ACPI_IORT_NODE, Subtable->Buffer); + NodeLength = ACPI_OFFSET (ACPI_IORT_NODE, NodeData); + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + switch (IortNode->Type) + { + case ACPI_IORT_NODE_ITS_GROUP: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + IortItsGroup = ACPI_CAST_PTR (ACPI_IORT_ITS_GROUP, Subtable->Buffer); + NodeLength += Subtable->Length; + + ItsNumber = 0; + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + ItsNumber++; + } + + IortItsGroup->ItsCount = ItsNumber; + break; + + case ACPI_IORT_NODE_NAMED_COMPONENT: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + + /* + * Padding - Variable-length data + * Optionally allows the offset of the ID mappings to be used + * for filling this field. + */ + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Subtable) + { + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + } + else + { + if (NodeLength > IortNode->MappingOffset) + { + return (AE_BAD_DATA); + } + + if (NodeLength < IortNode->MappingOffset) + { + Status = DtCompilePadding ( + IortNode->MappingOffset - NodeLength, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength = IortNode->MappingOffset; + } + } + break; + + case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + break; + + case ACPI_IORT_NODE_SMMU: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + IortSmmu = ACPI_CAST_PTR (ACPI_IORT_SMMU, Subtable->Buffer); + NodeLength += Subtable->Length; + + /* Compile global interrupt array */ + + IortSmmu->GlobalInterruptOffset = NodeLength; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + + /* Compile context interrupt array */ + + ContextIrptNumber = 0; + IortSmmu->ContextInterruptOffset = NodeLength; + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3b, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + ContextIrptNumber++; + } + + IortSmmu->ContextInterruptCount = ContextIrptNumber; + + /* Compile PMU interrupt array */ + + PmuIrptNumber = 0; + IortSmmu->PmuInterruptOffset = NodeLength; + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3c, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + PmuIrptNumber++; + } + + IortSmmu->PmuInterruptCount = PmuIrptNumber; + break; + + case ACPI_IORT_NODE_SMMU_V3: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort4, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IORT"); + return (AE_ERROR); + } + + /* Compile Array of ID mappings */ + + IortNode->MappingOffset = NodeLength; + IdMappingNumber = 0; + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortMap, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + break; + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += sizeof (ACPI_IORT_ID_MAPPING); + IdMappingNumber++; + } + + IortNode->MappingCount = IdMappingNumber; + + /* + * Node length can be determined by DT_LENGTH option + * IortNode->Length = NodeLength; + */ + DtPopSubtable (); + ParentTable = DtPeekSubtable (); + NodeNumber++; + } + + Iort->NodeCount = NodeNumber; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileIvrs + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile IVRS. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileIvrs ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_IVRS_HEADER *IvrsHeader; + UINT8 EntryType; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrs, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrsHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + IvrsHeader = ACPI_CAST_PTR (ACPI_IVRS_HEADER, Subtable->Buffer); + + switch (IvrsHeader->Type) + { + case ACPI_IVRS_TYPE_HARDWARE: + + InfoTable = AcpiDmTableInfoIvrs0; + break; + + case ACPI_IVRS_TYPE_MEMORY1: + case ACPI_IVRS_TYPE_MEMORY2: + case ACPI_IVRS_TYPE_MEMORY3: + + InfoTable = AcpiDmTableInfoIvrs1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IVRS"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + if (IvrsHeader->Type == ACPI_IVRS_TYPE_HARDWARE) + { + while (*PFieldList && + !strcmp ((*PFieldList)->Name, "Entry Type")) + { + SubtableStart = *PFieldList; + DtCompileInteger (&EntryType, *PFieldList, 1, 0); + + switch (EntryType) + { + /* 4-byte device entries */ + + case ACPI_IVRS_TYPE_PAD4: + case ACPI_IVRS_TYPE_ALL: + case ACPI_IVRS_TYPE_SELECT: + case ACPI_IVRS_TYPE_START: + case ACPI_IVRS_TYPE_END: + + InfoTable = AcpiDmTableInfoIvrs4; + break; + + /* 8-byte entries, type A */ + + case ACPI_IVRS_TYPE_ALIAS_SELECT: + case ACPI_IVRS_TYPE_ALIAS_START: + + InfoTable = AcpiDmTableInfoIvrs8a; + break; + + /* 8-byte entries, type B */ + + case ACPI_IVRS_TYPE_PAD8: + case ACPI_IVRS_TYPE_EXT_SELECT: + case ACPI_IVRS_TYPE_EXT_START: + + InfoTable = AcpiDmTableInfoIvrs8b; + break; + + /* 8-byte entries, type C */ + + case ACPI_IVRS_TYPE_SPECIAL: + + InfoTable = AcpiDmTableInfoIvrs8c; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, + "IVRS Device Entry"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + } + + DtPopSubtable (); + } + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/dttable2.c b/sys/contrib/dev/acpica/compiler/dttable2.c new file mode 100644 index 0000000..8297ba3 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/dttable2.c @@ -0,0 +1,1691 @@ +/****************************************************************************** + * + * Module Name: dttable2.c - handling for specific ACPI tables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +/* Compile all complex data tables, signatures starting with L-Z */ + +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/compiler/dtcompiler.h> + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dttable2") + + +/****************************************************************************** + * + * FUNCTION: DtCompileLpit + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile LPIT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileLpit ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_LPIT_HEADER *LpitHeader; + + + /* Note: Main table consists only of the standard ACPI table header */ + + while (*PFieldList) + { + SubtableStart = *PFieldList; + + /* LPIT Subtable header */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoLpitHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + LpitHeader = ACPI_CAST_PTR (ACPI_LPIT_HEADER, Subtable->Buffer); + + switch (LpitHeader->Type) + { + case ACPI_LPIT_TYPE_NATIVE_CSTATE: + + InfoTable = AcpiDmTableInfoLpit0; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT"); + return (AE_ERROR); + } + + /* LPIT Subtable */ + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMadt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MADT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMadt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *MadtHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (MadtHeader->Type) + { + case ACPI_MADT_TYPE_LOCAL_APIC: + + InfoTable = AcpiDmTableInfoMadt0; + break; + + case ACPI_MADT_TYPE_IO_APIC: + + InfoTable = AcpiDmTableInfoMadt1; + break; + + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: + + InfoTable = AcpiDmTableInfoMadt2; + break; + + case ACPI_MADT_TYPE_NMI_SOURCE: + + InfoTable = AcpiDmTableInfoMadt3; + break; + + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: + + InfoTable = AcpiDmTableInfoMadt4; + break; + + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: + + InfoTable = AcpiDmTableInfoMadt5; + break; + + case ACPI_MADT_TYPE_IO_SAPIC: + + InfoTable = AcpiDmTableInfoMadt6; + break; + + case ACPI_MADT_TYPE_LOCAL_SAPIC: + + InfoTable = AcpiDmTableInfoMadt7; + break; + + case ACPI_MADT_TYPE_INTERRUPT_SOURCE: + + InfoTable = AcpiDmTableInfoMadt8; + break; + + case ACPI_MADT_TYPE_LOCAL_X2APIC: + + InfoTable = AcpiDmTableInfoMadt9; + break; + + case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: + + InfoTable = AcpiDmTableInfoMadt10; + break; + + case ACPI_MADT_TYPE_GENERIC_INTERRUPT: + + InfoTable = AcpiDmTableInfoMadt11; + break; + + case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt12; + break; + + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + + case ACPI_MADT_TYPE_GENERIC_TRANSLATOR: + + InfoTable = AcpiDmTableInfoMadt15; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMcfg + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MCFG. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMcfg ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMpst + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MPST. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMpst ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_MPST_CHANNEL *MpstChannelInfo; + ACPI_MPST_POWER_NODE *MpstPowerNode; + ACPI_MPST_DATA_HDR *MpstDataHeader; + UINT16 SubtableCount; + UINT32 PowerStateCount; + UINT32 ComponentCount; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer); + SubtableCount = MpstChannelInfo->PowerNodeCount; + + while (*PFieldList && SubtableCount) + { + /* Subtable: Memory Power Node(s) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer); + PowerStateCount = MpstPowerNode->NumPowerStates; + ComponentCount = MpstPowerNode->NumPhysicalComponents; + + ParentTable = DtPeekSubtable (); + + /* Sub-subtables - Memory Power State Structure(s) */ + + while (*PFieldList && PowerStateCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + PowerStateCount--; + } + + /* Sub-subtables - Physical Component ID Structure(s) */ + + while (*PFieldList && ComponentCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + ComponentCount--; + } + + SubtableCount--; + DtPopSubtable (); + } + + /* Subtable: Count of Memory Power State Characteristic structures */ + + DtPopSubtable (); + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer); + SubtableCount = MpstDataHeader->CharacteristicsCount; + + ParentTable = DtPeekSubtable (); + + /* Subtable: Memory Power State Characteristics structure(s) */ + + while (*PFieldList && SubtableCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + SubtableCount--; + } + + DtPopSubtable (); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMsct + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MSCT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMsct ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMtmr + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MTMR. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMtmr ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoMtmr, AcpiDmTableInfoMtmr0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileNfit + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile NFIT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileNfit ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_NFIT_HEADER *NfitHeader; + ACPI_DMTABLE_INFO *InfoTable; + UINT32 Count; + ACPI_NFIT_INTERLEAVE *Interleave = NULL; + ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + /* Subtables */ + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer); + + switch (NfitHeader->Type) + { + case ACPI_NFIT_TYPE_SYSTEM_ADDRESS: + + InfoTable = AcpiDmTableInfoNfit0; + break; + + case ACPI_NFIT_TYPE_MEMORY_MAP: + + InfoTable = AcpiDmTableInfoNfit1; + break; + + case ACPI_NFIT_TYPE_INTERLEAVE: + + Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer); + InfoTable = AcpiDmTableInfoNfit2; + break; + + case ACPI_NFIT_TYPE_SMBIOS: + + InfoTable = AcpiDmTableInfoNfit3; + break; + + case ACPI_NFIT_TYPE_CONTROL_REGION: + + InfoTable = AcpiDmTableInfoNfit4; + break; + + case ACPI_NFIT_TYPE_DATA_REGION: + + InfoTable = AcpiDmTableInfoNfit5; + break; + + case ACPI_NFIT_TYPE_FLUSH_ADDRESS: + + Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer); + InfoTable = AcpiDmTableInfoNfit6; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + + switch (NfitHeader->Type) + { + case ACPI_NFIT_TYPE_INTERLEAVE: + + Count = 0; + DtPushSubtable (Subtable); + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a, + &Subtable, FALSE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + DtPopSubtable (); + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + Count++; + } + + Interleave->LineCount = Count; + DtPopSubtable (); + break; + + case ACPI_NFIT_TYPE_SMBIOS: + + if (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Subtable) + { + DtInsertSubtable (ParentTable, Subtable); + } + } + break; + + case ACPI_NFIT_TYPE_FLUSH_ADDRESS: + + Count = 0; + DtPushSubtable (Subtable); + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a, + &Subtable, FALSE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Subtable) + { + DtPopSubtable (); + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + Count++; + } + + Hint->HintCount = (UINT16) Count; + DtPopSubtable (); + break; + + default: + break; + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompilePcct + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile PCCT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompilePcct ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *PcctHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Subtables */ + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (PcctHeader->Type) + { + case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct0; + break; + + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2: + + InfoTable = AcpiDmTableInfoPcct2; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompilePmtt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile PMTT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompilePmtt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_PMTT_HEADER *PmttHeader; + ACPI_PMTT_CONTROLLER *PmttController; + UINT16 DomainCount; + UINT8 PrevType = ACPI_PMTT_TYPE_SOCKET; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer); + while (PrevType >= PmttHeader->Type) + { + DtPopSubtable (); + + if (PrevType == ACPI_PMTT_TYPE_SOCKET) + { + break; + } + + PrevType--; + } + + PrevType = PmttHeader->Type; + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + switch (PmttHeader->Type) + { + case ACPI_PMTT_TYPE_SOCKET: + + /* Subtable: Socket Structure */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + break; + + case ACPI_PMTT_TYPE_CONTROLLER: + + /* Subtable: Memory Controller Structure */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER, + (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER))); + DomainCount = PmttController->DomainCount; + + while (DomainCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DomainCount--; + } + break; + + case ACPI_PMTT_TYPE_DIMM: + + /* Subtable: Physical Component Structure */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT"); + return (AE_ERROR); + } + } + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileRsdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile RSDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileRsdt ( + void **List) +{ + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD *FieldList = *(DT_FIELD **) List; + UINT32 Address; + + + ParentTable = DtPeekSubtable (); + + while (FieldList) + { + DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO); + + DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + FieldList = FieldList->Next; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileS3pt + * + * PARAMETERS: PFieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile S3PT (Pointed to by FPDT) + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileS3pt ( + DT_FIELD **PFieldList) +{ + ACPI_STATUS Status; + ACPI_FPDT_HEADER *S3ptHeader; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_DMTABLE_INFO *InfoTable; + DT_FIELD *SubtableStart; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt, + &Gbl_RootTable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtPushSubtable (Gbl_RootTable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); + + switch (S3ptHeader->Type) + { + case ACPI_S3PT_TYPE_RESUME: + + InfoTable = AcpiDmTableInfoS3pt0; + break; + + case ACPI_S3PT_TYPE_SUSPEND: + + InfoTable = AcpiDmTableInfoS3pt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileSlic + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile SLIC. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileSlic ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileSlit + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile SLIT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileSlit ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *FieldList; + UINT32 Localities; + UINT8 *LocalityBuffer; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer); + LocalityBuffer = UtLocalCalloc (Localities); + + /* Compile each locality buffer */ + + FieldList = *PFieldList; + while (FieldList) + { + DtCompileBuffer (LocalityBuffer, + FieldList->Value, FieldList, Localities); + + DtCreateSubtable (LocalityBuffer, Localities, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + FieldList = FieldList->Next; + } + + ACPI_FREE (LocalityBuffer); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileSrat + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile SRAT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileSrat ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *SratHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (SratHeader->Type) + { + case ACPI_SRAT_TYPE_CPU_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat0; + break; + + case ACPI_SRAT_TYPE_MEMORY_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat1; + break; + + case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat2; + break; + + case ACPI_SRAT_TYPE_GICC_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat3; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileStao + * + * PARAMETERS: PFieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile STAO. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileStao ( + void **List) +{ + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_STATUS Status; + + + /* Compile the main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Compile each ASCII namestring as a subtable */ + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileTcpa + * + * PARAMETERS: PFieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile TCPA. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileTcpa ( + void **List) +{ + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_SUBTABLE *Subtable; + ACPI_TABLE_TCPA_HDR *TcpaHeader; + DT_SUBTABLE *ParentTable; + ACPI_STATUS Status; + + + /* Compile the main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Examine the PlatformClass field to determine the table type. + * Either a client or server table. Only one. + */ + TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer); + + switch (TcpaHeader->PlatformClass) + { + case ACPI_TCPA_CLIENT_TABLE: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaClient, + &Subtable, TRUE); + break; + + case ACPI_TCPA_SERVER_TABLE: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaServer, + &Subtable, TRUE); + break; + + default: + + AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n", + TcpaHeader->PlatformClass); + Status = AE_ERROR; + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetGenericTableInfo + * + * PARAMETERS: Name - Generic type name + * + * RETURN: Info entry + * + * DESCRIPTION: Obtain table info for a generic name entry + * + *****************************************************************************/ + +ACPI_DMTABLE_INFO * +DtGetGenericTableInfo ( + char *Name) +{ + ACPI_DMTABLE_INFO *Info; + UINT32 i; + + + if (!Name) + { + return (NULL); + } + + /* Search info table for name match */ + + for (i = 0; ; i++) + { + Info = AcpiDmTableInfoGeneric[i]; + if (Info->Opcode == ACPI_DMT_EXIT) + { + Info = NULL; + break; + } + + /* Use caseless compare for generic keywords */ + + if (!AcpiUtStricmp (Name, Info->Name)) + { + break; + } + } + + return (Info); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileUefi + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile UEFI. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileUefi ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT16 *DataOffset; + + + /* Compile the predefined portion of the UEFI table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DataOffset = (UINT16 *) (Subtable->Buffer + 16); + *DataOffset = sizeof (ACPI_TABLE_UEFI); + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Compile the "generic" portion of the UEFI table. This + * part of the table is not predefined and any of the generic + * operators may be used. + */ + DtCompileGeneric ((void **) PFieldList, NULL, NULL); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileVrtc + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile VRTC. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileVrtc ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoVrtc, AcpiDmTableInfoVrtc0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileWdat + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile WDAT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileWdat ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileWpbt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile WPBT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileWpbt ( + void **List) +{ + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_TABLE_WPBT *Table; + ACPI_STATUS Status; + UINT16 Length; + + + /* Compile the main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Compile the argument list subtable */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Extract the length of the Arguments buffer, insert into main table */ + + Length = (UINT16) Subtable->TotalLength; + Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer); + Table->ArgumentsLength = Length; + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileXsdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile XSDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileXsdt ( + void **List) +{ + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD *FieldList = *(DT_FIELD **) List; + UINT64 Address; + + + ParentTable = DtPeekSubtable (); + + while (FieldList) + { + DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO); + + DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + FieldList = FieldList->Next; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileGeneric + * + * PARAMETERS: List - Current field list pointer + * Name - Field name to end generic compiling + * Length - Compiled table length to return + * + * RETURN: Status + * + * DESCRIPTION: Compile generic unknown table. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileGeneric ( + void **List, + char *Name, + UINT32 *Length) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_DMTABLE_INFO *Info; + + + ParentTable = DtPeekSubtable (); + + /* + * Compile the "generic" portion of the table. This + * part of the table is not predefined and any of the generic + * operators may be used. + */ + + /* Find any and all labels in the entire generic portion */ + + DtDetectAllLabels (*PFieldList); + + /* Now we can actually compile the parse tree */ + + if (Length && *Length) + { + *Length = 0; + } + while (*PFieldList) + { + if (Name && !strcmp ((*PFieldList)->Name, Name)) + { + break; + } + + Info = DtGetGenericTableInfo ((*PFieldList)->Name); + if (!Info) + { + sprintf (MsgBuffer, "Generic data type \"%s\" not found", + (*PFieldList)->Name); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, + (*PFieldList), MsgBuffer); + + *PFieldList = (*PFieldList)->Next; + continue; + } + + Status = DtCompileTable (PFieldList, Info, + &Subtable, TRUE); + if (ACPI_SUCCESS (Status)) + { + DtInsertSubtable (ParentTable, Subtable); + if (Length) + { + *Length += Subtable->Length; + } + } + else + { + *PFieldList = (*PFieldList)->Next; + + if (Status == AE_NOT_FOUND) + { + sprintf (MsgBuffer, "Generic data type \"%s\" not found", + (*PFieldList)->Name); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, + (*PFieldList), MsgBuffer); + } + } + } + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.c b/sys/contrib/dev/acpica/compiler/dttemplate.c index 90b6b17..319ee29 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.c +++ b/sys/contrib/dev/acpica/compiler/dttemplate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,14 +57,27 @@ AcpiUtIsSpecialTable ( char *Signature); static ACPI_STATUS +DtCreateOneTemplateFile ( + char *Signature, + UINT32 TableCount); + +static ACPI_STATUS DtCreateOneTemplate ( char *Signature, + UINT32 TableCount, const ACPI_DMTABLE_DATA *TableData); static ACPI_STATUS DtCreateAllTemplates ( void); +static int +DtEmitDefinitionBlock ( + FILE *File, + char *Filename, + char *Signature, + UINT32 Instance); + /******************************************************************************* * @@ -85,6 +98,7 @@ AcpiUtIsSpecialTable ( { if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT) || ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT) || ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS) || ACPI_COMPARE_NAME (Signature, ACPI_RSDP_NAME)) @@ -100,7 +114,7 @@ AcpiUtIsSpecialTable ( * * FUNCTION: DtCreateTemplates * - * PARAMETERS: Signature - ACPI table signature + * PARAMETERS: argv - Standard command line arguments * * RETURN: Status * @@ -110,32 +124,115 @@ AcpiUtIsSpecialTable ( ACPI_STATUS DtCreateTemplates ( - char *Signature) + char **argv) { - const ACPI_DMTABLE_DATA *TableData; - ACPI_STATUS Status; + char *Signature; + char *End; + unsigned long TableCount; + ACPI_STATUS Status = AE_OK; AslInitializeGlobals (); - /* Default (no signature) is DSDT */ + Status = AdInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Special cases for DSDT, ALL, and '*' + */ + + /* Default (no signature option) is DSDT */ - if (!Signature) + if (AcpiGbl_Optind < 3) { - Signature = "DSDT"; - goto GetTemplate; + Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, 0); + goto Exit; } + AcpiGbl_Optind--; + Signature = argv[AcpiGbl_Optind]; AcpiUtStrupr (Signature); - if (!ACPI_STRCMP (Signature, "ALL") || - !ACPI_STRCMP (Signature, "*")) + + /* + * Multiple SSDT support (-T <ssdt count>) + */ + TableCount = strtoul (Signature, &End, 0); + if (Signature != End) + { + /* The count is used for table ID and method name - max is 254(+1) */ + + if (TableCount > 254) + { + fprintf (stderr, "%u SSDTs requested, maximum is 254\n", + (unsigned int) TableCount); + + Status = AE_LIMIT; + goto Exit; + } + + Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, TableCount); + goto Exit; + } + + if (!strcmp (Signature, "ALL")) { /* Create all available/known templates */ Status = DtCreateAllTemplates (); - return (Status); + goto Exit; + } + + /* + * Normal case: Create template for each signature + */ + while (argv[AcpiGbl_Optind]) + { + Signature = argv[AcpiGbl_Optind]; + AcpiUtStrupr (Signature); + + Status = DtCreateOneTemplateFile (Signature, 0); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + AcpiGbl_Optind++; } + +Exit: + /* Shutdown ACPICA subsystem */ + + (void) AcpiTerminate (); + CmDeleteCaches (); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: DtCreateOneTemplateFile + * + * PARAMETERS: Signature - ACPI table signature + * + * RETURN: Status + * + * DESCRIPTION: Create one template file of the requested signature. + * + ******************************************************************************/ + +static ACPI_STATUS +DtCreateOneTemplateFile ( + char *Signature, + UINT32 TableCount) +{ + const ACPI_DMTABLE_DATA *TableData; + ACPI_STATUS Status; + + /* * Validate signature and get the template data: * 1) Signature must be 4 characters @@ -145,8 +242,8 @@ DtCreateTemplates ( if (strlen (Signature) != ACPI_NAME_SIZE) { fprintf (stderr, - "%s: Invalid ACPI table signature (length must be 4 characters)\n", - Signature); + "%s: Invalid ACPI table signature " + "(length must be 4 characters)\n", Signature); return (AE_ERROR); } @@ -163,7 +260,8 @@ DtCreateTemplates ( Signature = "FACP"; } -GetTemplate: + /* TableData will point to the template */ + TableData = AcpiDmGetTableData (Signature); if (TableData) { @@ -180,19 +278,7 @@ GetTemplate: return (AE_ERROR); } - Status = AdInitialize (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Status = DtCreateOneTemplate (Signature, TableData); - - - /* Shutdown ACPICA subsystem */ - - (void) AcpiTerminate (); - CmDeleteCaches (); + Status = DtCreateOneTemplate (Signature, TableCount, TableData); return (Status); } @@ -217,12 +303,6 @@ DtCreateAllTemplates ( ACPI_STATUS Status; - Status = AdInitialize (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - fprintf (stderr, "Creating all supported Template files\n"); /* Walk entire ACPI table data structure */ @@ -234,7 +314,7 @@ DtCreateAllTemplates ( if (TableData->Template) { Status = DtCreateOneTemplate (TableData->Signature, - TableData); + 0, TableData); if (ACPI_FAILURE (Status)) { return (Status); @@ -247,25 +327,31 @@ DtCreateAllTemplates ( * 1) DSDT/SSDT are AML tables, not data tables * 2) FACS and RSDP have non-standard headers */ - Status = DtCreateOneTemplate (ACPI_SIG_DSDT, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_DSDT, 0, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = DtCreateOneTemplate (ACPI_SIG_SSDT, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_SIG_SSDT, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_OSDT, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_SIG_FACS, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_FACS, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_RSDP_NAME, NULL); + Status = DtCreateOneTemplate (ACPI_RSDP_NAME, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); @@ -280,6 +366,7 @@ DtCreateAllTemplates ( * FUNCTION: DtCreateOneTemplate * * PARAMETERS: Signature - ACPI signature, NULL terminated. + * TableCount - Used for SSDTs in same file as DSDT * TableData - Entry in ACPI table data structure. * NULL if a special ACPI table. * @@ -292,12 +379,14 @@ DtCreateAllTemplates ( static ACPI_STATUS DtCreateOneTemplate ( char *Signature, + UINT32 TableCount, const ACPI_DMTABLE_DATA *TableData) { char *DisasmFilename; FILE *File; ACPI_STATUS Status = AE_OK; - ACPI_SIZE Actual; + int Actual; + UINT32 i; /* New file will have a .asl suffix */ @@ -310,13 +399,17 @@ DtCreateOneTemplate ( return (AE_ERROR); } - /* Probably should prompt to overwrite the file */ - AcpiUtStrlwr (DisasmFilename); + if (!UtQueryForOverwrite (DisasmFilename)) + { + return (AE_ERROR); + } + File = fopen (DisasmFilename, "w+"); if (!File) { - fprintf (stderr, "Could not open output file %s\n", DisasmFilename); + fprintf (stderr, "Could not open output file %s\n", + DisasmFilename); return (AE_ERROR); } @@ -327,8 +420,16 @@ DtCreateOneTemplate ( AcpiOsPrintf ("/*\n"); AcpiOsPrintf (ACPI_COMMON_HEADER ("iASL Compiler/Disassembler", " * ")); - AcpiOsPrintf (" * Template for [%4.4s] ACPI Table\n", - Signature); + if (TableCount == 0) + { + AcpiOsPrintf (" * Template for [%4.4s] ACPI Table", + Signature); + } + else + { + AcpiOsPrintf (" * Template for [%4.4s] and %u [SSDT] ACPI Tables", + Signature, TableCount); + } /* Dump the actual ACPI table */ @@ -336,6 +437,8 @@ DtCreateOneTemplate ( { /* Normal case, tables that appear in AcpiDmTableData */ + AcpiOsPrintf (" (static data table)\n"); + if (Gbl_VerboseTemplates) { AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]" @@ -344,7 +447,7 @@ DtCreateOneTemplate ( else { AcpiOsPrintf (" * Format: [ByteLength]" - " FieldName : HexFieldValue\n */\n\n"); + " FieldName : HexFieldValue\n */\n"); } AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, @@ -352,32 +455,55 @@ DtCreateOneTemplate ( } else { - /* Special ACPI tables - DSDT, SSDT, FADT, RSDP */ + /* Special ACPI tables - DSDT, SSDT, OSDT, FACS, RSDP */ + + AcpiOsPrintf (" (AML byte code table)\n"); + AcpiOsPrintf (" */\n"); - AcpiOsPrintf (" */\n\n"); if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT)) { - Actual = fwrite (TemplateDsdt, 1, sizeof (TemplateDsdt) -1, File); - if (Actual != sizeof (TemplateDsdt) -1) + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_DSDT, 1); + if (Actual < 0) { - fprintf (stderr, - "Could not write to output file %s\n", DisasmFilename); Status = AE_ERROR; goto Cleanup; } + + /* Emit any requested SSDTs into the same file */ + + for (i = 1; i <= TableCount; i++) + { + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_SSDT, i + 1); + if (Actual < 0) + { + Status = AE_ERROR; + goto Cleanup; + } + } } else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT)) { - Actual = fwrite (TemplateSsdt, 1, sizeof (TemplateSsdt) -1, File); - if (Actual != sizeof (TemplateSsdt) -1) + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_SSDT, 1); + if (Actual < 0) { - fprintf (stderr, - "Could not write to output file %s\n", DisasmFilename); Status = AE_ERROR; goto Cleanup; } } - else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) /* FADT */ + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT)) + { + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_OSDT, 1); + if (Actual < 0) + { + Status = AE_ERROR; + goto Cleanup; + } + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) { AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, TemplateFacs)); @@ -396,12 +522,72 @@ DtCreateOneTemplate ( } } - fprintf (stderr, - "Created ACPI table template for [%4.4s], written to \"%s\"\n", - Signature, DisasmFilename); + if (TableCount == 0) + { + fprintf (stderr, + "Created ACPI table template for [%4.4s], " + "written to \"%s\"\n", + Signature, DisasmFilename); + } + else + { + fprintf (stderr, + "Created ACPI table templates for [%4.4s] " + "and %u [SSDT], written to \"%s\"\n", + Signature, TableCount, DisasmFilename); + } Cleanup: fclose (File); AcpiOsRedirectOutput (stdout); return (Status); } + + +/******************************************************************************* + * + * FUNCTION: DtEmitDefinitionBlock + * + * PARAMETERS: File - An open file for the block + * Filename - Filename for same, for error msg(s) + * Signature - ACPI signature for the block + * Instance - Used for multiple SSDTs in the same file + * + * RETURN: Status from fprintf + * + * DESCRIPTION: Emit the raw ASL for a complete Definition Block (DSDT or SSDT) + * + * Note: The AMLFileName parameter for DefinitionBlock is left as a NULL + * string. This allows the compiler to create the output AML filename from + * the input filename. + * + ******************************************************************************/ + +static int +DtEmitDefinitionBlock ( + FILE *File, + char *Filename, + char *Signature, + UINT32 Instance) +{ + int Status; + + + Status = fprintf (File, + "DefinitionBlock (\"\", \"%4.4s\", 2, \"Intel\", \"_%4.4s_%.2X\", 0x00000001)\n" + "{\n" + " Method (%2.2s%.2X)\n" + " {\n" + " }\n" + "}\n\n", + Signature, Signature, Instance, Signature, Instance); + + if (Status < 0) + { + fprintf (stderr, + "Could not write %4.4s to output file %s\n", + Signature, Filename); + } + + return (Status); +} diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.h b/sys/contrib/dev/acpica/compiler/dttemplate.h index 1b27b4e..23ef051 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.h +++ b/sys/contrib/dev/acpica/compiler/dttemplate.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,27 +45,6 @@ #define __DTTEMPLATE_H -/* Special templates for DSDT and SSDT (AML byte-code tables) */ - -const char TemplateDsdt[] = - "DefinitionBlock (\"dsdt.aml\", \"DSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" - "{\n" - " Method (MAIN, 0, NotSerialized)\n" - " {\n" - " Return (Zero)\n" - " }\n" - "}\n\n"; - -const char TemplateSsdt[] = - "DefinitionBlock (\"ssdt.aml\", \"SSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" - "{\n" - " Method (MAIN, 0, NotSerialized)\n" - " {\n" - " Return (Zero)\n" - " }\n" - "}\n\n"; - - /* Templates for ACPI data tables */ const unsigned char TemplateAsf[] = @@ -564,11 +543,11 @@ const unsigned char TemplateHpet[] = const unsigned char TemplateIort[] = { - 0x49,0x4F,0x52,0x54,0x0C,0x01,0x00,0x00, /* 00000000 "IORT...." */ - 0x00,0xBC,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x49,0x4F,0x52,0x54,0x48,0x01,0x00,0x00, /* 00000000 "IORTH..." */ + 0x00,0x02,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x10,0x04,0x15,0x20,0x04,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x12,0x02,0x16,0x20,0x05,0x00,0x00,0x00, /* 00000020 "... ...." */ 0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "4......." */ 0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0x00, /* 00000030 ".....,.." */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */ @@ -597,7 +576,14 @@ const unsigned char TemplateIort[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F0 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000100 "........" */ - 0x00,0x00,0x00,0x00 /* 00000108 "...." */ + 0x00,0x00,0x00,0x00,0x04,0x3C,0x00,0x00, /* 00000108 ".....<.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000110 "........" */ + 0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "<......." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000128 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000130 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000138 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000140 "........" */ }; const unsigned char TemplateIvrs[] = @@ -858,28 +844,39 @@ const unsigned char TemplateMtmr[] = const unsigned char TemplatePcct[] = { - 0x50,0x43,0x43,0x54,0xAC,0x00,0x00,0x00, /* 00000000 "PCCT...." */ - 0x01,0xCF,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ + 0x50,0x43,0x43,0x54,0x06,0x01,0x00,0x00, /* 00000000 "PCCT...." */ + 0x01,0xE3,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x27,0x06,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "'.. ...." */ + 0x18,0x03,0x16,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 ".>......" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x01,0x32,0x00,0x03,0x00,0x00,0x00,0x00, /* 00000048 ".2......" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ - 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, /* 00000058 "........" */ - 0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00, /* 00000060 "........" */ - 0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x3E, /* 00000068 ".......>" */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00, /* 00000078 "........" */ + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, /* 00000038 "........" */ + 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, /* 00000040 """""""""" */ + 0x01,0x32,0x00,0x03,0x33,0x33,0x33,0x33, /* 00000048 ".2..3333" */ + 0x33,0x33,0x33,0x33,0x44,0x44,0x44,0x44, /* 00000050 "3333DDDD" */ + 0x44,0x44,0x44,0x44,0x55,0x55,0x55,0x55, /* 00000058 "DDDDUUUU" */ + 0x55,0x55,0x55,0x55,0x66,0x66,0x66,0x66, /* 00000060 "UUUUffff" */ + 0x77,0x77,0x77,0x77,0x88,0x88,0x01,0x3E, /* 00000068 "wwww...>" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x32, /* 00000080 ".......2" */ - 0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */ - 0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000098 "........" */ - 0xFF,0xFF,0x01,0x00,0x00,0x00,0x01,0x00, /* 000000A0 "........" */ - 0x00,0x00,0x01,0x00 /* 000000A8 "...." */ + 0x00,0x03,0x44,0x44,0x44,0x44,0x44,0x44, /* 00000088 "..DDDDDD" */ + 0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44, /* 00000090 "DDDDDDDD" */ + 0x44,0x44,0x55,0x55,0x55,0x55,0x55,0x55, /* 00000098 "DDUUUUUU" */ + 0x55,0x55,0x66,0x66,0x66,0x66,0x77,0x77, /* 000000A0 "UUffffww" */ + 0x77,0x77,0x88,0x88,0x02,0x5A,0x01,0x00, /* 000000A8 "ww...Z.." */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x32,0x00,0x03, /* 000000C0 ".....2.." */ + 0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44, /* 000000C8 "DDDDDDDD" */ + 0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44, /* 000000D0 "DDDDDDDD" */ + 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, /* 000000D8 "UUUUUUUU" */ + 0x66,0x66,0x66,0x66,0x77,0x77,0x77,0x77, /* 000000E0 "ffffwwww" */ + 0x88,0x88,0x01,0x32,0x00,0x03,0x33,0x33, /* 000000E8 "...2..33" */ + 0x33,0x33,0x33,0x33,0x33,0x33,0x44,0x44, /* 000000F0 "333333DD" */ + 0x44,0x44,0x44,0x44,0x44,0x44,0x55,0x55, /* 000000F8 "DDDDDDUU" */ + 0x55,0x55,0x55,0x55,0x55,0x55 /* 00000100 "UUUUUU" */ }; const unsigned char TemplatePmtt[] = @@ -1135,13 +1132,19 @@ const unsigned char TemplateStao[] = const unsigned char TemplateTcpa[] = { - 0x54,0x43,0x50,0x41,0x32,0x00,0x00,0x00, /* 00000000 "TCPA2..." */ - 0x01,0x67,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".gINTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x54,0x43,0x50,0x41,0x64,0x00,0x00,0x00, /* 00000000 "TCPAd..." */ + 0x02,0xFF,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x80,0x31,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 ".1..INTL" */ - 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ - 0x00,0x00 /* 00000030 ".." */ + 0x19,0x06,0x15,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x11,0x00,0xFF,0xEE,0xDD,0xCC,0xBB,0xAA, /* 00000030 "........" */ + 0x02,0x01,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x03, /* 00000040 "..... .." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x03, /* 00000050 "..... .." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x01,0x01,0x01,0x01 /* 00000060 "...." */ }; const unsigned char TemplateTpm2[] = diff --git a/sys/contrib/dev/acpica/compiler/dtutils.c b/sys/contrib/dev/acpica/compiler/dtutils.c index 2d5b762..2f3fdcd 100644 --- a/sys/contrib/dev/acpica/compiler/dtutils.c +++ b/sys/contrib/dev/acpica/compiler/dtutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -241,7 +241,7 @@ DtStrtoul64 ( while (*ThisChar) { - if (ACPI_IS_DIGIT (*ThisChar)) + if (isdigit ((int) *ThisChar)) { /* Convert ASCII 0-9 to Decimal value */ @@ -249,8 +249,8 @@ DtStrtoul64 ( } else /* Letter */ { - ThisDigit = (UINT32) ACPI_TOUPPER (*ThisChar); - if (!ACPI_IS_XDIGIT ((char) ThisDigit)) + ThisDigit = (UINT32) toupper ((int) *ThisChar); + if (!isxdigit ((int) ThisDigit)) { /* Not A-F */ @@ -568,7 +568,7 @@ DtGetFieldLength ( Value = DtGetFieldValue (Field); if (Value) { - ByteLength = ACPI_STRLEN (Value) + 1; + ByteLength = strlen (Value) + 1; } else { /* At this point, this is a fatal error */ @@ -633,7 +633,7 @@ DtGetFieldLength ( /* TBD: error if Value is NULL? (as below?) */ - ByteLength = (ACPI_STRLEN (Value) + 1) * sizeof(UINT16); + ByteLength = (strlen (Value) + 1) * sizeof(UINT16); break; default: diff --git a/sys/contrib/dev/acpica/compiler/preprocess.h b/sys/contrib/dev/acpica/compiler/preprocess.h index 9dc2bdb..50759b5 100644 --- a/sys/contrib/dev/acpica/compiler/preprocess.h +++ b/sys/contrib/dev/acpica/compiler/preprocess.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prexpress.c b/sys/contrib/dev/acpica/compiler/prexpress.c index 0f0d938..32e2b62 100644 --- a/sys/contrib/dev/acpica/compiler/prexpress.c +++ b/sys/contrib/dev/acpica/compiler/prexpress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,6 +84,7 @@ PrUnTokenize ( { return; } + if (Buffer[Length] != '\n') { Buffer[strlen(Buffer)] = ' '; diff --git a/sys/contrib/dev/acpica/compiler/prmacros.c b/sys/contrib/dev/acpica/compiler/prmacros.c index 866d089..0849903 100644 --- a/sys/contrib/dev/acpica/compiler/prmacros.c +++ b/sys/contrib/dev/acpica/compiler/prmacros.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -387,7 +387,8 @@ PrAddMacro ( { UseCount = Args[i].UseCount; - Args[i].Offset[UseCount] = (Token - Gbl_MainTokenBuffer) - MacroBodyOffset; + Args[i].Offset[UseCount] = + (Token - Gbl_MainTokenBuffer) - MacroBodyOffset; DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Macro Arg #%u: %s UseCount %u Offset %u \n", diff --git a/sys/contrib/dev/acpica/compiler/prparser.l b/sys/contrib/dev/acpica/compiler/prparser.l index 3150b69..18d78f7 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.l +++ b/sys/contrib/dev/acpica/compiler/prparser.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,14 +50,22 @@ #define STRING_SETUP strcpy (StringBuffer, PrParsertext);\ PrParserlval.str = StringBuffer -#define YY_NO_INPUT /* No file input, we use strings only */ - #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("prscanner") + + +/* Local prototypes */ + +static char +PrDoCommentType1 ( + void); + +static char +PrDoCommentType2 ( + void); %} %option noyywrap -%option nounput Number [0-9a-fA-F]+ HexNumber 0[xX][0-9a-fA-F]+ @@ -66,6 +74,8 @@ NewLine [\n] Identifier [a-zA-Z][0-9a-zA-Z]* %% +"/*" { if (!PrDoCommentType1 ()) {yyterminate ();} } +"//" { if (!PrDoCommentType2 ()) {yyterminate ();} } \( return (EXPOP_PAREN_OPEN); \) return (EXPOP_PAREN_CLOSE); @@ -151,3 +161,76 @@ PrTerminateLexer ( yy_delete_buffer (LexBuffer); } + + +/******************************************************************************** + * + * FUNCTION: PrDoCommentType1 + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Process a new legacy comment. Just toss it. + * + ******************************************************************************/ + +static char +PrDoCommentType1 ( + void) +{ + int c; + + +Loop: + while (((c = input ()) != '*') && (c != EOF)) + { + } + if (c == EOF) + { + return (FALSE); + } + + if (((c = input ()) != '/') && (c != EOF)) + { + unput (c); + goto Loop; + } + if (c == EOF) + { + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************** + * + * FUNCTION: PrDoCommentType2 + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Process a new "//" comment. Just toss it. + * + ******************************************************************************/ + +static char +PrDoCommentType2 ( + void) +{ + int c; + + + while (((c = input ()) != '\n') && (c != EOF)) + { + } + if (c == EOF) + { + return (FALSE); + } + + return (TRUE); +} diff --git a/sys/contrib/dev/acpica/compiler/prparser.y b/sys/contrib/dev/acpica/compiler/prparser.y index 20d6e6a..749f7d5 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.y +++ b/sys/contrib/dev/acpica/compiler/prparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,13 @@ #define _COMPONENT ASL_PREPROCESSOR ACPI_MODULE_NAME ("prparser") +void * AslLocalAllocate (unsigned int Size); + +/* Bison/yacc configuration */ + +#undef alloca +#define alloca AslLocalAllocate + int PrParserlex (void); int PrParserparse (void); void PrParsererror (char const *msg); @@ -175,11 +182,11 @@ Expression /* Default base for a non-prefixed integer is 10 */ - | EXPOP_NUMBER { UtStrtoul64 (PrParsertext, 10, &$$);} + | EXPOP_NUMBER { AcpiUtStrtoul64 (PrParsertext, 10, ACPI_MAX64_BYTE_WIDTH, &$$);} /* Standard hex number (0x1234) */ - | EXPOP_HEX_NUMBER { UtStrtoul64 (PrParsertext, 16, &$$);} + | EXPOP_HEX_NUMBER { AcpiUtStrtoul64 (PrParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} ; %% @@ -206,8 +213,11 @@ void PrParsererror ( char const *Message) { + + sprintf (StringBuffer, "Preprocessor Parser : %s (near line %u)", + Message, Gbl_CurrentLineNumber); DtError (ASL_ERROR, ASL_MSG_SYNTAX, - NULL, (char *) Message); + NULL, (char *) StringBuffer); } diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c index 12d303c..c02280d 100644 --- a/sys/contrib/dev/acpica/compiler/prscan.c +++ b/sys/contrib/dev/acpica/compiler/prscan.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,6 +67,14 @@ PrDoDirective ( char *DirectiveToken, char **Next); +static void +PrGetNextLineInit ( + void); + +static UINT32 +PrGetNextLine ( + FILE *Handle); + static int PrMatchDirective ( char *Directive); @@ -112,7 +120,6 @@ static const PR_DIRECTIVE_INFO Gbl_DirectiveInfo[] = {"include", 0}, /* Argument is not standard format, so just use 0 here */ {"includebuffer", 0}, /* Argument is not standard format, so just use 0 here */ {"line", 1}, - {"loadbuffer", 0}, {"pragma", 1}, {"undef", 1}, {"warning", 1}, @@ -136,7 +143,7 @@ enum Gbl_DirectiveIndexes PR_DIRECTIVE_LINE, PR_DIRECTIVE_PRAGMA, PR_DIRECTIVE_UNDEF, - PR_DIRECTIVE_WARNING, + PR_DIRECTIVE_WARNING }; #define ASL_DIRECTIVE_NOT_FOUND -1 @@ -186,7 +193,7 @@ PrInitializeGlobals ( /* Init globals */ Gbl_InputFileList = NULL; - Gbl_CurrentLineNumber = 0; + Gbl_CurrentLineNumber = 1; Gbl_PreprocessorLineNumber = 1; Gbl_PreprocessorError = FALSE; @@ -271,7 +278,7 @@ PrDoPreprocess ( } while (MoreInputFiles); - /* Point compiler input to the new preprocessor output file (.i) */ + /* Point compiler input to the new preprocessor output file (.pre) */ FlCloseFile (ASL_FILE_INPUT); Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle; @@ -280,7 +287,10 @@ PrDoPreprocess ( /* Reset globals to allow compiler to run */ FlSeekFile (ASL_FILE_INPUT, 0); - Gbl_CurrentLineNumber = 1; + if (!Gbl_PreprocessOnly) + { + Gbl_CurrentLineNumber = 0; + } DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n"); } @@ -297,7 +307,8 @@ PrDoPreprocess ( * DESCRIPTION: Preprocess one entire file, line-by-line. * * Input: Raw user ASL from ASL_FILE_INPUT - * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR + * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR and + * (optionally) ASL_FILE_PREPROCESSOR_USER * ******************************************************************************/ @@ -305,7 +316,7 @@ static void PrPreprocessInputFile ( void) { - UINT32 Offset; + UINT32 Status; char *Token; char *ReplaceString; PR_DEFINE_INFO *DefineInfo; @@ -314,10 +325,20 @@ PrPreprocessInputFile ( int OffsetAdjust; - /* Scan line-by-line. Comments and blank lines are skipped by this function */ + PrGetNextLineInit (); + + /* Scan source line-by-line and process directives. Then write the .i file */ - while ((Offset = DtGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF) + while ((Status = PrGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF) { + Gbl_CurrentLineNumber++; + Gbl_LogicalLineNumber++; + + if (Status == ASL_IGNORE_LINE) + { + goto WriteEntireLine; + } + /* Need a copy of the input line for strok() */ strcpy (Gbl_MainTokenBuffer, Gbl_CurrentLineBuffer); @@ -397,24 +418,13 @@ PrPreprocessInputFile ( Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next); } - /* - * Emit a #line directive if necessary, to keep the line numbers in - * the (.i) file synchronized with the original source code file, so - * that the correct line number appears in any error messages - * generated by the actual compiler. - */ - if (Gbl_CurrentLineNumber > (Gbl_PreviousLineNumber + 1)) - { - FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u\n", - Gbl_CurrentLineNumber); - } - - Gbl_PreviousLineNumber = Gbl_CurrentLineNumber; Gbl_PreprocessorLineNumber++; + +WriteEntireLine: /* * Now we can write the possibly modified source line to the - * preprocessor (.i) file + * preprocessor file(s). */ FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer, strlen (Gbl_CurrentLineBuffer)); @@ -467,6 +477,16 @@ PrDoDirective ( } /* + * Emit a line directive into the preprocessor file (.pre) after + * every matched directive. This is passed through to the compiler + * so that error/warning messages are kept in sync with the + * original source file. + */ + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\" // #%s\n", + Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename, + Gbl_DirectiveInfo[Directive].Name); + + /* * If we are currently ignoring this block and we encounter a #else or * #elif, we must ignore their blocks also if the parent block is also * being ignored. @@ -478,7 +498,8 @@ PrDoDirective ( case PR_DIRECTIVE_ELSE: case PR_DIRECTIVE_ELIF: - if (Gbl_DirectiveStack && Gbl_DirectiveStack->IgnoringThisCodeBlock) + if (Gbl_DirectiveStack && + Gbl_DirectiveStack->IgnoringThisCodeBlock) { PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name); return; @@ -653,8 +674,9 @@ PrDoDirective ( if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(') { #ifndef MACROS_SUPPORTED - AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n", - Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber); + AcpiOsPrintf ( + "%s ERROR - line %u: #define macros are not supported yet\n", + Gbl_CurrentLineBuffer, Gbl_LogicalLineNumber); exit(1); #else PrAddMacro (Token, Next); @@ -671,11 +693,13 @@ PrDoDirective ( { Token2++; } + End = Token2; while (*End != '\n') { End++; } + *End = 0; } else @@ -691,7 +715,7 @@ PrDoDirective ( #endif DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID "New #define: %s->%s\n", - Gbl_CurrentLineNumber, Token, Token2); + Gbl_LogicalLineNumber, Token, Token2); PrAddDefine (Token, Token2, FALSE); } @@ -760,10 +784,7 @@ PrDoDirective ( "User #line invocation %s\n", Gbl_CurrentLineNumber, Token); - /* Update local line numbers */ - Gbl_CurrentLineNumber = (UINT32) Value; - Gbl_PreviousLineNumber = 0; /* Emit #line into the preprocessor file */ @@ -816,6 +837,9 @@ PrDoDirective ( PrError (ASL_WARNING, ASL_MSG_WARNING_DIRECTIVE, THIS_TOKEN_OFFSET (Token)); + + Gbl_SourceLine = 0; + Gbl_NextError = Gbl_ErrorLog; break; default: @@ -839,6 +863,166 @@ SyntaxError: /******************************************************************************* * + * FUNCTION: PrGetNextLine, PrGetNextLineInit + * + * PARAMETERS: Handle - Open file handle for the source file + * + * RETURN: Status of the GetLine operation: + * AE_OK - Normal line, OK status + * ASL_IGNORE_LINE - Line is blank or part of a multi-line + * comment + * ASL_EOF - End-of-file reached + * + * DESCRIPTION: Get the next text line from the input file. Does not strip + * comments. + * + ******************************************************************************/ + +#define PR_NORMAL_TEXT 0 +#define PR_MULTI_LINE_COMMENT 1 +#define PR_SINGLE_LINE_COMMENT 2 +#define PR_QUOTED_STRING 3 + +static UINT8 AcpiGbl_LineScanState = PR_NORMAL_TEXT; + +static void +PrGetNextLineInit ( + void) +{ + AcpiGbl_LineScanState = 0; +} + +static UINT32 +PrGetNextLine ( + FILE *Handle) +{ + UINT32 i; + int c = 0; + int PreviousChar; + + + /* Always clear the global line buffer */ + + memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize); + for (i = 0; ;) + { + /* + * If line is too long, expand the line buffers. Also increases + * Gbl_LineBufferSize. + */ + if (i >= Gbl_LineBufferSize) + { + UtExpandLineBuffers (); + } + + PreviousChar = c; + c = getc (Handle); + if (c == EOF) + { + /* + * On EOF: If there is anything in the line buffer, terminate + * it with a newline, and catch the EOF on the next call + * to this function. + */ + if (i > 0) + { + Gbl_CurrentLineBuffer[i] = '\n'; + return (AE_OK); + } + + return (ASL_EOF); + } + + /* Update state machine as necessary */ + + switch (AcpiGbl_LineScanState) + { + case PR_NORMAL_TEXT: + + /* Check for multi-line comment start */ + + if ((PreviousChar == '/') && (c == '*')) + { + AcpiGbl_LineScanState = PR_MULTI_LINE_COMMENT; + } + + /* Check for single-line comment start */ + + else if ((PreviousChar == '/') && (c == '/')) + { + AcpiGbl_LineScanState = PR_SINGLE_LINE_COMMENT; + } + + /* Check for quoted string start */ + + else if (PreviousChar == '"') + { + AcpiGbl_LineScanState = PR_QUOTED_STRING; + } + break; + + case PR_QUOTED_STRING: + + if (PreviousChar == '"') + { + AcpiGbl_LineScanState = PR_NORMAL_TEXT; + } + break; + + case PR_MULTI_LINE_COMMENT: + + /* Check for multi-line comment end */ + + if ((PreviousChar == '*') && (c == '/')) + { + AcpiGbl_LineScanState = PR_NORMAL_TEXT; + } + break; + + case PR_SINGLE_LINE_COMMENT: /* Just ignore text until EOL */ + default: + break; + } + + /* Always copy the character into line buffer */ + + Gbl_CurrentLineBuffer[i] = (char) c; + i++; + + /* Always exit on end-of-line */ + + if (c == '\n') + { + /* Handle multi-line comments */ + + if (AcpiGbl_LineScanState == PR_MULTI_LINE_COMMENT) + { + return (ASL_IGNORE_LINE); + } + + /* End of single-line comment */ + + if (AcpiGbl_LineScanState == PR_SINGLE_LINE_COMMENT) + { + AcpiGbl_LineScanState = PR_NORMAL_TEXT; + return (AE_OK); + } + + /* Blank line */ + + if (i == 1) + { + return (ASL_IGNORE_LINE); + } + + return (AE_OK); + } + } +} + + +/******************************************************************************* + * * FUNCTION: PrMatchDirective * * PARAMETERS: Directive - Pointer to directive name token diff --git a/sys/contrib/dev/acpica/compiler/prutils.c b/sys/contrib/dev/acpica/compiler/prutils.c index 7e880b1..c4c9dd6 100644 --- a/sys/contrib/dev/acpica/compiler/prutils.c +++ b/sys/contrib/dev/acpica/compiler/prutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -122,8 +122,10 @@ PrGetNextToken ( { *Next = NULL; } + return (TokenStart); } + Buffer++; } @@ -382,6 +384,8 @@ PrPushInputFileStack ( PR_FILE_NODE *Fnode; + Gbl_HasIncludeFiles = TRUE; + /* Save the current state in an Fnode */ Fnode = UtLocalCalloc (sizeof (PR_FILE_NODE)); @@ -406,8 +410,7 @@ PrPushInputFileStack ( strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); Gbl_Files[ASL_FILE_INPUT].Handle = InputFile; - Gbl_PreviousLineNumber = 0; - Gbl_CurrentLineNumber = 0; + Gbl_CurrentLineNumber = 1; /* Emit a new #line directive for the include file */ @@ -460,12 +463,11 @@ PrPopInputFileStack ( Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; Gbl_Files[ASL_FILE_INPUT].Handle = Fnode->File; Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; - Gbl_PreviousLineNumber = 0; /* Emit a new #line directive after the include file */ FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", - Gbl_CurrentLineNumber + 1, Fnode->Filename); + Gbl_CurrentLineNumber, Fnode->Filename); /* All done with this node */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbcmds.c b/sys/contrib/dev/acpica/components/debugger/dbcmds.c index c11451d..191b1b4 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbcmds.c +++ b/sys/contrib/dev/acpica/components/debugger/dbcmds.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,6 @@ #include <contrib/dev/acpica/include/acresrc.h> #include <contrib/dev/acpica/include/actables.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbcmds") @@ -86,6 +85,9 @@ AcpiDbDoOneSleepState ( UINT8 SleepState); +static char *AcpiDbTraceMethodName = NULL; + + /******************************************************************************* * * FUNCTION: AcpiDbConvertToNode @@ -111,12 +113,11 @@ AcpiDbConvertToNode ( { /* Numeric argument, convert */ - Address = ACPI_STRTOUL (InString, NULL, 16); + Address = strtoul (InString, NULL, 16); Node = ACPI_TO_POINTER (Address); if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) { - AcpiOsPrintf ("Address %p is invalid", - Node); + AcpiOsPrintf ("Address %p is invalid", Node); return (NULL); } @@ -125,7 +126,7 @@ AcpiDbConvertToNode ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n", - Node, AcpiUtGetDescriptorName (Node)); + Node, AcpiUtGetDescriptorName (Node)); return (NULL); } } @@ -138,7 +139,8 @@ AcpiDbConvertToNode ( Node = AcpiDbLocalNsLookup (InString); if (!Node) { - AcpiOsPrintf ("Could not find [%s] in namespace, defaulting to root node\n", + AcpiOsPrintf ( + "Could not find [%s] in namespace, defaulting to root node\n", InString); Node = AcpiGbl_RootNode; } @@ -189,7 +191,7 @@ AcpiDbSleep ( /* Convert argument to binary and invoke the sleep state */ - SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); + SleepState = (UINT8) strtoul (ObjectArg, NULL, 0); AcpiDbDoOneSleepState (SleepState); return_ACPI_STATUS (AE_OK); } @@ -201,7 +203,7 @@ AcpiDbSleep ( * * PARAMETERS: SleepState - Desired sleep state (0-5) * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Simulate a sleep/wake sequence * @@ -338,7 +340,8 @@ AcpiDbDisplayTableInfo ( /* Header */ - AcpiOsPrintf ("Idx ID Status Type TableHeader (Sig, Address, Length)\n"); + AcpiOsPrintf ("Idx ID Status Type " + "TableHeader (Sig, Address, Length, Misc)\n"); /* Walk the entire root table list */ @@ -402,7 +405,7 @@ AcpiDbDisplayTableInfo ( { /* If the pointer is null, the table has been unloaded */ - ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded", + ACPI_INFO (("%4.4s - Table has been unloaded", TableDesc->Signature.Ascii)); } } @@ -497,7 +500,8 @@ AcpiDbSendNotify ( else { AcpiOsPrintf ( - "Named object [%4.4s] Type %s, must be Device/Thermal/Processor type\n", + "Named object [%4.4s] Type %s, " + "must be Device/Thermal/Processor type\n", AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)); } } @@ -530,8 +534,7 @@ AcpiDbDisplayInterfaces ( if (!ActionArg) { - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, - ACPI_WAIT_FOREVER); + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); NextInterface = AcpiGbl_SupportedInterfaces; while (NextInterface) @@ -540,6 +543,7 @@ AcpiDbDisplayInterfaces ( { AcpiOsPrintf ("%s\n", NextInterface->Name); } + NextInterface = NextInterface->Next; } @@ -561,7 +565,7 @@ AcpiDbDisplayInterfaces ( /* Install - install an interface */ - SubString = ACPI_STRSTR ("INSTALL", ActionArg); + SubString = strstr ("INSTALL", ActionArg); if (SubString) { Status = AcpiInstallInterface (InterfaceNameArg); @@ -575,7 +579,7 @@ AcpiDbDisplayInterfaces ( /* Remove - remove an interface */ - SubString = ACPI_STRSTR ("REMOVE", ActionArg); + SubString = strstr ("REMOVE", ActionArg); if (SubString) { Status = AcpiRemoveInterface (InterfaceNameArg); @@ -645,7 +649,8 @@ AcpiDbDisplayTemplate ( if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not convert Buffer to a resource list: %s, %s\n", + AcpiOsPrintf ( + "Could not convert Buffer to a resource list: %s, %s\n", BufferArg, AcpiFormatException (Status)); goto DumpBuffer; } @@ -706,7 +711,8 @@ AcpiDmCompareAmlResources ( if (Aml1BufferLength != Aml2BufferLength) { AcpiOsPrintf ( - "**** Buffer length mismatch in converted AML: Original %X, New %X ****\n", + "**** Buffer length mismatch in converted " + "AML: Original %X, New %X ****\n", Aml1BufferLength, Aml2BufferLength); } @@ -730,16 +736,18 @@ AcpiDmCompareAmlResources ( if (Aml1Length != Aml2Length) { AcpiOsPrintf ( - "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X Len1 %X, Len2 %X ****\n", + "**** Length mismatch in descriptor [%.2X] type %2.2X, " + "Offset %8.8X Len1 %X, Len2 %X ****\n", Count, ResourceType, Offset, Aml1Length, Aml2Length); } /* Check for descriptor byte match */ - else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length)) + else if (memcmp (Aml1, Aml2, Aml1Length)) { AcpiOsPrintf ( - "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n", + "**** Data mismatch in descriptor [%.2X] type %2.2X, " + "Offset %8.8X ****\n", Count, ResourceType, Offset); for (i = 0; i < Aml1Length; i++) @@ -747,7 +755,8 @@ AcpiDmCompareAmlResources ( if (Aml1[i] != Aml2[i]) { AcpiOsPrintf ( - "Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n", + "Mismatch at byte offset %.2X: is %2.2X, " + "should be %2.2X\n", i, Aml2[i], Aml1[i]); } } @@ -904,7 +913,7 @@ AcpiDbDeviceResources ( Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); - ParentPath = AcpiNsGetExternalPathname (Node); + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); if (!ParentPath) { return (AE_NO_MEMORY); @@ -912,10 +921,15 @@ AcpiDbDeviceResources ( /* Get handles to the resource methods for this device */ - (void) AcpiGetHandle (Node, METHOD_NAME__PRT, ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode)); - (void) AcpiGetHandle (Node, METHOD_NAME__CRS, ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode)); - (void) AcpiGetHandle (Node, METHOD_NAME__PRS, ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode)); - (void) AcpiGetHandle (Node, METHOD_NAME__AEI, ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode)); + (void) AcpiGetHandle (Node, METHOD_NAME__PRT, + ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode)); + (void) AcpiGetHandle (Node, METHOD_NAME__CRS, + ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode)); + (void) AcpiGetHandle (Node, METHOD_NAME__PRS, + ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode)); + (void) AcpiGetHandle (Node, METHOD_NAME__AEI, + ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode)); + if (!PrtNode && !CrsNode && !PrsNode && !AeiNode) { goto Cleanup; /* Nothing to do */ @@ -990,7 +1004,7 @@ GetCrs: /* Get the _CRS resource list (test ALLOCATE buffer) */ ReturnBuffer.Pointer = NULL; - ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiGetCurrentResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) @@ -1059,7 +1073,7 @@ GetPrs: } ReturnBuffer.Pointer = AcpiGbl_DbBuffer; - ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; Status = AcpiGetPossibleResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) @@ -1069,7 +1083,8 @@ GetPrs: goto GetAei; } - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); + AcpiRsDumpResourceList (ACPI_CAST_PTR ( + ACPI_RESOURCE, AcpiGbl_DbBuffer)); } @@ -1081,7 +1096,7 @@ GetAei: AcpiOsPrintf ("Evaluating _AEI\n"); ReturnBuffer.Pointer = AcpiGbl_DbBuffer; - ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer); if (ACPI_FAILURE (Status)) @@ -1092,7 +1107,7 @@ GetAei: } ReturnBuffer.Pointer = AcpiGbl_DbBuffer; - ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; Status = AcpiGetEventResources (Node, &ReturnBuffer); if (ACPI_FAILURE (Status)) @@ -1102,7 +1117,8 @@ GetAei: goto Cleanup; } - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); + AcpiRsDumpResourceList (ACPI_CAST_PTR ( + ACPI_RESOURCE, AcpiGbl_DbBuffer)); } @@ -1138,10 +1154,10 @@ AcpiDbDisplayResources ( /* Asterisk means "display resources for all devices" */ - if (!ObjectArg || (!ACPI_STRCMP (ObjectArg, "*"))) + if (!ObjectArg || (!strcmp (ObjectArg, "*"))) { (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL); } else { @@ -1152,7 +1168,8 @@ AcpiDbDisplayResources ( { if (Node->Type != ACPI_TYPE_DEVICE) { - AcpiOsPrintf ("%4.4s: Name is not a device object (%s)\n", + AcpiOsPrintf ( + "%4.4s: Name is not a device object (%s)\n", Node->Name.Ascii, AcpiUtGetTypeName (Node->Type)); } else @@ -1191,7 +1208,7 @@ AcpiDbGenerateGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo; - GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); + GpeNumber = strtoul (GpeArg, NULL, 0); /* * If no block arg, or block arg == 0 or 1, use the FADT-defined @@ -1199,15 +1216,15 @@ AcpiDbGenerateGpe ( */ if (BlockArg) { - BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); + BlockNumber = strtoul (BlockArg, NULL, 0); if (BlockNumber == 1) { BlockNumber = 0; } } - GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), - GpeNumber); + GpeEventInfo = AcpiEvGetGpeEventInfo ( + ACPI_TO_POINTER (BlockNumber), GpeNumber); if (!GpeEventInfo) { AcpiOsPrintf ("Invalid GPE\n"); @@ -1217,6 +1234,19 @@ AcpiDbGenerateGpe ( (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber); } + +/******************************************************************************* + * + * FUNCTION: AcpiDbGenerateSci + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch. + * + ******************************************************************************/ + void AcpiDbGenerateSci ( void) @@ -1226,4 +1256,87 @@ AcpiDbGenerateSci ( #endif /* !ACPI_REDUCED_HARDWARE */ -#endif /* ACPI_DEBUGGER */ + +/******************************************************************************* + * + * FUNCTION: AcpiDbTrace + * + * PARAMETERS: EnableArg - ENABLE/AML to enable tracer + * DISABLE to disable tracer + * MethodArg - Method to trace + * OnceArg - Whether trace once + * + * RETURN: None + * + * DESCRIPTION: Control method tracing facility + * + ******************************************************************************/ + +void +AcpiDbTrace ( + char *EnableArg, + char *MethodArg, + char *OnceArg) +{ + UINT32 DebugLevel = 0; + UINT32 DebugLayer = 0; + UINT32 Flags = 0; + + + AcpiUtStrupr (EnableArg); + AcpiUtStrupr (OnceArg); + + if (MethodArg) + { + if (AcpiDbTraceMethodName) + { + ACPI_FREE (AcpiDbTraceMethodName); + AcpiDbTraceMethodName = NULL; + } + + AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1); + if (!AcpiDbTraceMethodName) + { + AcpiOsPrintf ("Failed to allocate method name (%s)\n", + MethodArg); + return; + } + + strcpy (AcpiDbTraceMethodName, MethodArg); + } + + if (!strcmp (EnableArg, "ENABLE") || + !strcmp (EnableArg, "METHOD") || + !strcmp (EnableArg, "OPCODE")) + { + if (!strcmp (EnableArg, "ENABLE")) + { + /* Inherit current console settings */ + + DebugLevel = AcpiGbl_DbConsoleDebugLevel; + DebugLayer = AcpiDbgLayer; + } + else + { + /* Restrict console output to trace points only */ + + DebugLevel = ACPI_LV_TRACE_POINT; + DebugLayer = ACPI_EXECUTER; + } + + Flags = ACPI_TRACE_ENABLED; + + if (!strcmp (EnableArg, "OPCODE")) + { + Flags |= ACPI_TRACE_OPCODE; + } + + if (OnceArg && !strcmp (OnceArg, "ONCE")) + { + Flags |= ACPI_TRACE_ONESHOT; + } + } + + (void) AcpiDebugTrace (AcpiDbTraceMethodName, + DebugLevel, DebugLayer, Flags); +} diff --git a/sys/contrib/dev/acpica/components/debugger/dbconvert.c b/sys/contrib/dev/acpica/components/debugger/dbconvert.c index f6c0286..09379a8 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbconvert.c +++ b/sys/contrib/dev/acpica/components/debugger/dbconvert.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acdebug.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbconvert") @@ -77,7 +76,7 @@ AcpiDbHexCharToValue ( /* Digit must be ascii [0-9a-fA-F] */ - if (!ACPI_IS_XDIGIT (HexChar)) + if (!isxdigit (HexChar)) { return (AE_BAD_HEX_CONSTANT); } @@ -88,7 +87,7 @@ AcpiDbHexCharToValue ( } else { - Value = (UINT8) (ACPI_TOUPPER (HexChar) - 0x37); + Value = (UINT8) (toupper (HexChar) - 0x37); } *ReturnValue = Value; @@ -199,7 +198,7 @@ AcpiDbConvertToBuffer ( } j++; - i+=2; + i += 2; while (String[i] && ((String[i] == ',') || (String[i] == ' '))) { @@ -306,7 +305,7 @@ AcpiDbConvertToObject ( Object->Type = ACPI_TYPE_STRING; Object->String.Pointer = String; - Object->String.Length = (UINT32) ACPI_STRLEN (String); + Object->String.Length = (UINT32) strlen (String); break; case ACPI_TYPE_BUFFER: @@ -322,7 +321,8 @@ AcpiDbConvertToObject ( default: Object->Type = ACPI_TYPE_INTEGER; - Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value); + Status = AcpiUtStrtoul64 (String, 16, AcpiGbl_IntegerByteWidth, + &Object->Integer.Value); break; } @@ -466,12 +466,12 @@ AcpiDbDumpPldBuffer ( NewBuffer = AcpiDbEncodePldBuffer (PldInfo); if (!NewBuffer) { - return; + goto Exit; } /* The two bit-packed buffers should match */ - if (ACPI_MEMCMP (NewBuffer, BufferDesc->Buffer.Pointer, + if (memcmp (NewBuffer, BufferDesc->Buffer.Pointer, BufferDesc->Buffer.Length)) { AcpiOsPrintf ("Converted _PLD buffer does not compare. New:\n"); @@ -525,8 +525,7 @@ AcpiDbDumpPldBuffer ( AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_HorizontalOffset", PldInfo->HorizontalOffset); } - ACPI_FREE (PldInfo); ACPI_FREE (NewBuffer); +Exit: + ACPI_FREE (PldInfo); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbdisply.c b/sys/contrib/dev/acpica/components/debugger/dbdisply.c index 507c2b0..8db59bc 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbdisply.c +++ b/sys/contrib/dev/acpica/components/debugger/dbdisply.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,12 +48,10 @@ #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/include/acevents.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbdisply") @@ -141,7 +139,7 @@ AcpiDbGetPointer ( ACPI_SIZE Address; - Address = ACPI_STRTOUL (Target, NULL, 16); + Address = strtoul (Target, NULL, 16); ObjPtr = ACPI_TO_POINTER (Address); return (ObjPtr); } @@ -243,7 +241,8 @@ AcpiDbDecodeAndDisplayObject ( ObjPtr = AcpiDbGetPointer (Target); if (!AcpiOsReadable (ObjPtr, 16)) { - AcpiOsPrintf ("Address %p is invalid in this address space\n", + AcpiOsPrintf ( + "Address %p is invalid in this address space\n", ObjPtr); return; } @@ -259,7 +258,8 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) { AcpiOsPrintf ( - "Cannot read entire Named object at address %p\n", ObjPtr); + "Cannot read entire Named object at address %p\n", + ObjPtr); return; } @@ -272,13 +272,14 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) { - AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", + AcpiOsPrintf ( + "Cannot read entire ACPI object at address %p\n", ObjPtr); return; } - AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, - ACPI_UINT32_MAX); + AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), + Display, ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjPtr, 1); break; @@ -289,12 +290,13 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) { AcpiOsPrintf ( - "Cannot read entire Parser object at address %p\n", ObjPtr); + "Cannot read entire Parser object at address %p\n", + ObjPtr); return; } - AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, - ACPI_UINT32_MAX); + AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), + Display, ACPI_UINT32_MAX); AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); break; @@ -333,7 +335,7 @@ AcpiDbDecodeAndDisplayObject ( DumpNode: /* Now dump the NS node */ - Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); + Status = AcpiGetName (Node, ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not convert name to pathname\n"); @@ -366,8 +368,8 @@ DumpNode: return; } - AcpiUtDebugDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), - Display, ACPI_UINT32_MAX); + AcpiUtDebugDumpBuffer ((void *) ObjDesc, + sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjDesc, 1); } } @@ -412,14 +414,13 @@ AcpiDbDisplayMethodInfo ( } ObjDesc = WalkState->MethodDesc; - Node = WalkState->MethodNode; + Node = WalkState->MethodNode; AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", - AcpiUtGetNodeName (Node)); + AcpiUtGetNodeName (Node)); AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n", - (UINT32) ObjDesc->Method.ParamCount, - (UINT32) ObjDesc->Method.SyncLevel); - + (UINT32) ObjDesc->Method.ParamCount, + (UINT32) ObjDesc->Method.SyncLevel); RootOp = StartOp; while (RootOp->Common.Parent) @@ -513,7 +514,7 @@ AcpiDbDisplayLocals ( return; } - AcpiDmDisplayLocals (WalkState); + AcpiDbDecodeLocals (WalkState); } @@ -543,7 +544,7 @@ AcpiDbDisplayArguments ( return; } - AcpiDmDisplayArguments (WalkState); + AcpiDbDecodeArguments (WalkState); } @@ -580,7 +581,7 @@ AcpiDbDisplayResults ( } ObjDesc = WalkState->MethodDesc; - Node = WalkState->MethodNode; + Node = WalkState->MethodNode; if (WalkState->Results) { @@ -588,7 +589,7 @@ AcpiDbDisplayResults ( } AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", - AcpiUtGetNodeName (Node), ResultCount); + AcpiUtGetNodeName (Node), ResultCount); /* From the top element of result stack */ @@ -599,12 +600,14 @@ AcpiDbDisplayResults ( { ObjDesc = Frame->Results.ObjDesc[Index]; AcpiOsPrintf ("Result%u: ", i); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + if (Index == 0) { Frame = Frame->Results.Next; Index = ACPI_RESULTS_FRAME_OBJ_NUM; } + Index--; } } @@ -643,7 +646,6 @@ AcpiDbDisplayCallingTree ( while (WalkState) { Node = WalkState->MethodNode; - AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node)); WalkState = WalkState->Next; @@ -655,7 +657,7 @@ AcpiDbDisplayCallingTree ( * * FUNCTION: AcpiDbDisplayObjectType * - * PARAMETERS: Name - User entered NS node handle or name + * PARAMETERS: ObjectArg - User entered NS node handle * * RETURN: None * @@ -665,21 +667,19 @@ AcpiDbDisplayCallingTree ( void AcpiDbDisplayObjectType ( - char *Name) + char *ObjectArg) { - ACPI_NAMESPACE_NODE *Node; + ACPI_SIZE Arg; + ACPI_HANDLE Handle; ACPI_DEVICE_INFO *Info; ACPI_STATUS Status; UINT32 i; - Node = AcpiDbConvertToNode (Name); - if (!Node) - { - return; - } + Arg = strtoul (ObjectArg, NULL, 16); + Handle = ACPI_TO_POINTER (Arg); - Status = AcpiGetObjectInfo (ACPI_CAST_PTR (ACPI_HANDLE, Node), &Info); + Status = AcpiGetObjectInfo (Handle, &Info); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get object info, %s\n", @@ -687,38 +687,29 @@ AcpiDbDisplayObjectType ( return; } - if (Info->Valid & ACPI_VALID_ADR) - { - AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus, Info->Flags); - } - if (Info->Valid & ACPI_VALID_SXDS) - { - AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", - Info->HighestDstates[0], Info->HighestDstates[1], - Info->HighestDstates[2], Info->HighestDstates[3]); - } - if (Info->Valid & ACPI_VALID_SXWS) - { - AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", - Info->LowestDstates[0], Info->LowestDstates[1], - Info->LowestDstates[2], Info->LowestDstates[3], - Info->LowestDstates[4]); - } + AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", + ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus, Info->Flags); + + AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", + Info->HighestDstates[0], Info->HighestDstates[1], + Info->HighestDstates[2], Info->HighestDstates[3]); + + AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", + Info->LowestDstates[0], Info->LowestDstates[1], + Info->LowestDstates[2], Info->LowestDstates[3], + Info->LowestDstates[4]); if (Info->Valid & ACPI_VALID_HID) { AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String); } + if (Info->Valid & ACPI_VALID_UID) { AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); } - if (Info->Valid & ACPI_VALID_SUB) - { - AcpiOsPrintf ("SUB: %s\n", Info->SubsystemId.String); - } + if (Info->Valid & ACPI_VALID_CID) { for (i = 0; i < Info->CompatibleIdList.Count; i++) @@ -755,6 +746,13 @@ AcpiDbDisplayResultObject ( ACPI_WALK_STATE *WalkState) { +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId()) + { + return; + } +#endif + /* Only display if single stepping */ if (!AcpiGbl_CmSingleStep) @@ -763,7 +761,7 @@ AcpiDbDisplayResultObject ( } AcpiOsPrintf ("ResultObj: "); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); AcpiOsPrintf ("\n"); } @@ -787,13 +785,20 @@ AcpiDbDisplayArgumentObject ( ACPI_WALK_STATE *WalkState) { +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId()) + { + return; + } +#endif + if (!AcpiGbl_CmSingleStep) { return; } AcpiOsPrintf ("ArgObj: "); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); } @@ -843,7 +848,8 @@ AcpiDbDisplayGpes ( GpeBlock = GpeXruptInfo->GpeBlockListHead; while (GpeBlock) { - Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf); + Status = AcpiGetName (GpeBlock->Node, + ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not convert name to pathname\n"); @@ -858,13 +864,16 @@ AcpiDbDisplayGpes ( GpeType = "GPE Block Device"; } - AcpiOsPrintf ("\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", + AcpiOsPrintf ( + "\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", Block, GpeBlock, GpeBlock->Node, Buffer, GpeType); - AcpiOsPrintf (" Registers: %u (%u GPEs)\n", + AcpiOsPrintf ( + " Registers: %u (%u GPEs)\n", GpeBlock->RegisterCount, GpeBlock->GpeCount); - AcpiOsPrintf (" GPE range: 0x%X to 0x%X on interrupt %u\n", + AcpiOsPrintf ( + " GPE range: 0x%X to 0x%X on interrupt %u\n", GpeBlock->BlockBaseNumber, GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1), GpeXruptInfo->InterruptNumber); @@ -872,8 +881,10 @@ AcpiDbDisplayGpes ( AcpiOsPrintf ( " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", GpeBlock->RegisterInfo, - ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address), - ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address)); + ACPI_FORMAT_UINT64 ( + GpeBlock->RegisterInfo->StatusAddress.Address), + ACPI_FORMAT_UINT64 ( + GpeBlock->RegisterInfo->EnableAddress.Address)); AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); @@ -884,14 +895,18 @@ AcpiDbDisplayGpes ( GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; AcpiOsPrintf ( - " Reg %u: (GPE %.2X-%.2X) RunEnable %2.2X WakeEnable %2.2X" + " Reg %u: (GPE %.2X-%.2X) " + "RunEnable %2.2X WakeEnable %2.2X" " Status %8.8X%8.8X Enable %8.8X%8.8X\n", i, GpeRegisterInfo->BaseGpeNumber, - GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1), + GpeRegisterInfo->BaseGpeNumber + + (ACPI_GPE_REGISTER_WIDTH - 1), GpeRegisterInfo->EnableForRun, GpeRegisterInfo->EnableForWake, - ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address), - ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address)); + ACPI_FORMAT_UINT64 ( + GpeRegisterInfo->StatusAddress.Address), + ACPI_FORMAT_UINT64 ( + GpeRegisterInfo->EnableAddress.Address)); /* Now look at the individual GPEs in this byte register */ @@ -959,7 +974,9 @@ AcpiDbDisplayGpes ( Count++; Notify = Notify->Next; } - AcpiOsPrintf ("Implicit Notify on %u devices", Count); + + AcpiOsPrintf ("Implicit Notify on %u devices", + Count); break; case ACPI_GPE_DISPATCH_RAW_HANDLER: @@ -977,9 +994,11 @@ AcpiDbDisplayGpes ( AcpiOsPrintf (")\n"); } } + Block++; GpeBlock = GpeBlock->Next; } + GpeXruptInfo = GpeXruptInfo->Next; } } @@ -1018,23 +1037,21 @@ AcpiDbDisplayHandlers ( for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++) { SpaceId = AcpiGbl_SpaceIdList[i]; - HandlerObj = ObjDesc->Device.Handler; AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId); - while (HandlerObj) + HandlerObj = AcpiEvFindRegionHandler ( + SpaceId, ObjDesc->CommonNotify.Handler); + if (HandlerObj) { - if (AcpiGbl_SpaceIdList[i] == HandlerObj->AddressSpace.SpaceId) - { - AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, - (HandlerObj->AddressSpace.HandlerFlags & - ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User", - HandlerObj->AddressSpace.Handler); - goto FoundHandler; - } + AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, + (HandlerObj->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? + "Default" : "User", + HandlerObj->AddressSpace.Handler); - HandlerObj = HandlerObj->AddressSpace.Next; + goto FoundHandler; } /* There is no handler for this SpaceId */ @@ -1046,7 +1063,7 @@ AcpiDbDisplayHandlers ( /* Find all handlers for user-defined SpaceIDs */ - HandlerObj = ObjDesc->Device.Handler; + HandlerObj = ObjDesc->CommonNotify.Handler; while (HandlerObj) { if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN) @@ -1055,7 +1072,8 @@ AcpiDbDisplayHandlers ( "User-defined ID", HandlerObj->AddressSpace.SpaceId); AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, (HandlerObj->AddressSpace.HandlerFlags & - ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User", + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? + "Default" : "User", HandlerObj->AddressSpace.Handler); } @@ -1091,7 +1109,9 @@ AcpiDbDisplayHandlers ( for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++) { - AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, AcpiGbl_HandlerList[i].Name); + AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, + AcpiGbl_HandlerList[i].Name); + if (AcpiGbl_HandlerList[i].Handler) { AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User", @@ -1109,8 +1129,8 @@ AcpiDbDisplayHandlers ( AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n"); (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers, - NULL, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers, + NULL, NULL, NULL); } @@ -1146,7 +1166,7 @@ AcpiDbDisplayNonRootHandlers ( return (AE_OK); } - Pathname = AcpiNsGetExternalPathname (Node); + Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); if (!Pathname) { return (AE_OK); @@ -1154,7 +1174,7 @@ AcpiDbDisplayNonRootHandlers ( /* Display all handlers associated with this device */ - HandlerObj = ObjDesc->Device.Handler; + HandlerObj = ObjDesc->CommonNotify.Handler; while (HandlerObj) { AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, @@ -1174,5 +1194,3 @@ AcpiDbDisplayNonRootHandlers ( ACPI_FREE (Pathname); return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbexec.c b/sys/contrib/dev/acpica/components/debugger/dbexec.c index 79c0ee9..00890e6 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbexec.c +++ b/sys/contrib/dev/acpica/components/debugger/dbexec.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,6 @@ #include <contrib/dev/acpica/include/acdebug.h> #include <contrib/dev/acpica/include/acnamesp.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbexec") @@ -213,7 +212,8 @@ AcpiDbExecuteMethod ( if (Status == AE_BUFFER_OVERFLOW) { ACPI_ERROR ((AE_INFO, - "Possible overflow of internal debugger buffer (size 0x%X needed 0x%X)", + "Possible overflow of internal debugger " + "buffer (size 0x%X needed 0x%X)", ACPI_DEBUG_BUFFER_SIZE, (UINT32) ReturnObj->Length)); } } @@ -380,10 +380,11 @@ AcpiDbExecutionWalk ( Status = AcpiEvaluateObject (Node, NULL, NULL, &ReturnObj); - AcpiOsPrintf ("Evaluation of [%4.4s] returned %s\n", AcpiUtGetNodeName (Node), - AcpiFormatException (Status)); - AcpiGbl_MethodExecuting = FALSE; + AcpiOsPrintf ("Evaluation of [%4.4s] returned %s\n", + AcpiUtGetNodeName (Node), + AcpiFormatException (Status)); + AcpiGbl_MethodExecuting = FALSE; return (AE_OK); } @@ -394,6 +395,7 @@ AcpiDbExecutionWalk ( * * PARAMETERS: Name - Name of method to execute * Args - Parameters to the method + * Types - * Flags - single step/no single step * * RETURN: None @@ -414,12 +416,23 @@ AcpiDbExecute ( ACPI_BUFFER ReturnObj; char *NameString; - #ifdef ACPI_DEBUG_OUTPUT UINT32 PreviousAllocations; UINT32 Allocations; +#endif + /* + * Allow one execution to be performed by debugger or single step + * execution will be dead locked by the interpreter mutexes. + */ + if (AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("Only one debugger execution is allowed.\n"); + return; + } + +#ifdef ACPI_DEBUG_OUTPUT /* Memory allocation tracking */ PreviousAllocations = AcpiDbGetOutstandingAllocations (); @@ -428,20 +441,20 @@ AcpiDbExecute ( if (*Name == '*') { (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL); return; } else { - NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1); + NameString = ACPI_ALLOCATE (strlen (Name) + 1); if (!NameString) { return; } - ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); + memset (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); - ACPI_STRCPY (NameString, Name); + strcpy (NameString, Name); AcpiUtStrupr (NameString); AcpiGbl_DbMethodInfo.Name = NameString; AcpiGbl_DbMethodInfo.Args = Args; @@ -464,7 +477,8 @@ AcpiDbExecute ( &AcpiGbl_DbMethodInfo.Method); if (ACPI_SUCCESS (Status)) { - Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj); + Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, + &ReturnObj); } ACPI_FREE (NameString); } @@ -485,15 +499,17 @@ AcpiDbExecute ( if (Allocations > 0) { - AcpiOsPrintf ("0x%X Outstanding allocations after evaluation of %s\n", - Allocations, AcpiGbl_DbMethodInfo.Pathname); + AcpiOsPrintf ( + "0x%X Outstanding allocations after evaluation of %s\n", + Allocations, AcpiGbl_DbMethodInfo.Pathname); } #endif if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Evaluation of %s failed with status %s\n", - AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); + AcpiGbl_DbMethodInfo.Pathname, + AcpiFormatException (Status)); } else { @@ -502,15 +518,18 @@ AcpiDbExecute ( if (ReturnObj.Length) { AcpiOsPrintf ( - "Evaluation of %s returned object %p, external buffer length %X\n", + "Evaluation of %s returned object %p, " + "external buffer length %X\n", AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); + AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); /* Dump a _PLD buffer if present */ if (ACPI_COMPARE_NAME ((ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, - AcpiGbl_DbMethodInfo.Method)->Name.Ascii), METHOD_NAME__PLD)) + AcpiGbl_DbMethodInfo.Method)->Name.Ascii), + METHOD_NAME__PLD)) { AcpiDbDumpPldBuffer (ReturnObj.Pointer); } @@ -563,8 +582,10 @@ AcpiDbMethodThread ( if (Info->InitArgs) { - AcpiDbUint32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); - AcpiDbUint32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr); + AcpiDbUint32ToHexString (Info->NumCreated, + Info->IndexOfThreadStr); + AcpiDbUint32ToHexString ((UINT32) AcpiOsGetThreadId (), + Info->IdOfThreadStr); } if (Info->Threads && (Info->NumCreated < Info->NumThreads)) @@ -599,13 +620,15 @@ AcpiDbMethodThread ( #if 0 if ((i % 100) == 0) { - AcpiOsPrintf ("%u loops, Thread 0x%x\n", i, AcpiOsGetThreadId ()); + AcpiOsPrintf ("%u loops, Thread 0x%x\n", + i, AcpiOsGetThreadId ()); } if (ReturnObj.Length) { AcpiOsPrintf ("Evaluation of %s returned object %p Buflen %X\n", - Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); + Info->Pathname, ReturnObj.Pointer, + (UINT32) ReturnObj.Length); AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); } #endif @@ -614,7 +637,8 @@ AcpiDbMethodThread ( /* Signal our completion */ Allow = 0; - (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER); + (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, + 1, ACPI_WAIT_FOREVER); Info->NumCompleted++; if (Info->NumCompleted == Info->NumThreads) @@ -630,7 +654,8 @@ AcpiDbMethodThread ( Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n", + AcpiOsPrintf ( + "Could not signal debugger thread sync semaphore, %s\n", AcpiFormatException (Status)); } } @@ -669,8 +694,8 @@ AcpiDbCreateExecutionThreads ( /* Get the arguments */ - NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0); - NumLoops = ACPI_STRTOUL (NumLoopsArg, NULL, 0); + NumThreads = strtoul (NumThreadsArg, NULL, 0); + NumLoops = strtoul (NumLoopsArg, NULL, 0); if (!NumThreads || !NumLoops) { @@ -686,7 +711,8 @@ AcpiDbCreateExecutionThreads ( Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n", + AcpiOsPrintf ("Could not create semaphore for " + "synchronization with the main thread, %s\n", AcpiFormatException (Status)); return; } @@ -698,8 +724,10 @@ AcpiDbCreateExecutionThreads ( Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n", + AcpiOsPrintf ("Could not create semaphore for " + "synchronization between the created threads, %s\n", AcpiFormatException (Status)); + (void) AcpiOsDeleteSemaphore (MainThreadGate); return; } @@ -707,19 +735,22 @@ AcpiDbCreateExecutionThreads ( Status = AcpiOsCreateSemaphore (1, 1, &InfoGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore for synchronization of AcpiGbl_DbMethodInfo, %s\n", + AcpiOsPrintf ("Could not create semaphore for " + "synchronization of AcpiGbl_DbMethodInfo, %s\n", AcpiFormatException (Status)); + (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); (void) AcpiOsDeleteSemaphore (MainThreadGate); return; } - ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); + memset (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); /* Array to store IDs of threads */ AcpiGbl_DbMethodInfo.NumThreads = NumThreads; Size = sizeof (ACPI_THREAD_ID) * AcpiGbl_DbMethodInfo.NumThreads; + AcpiGbl_DbMethodInfo.Threads = AcpiOsAllocate (Size); if (AcpiGbl_DbMethodInfo.Threads == NULL) { @@ -729,7 +760,7 @@ AcpiDbCreateExecutionThreads ( (void) AcpiOsDeleteSemaphore (InfoGate); return; } - ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size); + memset (AcpiGbl_DbMethodInfo.Threads, 0, Size); /* Setup the context to be passed to each thread */ @@ -780,7 +811,7 @@ AcpiDbCreateExecutionThreads ( for (i = 0; i < (NumThreads); i++) { - Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbMethodThread, + Status = AcpiOsExecute (OSL_DEBUGGER_EXEC_THREAD, AcpiDbMethodThread, &AcpiGbl_DbMethodInfo); if (ACPI_FAILURE (Status)) { @@ -807,5 +838,3 @@ CleanupAndExit: AcpiOsFree (AcpiGbl_DbMethodInfo.Threads); AcpiGbl_DbMethodInfo.Threads = NULL; } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbfileio.c b/sys/contrib/dev/acpica/components/debugger/dbfileio.c index 59a9a52..38f3678 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbfileio.c +++ b/sys/contrib/dev/acpica/components/debugger/dbfileio.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,14 +46,16 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acdebug.h> #include <contrib/dev/acpica/include/actables.h> - -#if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER) +#include <stdio.h> +#ifdef ACPI_APPLICATION +#include <contrib/dev/acpica/include/acapps.h> +#endif #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbfileio") -#ifdef ACPI_DEBUGGER +#ifdef ACPI_DEBUGGER /******************************************************************************* * * FUNCTION: AcpiDbCloseDebugFile @@ -78,7 +80,8 @@ AcpiDbCloseDebugFile ( fclose (AcpiGbl_DebugFile); AcpiGbl_DebugFile = NULL; AcpiGbl_DbOutputToFile = FALSE; - AcpiOsPrintf ("Debug output file %s closed\n", AcpiGbl_DbDebugFilename); + AcpiOsPrintf ("Debug output file %s closed\n", + AcpiGbl_DbDebugFilename); } #endif } @@ -112,7 +115,7 @@ AcpiDbOpenDebugFile ( } AcpiOsPrintf ("Debug output file %s opened\n", Name); - ACPI_STRNCPY (AcpiGbl_DbDebugFilename, Name, + strncpy (AcpiGbl_DbDebugFilename, Name, sizeof (AcpiGbl_DbDebugFilename)); AcpiGbl_DbOutputToFile = TRUE; @@ -121,134 +124,35 @@ AcpiDbOpenDebugFile ( #endif -#ifdef ACPI_APPLICATION -#include <contrib/dev/acpica/include/acapps.h> - -/******************************************************************************* - * - * FUNCTION: AeLocalLoadTable - * - * PARAMETERS: Table - pointer to a buffer containing the entire - * table to be loaded - * - * RETURN: Status - * - * DESCRIPTION: This function is called to load a table from the caller's - * buffer. The buffer must contain an entire ACPI Table including - * a valid header. The header fields will be verified, and if it - * is determined that the table is invalid, the call will fail. - * - ******************************************************************************/ - -static ACPI_STATUS -AeLocalLoadTable ( - ACPI_TABLE_HEADER *Table) -{ - ACPI_STATUS Status = AE_OK; -/* ACPI_TABLE_DESC TableInfo; */ - - - ACPI_FUNCTION_TRACE (AeLocalLoadTable); -#if 0 - - - if (!Table) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - TableInfo.Pointer = Table; - Status = AcpiTbRecognizeTable (&TableInfo, ACPI_TABLE_ALL); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Install the new table into the local data structures */ - - Status = AcpiTbInitTableDescriptor (&TableInfo); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_ALREADY_EXISTS) - { - /* Table already exists, no error */ - - Status = AE_OK; - } - - /* Free table allocated by AcpiTbGetTable */ - - AcpiTbDeleteSingleTable (&TableInfo); - return_ACPI_STATUS (Status); - } - -#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) - - Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); - if (ACPI_FAILURE (Status)) - { - /* Uninstall table and free the buffer */ - - AcpiTbDeleteTablesByType (ACPI_TABLE_ID_DSDT); - return_ACPI_STATUS (Status); - } -#endif -#endif - - return_ACPI_STATUS (Status); -} -#endif - - /******************************************************************************* * - * FUNCTION: AcpiDbGetTableFromFile + * FUNCTION: AcpiDbLoadTables * - * PARAMETERS: Filename - File where table is located - * ReturnTable - Where a pointer to the table is returned + * PARAMETERS: ListHead - List of ACPI tables to load * * RETURN: Status * - * DESCRIPTION: Load an ACPI table from a file + * DESCRIPTION: Load ACPI tables from a previously constructed table list. * ******************************************************************************/ ACPI_STATUS -AcpiDbGetTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **ReturnTable, - BOOLEAN MustBeAmlFile) +AcpiDbLoadTables ( + ACPI_NEW_TABLE_DESC *ListHead) { -#ifdef ACPI_APPLICATION ACPI_STATUS Status; + ACPI_NEW_TABLE_DESC *TableListHead; ACPI_TABLE_HEADER *Table; - BOOLEAN IsAmlTable = TRUE; - Status = AcpiUtReadTableFromFile (Filename, &Table); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + /* Load all ACPI tables in the list */ - if (MustBeAmlFile) + TableListHead = ListHead; + while (TableListHead) { - IsAmlTable = AcpiUtIsAmlTable (Table); - if (!IsAmlTable) - { - ACPI_EXCEPTION ((AE_INFO, AE_OK, - "Input for -e is not an AML table: " - "\"%4.4s\" (must be DSDT/SSDT)", - Table->Signature)); - return (AE_TYPE); - } - } + Table = TableListHead->Table; - if (IsAmlTable) - { - /* Attempt to recognize and install the table */ - - Status = AeLocalLoadTable (Table); + Status = AcpiLoadTable (Table); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -265,22 +169,12 @@ AcpiDbGetTableFromFile ( return (Status); } - AcpiTbPrintTableHeader (0, Table); - fprintf (stderr, "Acpi table [%4.4s] successfully installed and loaded\n", Table->Signature); - } - AcpiGbl_AcpiHardwarePresent = FALSE; - if (ReturnTable) - { - *ReturnTable = Table; + TableListHead = TableListHead->Next; } - -#endif /* ACPI_APPLICATION */ return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbhistry.c b/sys/contrib/dev/acpica/components/debugger/dbhistry.c index e945779..b55f108 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbhistry.c +++ b/sys/contrib/dev/acpica/components/debugger/dbhistry.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acdebug.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbhistry") @@ -92,7 +91,7 @@ AcpiDbAddToHistory ( /* Put command into the next available slot */ - CmdLen = (UINT16) ACPI_STRLEN (CommandLine); + CmdLen = (UINT16) strlen (CommandLine); if (!CmdLen) { return; @@ -100,8 +99,9 @@ AcpiDbAddToHistory ( if (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command != NULL) { - BufferLen = (UINT16) ACPI_STRLEN ( + BufferLen = (UINT16) strlen ( AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command); + if (CmdLen > BufferLen) { AcpiOsFree (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex]. @@ -116,7 +116,7 @@ AcpiDbAddToHistory ( AcpiOsAllocate (CmdLen + 1); } - ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, + strcpy (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, CommandLine); AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum = @@ -217,7 +217,7 @@ AcpiDbGetFromHistory ( else { - CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0); + CmdNum = strtoul (CommandNumArg, NULL, 0); } return (AcpiDbGetHistoryByIndex (CmdNum)); @@ -269,5 +269,3 @@ AcpiDbGetHistoryByIndex ( AcpiOsPrintf ("Invalid history number: %u\n", HistoryIndex); return (NULL); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbinput.c b/sys/contrib/dev/acpica/components/debugger/dbinput.c index 623bc48..a52ee4d 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbinput.c +++ b/sys/contrib/dev/acpica/components/debugger/dbinput.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,12 +45,14 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acdebug.h> - -#ifdef ACPI_DEBUGGER +#ifdef ACPI_APPLICATION +#include <contrib/dev/acpica/include/acapps.h> +#endif #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbinput") + /* Local prototypes */ static UINT32 @@ -67,7 +69,7 @@ AcpiDbSingleThread ( static void AcpiDbDisplayCommandInfo ( - char *Command, + const char *Command, BOOLEAN DisplayAll); static void @@ -76,7 +78,7 @@ AcpiDbDisplayHelp ( static BOOLEAN AcpiDbMatchCommandHelp ( - char *Command, + const char *Command, const ACPI_DB_COMMAND_HELP *Help); @@ -95,20 +97,15 @@ enum AcpiExDebuggerCommands CMD_BREAKPOINT, CMD_BUSINFO, CMD_CALL, - CMD_CLOSE, CMD_DEBUG, CMD_DISASSEMBLE, CMD_DISASM, CMD_DUMP, - CMD_ENABLEACPI, CMD_EVALUATE, - CMD_EVENT, CMD_EXECUTE, CMD_EXIT, CMD_FIND, CMD_GO, - CMD_GPE, - CMD_GPES, CMD_HANDLERS, CMD_HELP, CMD_HELP2, @@ -120,14 +117,12 @@ enum AcpiExDebuggerCommands CMD_INTO, CMD_LEVEL, CMD_LIST, - CMD_LOAD, CMD_LOCALS, CMD_LOCKS, CMD_METHODS, CMD_NAMESPACE, CMD_NOTIFY, CMD_OBJECTS, - CMD_OPEN, CMD_OSI, CMD_OWNER, CMD_PATHS, @@ -137,20 +132,32 @@ enum AcpiExDebuggerCommands CMD_REFERENCES, CMD_RESOURCES, CMD_RESULTS, - CMD_SCI, CMD_SET, - CMD_SLEEP, CMD_STATS, CMD_STOP, CMD_TABLES, CMD_TEMPLATE, - CMD_TERMINATE, - CMD_TEST, - CMD_THREADS, CMD_TRACE, CMD_TREE, CMD_TYPE, - CMD_UNLOAD +#ifdef ACPI_APPLICATION + CMD_ENABLEACPI, + CMD_EVENT, + CMD_GPE, + CMD_GPES, + CMD_SCI, + CMD_SLEEP, + + CMD_CLOSE, + CMD_LOAD, + CMD_OPEN, + CMD_UNLOAD, + + CMD_TERMINATE, + CMD_THREADS, + + CMD_TEST, +#endif }; #define CMD_FIRST_VALID 2 @@ -168,20 +175,15 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"BREAKPOINT", 1}, {"BUSINFO", 0}, {"CALL", 0}, - {"CLOSE", 0}, {"DEBUG", 1}, {"DISASSEMBLE", 1}, {"DISASM", 1}, {"DUMP", 1}, - {"ENABLEACPI", 0}, {"EVALUATE", 1}, - {"EVENT", 1}, {"EXECUTE", 1}, {"EXIT", 0}, {"FIND", 1}, {"GO", 0}, - {"GPE", 1}, - {"GPES", 0}, {"HANDLERS", 0}, {"HELP", 0}, {"?", 0}, @@ -193,14 +195,12 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"INTO", 0}, {"LEVEL", 0}, {"LIST", 0}, - {"LOAD", 1}, {"LOCALS", 0}, {"LOCKS", 0}, {"METHODS", 0}, {"NAMESPACE", 0}, {"NOTIFY", 2}, - {"OBJECTS", 1}, - {"OPEN", 1}, + {"OBJECTS", 0}, {"OSI", 0}, {"OWNER", 1}, {"PATHS", 0}, @@ -210,20 +210,32 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"REFERENCES", 1}, {"RESOURCES", 0}, {"RESULTS", 0}, - {"SCI", 0}, {"SET", 3}, - {"SLEEP", 0}, {"STATS", 1}, {"STOP", 0}, {"TABLES", 0}, {"TEMPLATE", 1}, - {"TERMINATE", 0}, - {"TEST", 1}, - {"THREADS", 3}, {"TRACE", 1}, {"TREE", 0}, {"TYPE", 1}, +#ifdef ACPI_APPLICATION + {"ENABLEACPI", 0}, + {"EVENT", 1}, + {"GPE", 1}, + {"GPES", 0}, + {"SCI", 0}, + {"SLEEP", 0}, + + {"CLOSE", 0}, + {"LOAD", 1}, + {"OPEN", 1}, {"UNLOAD", 1}, + + {"TERMINATE", 0}, + {"THREADS", 3}, + + {"TEST", 1}, +#endif {NULL, 0} }; @@ -237,7 +249,6 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Allocations", "Display list of current memory allocations\n"}, {2, " Dump <Address>|<Namepath>", "\n"}, {0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"}, - {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"}, {1, " Handlers", "Info about global handlers\n"}, {1, " Help [Command]", "This help screen or individual command\n"}, {1, " History", "Display command history buffer\n"}, @@ -254,7 +265,6 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Stack", "Display CPU stack usage\n"}, {1, " Tables", "Info about current ACPI table(s)\n"}, {1, " Tables", "Display info about loaded ACPI tables\n"}, - {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"}, {1, " ! <CommandNumber>", "Execute command from history buffer\n"}, {1, " !!", "Execute last command again\n"}, @@ -266,16 +276,15 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Methods", "Display list of loaded control methods\n"}, {1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"}, {1, " Notify <Object> <Value>", "Send a notification on Object\n"}, - {1, " Objects <ObjectType>", "Display all objects of the given type\n"}, + {1, " Objects [ObjectType]", "Display summary of all objects or just given type\n"}, {1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"}, {1, " Paths", "Display full pathnames of namespace objects\n"}, {1, " Predefined", "Check all predefined names\n"}, - {1, " Prefix [<NamePath>]", "Set or Get current execution prefix\n"}, + {1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"}, {1, " References <Addr>", "Find all references to object at addr\n"}, {1, " Resources [DeviceName]", "Display Device resources (no arg = all devices)\n"}, {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"}, {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"}, - {1, " Terminate", "Delete namespace and all internal objects\n"}, {1, " Type <Object>", "Display object type\n"}, {0, "\nControl Method Execution Commands:","\n"}, @@ -297,15 +306,20 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Results", "Display method result stack\n"}, {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"}, {1, " Stop", "Terminate control method\n"}, - {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"}, - {1, " Trace <method name>", "Trace method execution\n"}, + {5, " Trace <State> [<Namepath>] [Once]", "Trace control method execution\n"}, + {1, " Enable", "Enable all messages\n"}, + {1, " Disable", "Disable tracing\n"}, + {1, " Method", "Enable method execution messages\n"}, + {1, " Opcode", "Enable opcode execution messages\n"}, {1, " Tree", "Display control method calling tree\n"}, {1, " <Enter>", "Single step next AML opcode (over calls)\n"}, - {0, "\nHardware Related Commands:", "\n"}, +#ifdef ACPI_APPLICATION + {0, "\nHardware Simulation Commands:", "\n"}, + {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"}, {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"}, {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"}, - {1, " Gpes", "Display info on all GPEs\n"}, + {1, " Gpes", "Display info on all GPE devices\n"}, {1, " Sci", "Generate an SCI\n"}, {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"}, @@ -313,11 +327,17 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Close", "Close debug output file\n"}, {1, " Load <Input Filename>", "Load ACPI table from a file\n"}, {1, " Open <Output Filename>", "Open a file for debug output\n"}, + {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"}, + + {0, "\nUser Space Commands:", "\n"}, + {1, " Terminate", "Delete namespace and all internal objects\n"}, + {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"}, {0, "\nDebug Test Commands:", "\n"}, {3, " Test <TestName>", "Invoke a debug test\n"}, {1, " Objects", "Read/write/compare all namespace data objects\n"}, {1, " Predefined", "Execute all ACPI predefined names (_STA, etc.)\n"}, +#endif {0, NULL, NULL} }; @@ -338,7 +358,7 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = static BOOLEAN AcpiDbMatchCommandHelp ( - char *Command, + const char *Command, const ACPI_DB_COMMAND_HELP *Help) { char *Invocation = Help->Invocation; @@ -361,7 +381,7 @@ AcpiDbMatchCommandHelp ( while ((*Command) && (*Invocation) && (*Invocation != ' ')) { - if (ACPI_TOLOWER (*Command) != ACPI_TOLOWER (*Invocation)) + if (tolower ((int) *Command) != tolower ((int) *Invocation)) { return (FALSE); } @@ -400,7 +420,7 @@ AcpiDbMatchCommandHelp ( static void AcpiDbDisplayCommandInfo ( - char *Command, + const char *Command, BOOLEAN DisplayAll) { const ACPI_DB_COMMAND_HELP *Next; @@ -641,7 +661,8 @@ AcpiDbGetLine ( if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf), InputBuffer)) { - AcpiOsPrintf ("Buffer overflow while parsing input line (max %u characters)\n", + AcpiOsPrintf ( + "Buffer overflow while parsing input line (max %u characters)\n", sizeof (AcpiGbl_DbParsedBuf)); return (0); } @@ -661,10 +682,7 @@ AcpiDbGetLine ( /* Uppercase the actual command */ - if (AcpiGbl_DbArgs[0]) - { - AcpiUtStrupr (AcpiGbl_DbArgs[0]); - } + AcpiUtStrupr (AcpiGbl_DbArgs[0]); Count = i; if (Count) @@ -702,8 +720,9 @@ AcpiDbMatchCommand ( for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++) { - if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) == - AcpiGbl_DbCommands[i].Name) + if (strstr ( + ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) == + AcpiGbl_DbCommands[i].Name) { return (i); } @@ -744,20 +763,27 @@ AcpiDbCommandDispatch ( /* If AcpiTerminate has been called, terminate this thread */ - if (AcpiGbl_DbTerminateThreads) + if (AcpiGbl_DbTerminateLoop) { return (AE_CTRL_TERMINATE); } - - /* Add all commands that come here to the history buffer */ - - AcpiDbAddToHistory (InputBuffer); + /* Find command and add to the history buffer */ ParamCount = AcpiDbGetLine (InputBuffer); CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]); Temp = 0; + /* + * We don't want to add the !! command to the history buffer. It + * would cause an infinite loop because it would always be the + * previous command. + */ + if (CommandIndex != CMD_HISTORY_LAST) + { + AcpiDbAddToHistory (InputBuffer); + } + /* Verify that we have the minimum number of params */ if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) @@ -766,7 +792,8 @@ AcpiDbCommandDispatch ( ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, AcpiGbl_DbCommands[CommandIndex].MinArgs); - AcpiDbDisplayCommandInfo (AcpiGbl_DbCommands[CommandIndex].Name, FALSE); + AcpiDbDisplayCommandInfo ( + AcpiGbl_DbCommands[CommandIndex].Name, FALSE); return (AE_CTRL_TRUE); } @@ -811,11 +838,6 @@ AcpiDbCommandDispatch ( Status = AE_OK; break; - case CMD_CLOSE: - - AcpiDbCloseDebugFile (); - break; - case CMD_DEBUG: AcpiDbExecute (AcpiGbl_DbArgs[1], @@ -833,23 +855,6 @@ AcpiDbCommandDispatch ( AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; - case CMD_ENABLEACPI: -#if (!ACPI_REDUCED_HARDWARE) - - Status = AcpiEnable(); - if (ACPI_FAILURE(Status)) - { - AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); - return (Status); - } -#endif /* !ACPI_REDUCED_HARDWARE */ - break; - - case CMD_EVENT: - - AcpiOsPrintf ("Event command not implemented\n"); - break; - case CMD_EVALUATE: case CMD_EXECUTE: @@ -867,16 +872,6 @@ AcpiDbCommandDispatch ( AcpiGbl_CmSingleStep = FALSE; return (AE_OK); - case CMD_GPE: - - AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); - break; - - case CMD_GPES: - - AcpiDbDisplayGpes (); - break; - case CMD_HANDLERS: AcpiDbDisplayHandlers (); @@ -938,16 +933,18 @@ AcpiDbCommandDispatch ( if (ParamCount == 0) { - AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", + AcpiOsPrintf ( + "Current debug level for file output is: %8.8lX\n", AcpiGbl_DbDebugLevel); - AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", + AcpiOsPrintf ( + "Current debug level for console output is: %8.8lX\n", AcpiGbl_DbConsoleDebugLevel); } else if (ParamCount == 2) { Temp = AcpiGbl_DbConsoleDebugLevel; - AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], - NULL, 16); + AcpiGbl_DbConsoleDebugLevel = + strtoul (AcpiGbl_DbArgs[1], NULL, 16); AcpiOsPrintf ( "Debug Level for console output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbConsoleDebugLevel); @@ -955,7 +952,7 @@ AcpiDbCommandDispatch ( else { Temp = AcpiGbl_DbDebugLevel; - AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); + AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16); AcpiOsPrintf ( "Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); @@ -967,11 +964,6 @@ AcpiDbCommandDispatch ( AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op); break; - case CMD_LOAD: - - Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL, FALSE); - break; - case CMD_LOCKS: AcpiDbDisplayLocks (); @@ -994,7 +986,7 @@ AcpiDbCommandDispatch ( case CMD_NOTIFY: - Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0); + Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0); AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp); break; @@ -1004,11 +996,6 @@ AcpiDbCommandDispatch ( Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; - case CMD_OPEN: - - AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); - break; - case CMD_OSI: AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); @@ -1024,11 +1011,6 @@ AcpiDbCommandDispatch ( AcpiDbDumpNamespacePaths (); break; - case CMD_PREDEFINED: - - AcpiDbCheckPredefinedNames (); - break; - case CMD_PREFIX: AcpiDbSetScope (AcpiGbl_DbArgs[1]); @@ -1049,22 +1031,12 @@ AcpiDbCommandDispatch ( AcpiDbDisplayResults (); break; - case CMD_SCI: - - AcpiDbGenerateSci (); - break; - case CMD_SET: AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); break; - case CMD_SLEEP: - - Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); - break; - case CMD_STATS: Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); @@ -1084,6 +1056,89 @@ AcpiDbCommandDispatch ( AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]); break; + case CMD_TRACE: + + AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); + break; + + case CMD_TREE: + + AcpiDbDisplayCallingTree (); + break; + + case CMD_TYPE: + + AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]); + break; + +#ifdef ACPI_APPLICATION + + /* Hardware simulation commands. */ + + case CMD_ENABLEACPI: +#if (!ACPI_REDUCED_HARDWARE) + + Status = AcpiEnable(); + if (ACPI_FAILURE(Status)) + { + AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); + return (Status); + } +#endif /* !ACPI_REDUCED_HARDWARE */ + break; + + case CMD_EVENT: + + AcpiOsPrintf ("Event command not implemented\n"); + break; + + case CMD_GPE: + + AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); + break; + + case CMD_GPES: + + AcpiDbDisplayGpes (); + break; + + case CMD_SCI: + + AcpiDbGenerateSci (); + break; + + case CMD_SLEEP: + + Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); + break; + + /* File I/O commands. */ + + case CMD_CLOSE: + + AcpiDbCloseDebugFile (); + break; + + case CMD_LOAD: + { + ACPI_NEW_TABLE_DESC *ListHead = NULL; + + Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1], + ACPI_GET_ALL_TABLES, &ListHead); + if (ACPI_SUCCESS (Status)) + { + AcpiDbLoadTables (ListHead); + } + } + break; + + case CMD_OPEN: + + AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); + break; + + /* User space commands. */ + case CMD_TERMINATE: AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); @@ -1094,39 +1149,33 @@ AcpiDbCommandDispatch ( * re-creating the semaphores! */ + AcpiGbl_DbTerminateLoop = TRUE; /* AcpiInitialize (NULL); */ break; - case CMD_TEST: - - AcpiDbExecuteTest (AcpiGbl_DbArgs[1]); - break; - case CMD_THREADS: AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); break; - case CMD_TRACE: - - (void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1); - break; + /* Debug test commands. */ - case CMD_TREE: + case CMD_PREDEFINED: - AcpiDbDisplayCallingTree (); + AcpiDbCheckPredefinedNames (); break; - case CMD_TYPE: + case CMD_TEST: - AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]); + AcpiDbExecuteTest (AcpiGbl_DbArgs[1]); break; case CMD_UNLOAD: AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]); break; +#endif case CMD_EXIT: case CMD_QUIT: @@ -1142,8 +1191,10 @@ AcpiDbCommandDispatch ( AcpiDbgLevel = ACPI_DEBUG_DEFAULT; } +#ifdef ACPI_APPLICATION AcpiDbCloseDebugFile (); - AcpiGbl_DbTerminateThreads = TRUE; +#endif + AcpiGbl_DbTerminateLoop = TRUE; return (AE_CTRL_TERMINATE); case CMD_NOT_FOUND: @@ -1183,12 +1234,13 @@ AcpiDbExecuteThread ( ACPI_STATUS MStatus; - while (Status != AE_CTRL_TERMINATE) + while (Status != AE_CTRL_TERMINATE && !AcpiGbl_DbTerminateLoop) { AcpiGbl_MethodExecuting = FALSE; AcpiGbl_StepToNextCall = FALSE; - MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + MStatus = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (MStatus)) { return; @@ -1196,12 +1248,9 @@ AcpiDbExecuteThread ( Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); - MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); - if (ACPI_FAILURE (MStatus)) - { - return; - } + AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); } + AcpiGbl_DbThreadsTerminated = TRUE; } @@ -1256,7 +1305,7 @@ AcpiDbUserCommands ( /* TBD: [Restructure] Need a separate command line buffer for step mode */ - while (!AcpiGbl_DbTerminateThreads) + while (!AcpiGbl_DbTerminateLoop) { /* Force output to console until a command is entered */ @@ -1291,13 +1340,10 @@ AcpiDbUserCommands ( * Signal the debug thread that we have a command to execute, * and wait for the command to complete. */ - Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { return (Status); @@ -1311,12 +1357,5 @@ AcpiDbUserCommands ( } } - /* - * Only this thread (the original thread) should actually terminate the - * subsystem, because all the semaphores are deleted during termination - */ - Status = AcpiTerminate (); return (Status); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbmethod.c b/sys/contrib/dev/acpica/components/debugger/dbmethod.c index 5224854..2d047f5 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbmethod.c +++ b/sys/contrib/dev/acpica/components/debugger/dbmethod.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,13 +46,10 @@ #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/acpredef.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbmethod") @@ -79,6 +76,7 @@ AcpiDbSetMethodBreakpoint ( ACPI_PARSE_OBJECT *Op) { UINT32 Address; + UINT32 AmlOffset; if (!Op) @@ -89,11 +87,13 @@ AcpiDbSetMethodBreakpoint ( /* Get and verify the breakpoint address */ - Address = ACPI_STRTOUL (Location, NULL, 16); - if (Address <= Op->Common.AmlOffset) + Address = strtoul (Location, NULL, 16); + AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml, + WalkState->ParserState.AmlStart); + if (Address <= AmlOffset) { AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", - Address, Op->Common.AmlOffset); + Address, AmlOffset); } /* Save breakpoint in current walk */ @@ -174,7 +174,7 @@ AcpiDbSetMethodData ( return; } - Value = ACPI_STRTOUL (ValueArg, NULL, 16); + Value = strtoul (ValueArg, NULL, 16); if (Type == 'N') { @@ -196,7 +196,7 @@ AcpiDbSetMethodData ( /* Get the index and value */ - Index = ACPI_STRTOUL (IndexArg, NULL, 16); + Index = strtoul (IndexArg, NULL, 16); WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) @@ -224,12 +224,13 @@ AcpiDbSetMethodData ( if (Index > ACPI_METHOD_MAX_ARG) { - AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index); + AcpiOsPrintf ("Arg%u - Invalid argument name\n", + Index); goto Cleanup; } - Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc, - WalkState); + Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, + Index, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -238,7 +239,7 @@ AcpiDbSetMethodData ( ObjDesc = WalkState->Arguments[Index].Object; AcpiOsPrintf ("Arg%u: ", Index); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); break; case 'L': @@ -247,12 +248,13 @@ AcpiDbSetMethodData ( if (Index > ACPI_METHOD_MAX_LOCAL) { - AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index); + AcpiOsPrintf ("Local%u - Invalid local variable name\n", + Index); goto Cleanup; } - Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc, - WalkState); + Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, + Index, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -261,7 +263,7 @@ AcpiDbSetMethodData ( ObjDesc = WalkState->LocalVariables[Index].Object; AcpiOsPrintf ("Local%u: ", Index); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); break; default: @@ -304,7 +306,7 @@ AcpiDbDisassembleAml ( if (Statements) { - NumStatements = ACPI_STRTOUL (Statements, NULL, 0); + NumStatements = strtoul (Statements, NULL, 0); } #ifdef ACPI_DISASSEMBLER @@ -352,7 +354,7 @@ AcpiDbDisassembleMethod ( ObjDesc = Method->Object; - Op = AcpiPsCreateScopeOp (); + Op = AcpiPsCreateScopeOp (ObjDesc->Method.AmlStart); if (!Op) { return (AE_NO_MEMORY); @@ -392,15 +394,16 @@ AcpiDbDisassembleMethod ( WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiPsParseAml (WalkState); + +#ifdef ACPI_DISASSEMBLER (void) AcpiDmParseDeferredOps (Op); /* Now we can disassemble the method */ - AcpiGbl_DbOpt_Verbose = FALSE; -#ifdef ACPI_DISASSEMBLER + AcpiGbl_DmOpt_Verbose = FALSE; AcpiDmDisassemble (NULL, Op, 0); + AcpiGbl_DmOpt_Verbose = TRUE; #endif - AcpiGbl_DbOpt_Verbose = TRUE; AcpiPsDeleteParseTree (Op); @@ -411,5 +414,3 @@ AcpiDbDisassembleMethod ( AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId); return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbnames.c b/sys/contrib/dev/acpica/components/debugger/dbnames.c index d749b1d..f91bf97 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbnames.c +++ b/sys/contrib/dev/acpica/components/debugger/dbnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,8 +48,6 @@ #include <contrib/dev/acpica/include/acpredef.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbnames") @@ -78,6 +76,13 @@ AcpiDbWalkForSpecificObjects ( void **ReturnValue); static ACPI_STATUS +AcpiDbWalkForObjectCounts ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS AcpiDbIntegrityWalk ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -125,7 +130,13 @@ static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] = {"BANKFIELDS"}, {"INDEXFIELDS"}, {"REFERENCES"}, - {"ALIAS"}, + {"ALIASES"}, + {"METHODALIASES"}, + {"NOTIFY"}, + {"ADDRESSHANDLER"}, + {"RESOURCE"}, + {"RESOURCEFIELD"}, + {"SCOPES"}, {NULL} /* Must be null terminated */ }; @@ -163,8 +174,8 @@ AcpiDbSetScope ( { /* Validate new scope from the root */ - Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH, - &Node); + Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -176,8 +187,8 @@ AcpiDbSetScope ( { /* Validate new scope relative to old scope */ - Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH, - &Node); + Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -194,7 +205,7 @@ AcpiDbSetScope ( } if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf), - "\\")) + "\\")) { Status = AE_BUFFER_OVERFLOW; goto ErrorExit; @@ -248,7 +259,7 @@ AcpiDbDumpNamespace ( if (DepthArg) { - MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); + MaxDepth = strtoul (DepthArg, NULL, 0); } } @@ -319,13 +330,13 @@ AcpiDbDumpNamespaceByOwner ( ACPI_OWNER_ID OwnerId; - OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0); + OwnerId = (ACPI_OWNER_ID) strtoul (OwnerArg, NULL, 0); /* Now we can check for the depth argument */ if (DepthArg) { - MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); + MaxDepth = strtoul (DepthArg, NULL, 0); } AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); @@ -334,8 +345,8 @@ AcpiDbDumpNamespaceByOwner ( /* Display the subtree */ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, - SubtreeEntry); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, + OwnerId, SubtreeEntry); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } @@ -374,7 +385,8 @@ AcpiDbWalkAndMatchName ( /* Wildcard support */ if ((RequestedName[i] != '?') && - (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) + (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) + ObjHandle)->Name.Ascii[i])) { /* No match, just exit */ @@ -385,10 +397,11 @@ AcpiDbWalkAndMatchName ( /* Get the full pathname to this object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + AcpiOsPrintf ("Could Not get pathname for object %p\n", + ObjHandle); } else { @@ -426,7 +439,7 @@ AcpiDbFindNameInNamespace ( char *AcpiNamePtr = AcpiName; - if (ACPI_STRLEN (NameArg) > 4) + if (strlen (NameArg) > ACPI_NAME_SIZE) { AcpiOsPrintf ("Name must be no longer than 4 characters\n"); return (AE_OK); @@ -444,8 +457,8 @@ AcpiDbFindNameInNamespace ( /* Walk the namespace from the root */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkAndMatchName, NULL, AcpiName, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbWalkAndMatchName, NULL, AcpiName, NULL); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); return (AE_OK); @@ -486,7 +499,7 @@ AcpiDbWalkForPredefinedNames ( return (AE_OK); } - Pathname = AcpiNsGetExternalPathname (Node); + Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); if (!Pathname) { return (AE_OK); @@ -546,8 +559,9 @@ AcpiDbCheckPredefinedNames ( /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbWalkForPredefinedNames, + NULL, (void *) &Count, NULL); AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count); } @@ -555,6 +569,43 @@ AcpiDbCheckPredefinedNames ( /******************************************************************************* * + * FUNCTION: AcpiDbWalkForObjectCounts + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Display short info about objects in the namespace + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkForObjectCounts ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OBJECT_INFO *Info = (ACPI_OBJECT_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + + + if (Node->Type > ACPI_TYPE_NS_NODE_MAX) + { + AcpiOsPrintf ("[%4.4s]: Unknown object type %X\n", + Node->Name.Ascii, Node->Type); + } + else + { + Info->Types[Node->Type]++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbWalkForSpecificObjects * * PARAMETERS: Callback from WalkNamespace @@ -582,7 +633,7 @@ AcpiDbWalkForSpecificObjects ( /* Get and display the full pathname to this object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); @@ -619,7 +670,39 @@ AcpiDbDisplayObjects ( { ACPI_WALK_INFO Info; ACPI_OBJECT_TYPE Type; + ACPI_OBJECT_INFO *ObjectInfo; + UINT32 i; + UINT32 TotalObjects = 0; + + + /* No argument means display summary/count of all object types */ + if (!ObjTypeArg) + { + ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO)); + + /* Walk the namespace from the root */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbWalkForObjectCounts, NULL, + (void *) ObjectInfo, NULL); + + AcpiOsPrintf ("\nSummary of namespace objects:\n\n"); + + for (i = 0; i < ACPI_TOTAL_TYPES; i++) + { + AcpiOsPrintf ("%8u %s\n", ObjectInfo->Types[i], + AcpiUtGetTypeName (i)); + + TotalObjects += ObjectInfo->Types[i]; + } + + AcpiOsPrintf ("\n%8u Total namespace objects\n\n", + TotalObjects); + + ACPI_FREE (ObjectInfo); + return (AE_OK); + } /* Get the object type */ @@ -645,7 +728,7 @@ AcpiDbDisplayObjects ( /* Walk the namespace from the root */ (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL); + AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL); AcpiOsPrintf ( "\nFound %u objects of type [%s] in the current ACPI Namespace\n", @@ -689,9 +772,11 @@ AcpiDbIntegrityWalk ( { if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { - AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n", - Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node), - ACPI_DESC_TYPE_NAMED); + AcpiOsPrintf ( + "Invalid Descriptor Type for Node %p [%s] - " + "is %2.2X should be %2.2X\n", + Node, AcpiUtGetDescriptorName (Node), + ACPI_GET_DESCRIPTOR_TYPE (Node), ACPI_DESC_TYPE_NAMED); return (AE_OK); } @@ -713,7 +798,7 @@ AcpiDbIntegrityWalk ( return (AE_OK); } - if (!AcpiUtValidAcpiName (Node->Name.Ascii)) + if (!AcpiUtValidNameseg (Node->Name.Ascii)) { AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); return (AE_OK); @@ -754,8 +839,8 @@ AcpiDbCheckIntegrity ( /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL); AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n", Info.Nodes, Info.Objects); @@ -830,13 +915,14 @@ AcpiDbFindReferences ( /* Convert string to object pointer */ - Address = ACPI_STRTOUL (ObjectArg, NULL, 16); + Address = strtoul (ObjectArg, NULL, 16); ObjDesc = ACPI_TO_POINTER (Address); /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbWalkForReferences, NULL, + (void *) ObjDesc, NULL); } @@ -877,7 +963,7 @@ AcpiDbBusWalk ( /* Exit if there is no _PRT under this device */ Status = AcpiGetHandle (Node, METHOD_NAME__PRT, - ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); + ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); if (ACPI_FAILURE (Status)) { return (AE_OK); @@ -886,10 +972,11 @@ AcpiDbBusWalk ( /* Get the full path to this device object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + AcpiOsPrintf ("Could Not get pathname for object %p\n", + ObjHandle); return (AE_OK); } @@ -918,7 +1005,8 @@ AcpiDbBusWalk ( if (Info->Valid & ACPI_VALID_ADR) { - AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address)); + AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Info->Address)); } else { @@ -979,8 +1067,6 @@ AcpiDbGetBusInfo ( { /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbBusWalk, NULL, NULL, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbBusWalk, NULL, NULL, NULL); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/disassembler/dmobject.c b/sys/contrib/dev/acpica/components/debugger/dbobject.c index 6559ec0..062ad25 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmobject.c +++ b/sys/contrib/dev/acpica/components/debugger/dbobject.c @@ -1,11 +1,11 @@ /******************************************************************************* * - * Module Name: dmobject - ACPI object decode and display + * Module Name: dbobject - ACPI object decode and display * ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,28 +44,26 @@ #include <contrib/dev/acpica/include/acpi.h> #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acnamesp.h> -#include <contrib/dev/acpica/include/acdisasm.h> +#include <contrib/dev/acpica/include/acdebug.h> -#ifdef ACPI_DISASSEMBLER - #define _COMPONENT ACPI_CA_DEBUGGER - ACPI_MODULE_NAME ("dmnames") + ACPI_MODULE_NAME ("dbobject") + /* Local prototypes */ static void -AcpiDmDecodeNode ( +AcpiDbDecodeNode ( ACPI_NAMESPACE_NODE *Node); /******************************************************************************* * - * FUNCTION: AcpiDmDumpMethodInfo + * FUNCTION: AcpiDbDumpMethodInfo * * PARAMETERS: Status - Method execution status * WalkState - Current state of the parse tree walk - * Op - Executing parse op * * RETURN: None * @@ -76,15 +74,11 @@ AcpiDmDecodeNode ( ******************************************************************************/ void -AcpiDmDumpMethodInfo ( +AcpiDbDumpMethodInfo ( ACPI_STATUS Status, - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op) + ACPI_WALK_STATE *WalkState) { - ACPI_PARSE_OBJECT *Next; ACPI_THREAD_STATE *Thread; - ACPI_WALK_STATE *NextWalkState; - ACPI_NAMESPACE_NODE *PreviousMethod = NULL; /* Ignore control codes, they are not errors */ @@ -113,68 +107,19 @@ AcpiDmDumpMethodInfo ( return; } - /* Display exception and method name */ - - AcpiOsPrintf ("\n**** Exception %s during execution of method ", - AcpiFormatException (Status)); - AcpiNsPrintNodePathname (WalkState->MethodNode, NULL); - - /* Display stack of executing methods */ - - AcpiOsPrintf ("\n\nMethod Execution Stack:\n"); - NextWalkState = Thread->WalkStateList; - - /* Walk list of linked walk states */ - - while (NextWalkState) - { - AcpiOsPrintf (" Method [%4.4s] executing: ", - AcpiUtGetNodeName (NextWalkState->MethodNode)); - - /* First method is the currently executing method */ - - if (NextWalkState == WalkState) - { - if (Op) - { - /* Display currently executing ASL statement */ - - Next = Op->Common.Next; - Op->Common.Next = NULL; - - AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX); - Op->Common.Next = Next; - } - } - else - { - /* - * This method has called another method - * NOTE: the method call parse subtree is already deleted at this - * point, so we cannot disassemble the method invocation. - */ - AcpiOsPrintf ("Call to method "); - AcpiNsPrintNodePathname (PreviousMethod, NULL); - } - - PreviousMethod = NextWalkState->MethodNode; - NextWalkState = NextWalkState->Next; - AcpiOsPrintf ("\n"); - } - /* Display the method locals and arguments */ AcpiOsPrintf ("\n"); - AcpiDmDisplayLocals (WalkState); + AcpiDbDecodeLocals (WalkState); AcpiOsPrintf ("\n"); - AcpiDmDisplayArguments (WalkState); + AcpiDbDecodeArguments (WalkState); AcpiOsPrintf ("\n"); } /******************************************************************************* * - * FUNCTION: AcpiDmDecodeInternalObject + * FUNCTION: AcpiDbDecodeInternalObject * * PARAMETERS: ObjDesc - Object to be displayed * @@ -185,7 +130,7 @@ AcpiDmDumpMethodInfo ( ******************************************************************************/ void -AcpiDmDecodeInternalObject ( +AcpiDbDecodeInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc) { UINT32 i; @@ -199,7 +144,8 @@ AcpiDmDecodeInternalObject ( if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { - AcpiOsPrintf (" %p [%s]", ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); + AcpiOsPrintf (" %p [%s]", ObjDesc, + AcpiUtGetDescriptorName (ObjDesc)); return; } @@ -210,15 +156,15 @@ AcpiDmDecodeInternalObject ( case ACPI_TYPE_INTEGER: AcpiOsPrintf (" %8.8X%8.8X", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; case ACPI_TYPE_STRING: - AcpiOsPrintf ("(%u) \"%.24s", - ObjDesc->String.Length, ObjDesc->String.Pointer); + AcpiOsPrintf ("(%u) \"%.60s", + ObjDesc->String.Length, ObjDesc->String.Pointer); - if (ObjDesc->String.Length > 24) + if (ObjDesc->String.Length > 60) { AcpiOsPrintf ("..."); } @@ -247,7 +193,7 @@ AcpiDmDecodeInternalObject ( /******************************************************************************* * - * FUNCTION: AcpiDmDecodeNode + * FUNCTION: AcpiDbDecodeNode * * PARAMETERS: Node - Object to be displayed * @@ -258,12 +204,12 @@ AcpiDmDecodeInternalObject ( ******************************************************************************/ static void -AcpiDmDecodeNode ( +AcpiDbDecodeNode ( ACPI_NAMESPACE_NODE *Node) { AcpiOsPrintf ("<Node> Name %4.4s", - AcpiUtGetNodeName (Node)); + AcpiUtGetNodeName (Node)); if (Node->Flags & ANOBJ_METHOD_ARG) { @@ -290,7 +236,7 @@ AcpiDmDecodeNode ( default: - AcpiDmDecodeInternalObject (AcpiNsGetAttachedObject (Node)); + AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node)); break; } } @@ -298,7 +244,7 @@ AcpiDmDecodeNode ( /******************************************************************************* * - * FUNCTION: AcpiDmDisplayInternalObject + * FUNCTION: AcpiDbDisplayInternalObject * * PARAMETERS: ObjDesc - Object to be displayed * WalkState - Current walk state @@ -310,7 +256,7 @@ AcpiDmDecodeNode ( ******************************************************************************/ void -AcpiDmDisplayInternalObject ( +AcpiDbDisplayInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { @@ -336,7 +282,7 @@ AcpiDmDisplayInternalObject ( case ACPI_DESC_TYPE_NAMED: - AcpiDmDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc); + AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc); break; case ACPI_DESC_TYPE_OPERAND: @@ -366,9 +312,9 @@ AcpiDmDisplayInternalObject ( if (WalkState) { ObjDesc = WalkState->LocalVariables - [ObjDesc->Reference.Value].Object; + [ObjDesc->Reference.Value].Object; AcpiOsPrintf ("%p", ObjDesc); - AcpiDmDecodeInternalObject (ObjDesc); + AcpiDbDecodeInternalObject (ObjDesc); } break; @@ -378,9 +324,9 @@ AcpiDmDisplayInternalObject ( if (WalkState) { ObjDesc = WalkState->Arguments - [ObjDesc->Reference.Value].Object; + [ObjDesc->Reference.Value].Object; AcpiOsPrintf ("%p", ObjDesc); - AcpiDmDecodeInternalObject (ObjDesc); + AcpiDbDecodeInternalObject (ObjDesc); } break; @@ -391,7 +337,7 @@ AcpiDmDisplayInternalObject ( case ACPI_TYPE_BUFFER_FIELD: AcpiOsPrintf ("%p", ObjDesc->Reference.Object); - AcpiDmDecodeInternalObject (ObjDesc->Reference.Object); + AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); break; case ACPI_TYPE_PACKAGE: @@ -403,7 +349,7 @@ AcpiDmDisplayInternalObject ( } else { - AcpiDmDecodeInternalObject ( + AcpiDbDecodeInternalObject ( *(ObjDesc->Reference.Where)); } break; @@ -419,7 +365,8 @@ AcpiDmDisplayInternalObject ( if (!ObjDesc->Reference.Object) { - AcpiOsPrintf ("Uninitialized reference subobject pointer"); + AcpiOsPrintf ( + "Uninitialized reference subobject pointer"); break; } @@ -428,11 +375,13 @@ AcpiDmDisplayInternalObject ( switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object)) { case ACPI_DESC_TYPE_NAMED: - AcpiDmDecodeNode (ObjDesc->Reference.Object); + + AcpiDbDecodeNode (ObjDesc->Reference.Object); break; case ACPI_DESC_TYPE_OPERAND: - AcpiDmDecodeInternalObject (ObjDesc->Reference.Object); + + AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); break; default: @@ -442,7 +391,7 @@ AcpiDmDisplayInternalObject ( case ACPI_REFCLASS_NAME: - AcpiDmDecodeNode (ObjDesc->Reference.Node); + AcpiDbDecodeNode (ObjDesc->Reference.Node); break; case ACPI_REFCLASS_DEBUG: @@ -461,7 +410,7 @@ AcpiDmDisplayInternalObject ( default: AcpiOsPrintf ("<Obj> "); - AcpiDmDecodeInternalObject (ObjDesc); + AcpiDbDecodeInternalObject (ObjDesc); break; } break; @@ -479,7 +428,7 @@ AcpiDmDisplayInternalObject ( /******************************************************************************* * - * FUNCTION: AcpiDmDisplayLocals + * FUNCTION: AcpiDbDecodeLocals * * PARAMETERS: WalkState - State for current method * @@ -490,16 +439,18 @@ AcpiDmDisplayInternalObject ( ******************************************************************************/ void -AcpiDmDisplayLocals ( +AcpiDbDecodeLocals ( ACPI_WALK_STATE *WalkState) { UINT32 i; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; + BOOLEAN DisplayLocals = FALSE; ObjDesc = WalkState->MethodDesc; Node = WalkState->MethodNode; + if (!Node) { AcpiOsPrintf ( @@ -513,21 +464,47 @@ AcpiDmDisplayLocals ( return; } - AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", - AcpiUtGetNodeName (Node)); + /* Are any locals actually set? */ for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) { ObjDesc = WalkState->LocalVariables[i].Object; - AcpiOsPrintf (" Local%X: ", i); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + if (ObjDesc) + { + DisplayLocals = TRUE; + break; + } + } + + /* If any are set, only display the ones that are set */ + + if (DisplayLocals) + { + AcpiOsPrintf ("\nInitialized Local Variables for method [%4.4s]:\n", + AcpiUtGetNodeName (Node)); + + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + ObjDesc = WalkState->LocalVariables[i].Object; + if (ObjDesc) + { + AcpiOsPrintf (" Local%X: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } + } + } + else + { + AcpiOsPrintf ( + "No Local Variables are initialized for method [%4.4s]\n", + AcpiUtGetNodeName (Node)); } } /******************************************************************************* * - * FUNCTION: AcpiDmDisplayArguments + * FUNCTION: AcpiDbDecodeArguments * * PARAMETERS: WalkState - State for current method * @@ -538,16 +515,18 @@ AcpiDmDisplayLocals ( ******************************************************************************/ void -AcpiDmDisplayArguments ( +AcpiDbDecodeArguments ( ACPI_WALK_STATE *WalkState) { UINT32 i; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; + BOOLEAN DisplayArgs = FALSE; + Node = WalkState->MethodNode; ObjDesc = WalkState->MethodDesc; - Node = WalkState->MethodNode; + if (!Node) { AcpiOsPrintf ( @@ -561,16 +540,41 @@ AcpiDmDisplayArguments ( return; } - AcpiOsPrintf ( - "Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n", - AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount, ObjDesc->Method.SyncLevel); + /* Are any arguments actually set? */ for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { ObjDesc = WalkState->Arguments[i].Object; - AcpiOsPrintf (" Arg%u: ", i); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); + if (ObjDesc) + { + DisplayArgs = TRUE; + break; + } } -} -#endif + /* If any are set, only display the ones that are set */ + + if (DisplayArgs) + { + AcpiOsPrintf ( + "Initialized Arguments for Method [%4.4s]: " + "(%X arguments defined for method invocation)\n", + AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount); + + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + ObjDesc = WalkState->Arguments[i].Object; + if (ObjDesc) + { + AcpiOsPrintf (" Arg%u: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } + } + } + else + { + AcpiOsPrintf ( + "No Arguments are initialized for method [%4.4s]\n", + AcpiUtGetNodeName (Node)); + } +} diff --git a/sys/contrib/dev/acpica/components/debugger/dbstats.c b/sys/contrib/dev/acpica/components/debugger/dbstats.c index ecedcf9..7b48ba0 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbstats.c +++ b/sys/contrib/dev/acpica/components/debugger/dbstats.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,11 +46,11 @@ #include <contrib/dev/acpica/include/acdebug.h> #include <contrib/dev/acpica/include/acnamesp.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbstats") + /* Local prototypes */ static void @@ -127,7 +127,8 @@ AcpiDbListInfo ( if (List->MaxDepth > 0) { AcpiOsPrintf ( - " Cache: [Depth MaxD Avail Size] %8.2X %8.2X %8.2X %8.2X\n", + " Cache: [Depth MaxD Avail Size] " + "%8.2X %8.2X %8.2X %8.2X\n", List->CurrentDepth, List->MaxDepth, List->MaxDepth - List->CurrentDepth, @@ -138,7 +139,8 @@ AcpiDbListInfo ( if (List->MaxDepth > 0) { AcpiOsPrintf ( - " Cache: [Requests Hits Misses ObjSize] %8.2X %8.2X %8.2X %8.2X\n", + " Cache: [Requests Hits Misses ObjSize] " + "%8.2X %8.2X %8.2X %8.2X\n", List->Requests, List->Hits, List->Requests - List->Hits, @@ -150,7 +152,8 @@ AcpiDbListInfo ( if (List->ObjectSize) { AcpiOsPrintf ( - " Mem: [Alloc Free Max CurSize Outstanding] %8.2X %8.2X %8.2X %8.2X %8.2X\n", + " Mem: [Alloc Free Max CurSize Outstanding] " + "%8.2X %8.2X %8.2X %8.2X %8.2X\n", List->TotalAllocated, List->TotalFreed, List->MaxOccupied, @@ -160,7 +163,8 @@ AcpiDbListInfo ( else { AcpiOsPrintf ( - " Mem: [Alloc Free Max CurSize Outstanding Total] %8.2X %8.2X %8.2X %8.2X %8.2X %8.2X\n", + " Mem: [Alloc Free Max CurSize Outstanding Total] " + "%8.2X %8.2X %8.2X %8.2X %8.2X %8.2X\n", List->TotalAllocated, List->TotalFreed, List->MaxOccupied, @@ -335,7 +339,7 @@ AcpiDbClassifyOneObject ( Op = AcpiPsGetDepthNext (Root, Op); SizeOfParseTree = (NumGrammarElements - NumMethodElements) * - (UINT32) sizeof (ACPI_PARSE_OBJECT); + (UINT32) sizeof (ACPI_PARSE_OBJECT); SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); @@ -374,7 +378,7 @@ AcpiDbCountNamespaceObjects ( } (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL, NULL); + ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL, NULL); } @@ -435,6 +439,7 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiUtGetTypeName (i), AcpiGbl_NodeTypeCount [i], AcpiGbl_ObjTypeCount [i]); } + AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown", AcpiGbl_NodeTypeCountMisc, AcpiGbl_ObjTypeCountMisc); @@ -532,7 +537,8 @@ AcpiDbDisplayStatistics ( case CMD_STAT_STACK: #if defined(ACPI_DEBUG_OUTPUT) - Temp = (UINT32) ACPI_PTR_DIFF (AcpiGbl_EntryStackPointer, AcpiGbl_LowestStackPointer); + Temp = (UINT32) ACPI_PTR_DIFF ( + AcpiGbl_EntryStackPointer, AcpiGbl_LowestStackPointer); AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n"); AcpiOsPrintf ("Entry Stack Pointer %p\n", AcpiGbl_EntryStackPointer); @@ -550,5 +556,3 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("\n"); return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbtest.c b/sys/contrib/dev/acpica/components/debugger/dbtest.c index ab14984..6be75f2 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbtest.c +++ b/sys/contrib/dev/acpica/components/debugger/dbtest.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,6 @@ #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acpredef.h> -#ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbtest") @@ -124,8 +123,8 @@ static ACPI_DB_ARGUMENT_INFO AcpiDbTestTypes [] = * used to read and write the various namespace objects. The point * is to force the AML interpreter do all of the work. */ -#define ACPI_DB_READ_METHOD "\\_T98" -#define ACPI_DB_WRITE_METHOD "\\_T99" +#define ACPI_DB_READ_METHOD "\\_T98" +#define ACPI_DB_WRITE_METHOD "\\_T99" static ACPI_HANDLE ReadHandle = NULL; static ACPI_HANDLE WriteHandle = NULL; @@ -283,7 +282,7 @@ AcpiDbTestAllObjects ( /* Walk the entire namespace, testing each supported named data object */ (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL); } @@ -646,7 +645,7 @@ AcpiDbTestBufferType ( * count is not an integral number of bytes. Zero out the * unused bits. */ - ACPI_MEMSET (Buffer, BUFFER_FILL_VALUE, ByteLength); + memset (Buffer, BUFFER_FILL_VALUE, ByteLength); ExtraBits = BitLength % 8; if (ExtraBits) { @@ -671,7 +670,7 @@ AcpiDbTestBufferType ( goto Exit; } - if (ACPI_MEMCMP (Temp2->Buffer.Pointer, Buffer, ByteLength)) + if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength)) { AcpiOsPrintf (" MISMATCH 2: New buffer value"); } @@ -695,7 +694,8 @@ AcpiDbTestBufferType ( goto Exit; } - if (ACPI_MEMCMP (Temp1->Buffer.Pointer, Temp3->Buffer.Pointer, ByteLength)) + if (memcmp (Temp1->Buffer.Pointer, + Temp3->Buffer.Pointer, ByteLength)) { AcpiOsPrintf (" MISMATCH 3: While restoring original buffer"); } @@ -751,7 +751,7 @@ AcpiDbTestStringType ( /* Write a new value */ WriteValue.Type = ACPI_TYPE_STRING; - WriteValue.String.Length = ACPI_STRLEN (ValueToWrite); + WriteValue.String.Length = strlen (ValueToWrite); WriteValue.String.Pointer = ValueToWrite; Status = AcpiDbWriteToObject (Node, &WriteValue); @@ -768,7 +768,7 @@ AcpiDbTestStringType ( goto Exit; } - if (ACPI_STRCMP (Temp2->String.Pointer, ValueToWrite)) + if (strcmp (Temp2->String.Pointer, ValueToWrite)) { AcpiOsPrintf (" MISMATCH 2: %s, expecting %s", Temp2->String.Pointer, ValueToWrite); @@ -776,7 +776,7 @@ AcpiDbTestStringType ( /* Write back the original value */ - WriteValue.String.Length = ACPI_STRLEN (Temp1->String.Pointer); + WriteValue.String.Length = strlen (Temp1->String.Pointer); WriteValue.String.Pointer = Temp1->String.Pointer; Status = AcpiDbWriteToObject (Node, &WriteValue); @@ -793,7 +793,7 @@ AcpiDbTestStringType ( goto Exit; } - if (ACPI_STRCMP (Temp1->String.Pointer, Temp3->String.Pointer)) + if (strcmp (Temp1->String.Pointer, Temp3->String.Pointer)) { AcpiOsPrintf (" MISMATCH 3: %s, expecting %s", Temp3->String.Pointer, Temp1->String.Pointer); @@ -847,7 +847,8 @@ AcpiDbReadFromObject ( ReturnObj.Length = ACPI_ALLOCATE_BUFFER; AcpiGbl_MethodExecuting = TRUE; - Status = AcpiEvaluateObject (ReadHandle, NULL, &ParamObjects, &ReturnObj); + Status = AcpiEvaluateObject (ReadHandle, NULL, + &ParamObjects, &ReturnObj); AcpiGbl_MethodExecuting = FALSE; if (ACPI_FAILURE (Status)) @@ -885,8 +886,8 @@ AcpiDbReadFromObject ( AcpiOsPrintf (" Unsupported return object type, %s", AcpiUtGetTypeName (RetValue->Type)); - AcpiOsFree (ReturnObj.Pointer); + AcpiOsFree (ReturnObj.Pointer); return (AE_TYPE); } @@ -926,7 +927,7 @@ AcpiDbWriteToObject ( /* Copy the incoming user parameter */ - ACPI_MEMCPY (&Params[1], Value, sizeof (ACPI_OBJECT)); + memcpy (&Params[1], Value, sizeof (ACPI_OBJECT)); ParamObjects.Count = 2; ParamObjects.Pointer = Params; @@ -970,15 +971,17 @@ AcpiDbEvaluateAllPredefinedNames ( if (CountArg) { - Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0); + Info.MaxCount = strtoul (CountArg, NULL, 0); } /* Search all nodes in namespace */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbEvaluateOnePredefinedName, NULL, (void *) &Info, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbEvaluateOnePredefinedName, NULL, + (void *) &Info, NULL); - AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count); + AcpiOsPrintf ( + "Evaluated %u predefined names in the namespace\n", Info.Count); } @@ -1031,7 +1034,7 @@ AcpiDbEvaluateOnePredefinedName ( return (AE_OK); } - Pathname = AcpiNsGetExternalPathname (Node); + Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); if (!Pathname) { return (AE_OK); @@ -1076,8 +1079,10 @@ AcpiDbEvaluateOnePredefinedName ( case ACPI_TYPE_STRING: - ThisParam->String.Pointer = "This is the default argument string"; - ThisParam->String.Length = ACPI_STRLEN (ThisParam->String.Pointer); + ThisParam->String.Pointer = + "This is the default argument string"; + ThisParam->String.Length = + strlen (ThisParam->String.Pointer); break; case ACPI_TYPE_BUFFER: @@ -1116,7 +1121,8 @@ AcpiDbEvaluateOnePredefinedName ( Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj); - AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status)); + AcpiOsPrintf ("%-32s returned %s\n", + Pathname, AcpiFormatException (Status)); AcpiGbl_MethodExecuting = FALSE; ACPI_FREE (Pathname); @@ -1134,5 +1140,3 @@ AcpiDbEvaluateOnePredefinedName ( return (Status); } - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbutils.c b/sys/contrib/dev/acpica/components/debugger/dbutils.c index 5db98e1..8e56c20 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbutils.c +++ b/sys/contrib/dev/acpica/components/debugger/dbutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,14 +45,12 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbutils") + /* Local prototypes */ #ifdef ACPI_OBSOLETE_FUNCTIONS @@ -65,8 +63,6 @@ AcpiDbDumpBuffer ( UINT32 Address); #endif -static char *Converter = "0123456789ABCDEF"; - /******************************************************************************* * @@ -96,7 +92,9 @@ AcpiDbMatchArgument ( for (i = 0; Arguments[i].Name; i++) { - if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name) + if (strstr ( + ACPI_CAST_PTR (char, Arguments[i].Name), + ACPI_CAST_PTR (char, UserArgument)) == Arguments[i].Name) { return (i); } @@ -128,7 +126,8 @@ AcpiDbSetOutputDestination ( AcpiGbl_DbOutputFlags = (UINT8) OutputFlags; - if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && AcpiGbl_DbOutputToFile) + if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && + AcpiGbl_DbOutputToFile) { AcpiDbgLevel = AcpiGbl_DbDebugLevel; } @@ -181,7 +180,7 @@ AcpiDbDumpExternalObject ( case ACPI_TYPE_INTEGER: AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; case ACPI_TYPE_STRING: @@ -200,8 +199,10 @@ AcpiDbDumpExternalObject ( { AcpiOsPrintf ("\n"); } - AcpiUtDebugDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), - ObjDesc->Buffer.Length, DB_BYTE_DISPLAY, _COMPONENT); + + AcpiUtDebugDumpBuffer ( + ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), + ObjDesc->Buffer.Length, DB_BYTE_DISPLAY, _COMPONENT); } else { @@ -212,18 +213,19 @@ AcpiDbDumpExternalObject ( case ACPI_TYPE_PACKAGE: AcpiOsPrintf ("[Package] Contains %u Elements:\n", - ObjDesc->Package.Count); + ObjDesc->Package.Count); for (i = 0; i < ObjDesc->Package.Count; i++) { - AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1); + AcpiDbDumpExternalObject ( + &ObjDesc->Package.Elements[i], Level+1); } break; case ACPI_TYPE_LOCAL_REFERENCE: AcpiOsPrintf ("[Object Reference] = "); - AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); + AcpiDbDisplayInternalObject (ObjDesc->Reference.Handle, NULL); break; case ACPI_TYPE_PROCESSOR: @@ -336,12 +338,13 @@ AcpiDbLocalNsLookup ( * Lookup the name. * (Uses root node as the search starting point) */ - Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not locate name: %s, %s\n", - Name, AcpiFormatException (Status)); + Name, AcpiFormatException (Status)); } ACPI_FREE (InternalPath); @@ -375,7 +378,7 @@ AcpiDbUint32ToHexString ( if (Value == 0) { - ACPI_STRCPY (Buffer, "0"); + strcpy (Buffer, "0"); return; } @@ -383,7 +386,7 @@ AcpiDbUint32ToHexString ( for (i = 7; i >= 0; i--) { - Buffer[i] = Converter [Value & 0x0F]; + Buffer[i] = AcpiGbl_UpperHexDigits [Value & 0x0F]; Value = Value >> 4; } } @@ -505,8 +508,6 @@ AcpiDbDumpBuffer ( AcpiDbgLevel |= ACPI_LV_TABLES; AcpiUtDebugDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY, - ACPI_UINT32_MAX); + ACPI_UINT32_MAX); } #endif - -#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbxface.c b/sys/contrib/dev/acpica/components/debugger/dbxface.c index d72ee5e..2bcd47c 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbxface.c +++ b/sys/contrib/dev/acpica/components/debugger/dbxface.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,11 +45,8 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbxface") @@ -104,12 +101,10 @@ AcpiDbStartCommand ( { /* Handshake with the front-end that gets user command lines */ - Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); + + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { return (Status); @@ -140,7 +135,8 @@ AcpiDbStartCommand ( ACPI_DB_LINE_BUFFER_SIZE, NULL); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); + ACPI_EXCEPTION ((AE_INFO, Status, + "While parsing command line")); return (Status); } } @@ -156,6 +152,40 @@ AcpiDbStartCommand ( /******************************************************************************* * + * FUNCTION: AcpiDbSignalBreakPoint + * + * PARAMETERS: WalkState - Current walk + * + * RETURN: Status + * + * DESCRIPTION: Called for AML_BREAK_POINT_OP + * + ******************************************************************************/ + +void +AcpiDbSignalBreakPoint ( + ACPI_WALK_STATE *WalkState) +{ + +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ()) + { + return; + } +#endif + + /* + * Set the single-step flag. This will cause the debugger (if present) + * to break to the console within the AML debugger at the start of the + * next AML instruction. + */ + AcpiGbl_CmSingleStep = TRUE; + AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbSingleStep * * PARAMETERS: WalkState - Current walk @@ -179,11 +209,19 @@ AcpiDbSingleStep ( UINT32 OriginalDebugLevel; ACPI_PARSE_OBJECT *DisplayOp; ACPI_PARSE_OBJECT *ParentOp; + UINT32 AmlOffset; ACPI_FUNCTION_ENTRY (); +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ()) + { + return (AE_OK); + } +#endif + /* Check the abort flag */ if (AcpiGbl_AbortMethod) @@ -192,15 +230,18 @@ AcpiDbSingleStep ( return (AE_ABORT_METHOD); } + AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml, + WalkState->ParserState.AmlStart); + /* Check for single-step breakpoint */ if (WalkState->MethodBreakpoint && - (WalkState->MethodBreakpoint <= Op->Common.AmlOffset)) + (WalkState->MethodBreakpoint <= AmlOffset)) { /* Check if the breakpoint has been reached or passed */ /* Hit the breakpoint, resume single step, reset breakpoint */ - AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset); + AcpiOsPrintf ("***Break*** at AML offset %X\n", AmlOffset); AcpiGbl_CmSingleStep = TRUE; AcpiGbl_StepToNextCall = FALSE; WalkState->MethodBreakpoint = 0; @@ -209,10 +250,10 @@ AcpiDbSingleStep ( /* Check for user breakpoint (Must be on exact Aml offset) */ else if (WalkState->UserBreakpoint && - (WalkState->UserBreakpoint == Op->Common.AmlOffset)) + (WalkState->UserBreakpoint == AmlOffset)) { AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", - Op->Common.AmlOffset); + AmlOffset); AcpiGbl_CmSingleStep = TRUE; AcpiGbl_StepToNextCall = FALSE; WalkState->MethodBreakpoint = 0; @@ -394,7 +435,7 @@ AcpiDbSingleStep ( /******************************************************************************* * - * FUNCTION: AcpiDbInitialize + * FUNCTION: AcpiInitializeDebugger * * PARAMETERS: None * @@ -405,13 +446,13 @@ AcpiDbSingleStep ( ******************************************************************************/ ACPI_STATUS -AcpiDbInitialize ( +AcpiInitializeDebugger ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE (DbInitialize); + ACPI_FUNCTION_TRACE (AcpiInitializeDebugger); /* Init globals */ @@ -424,10 +465,6 @@ AcpiDbInitialize ( AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; - AcpiGbl_DbOpt_Disasm = FALSE; -#ifdef ACPI_DISASSEMBLER - AcpiGbl_DbOpt_Verbose = TRUE; -#endif AcpiGbl_DbOpt_NoIniMethods = FALSE; AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE); @@ -435,7 +472,7 @@ AcpiDbInitialize ( { return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE); + memset (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE); /* Initial scope is the root */ @@ -443,6 +480,10 @@ AcpiDbInitialize ( AcpiGbl_DbScopeBuf [1] = 0; AcpiGbl_DbScopeNode = AcpiGbl_RootNode; + /* Initialize user commands loop */ + + AcpiGbl_DbTerminateLoop = FALSE; + /* * If configured for multi-thread support, the debug executor runs in * a separate thread so that the front end can be in another address @@ -452,14 +493,16 @@ AcpiDbInitialize ( { /* These were created with one unit, grab it */ - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get debugger mutex\n"); return_ACPI_STATUS (Status); } - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get debugger mutex\n"); @@ -468,28 +511,31 @@ AcpiDbInitialize ( /* Create the debug execution thread to execute commands */ - Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL); + AcpiGbl_DbThreadsTerminated = FALSE; + Status = AcpiOsExecute (OSL_DEBUGGER_MAIN_THREAD, + AcpiDbExecuteThread, NULL); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not start debugger thread")); + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not start debugger thread")); + AcpiGbl_DbThreadsTerminated = TRUE; return_ACPI_STATUS (Status); } } - -#ifdef ACPI_DISASSEMBLER - if (!AcpiGbl_DbOpt_Verbose) + else { - AcpiGbl_DbOpt_Disasm = TRUE; + AcpiGbl_DbThreadId = AcpiOsGetThreadId (); } -#endif return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiInitializeDebugger) + /******************************************************************************* * - * FUNCTION: AcpiDbTerminate + * FUNCTION: AcpiTerminateDebugger * * PARAMETERS: None * @@ -500,10 +546,26 @@ AcpiDbInitialize ( ******************************************************************************/ void -AcpiDbTerminate ( +AcpiTerminateDebugger ( void) { + /* Terminate the AML Debugger */ + + AcpiGbl_DbTerminateLoop = TRUE; + + if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) + { + AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); + + /* Wait the AML Debugger threads */ + + while (!AcpiGbl_DbThreadsTerminated) + { + AcpiOsSleep (100); + } + } + if (AcpiGbl_DbBuffer) { AcpiOsFree (AcpiGbl_DbBuffer); @@ -515,34 +577,26 @@ AcpiDbTerminate ( AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT; } +ACPI_EXPORT_SYMBOL (AcpiTerminateDebugger) + -#ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * - * FUNCTION: AcpiDbMethodEnd + * FUNCTION: AcpiSetDebuggerThreadId * - * PARAMETERS: WalkState - Current walk + * PARAMETERS: ThreadId - Debugger thread ID * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Called at method termination + * DESCRIPTION: Set debugger thread ID * ******************************************************************************/ void -AcpiDbMethodEnd ( - ACPI_WALK_STATE *WalkState) +AcpiSetDebuggerThreadId ( + ACPI_THREAD_ID ThreadId) { - - if (!AcpiGbl_CmSingleStep) - { - return; - } - - AcpiOsPrintf ("<Method Terminating>\n"); - - AcpiDbStartCommand (WalkState, NULL); + AcpiGbl_DbThreadId = ThreadId; } -#endif -#endif /* ACPI_DEBUGGER */ +ACPI_EXPORT_SYMBOL (AcpiSetDebuggerThreadId) diff --git a/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c b/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c index 15b7e87..d4a9570 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,8 +50,6 @@ #include <contrib/dev/acpica/include/acinterp.h> -#ifdef ACPI_DISASSEMBLER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmbuffer") @@ -75,53 +73,13 @@ AcpiDmPldBuffer ( UINT8 *ByteData, UINT32 ByteCount); +static const char * +AcpiDmFindNameByIndex ( + UINT64 Index, + const char **List); -#define ACPI_BUFFER_BYTES_PER_LINE 8 - - -/* Strings for ToPld */ - -static char *DmPanelList[] = -{ - "TOP", - "BOTTOM", - "LEFT", - "RIGHT", - "FRONT", - "BACK", - "UNKNOWN", - NULL -}; - -static char *DmVerticalPositionList[] = -{ - "UPPER", - "CENTER", - "LOWER", - NULL -}; - -static char *DmHorizontalPositionList[] = -{ - "LEFT", - "CENTER", - "RIGHT", - NULL -}; -static char *DmShapeList[] = -{ - "ROUND", - "OVAL", - "SQUARE", - "VERTICALRECTANGLE", - "HORIZONTALRECTANGLE", - "VERTICALTRAPEZOID", - "HORIZONTALTRAPEZOID", - "UNKNOWN", - "CHAMFERED", - NULL -}; +#define ACPI_BUFFER_BYTES_PER_LINE 8 /******************************************************************************* @@ -205,7 +163,7 @@ AcpiDmDisasmByteList ( } BufChar = ByteData[CurrentIndex]; - if (ACPI_IS_PRINT (BufChar)) + if (isprint (BufChar)) { AcpiOsPrintf ("%c", BufChar); } @@ -256,7 +214,8 @@ AcpiDmByteList ( { case ACPI_DASM_RESOURCE: - AcpiDmResourceTemplate (Info, Op->Common.Parent, ByteData, ByteCount); + AcpiDmResourceTemplate ( + Info, Op->Common.Parent, ByteData, ByteCount); break; case ACPI_DASM_STRING: @@ -554,7 +513,7 @@ AcpiDmIsStringBuffer ( * they will be handled in the string output routine */ - if (!ACPI_IS_PRINT (ByteData[i])) + if (!isprint (ByteData[i])) { return (FALSE); } @@ -654,24 +613,24 @@ AcpiDmIsPldBuffer ( * ******************************************************************************/ -static char * +static const char * AcpiDmFindNameByIndex ( UINT64 Index, - char **List) + const char **List) { - char *Str; - UINT32 i; + const char *NameString; + UINT32 i; /* Bounds check */ - Str = List[0]; + NameString = List[0]; i = 0; - while(Str) + while (NameString) { i++; - Str = List[i]; + NameString = List[i]; } if (Index >= i) @@ -699,12 +658,12 @@ AcpiDmFindNameByIndex ( * ******************************************************************************/ -#define ACPI_PLD_OUTPUT08 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT08P "%*.s%-18s = 0x%X)\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT16 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT16P "%*.s%-18s = 0x%X)\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT24 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUTSTR "%*.s%-18s = \"%s\",\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT08 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT08P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT16 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT16P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT24 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUTSTR "%*.s%-22s = \"%s\",\n", ACPI_MUL_4 (Level), " " static void AcpiDmPldBuffer ( @@ -752,14 +711,18 @@ AcpiDmPldBuffer ( AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Dock", PldInfo->Dock); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Lid", PldInfo->Lid); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Panel", - AcpiDmFindNameByIndex(PldInfo->Panel, DmPanelList)); + AcpiDmFindNameByIndex(PldInfo->Panel, AcpiGbl_PldPanelList)); + AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_VerticalPosition", - AcpiDmFindNameByIndex(PldInfo->VerticalPosition, DmVerticalPositionList)); + AcpiDmFindNameByIndex(PldInfo->VerticalPosition, AcpiGbl_PldVerticalPositionList)); + AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_HorizontalPosition", - AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, DmHorizontalPositionList)); + AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, AcpiGbl_PldHorizontalPositionList)); + AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Shape", - AcpiDmFindNameByIndex(PldInfo->Shape, DmShapeList)); + AcpiDmFindNameByIndex(PldInfo->Shape, AcpiGbl_PldShapeList)); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupOrientation", PldInfo->GroupOrientation); + AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupToken", PldInfo->GroupToken); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupPosition", PldInfo->GroupPosition); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Bay", PldInfo->Bay); @@ -773,22 +736,19 @@ AcpiDmPldBuffer ( AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Reference", PldInfo->Reference); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Rotation", PldInfo->Rotation); - if (ByteCount < ACPI_PLD_REV1_BUFFER_SIZE) - { - AcpiOsPrintf (ACPI_PLD_OUTPUT08P, "PLD_Order", PldInfo->Order); - } - else + if (ByteCount >= ACPI_PLD_REV2_BUFFER_SIZE) { AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Order", PldInfo->Order); - } - /* Fifth 32-bit dword */ + /* Fifth 32-bit dword */ - if (ByteCount >= ACPI_PLD_REV1_BUFFER_SIZE) - { - AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_VerticalOffset", PldInfo->VerticalOffset); + AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_VerticalOffset", PldInfo->VerticalOffset); AcpiOsPrintf (ACPI_PLD_OUTPUT16P, "PLD_HorizontalOffset", PldInfo->HorizontalOffset); } + else /* Rev 1 buffer */ + { + AcpiOsPrintf (ACPI_PLD_OUTPUT08P, "PLD_Order", PldInfo->Order); + } ACPI_FREE (PldInfo); } @@ -836,7 +796,7 @@ AcpiDmUnicode ( { AcpiOsPrintf ("\\%c", OutputValue); } - else if (!ACPI_IS_PRINT (OutputValue)) + else if (!isprint (OutputValue)) { AcpiOsPrintf ("\\x%2.2X", OutputValue); } @@ -902,7 +862,7 @@ AcpiDmGetHardwareIdType ( for (i = 0; i < 3; i++) { if (!ACPI_IS_ASCII (Prefix[i]) || - !ACPI_IS_ALPHA (Prefix[i])) + !isalpha (Prefix[i])) { return; } @@ -1030,5 +990,3 @@ AcpiDmDecompressEisaId ( AcpiOsPrintf (" /* %s */", Info->Description); } } - -#endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c b/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c index b66dbed..a7049ef 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,10 +45,8 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/amlcode.h> -#include <contrib/dev/acpica/include/acdisasm.h> #include <contrib/dev/acpica/include/acdebug.h> -#ifdef ACPI_DISASSEMBLER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmcstyle") @@ -217,6 +215,7 @@ AcpiDmCheckForSymbolicOpcode ( Child1->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX; Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX; + Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND_ASSIGNMENT; /* Save symbol string in the next child (not peer) */ @@ -229,12 +228,27 @@ AcpiDmCheckForSymbolicOpcode ( Child2->Common.OperatorSymbol = OperatorSymbol; return (TRUE); -#ifdef INDEX_SUPPORT case AML_INDEX_OP: + /* + * Check for constant source operand. Note: although technically + * legal syntax, the iASL compiler does not support this with + * the symbolic operators for Index(). It doesn't make sense to + * use Index() with a constant anyway. + */ + if ((Child1->Common.AmlOpcode == AML_STRING_OP) || + (Child1->Common.AmlOpcode == AML_BUFFER_OP) || + (Child1->Common.AmlOpcode == AML_PACKAGE_OP) || + (Child1->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + Op->Common.DisasmFlags |= ACPI_PARSEOP_CLOSING_PAREN; + return (FALSE); + } + + /* Index operator is [] */ + Child1->Common.OperatorSymbol = " ["; Child2->Common.OperatorSymbol = "]"; break; -#endif /* Unary operators */ @@ -337,23 +351,70 @@ AcpiDmCheckForSymbolicOpcode ( */ AcpiDmPromoteTarget (Op, Target); - /* - * Check for possible conversion to a "Compound Assignment". - * - * Determine if either operand is the same as the target - * and display compound assignment operator and other operand. - */ - if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)) || - (AcpiDmIsTargetAnOperand (Target, Child2, TRUE))) + /* Check operands for conversion to a "Compound Assignment" */ + + switch (Op->Common.AmlOpcode) { - Target->Common.OperatorSymbol = - AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode); + /* Commutative operators */ - /* Convert operator to compound assignment */ + case AML_ADD_OP: + case AML_MULTIPLY_OP: + case AML_BIT_AND_OP: + case AML_BIT_OR_OP: + case AML_BIT_XOR_OP: + /* + * For the commutative operators, we can convert to a + * compound statement only if at least one (either) operand + * is the same as the target. + * + * Add (A, B, A) --> A += B + * Add (B, A, A) --> A += B + * Add (B, C, A) --> A = (B + C) + */ + if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)) || + (AcpiDmIsTargetAnOperand (Target, Child2, TRUE))) + { + Target->Common.OperatorSymbol = + AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode); - Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND; - Child1->Common.OperatorSymbol = NULL; - return (TRUE); + /* Convert operator to compound assignment */ + + Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND_ASSIGNMENT; + Child1->Common.OperatorSymbol = NULL; + return (TRUE); + } + break; + + /* Non-commutative operators */ + + case AML_SUBTRACT_OP: + case AML_DIVIDE_OP: + case AML_MOD_OP: + case AML_SHIFT_LEFT_OP: + case AML_SHIFT_RIGHT_OP: + /* + * For the non-commutative operators, we can convert to a + * compound statement only if the target is the same as the + * first operand. + * + * Subtract (A, B, A) --> A -= B + * Subtract (B, A, A) --> A = (B - A) + */ + if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE))) + { + Target->Common.OperatorSymbol = + AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode); + + /* Convert operator to compound assignment */ + + Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND_ASSIGNMENT; + Child1->Common.OperatorSymbol = NULL; + return (TRUE); + } + break; + + default: + break; } /* @@ -397,7 +458,6 @@ AcpiDmCheckForSymbolicOpcode ( case AML_INCREMENT_OP: return (TRUE); -#ifdef INDEX_SUPPORT case AML_INDEX_OP: /* Target is optional, 3rd operand */ @@ -413,7 +473,6 @@ AcpiDmCheckForSymbolicOpcode ( } } return (TRUE); -#endif case AML_STORE_OP: /* @@ -423,8 +482,12 @@ AcpiDmCheckForSymbolicOpcode ( * source so that the target is processed first. */ Target = Child1->Common.Next; - AcpiDmPromoteTarget (Op, Target); + if (!Target) + { + return (FALSE); + } + AcpiDmPromoteTarget (Op, Target); if (!Target->Common.OperatorSymbol) { Target->Common.OperatorSymbol = " = "; @@ -460,6 +523,19 @@ AcpiDmCheckForSymbolicOpcode ( break; } + /* + * Nodes marked with ACPI_PARSEOP_PARAMLIST don't need a parens + * output here. We also need to check the parent to see if this op + * is part of a compound test (!=, >=, <=). + */ + if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) || + ((Op->Common.Parent->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) && + (Op->Common.DisasmOpcode == ACPI_DASM_LNOT_SUFFIX))) + { + /* Do Nothing. Paren already generated */ + return (TRUE); + } + /* All other operators, emit an open paren */ AcpiOsPrintf ("("); @@ -485,6 +561,7 @@ void AcpiDmCloseOperator ( ACPI_PARSE_OBJECT *Op) { + BOOLEAN IsCStyleOp = FALSE; /* Always emit paren if ASL+ disassembly disabled */ @@ -516,7 +593,7 @@ AcpiDmCloseOperator ( /* Emit paren only if this is not a compound assignment */ - if (Op->Common.DisasmFlags & ACPI_PARSEOP_COMPOUND) + if (Op->Common.DisasmFlags & ACPI_PARSEOP_COMPOUND_ASSIGNMENT) { return; } @@ -527,14 +604,22 @@ AcpiDmCloseOperator ( { AcpiOsPrintf (")"); } + + IsCStyleOp = TRUE; break; + case AML_INDEX_OP: + + /* This is case for unsupported Index() source constants */ + + if (Op->Common.DisasmFlags & ACPI_PARSEOP_CLOSING_PAREN) + { + AcpiOsPrintf (")"); + } + return; /* No need for parens for these */ -#ifdef INDEX_SUPPORT - case AML_INDEX_OP: -#endif case AML_DECREMENT_OP: case AML_INCREMENT_OP: case AML_LNOT_OP: @@ -548,7 +633,21 @@ AcpiDmCloseOperator ( break; } + /* + * Nodes marked with ACPI_PARSEOP_PARAMLIST don't need a parens + * output here. We also need to check the parent to see if this op + * is part of a compound test (!=, >=, <=). + */ + if (IsCStyleOp && + ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) || + ((Op->Common.Parent->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) && + (Op->Common.DisasmOpcode == ACPI_DASM_LNOT_SUFFIX)))) + { + return; + } + AcpiOsPrintf (")"); + return; } @@ -617,6 +716,7 @@ AcpiDmGetCompoundSymbol ( default: /* No operator string for all other opcodes */ + return (NULL); } @@ -674,7 +774,8 @@ AcpiDmPromoteTarget ( * * DESCRIPTION: Determine if a Target Op is a placeholder Op or a real Target. * In other words, determine if the optional target is used or - * not. + * not. Note: If Target is NULL, something is seriously wrong, + * probably with the parse tree. * ******************************************************************************/ @@ -683,6 +784,11 @@ AcpiDmIsValidTarget ( ACPI_PARSE_OBJECT *Target) { + if (!Target) + { + return (FALSE); + } + if ((Target->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && (Target->Common.Value.Arg == NULL)) { @@ -769,5 +875,3 @@ AcpiDmIsTargetAnOperand ( } return (TRUE); } - -#endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c b/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c index 9bf7451..5900614 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -105,7 +105,8 @@ AcpiDmParseDeferredOps ( case AML_PACKAGE_OP: case AML_VAR_PACKAGE_OP: - Status = AcpiDmDeferredParse (Op, Op->Named.Data, Op->Named.Length); + Status = AcpiDmDeferredParse ( + Op, Op->Named.Data, Op->Named.Length); if (ACPI_FAILURE (Status)) { return (Status); @@ -165,7 +166,6 @@ AcpiDmDeferredParse ( ACPI_STATUS Status; ACPI_PARSE_OBJECT *SearchOp; ACPI_PARSE_OBJECT *StartOp; - UINT32 BaseAmlOffset; ACPI_PARSE_OBJECT *NewRootOp; ACPI_PARSE_OBJECT *ExtraOp; @@ -202,19 +202,10 @@ AcpiDmDeferredParse ( WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiPsParseAml (WalkState); - /* - * We need to update all of the AML offsets, since the parser thought - * that the method began at offset zero. In reality, it began somewhere - * within the ACPI table, at the BaseAmlOffset. Walk the entire tree that - * was just created and update the AmlOffset in each Op. - */ - BaseAmlOffset = (Op->Common.Value.Arg)->Common.AmlOffset + 1; StartOp = (Op->Common.Value.Arg)->Common.Next; SearchOp = StartOp; - while (SearchOp) { - SearchOp->Common.AmlOffset += BaseAmlOffset; SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp); } diff --git a/sys/contrib/dev/acpica/components/disassembler/dmnames.c b/sys/contrib/dev/acpica/components/disassembler/dmnames.c index 07a90ff..d75db19 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmnames.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,8 +48,6 @@ #include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DISASSEMBLER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmnames") @@ -157,15 +155,15 @@ AcpiPsDisplayObjectPathname ( /* Node not defined in this scope, look it up */ Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { /* - * We can't get the pathname since the object - * is not in the namespace. This can happen during single - * stepping where a dynamic named object is *about* to be created. + * We can't get the pathname since the object is not in the + * namespace. This can happen during single stepping + * where a dynamic named object is *about* to be created. */ AcpiOsPrintf (" [Path not found]"); goto Exit; @@ -179,7 +177,7 @@ AcpiPsDisplayObjectPathname ( /* Convert NamedDesc/handle to a full pathname */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (Node, &Buffer); + Status = AcpiNsHandleToPathname (Node, &Buffer, FALSE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("****Could not get pathname****)"); @@ -271,6 +269,7 @@ AcpiDmNamestring ( AcpiOsPrintf ("."); } + Name += ACPI_NAME_SIZE; } } @@ -334,7 +333,6 @@ AcpiDmDisplayPath ( } Prev = NULL; /* Start with Root Node */ - while (Prev != Op) { /* Search upwards in the tree to find scope with "prev" as its parent */ @@ -392,6 +390,7 @@ AcpiDmDisplayPath ( DoDot = TRUE; } } + Prev = Search; } } @@ -414,6 +413,8 @@ AcpiDmValidateName ( char *Name, ACPI_PARSE_OBJECT *Op) { + ACPI_PARSE_OBJECT *TargetOp; + if ((!Name) || (!Op->Common.Parent)) @@ -427,9 +428,6 @@ AcpiDmValidateName ( " /**** Name not found or not accessible from this scope ****/ "); } - ACPI_PARSE_OBJECT *TargetOp; - - if ((!Name) || (!Op->Common.Parent)) { @@ -450,5 +448,3 @@ AcpiDmValidateName ( } } #endif - -#endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmopcode.c b/sys/contrib/dev/acpica/components/disassembler/dmopcode.c index b10d433..2ca1c85 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmopcode.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmopcode.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,11 +45,10 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/amlcode.h> -#include <contrib/dev/acpica/include/acdisasm.h> #include <contrib/dev/acpica/include/acinterp.h> #include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/include/acdebug.h> -#ifdef ACPI_DISASSEMBLER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmopcode") @@ -61,6 +60,10 @@ static void AcpiDmMatchKeyword ( ACPI_PARSE_OBJECT *Op); +static void +AcpiDmConvertToElseIf ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -246,11 +249,11 @@ AcpiDmPredefinedDescription ( /* Ensure that the comment field is emitted only once */ - if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED) + if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEFINED_CHECKED) { return; } - Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED; + Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEFINED_CHECKED; /* Predefined name must start with an underscore */ @@ -269,10 +272,10 @@ AcpiDmPredefinedDescription ( * Note: NameString is guaranteed to be upper case here. */ LastCharIsDigit = - (ACPI_IS_DIGIT (NameString[3])); /* d */ + (isdigit ((int) NameString[3])); /* d */ LastCharsAreHex = - (ACPI_IS_XDIGIT (NameString[2]) && /* xx */ - ACPI_IS_XDIGIT (NameString[3])); + (isxdigit ((int) NameString[2]) && /* xx */ + isxdigit ((int) NameString[3])); switch (NameString[1]) { @@ -382,11 +385,11 @@ AcpiDmFieldPredefinedDescription ( /* Ensure that the comment field is emitted only once */ - if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED) + if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEFINED_CHECKED) { return; } - Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED; + Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEFINED_CHECKED; /* * Op must be one of the Create* operators: CreateField, CreateBitField, @@ -643,8 +646,8 @@ AcpiDmMatchKeyword ( } else { - AcpiOsPrintf ("%s", ACPI_CAST_PTR (char, - AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer])); + AcpiOsPrintf ("%s", + AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]); } } @@ -684,6 +687,11 @@ AcpiDmDisassembleOneOp ( return; } + if (Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF) + { + return; /* ElseIf macro was already emitted */ + } + switch (Op->Common.DisasmOpcode) { case ACPI_DASM_MATCHOP: @@ -821,7 +829,9 @@ AcpiDmDisassembleOneOp ( } else if (Status == AE_AML_NO_RESOURCE_END_TAG) { - AcpiOsPrintf ("/**** Is ResourceTemplate, but EndTag not at buffer end ****/ "); + AcpiOsPrintf ( + "/**** Is ResourceTemplate, " + "but EndTag not at buffer end ****/ "); } } @@ -896,7 +906,8 @@ AcpiDmDisassembleOneOp ( if (Op->Common.AmlOpcode == AML_INT_EXTACCESSFIELD_OP) { - AcpiOsPrintf (" (0x%2.2X)", (unsigned) ((Op->Common.Value.Integer >> 16) & 0xFF)); + AcpiOsPrintf (" (0x%2.2X)", (unsigned) + ((Op->Common.Value.Integer >> 16) & 0xFF)); } AcpiOsPrintf (")"); @@ -953,6 +964,24 @@ AcpiDmDisassembleOneOp ( AcpiDmNamestring (Op->Common.Value.Name); break; + case AML_ELSE_OP: + + AcpiDmConvertToElseIf (Op); + break; + + case AML_EXTERNAL_OP: + + if (AcpiGbl_DmEmitExternalOpcodes) + { + AcpiOsPrintf ("/* Opcode 0x15 */ "); + + /* Fallthrough */ + } + else + { + break; + } + default: /* Just get the opcode name and print it */ @@ -967,7 +996,7 @@ AcpiDmDisassembleOneOp ( (WalkState->Results) && (WalkState->ResultCount)) { - AcpiDmDecodeInternalObject ( + AcpiDbDecodeInternalObject ( WalkState->Results->Results.ObjDesc [ (WalkState->ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM]); @@ -978,4 +1007,118 @@ AcpiDmDisassembleOneOp ( } } -#endif /* ACPI_DISASSEMBLER */ + +/******************************************************************************* + * + * FUNCTION: AcpiDmConvertToElseIf + * + * PARAMETERS: OriginalElseOp - ELSE Object to be examined + * + * RETURN: None. Emits either an "Else" or an "ElseIf" ASL operator. + * + * DESCRIPTION: Detect and convert an If..Else..If sequence to If..ElseIf + * + * EXAMPLE: + * + * This If..Else..If nested sequence: + * + * If (Arg0 == 1) + * { + * Local0 = 4 + * } + * Else + * { + * If (Arg0 == 2) + * { + * Local0 = 5 + * } + * } + * + * Is converted to this simpler If..ElseIf sequence: + * + * If (Arg0 == 1) + * { + * Local0 = 4 + * } + * ElseIf (Arg0 == 2) + * { + * Local0 = 5 + * } + * + * NOTE: There is no actual ElseIf AML opcode. ElseIf is essentially an ASL + * macro that emits an Else opcode followed by an If opcode. This function + * reverses these AML sequences back to an ElseIf macro where possible. This + * can make the disassembled ASL code simpler and more like the original code. + * + ******************************************************************************/ + +static void +AcpiDmConvertToElseIf ( + ACPI_PARSE_OBJECT *OriginalElseOp) +{ + ACPI_PARSE_OBJECT *IfOp; + ACPI_PARSE_OBJECT *ElseOp; + + + /* + * To be able to perform the conversion, two conditions must be satisfied: + * 1) The first child of the Else must be an If statement. + * 2) The If block can only be followed by an Else block and these must + * be the only blocks under the original Else. + */ + IfOp = OriginalElseOp->Common.Value.Arg; + if (!IfOp || + (IfOp->Common.AmlOpcode != AML_IF_OP) || + (IfOp->Asl.Next && (IfOp->Asl.Next->Common.AmlOpcode != AML_ELSE_OP))) + { + /* Not an Else..If sequence, cannot convert to ElseIf */ + + AcpiOsPrintf ("%s", "Else"); + return; + } + + /* Emit ElseIf, mark the IF as now an ELSEIF */ + + AcpiOsPrintf ("%s", "ElseIf"); + IfOp->Common.DisasmFlags |= ACPI_PARSEOP_ELSEIF; + + /* The IF parent will now be the same as the original ELSE parent */ + + IfOp->Common.Parent = OriginalElseOp->Common.Parent; + + /* + * Update the NEXT pointers to restructure the parse tree, essentially + * promoting an If..Else block up to the same level as the original + * Else. + * + * Check if the IF has a corresponding ELSE peer + */ + ElseOp = IfOp->Common.Next; + if (ElseOp && + (ElseOp->Common.AmlOpcode == AML_ELSE_OP)) + { + /* If an ELSE matches the IF, promote it also */ + + ElseOp->Common.Parent = OriginalElseOp->Common.Parent; + ElseOp->Common.Next = OriginalElseOp->Common.Next; + } + else + { + /* Otherwise, set the IF NEXT to the original ELSE NEXT */ + + IfOp->Common.Next = OriginalElseOp->Common.Next; + } + + /* Detach the child IF block from the original ELSE */ + + OriginalElseOp->Common.Value.Arg = NULL; + + /* Ignore the original ELSE from now on */ + + OriginalElseOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + OriginalElseOp->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX; + + /* Insert IF (now ELSEIF) as next peer of the original ELSE */ + + OriginalElseOp->Common.Next = IfOp; +} diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrc.c b/sys/contrib/dev/acpica/components/disassembler/dmresrc.c index 2a8147e..57903a9 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrc.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,6 @@ #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DISASSEMBLER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbresrc") @@ -146,7 +145,7 @@ AcpiDmDescriptorName ( void AcpiDmDumpInteger8 ( UINT8 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%2.2X, // %s\n", Value, Name); } @@ -154,7 +153,7 @@ AcpiDmDumpInteger8 ( void AcpiDmDumpInteger16 ( UINT16 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%4.4X, // %s\n", Value, Name); } @@ -162,7 +161,7 @@ AcpiDmDumpInteger16 ( void AcpiDmDumpInteger32 ( UINT32 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%8.8X, // %s\n", Value, Name); } @@ -170,7 +169,7 @@ AcpiDmDumpInteger32 ( void AcpiDmDumpInteger64 ( UINT64 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n", ACPI_FORMAT_UINT64 (Value), Name); } @@ -213,6 +212,7 @@ AcpiDmBitList ( { AcpiOsPrintf (","); } + Previous = TRUE; AcpiOsPrintf ("%u", i); } @@ -286,7 +286,8 @@ AcpiDmResourceTemplate ( Status = AcpiUtValidateResource (NULL, Aml, &ResourceIndex); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("/*** Could not validate Resource, type (%X) %s***/\n", + AcpiOsPrintf ( + "/*** Could not validate Resource, type (%X) %s***/\n", ResourceType, AcpiFormatException (Status)); return; } @@ -336,7 +337,8 @@ AcpiDmResourceTemplate ( AcpiDmIndent (Level); AcpiOsPrintf ( - "/*** Disassembler: inserted missing EndDependentFn () ***/\n"); + "/*** Disassembler: inserted " + "missing EndDependentFn () ***/\n"); } return; @@ -444,5 +446,3 @@ AcpiDmIsResourceTemplate ( */ return (AE_OK); } - -#endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c index b0cf41e..50b4bd6 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,15 +46,13 @@ #include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DISASSEMBLER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbresrcl") /* Common names for address and memory descriptors */ -static char *AcpiDmAddressNames[] = +static const char *AcpiDmAddressNames[] = { "Granularity", "Range Minimum", @@ -63,7 +61,7 @@ static char *AcpiDmAddressNames[] = "Length" }; -static char *AcpiDmMemoryNames[] = +static const char *AcpiDmMemoryNames[] = { "Range Minimum", "Range Maximum", @@ -309,7 +307,8 @@ AcpiDmAddressCommon ( if ((ResourceType > 2) && (ResourceType < 0xC0)) { - AcpiOsPrintf ("/**** Invalid Resource Type: 0x%X ****/", ResourceType); + AcpiOsPrintf ( + "/**** Invalid Resource Type: 0x%X ****/", ResourceType); return; } @@ -329,7 +328,8 @@ AcpiDmAddressCommon ( /* This is either a Memory, IO, or BusNumber descriptor (0,1,2) */ - AcpiOsPrintf ("%s (", AcpiGbl_WordDecode [ACPI_GET_2BIT_FLAG (ResourceType)]); + AcpiOsPrintf ("%s (", + AcpiGbl_WordDecode [ACPI_GET_2BIT_FLAG (ResourceType)]); /* Decode the general and type-specific flags */ @@ -342,7 +342,8 @@ AcpiDmAddressCommon ( AcpiDmIoFlags (Flags); if (ResourceType == ACPI_IO_RANGE) { - AcpiOsPrintf (" %s,", AcpiGbl_RngDecode [ACPI_GET_2BIT_FLAG (SpecificFlags)]); + AcpiOsPrintf (" %s,", + AcpiGbl_RngDecode [ACPI_GET_2BIT_FLAG (SpecificFlags)]); } } } @@ -737,7 +738,8 @@ AcpiDmExtendedDescriptor ( /* Dump resource name and flags */ - AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, Level); + AcpiDmAddressCommon ( + Resource, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, Level); /* Dump the 5 contiguous QWORD values */ @@ -873,10 +875,12 @@ AcpiDmFixedMemory32Descriptor ( AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->FixedMemory32.Flags)]); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger32 (Resource->FixedMemory32.Address, "Address Base"); + AcpiDmDumpInteger32 (Resource->FixedMemory32.Address, + "Address Base"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength, "Address Length"); + AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength, + "Address Length"); /* Insert a descriptor name */ @@ -1024,7 +1028,7 @@ AcpiDmInterruptDescriptor ( void AcpiDmVendorCommon ( - char *Name, + const char *Name, UINT8 *ByteData, UINT32 Length, UINT32 Level) @@ -1079,5 +1083,3 @@ AcpiDmVendorLargeDescriptor ( ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_LARGE_HEADER)), Length, Level); } - -#endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c index ff5fabc..58cdd7b 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,8 +46,6 @@ #include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DISASSEMBLER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbresrcl2") @@ -154,6 +152,7 @@ AcpiDmDumpRawDataBuffer ( AcpiOsPrintf (", "); } + AcpiOsPrintf ("\n"); AcpiDmIndent (Level + 2); @@ -199,7 +198,8 @@ AcpiDmGpioCommon ( AcpiDmIndent (Level + 1); if (Resource->Gpio.ResSourceOffset) { - DeviceName = ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset), + DeviceName = ACPI_ADD_PTR (char, + Resource, Resource->Gpio.ResSourceOffset), AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX); } @@ -243,14 +243,16 @@ AcpiDmGpioCommon ( for (i = 0; i < PinCount; i++) { AcpiDmIndent (Level + 2); - AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], ((i + 1) < PinCount) ? "," : ""); + AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], + ((i + 1) < PinCount) ? "," : ""); } AcpiDmIndent (Level + 1); AcpiOsPrintf ("}\n"); #ifndef _KERNEL - MpSaveGpioInfo (Info->MappingOp, Resource, PinCount, PinList, DeviceName); + MpSaveGpioInfo (Info->MappingOp, Resource, + PinCount, PinList, DeviceName); #endif } @@ -500,7 +502,7 @@ AcpiDmI2cSerialBusDescriptor ( /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */ AcpiDmIndent (Level); - AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n", + AcpiOsPrintf ("I2cSerialBusV2 (0x%4.4X, %s, 0x%8.8X,\n", Resource->I2cSerialBus.SlaveAddress, AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)], Resource->I2cSerialBus.ConnectionSpeed); @@ -529,7 +531,11 @@ AcpiDmI2cSerialBusDescriptor ( /* Insert a descriptor name */ AcpiDmDescriptorName (); - AcpiOsPrintf (",\n"); + + /* Share */ + + AcpiOsPrintf (", %s,\n", + AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->I2cSerialBus.Flags, 2)]); /* Dump the vendor data */ @@ -572,7 +578,7 @@ AcpiDmSpiSerialBusDescriptor ( /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */ AcpiDmIndent (Level); - AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n", + AcpiOsPrintf ("SpiSerialBusV2 (0x%4.4X, %s, %s, 0x%2.2X,\n", Resource->SpiSerialBus.DeviceSelection, AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)], AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)], @@ -610,7 +616,11 @@ AcpiDmSpiSerialBusDescriptor ( /* Insert a descriptor name */ AcpiDmDescriptorName (); - AcpiOsPrintf (",\n"); + + /* Share */ + + AcpiOsPrintf (", %s,\n", + AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.Flags, 2)]); /* Dump the vendor data */ @@ -653,7 +663,7 @@ AcpiDmUartSerialBusDescriptor ( /* ConnectionSpeed, BitsPerByte, StopBits */ AcpiDmIndent (Level); - AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n", + AcpiOsPrintf ("UartSerialBusV2 (0x%8.8X, %s, %s,\n", Resource->UartSerialBus.DefaultBaudRate, AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)], AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]); @@ -694,7 +704,11 @@ AcpiDmUartSerialBusDescriptor ( /* Insert a descriptor name */ AcpiDmDescriptorName (); - AcpiOsPrintf (",\n"); + + /* Share */ + + AcpiOsPrintf (", %s,\n", + AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.Flags, 2)]); /* Dump the vendor data */ @@ -734,5 +748,3 @@ AcpiDmSerialBusDescriptor ( SerialBusResourceDispatch [Resource->CommonSerialBus.Type] ( Info, Resource, Length, Level); } - -#endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c index 31b68b2..2840f80 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,8 +46,6 @@ #include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DISASSEMBLER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbresrcs") @@ -173,7 +171,8 @@ AcpiDmFixedDmaDescriptor ( } else { - AcpiOsPrintf ("%X /* INVALID DMA WIDTH */, ", Resource->FixedDma.Width); + AcpiOsPrintf ("%X /* INVALID DMA WIDTH */, ", + Resource->FixedDma.Width); } /* Insert a descriptor name */ @@ -368,5 +367,3 @@ AcpiDmVendorSmallDescriptor ( ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_SMALL_HEADER)), Length, Level); } - -#endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmutils.c b/sys/contrib/dev/acpica/components/disassembler/dmutils.c index bdc252e..32cc4b6 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmutils.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,7 +50,6 @@ #include <contrib/dev/acpica/include/acnamesp.h> #endif -#ifdef ACPI_DISASSEMBLER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmutils") @@ -228,7 +227,7 @@ AcpiDmIndent ( return; } - AcpiOsPrintf ("%*.s", ACPI_MUL_4 (Level), " "); + AcpiOsPrintf ("%*.s", (Level * 4), " "); } @@ -280,8 +279,8 @@ AcpiDmCommaIfListMember ( } } - if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) && - (!(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))) + if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) && + (!(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))) { return (FALSE); } @@ -296,8 +295,8 @@ AcpiDmCommaIfListMember ( return (TRUE); } - else if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) && - (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) + else if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) && + (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) { AcpiOsPrintf (", "); return (TRUE); @@ -329,5 +328,3 @@ AcpiDmCommaIfFieldMember ( AcpiOsPrintf (", "); } } - -#endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmwalk.c b/sys/contrib/dev/acpica/components/disassembler/dmwalk.c index 2dbaa84..9621862 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmwalk.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmwalk.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,12 +45,9 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/amlcode.h> -#include <contrib/dev/acpica/include/acdisasm.h> #include <contrib/dev/acpica/include/acdebug.h> -#ifdef ACPI_DISASSEMBLER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmwalk") @@ -117,10 +114,11 @@ AcpiDmDisassemble ( return; } - Info.Flags = 0; - Info.Level = 0; - Info.Count = 0; + memset (&Info, 0, sizeof (ACPI_OP_WALK_INFO)); Info.WalkState = WalkState; + Info.StartAml = Op->Common.Aml - sizeof (ACPI_TABLE_HEADER); + Info.AmlOffset = Op->Common.Aml - Info.StartAml; + AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info); return; } @@ -313,6 +311,8 @@ AcpiDmBlockType ( return (BLOCK_NONE); } + /*lint -fallthrough */ + default: OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); @@ -410,7 +410,43 @@ AcpiDmDescendingOp ( const ACPI_OPCODE_INFO *OpInfo; UINT32 Name; ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *NextOp2; + UINT32 AmlOffset; + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + + /* Listing support to dump the AML code after the ASL statement */ + + if (AcpiGbl_DmOpt_Listing) + { + /* We only care about these classes of objects */ + + if ((OpInfo->Class == AML_CLASS_NAMED_OBJECT) || + (OpInfo->Class == AML_CLASS_CONTROL) || + (OpInfo->Class == AML_CLASS_CREATE) || + ((OpInfo->Class == AML_CLASS_EXECUTE) && (!Op->Common.Next))) + { + if (AcpiGbl_DmOpt_Listing && Info->PreviousAml) + { + /* Dump the AML byte code for the previous Op */ + + if (Op->Common.Aml > Info->PreviousAml) + { + AcpiOsPrintf ("\n"); + AcpiUtDumpBuffer ( + (Info->StartAml + Info->AmlOffset), + (Op->Common.Aml - Info->PreviousAml), + DB_BYTE_DISPLAY, Info->AmlOffset); + AcpiOsPrintf ("\n"); + } + + Info->AmlOffset = (Op->Common.Aml - Info->StartAml); + } + Info->PreviousAml = Op->Common.Aml; + } + } if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) { @@ -419,6 +455,38 @@ AcpiDmDescendingOp ( return (AE_CTRL_DEPTH); } + if (Op->Common.AmlOpcode == AML_IF_OP) + { + NextOp = AcpiPsGetDepthNext (NULL, Op); + if (NextOp) + { + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; + + /* Don't emit the actual embedded externals unless asked */ + + if (!AcpiGbl_DmEmitExternalOpcodes) + { + /* + * A Zero predicate indicates the possibility of one or more + * External() opcodes within the If() block. + */ + if (NextOp->Common.AmlOpcode == AML_ZERO_OP) + { + NextOp2 = NextOp->Common.Next; + + if (NextOp2 && + (NextOp2->Common.AmlOpcode == AML_EXTERNAL_OP)) + { + /* Ignore the If 0 block and all children */ + + Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + return (AE_CTRL_DEPTH); + } + } + } + } + } + /* Level 0 is at the Definition Block level */ if (Level == 0) @@ -427,10 +495,15 @@ AcpiDmDescendingOp ( if (Info->WalkState) { - VERBOSE_PRINT ((DB_FULL_OP_INFO, - (Info->WalkState->MethodNode ? - Info->WalkState->MethodNode->Name.Ascii : " "), - Op->Common.AmlOffset, (UINT32) Op->Common.AmlOpcode)); + AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml, + Info->WalkState->ParserState.AmlStart); + if (AcpiGbl_DmOpt_Verbose) + { + AcpiOsPrintf (DB_FULL_OP_INFO, + (Info->WalkState->MethodNode ? + Info->WalkState->MethodNode->Name.Ascii : " "), + AmlOffset, (UINT32) Op->Common.AmlOpcode); + } } if (Op->Common.AmlOpcode == AML_SCOPE_OP) @@ -446,40 +519,41 @@ AcpiDmDescendingOp ( } } else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && - (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && - (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) + (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) && + (!(Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)) && + (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { + /* + * This is a first-level element of a term list, + * indent a new line + */ + switch (Op->Common.AmlOpcode) + { + case AML_NOOP_OP: /* - * This is a first-level element of a term list, - * indent a new line + * Optionally just ignore this opcode. Some tables use + * NoOp opcodes for "padding" out packages that the BIOS + * changes dynamically. This can leave hundreds or + * thousands of NoOp opcodes that if disassembled, + * cannot be compiled because they are syntactically + * incorrect. */ - switch (Op->Common.AmlOpcode) + if (AcpiGbl_IgnoreNoopOperator) { - case AML_NOOP_OP: - /* - * Optionally just ignore this opcode. Some tables use - * NoOp opcodes for "padding" out packages that the BIOS - * changes dynamically. This can leave hundreds or - * thousands of NoOp opcodes that if disassembled, - * cannot be compiled because they are syntactically - * incorrect. - */ - if (AcpiGbl_IgnoreNoopOperator) - { - Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; - return (AE_OK); - } + Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + return (AE_OK); + } - /* Fallthrough */ + /* Fallthrough */ - default: + default: - AcpiDmIndent (Level); - break; - } + AcpiDmIndent (Level); + break; + } - Info->LastLevel = Level; - Info->Count = 0; + Info->LastLevel = Level; + Info->Count = 0; } /* @@ -521,8 +595,6 @@ AcpiDmDescendingOp ( /* Start the opcode argument list if necessary */ - OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - if ((OpInfo->Flags & AML_HAS_ARGS) || (Op->Common.AmlOpcode == AML_EVENT_OP)) { @@ -562,7 +634,7 @@ AcpiDmDescendingOp ( if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP) { - if (AcpiGbl_DbOpt_Verbose) + if (AcpiGbl_DmOpt_Verbose) { (void) AcpiPsDisplayObjectPathname (NULL, Op); } @@ -601,10 +673,10 @@ AcpiDmDescendingOp ( AcpiOsPrintf (", "); NextOp = AcpiPsGetDepthNext (NULL, Op); - NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; NextOp = NextOp->Common.Next; - NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; return (AE_OK); case AML_PROCESSOR_OP: @@ -613,13 +685,13 @@ AcpiDmDescendingOp ( AcpiOsPrintf (", "); NextOp = AcpiPsGetDepthNext (NULL, Op); - NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; NextOp = NextOp->Common.Next; - NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; NextOp = NextOp->Common.Next; - NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; return (AE_OK); case AML_MUTEX_OP: @@ -678,12 +750,12 @@ AcpiDmDescendingOp ( * Bank Value. This is a TermArg in the middle of the parameter * list, must handle it here. * - * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMLIST + * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMETER_LIST * eliminates newline in the output. */ NextOp = NextOp->Common.Next; - Info->Flags = ACPI_PARSEOP_PARAMLIST; + Info->Flags = ACPI_PARSEOP_PARAMETER_LIST; AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, AcpiDmAscendingOp, Info); Info->Flags = 0; @@ -745,11 +817,11 @@ AcpiDmDescendingOp ( /* Normal Buffer, mark size as in the parameter list */ - NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; return (AE_OK); - case AML_VAR_PACKAGE_OP: case AML_IF_OP: + case AML_VAR_PACKAGE_OP: case AML_WHILE_OP: /* The next op is the size or predicate parameter */ @@ -757,7 +829,7 @@ AcpiDmDescendingOp ( NextOp = AcpiPsGetDepthNext (NULL, Op); if (NextOp) { - NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; } return (AE_OK); @@ -768,7 +840,7 @@ AcpiDmDescendingOp ( NextOp = AcpiPsGetDepthNext (NULL, Op); if (NextOp) { - NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; + NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; } return (AE_OK); @@ -867,14 +939,14 @@ AcpiDmAscendingOp ( if (!AcpiDmCommaIfListMember (Op)) { if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && - (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && - (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) + (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) && + (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { /* * This is a first-level element of a term list * start a new line */ - if (!(Info->Flags & ACPI_PARSEOP_PARAMLIST)) + if (!(Info->Flags & ACPI_PARSEOP_PARAMETER_LIST)) { AcpiOsPrintf ("\n"); } @@ -929,8 +1001,8 @@ AcpiDmAscendingOp ( if (!AcpiDmCommaIfListMember (Op)) { if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && - (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && - (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) + (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) && + (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { /* * This is a first-level element of a term list @@ -946,7 +1018,7 @@ AcpiDmAscendingOp ( case AML_PACKAGE_OP: case AML_VAR_PACKAGE_OP: - if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) + if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) { AcpiOsPrintf ("\n"); } @@ -960,17 +1032,17 @@ AcpiDmAscendingOp ( break; } - if (Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) + if (Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) { if ((Op->Common.Next) && - (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) + (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) { return (AE_OK); } /* * The parent Op is guaranteed to be valid because of the flag - * ACPI_PARSEOP_PARAMLIST -- which means that this op is part of + * ACPI_PARSEOP_PARAMETER_LIST -- which means that this op is part of * a parameter list and thus has a valid parent. */ ParentOp = Op->Common.Parent; @@ -1026,5 +1098,3 @@ AcpiDmAscendingOp ( return (AE_OK); } - -#endif /* ACPI_DISASSEMBLER */ diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsargs.c b/sys/contrib/dev/acpica/components/dispatcher/dsargs.c index 254f704..b669b56 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsargs.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsargs.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -94,7 +94,7 @@ AcpiDsExecuteArguments ( /* Allocate a new parser op to be the root of the parsed tree */ - Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP, AmlStart); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -114,7 +114,7 @@ AcpiDsExecuteArguments ( } Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); + AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -141,7 +141,7 @@ AcpiDsExecuteArguments ( /* Evaluate the deferred arguments */ - Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP, AmlStart); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -161,7 +161,7 @@ AcpiDsExecuteArguments ( /* Execute the opcode and arguments */ Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, ACPI_IMODE_EXECUTE); + AmlLength, NULL, ACPI_IMODE_EXECUTE); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -214,8 +214,8 @@ AcpiDsGetBufferFieldArguments ( ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); Node = ObjDesc->BufferField.Node; - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, - Node, NULL)); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_BUFFER_FIELD, Node, NULL)); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", AcpiUtGetNodeName (Node))); @@ -223,7 +223,7 @@ AcpiDsGetBufferFieldArguments ( /* Execute the AML code for the TermArg arguments */ Status = AcpiDsExecuteArguments (Node, Node->Parent, - ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); return_ACPI_STATUS (Status); } @@ -263,8 +263,8 @@ AcpiDsGetBankFieldArguments ( ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); Node = ObjDesc->BankField.Node; - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD, - Node, NULL)); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_LOCAL_BANK_FIELD, Node, NULL)); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", AcpiUtGetNodeName (Node))); @@ -272,7 +272,7 @@ AcpiDsGetBankFieldArguments ( /* Execute the AML code for the TermArg arguments */ Status = AcpiDsExecuteArguments (Node, Node->Parent, - ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); return_ACPI_STATUS (Status); } @@ -312,7 +312,8 @@ AcpiDsGetBufferArguments ( if (!Node) { ACPI_ERROR ((AE_INFO, - "No pointer back to namespace node in buffer object %p", ObjDesc)); + "No pointer back to namespace node in buffer object %p", + ObjDesc)); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -321,7 +322,7 @@ AcpiDsGetBufferArguments ( /* Execute the AML code for the TermArg arguments */ Status = AcpiDsExecuteArguments (Node, Node, - ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); + ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); return_ACPI_STATUS (Status); } @@ -370,7 +371,7 @@ AcpiDsGetPackageArguments ( /* Execute the AML code for the TermArg arguments */ Status = AcpiDsExecuteArguments (Node, Node, - ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); + ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); return_ACPI_STATUS (Status); } @@ -415,22 +416,23 @@ AcpiDsGetRegionArguments ( Node = ObjDesc->Region.Node; - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL)); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_REGION, Node, NULL)); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[%4.4s] OpRegion Arg Init at AML %p\n", AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); /* Execute the argument AML */ Status = AcpiDsExecuteArguments (Node, ExtraDesc->Extra.ScopeNode, - ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiUtAddAddressRange (ObjDesc->Region.SpaceId, - ObjDesc->Region.Address, ObjDesc->Region.Length, - Node); + ObjDesc->Region.Address, ObjDesc->Region.Length, Node); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c b/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c index bb23156..e3c68b7 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/include/acdebug.h> #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dscontrol") @@ -119,9 +120,12 @@ AcpiDsExecBeginControlOp ( * Save a pointer to the predicate for multiple executions * of a loop */ - ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; - ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; - ControlState->Control.Opcode = Op->Common.AmlOpcode; + ControlState->Control.AmlPredicateStart = + WalkState->ParserState.Aml - 1; + ControlState->Control.PackageEnd = + WalkState->ParserState.PkgEnd; + ControlState->Control.Opcode = + Op->Common.AmlOpcode; /* Push the control state on this walk's control stack */ @@ -221,7 +225,7 @@ AcpiDsExecEndControlOp ( * loop does not implement a timeout. */ ControlState->Control.LoopCount++; - if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS) + if (ControlState->Control.LoopCount > AcpiGbl_MaxLoopIterations) { Status = AE_AML_INFINITE_LOOP; break; @@ -232,7 +236,8 @@ AcpiDsExecEndControlOp ( * another time */ Status = AE_CTRL_PENDING; - WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; + WalkState->AmlLastWhile = + ControlState->Control.AmlPredicateStart; break; } @@ -276,7 +281,8 @@ AcpiDsExecEndControlOp ( * an arg or local), resolve it now because it may * cease to exist at the end of the method. */ - Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); + Status = AcpiExResolveToValue ( + &WalkState->Operands [0], WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -305,11 +311,15 @@ AcpiDsExecEndControlOp ( * Allow references created by the Index operator to return * unchanged. */ - if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && - ((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && - ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX)) + if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == + ACPI_DESC_TYPE_OPERAND) && + ((WalkState->Results->Results.ObjDesc [0])->Common.Type == + ACPI_TYPE_LOCAL_REFERENCE) && + ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != + ACPI_REFCLASS_INDEX)) { - Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); + Status = AcpiExResolveToValue ( + &WalkState->Results->Results.ObjDesc [0], WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -327,9 +337,9 @@ AcpiDsExecEndControlOp ( AcpiUtRemoveReference (WalkState->Operands [0]); } - WalkState->Operands [0] = NULL; - WalkState->NumOperands = 0; - WalkState->ReturnDesc = NULL; + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + WalkState->ReturnDesc = NULL; } @@ -350,20 +360,12 @@ AcpiDsExecEndControlOp ( case AML_BREAK_POINT_OP: - /* - * Set the single-step flag. This will cause the debugger (if present) - * to break to the console within the AML debugger at the start of the - * next AML instruction. - */ - ACPI_DEBUGGER_EXEC ( - AcpiGbl_CmSingleStep = TRUE); - ACPI_DEBUGGER_EXEC ( - AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n")); + AcpiDbSignalBreakPoint (WalkState); /* Call to the OSL in case OS wants a piece of the action */ Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, - "Executed AML Breakpoint opcode"); + "Executed AML Breakpoint opcode"); break; case AML_BREAK_OP: @@ -387,7 +389,8 @@ AcpiDsExecEndControlOp ( /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ - WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; + WalkState->AmlLastWhile = + WalkState->ControlState->Control.PackageEnd; /* Return status depending on opcode */ diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c b/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c new file mode 100644 index 0000000..9db1b7b --- /dev/null +++ b/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c @@ -0,0 +1,250 @@ +/****************************************************************************** + * + * Module Name: dsdebug - Parser/Interpreter interface - debugging + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acdispat.h> +#include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/include/acdisasm.h> +#include <contrib/dev/acpica/include/acinterp.h> + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsdebug") + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Local prototypes */ + +static void +AcpiDsPrintNodePathname ( + ACPI_NAMESPACE_NODE *Node, + const char *Message); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPrintNodePathname + * + * PARAMETERS: Node - Object + * Message - Prefix message + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ******************************************************************************/ + +static void +AcpiDsPrintNodePathname ( + ACPI_NAMESPACE_NODE *Node, + const char *Message) +{ + ACPI_BUFFER Buffer; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DsPrintNodePathname); + + if (!Node) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "[NULL NAME]")); + return_VOID; + } + + /* Convert handle to full pathname and print it (with supplied message) */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + + Status = AcpiNsHandleToPathname (Node, &Buffer, TRUE); + if (ACPI_SUCCESS (Status)) + { + if (Message) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "%s ", Message)); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "[%s] (Node %p)", + (char *) Buffer.Pointer, Node)); + ACPI_FREE (Buffer.Pointer); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDumpMethodStack + * + * PARAMETERS: Status - Method execution status + * WalkState - Current state of the parse tree walk + * Op - Executing parse op + * + * RETURN: None + * + * DESCRIPTION: Called when a method has been aborted because of an error. + * Dumps the method execution stack. + * + ******************************************************************************/ + +void +AcpiDsDumpMethodStack ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_THREAD_STATE *Thread; + ACPI_WALK_STATE *NextWalkState; + ACPI_NAMESPACE_NODE *PreviousMethod = NULL; + ACPI_OPERAND_OBJECT *MethodDesc; + + + ACPI_FUNCTION_TRACE (DsDumpMethodStack); + + /* Ignore control codes, they are not errors */ + + if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL) + { + return_VOID; + } + + /* We may be executing a deferred opcode */ + + if (WalkState->DeferredNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Executing subtree for Buffer/Package/Region\n")); + return_VOID; + } + + /* + * If there is no Thread, we are not actually executing a method. + * This can happen when the iASL compiler calls the interpreter + * to perform constant folding. + */ + Thread = WalkState->Thread; + if (!Thread) + { + return_VOID; + } + + /* Display exception and method name */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "\n**** Exception %s during execution of method ", + AcpiFormatException (Status))); + + AcpiDsPrintNodePathname (WalkState->MethodNode, NULL); + + /* Display stack of executing methods */ + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, + "\n\nMethod Execution Stack:\n")); + NextWalkState = Thread->WalkStateList; + + /* Walk list of linked walk states */ + + while (NextWalkState) + { + MethodDesc = NextWalkState->MethodDesc; + if (MethodDesc) + { + AcpiExStopTraceMethod ( + (ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node, + MethodDesc, WalkState); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + " Method [%4.4s] executing: ", + AcpiUtGetNodeName (NextWalkState->MethodNode))); + + /* First method is the currently executing method */ + + if (NextWalkState == WalkState) + { + if (Op) + { + /* Display currently executing ASL statement */ + + Next = Op->Common.Next; + Op->Common.Next = NULL; + +#ifdef ACPI_DISASSEMBLER + AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX); +#endif + Op->Common.Next = Next; + } + } + else + { + /* + * This method has called another method + * NOTE: the method call parse subtree is already deleted at + * this point, so we cannot disassemble the method invocation. + */ + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Call to method ")); + AcpiDsPrintNodePathname (PreviousMethod, NULL); + } + + PreviousMethod = NextWalkState->MethodNode; + NextWalkState = NextWalkState->Next; + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "\n")); + } + + return_VOID; +} + +#else + +void +AcpiDsDumpMethodStack ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + return; +} + +#endif diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsfield.c b/sys/contrib/dev/acpica/components/dispatcher/dsfield.c index d376bb1..4e3c29a 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsfield.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -115,6 +115,7 @@ AcpiDsCreateExternalRegion ( * insert the name into the namespace. */ AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_REGION, 0, 0); + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_REGION, ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, Node); if (ACPI_FAILURE (Status)) @@ -210,7 +211,7 @@ AcpiDsCreateBufferField ( /* Creating new namespace node, should not already exist */ Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | - ACPI_NS_ERROR_IF_FOUND; + ACPI_NS_ERROR_IF_FOUND; /* * Mark node temporary if we are executing a normal control @@ -224,9 +225,9 @@ AcpiDsCreateBufferField ( /* Enter the NameString into the namespace */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, - Flags, WalkState, &Node); + Status = AcpiNsLookup (WalkState->ScopeInfo, + Arg->Common.Value.String, ACPI_TYPE_ANY, + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); @@ -267,13 +268,13 @@ AcpiDsCreateBufferField ( } /* - * Remember location in AML stream of the field unit opcode and operands -- - * since the buffer and index operands must be evaluated. + * Remember location in AML stream of the field unit opcode and operands + * -- since the buffer and index operands must be evaluated. */ - SecondDesc = ObjDesc->Common.NextObject; - SecondDesc->Extra.AmlStart = Op->Named.Data; + SecondDesc = ObjDesc->Common.NextObject; + SecondDesc->Extra.AmlStart = Op->Named.Data; SecondDesc->Extra.AmlLength = Op->Named.Length; - ObjDesc->BufferField.Node = Node; + ObjDesc->BufferField.Node = Node; /* Attach constructed field descriptors to parent node */ @@ -341,8 +342,8 @@ AcpiDsGetFieldNames ( { case AML_INT_RESERVEDFIELD_OP: - Position = (UINT64) Info->FieldBitPosition - + (UINT64) Arg->Common.Value.Size; + Position = (UINT64) Info->FieldBitPosition + + (UINT64) Arg->Common.Value.Size; if (Position > ACPI_UINT32_MAX) { @@ -375,11 +376,13 @@ AcpiDsGetFieldNames ( /* AccessAttribute (AttribQuick, AttribByte, etc.) */ - Info->Attribute = (UINT8) ((Arg->Common.Value.Integer >> 8) & 0xFF); + Info->Attribute = (UINT8) + ((Arg->Common.Value.Integer >> 8) & 0xFF); /* AccessLength (for serial/buffer protocols) */ - Info->AccessLength = (UINT8) ((Arg->Common.Value.Integer >> 16) & 0xFF); + Info->AccessLength = (UINT8) + ((Arg->Common.Value.Integer >> 16) & 0xFF); break; case AML_INT_CONNECTION_OP: @@ -406,9 +409,9 @@ AcpiDsGetFieldNames ( /* Lookup the Connection() namepath, it should already exist */ Status = AcpiNsLookup (WalkState->ScopeInfo, - Child->Common.Value.Name, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &Info->ConnectionNode); + Child->Common.Value.Name, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &Info->ConnectionNode); if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (Child->Common.Value.Name, Status); @@ -422,9 +425,9 @@ AcpiDsGetFieldNames ( /* Lookup the name, it should already exist */ Status = AcpiNsLookup (WalkState->ScopeInfo, - (char *) &Arg->Named.Name, Info->FieldType, - ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &Info->FieldNode); + (char *) &Arg->Named.Name, Info->FieldType, + ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &Info->FieldNode); if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); @@ -453,8 +456,8 @@ AcpiDsGetFieldNames ( /* Keep track of bit position for the next field */ - Position = (UINT64) Info->FieldBitPosition - + (UINT64) Arg->Common.Value.Size; + Position = (UINT64) Info->FieldBitPosition + + (UINT64) Arg->Common.Value.Size; if (Position > ACPI_UINT32_MAX) { @@ -471,7 +474,8 @@ AcpiDsGetFieldNames ( default: ACPI_ERROR ((AE_INFO, - "Invalid opcode in field list: 0x%X", Arg->Common.AmlOpcode)); + "Invalid opcode in field list: 0x%X", + Arg->Common.AmlOpcode)); return_ACPI_STATUS (AE_AML_BAD_OPCODE); } @@ -517,8 +521,8 @@ AcpiDsCreateField ( if (!RegionNode) { Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, - ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); + ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); #ifdef ACPI_ASL_COMPILER Status = AcpiDsCreateExternalRegion (Status, Arg, Arg->Common.Value.Name, WalkState, &RegionNode); @@ -530,7 +534,7 @@ AcpiDsCreateField ( } } - ACPI_MEMSET (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO)); + memset (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO)); /* Second arg is the field flags */ @@ -624,7 +628,7 @@ AcpiDsInitFieldObjects ( /* Creating new namespace node(s), should not already exist */ Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | - ACPI_NS_ERROR_IF_FOUND; + ACPI_NS_ERROR_IF_FOUND; /* * Mark node(s) temporary if we are executing a normal control @@ -649,8 +653,8 @@ AcpiDsInitFieldObjects ( if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) { Status = AcpiNsLookup (WalkState->ScopeInfo, - (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1, - Flags, WalkState, &Node); + (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1, + Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); @@ -710,8 +714,8 @@ AcpiDsCreateBankField ( if (!RegionNode) { Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, - ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); + ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); #ifdef ACPI_ASL_COMPILER Status = AcpiDsCreateExternalRegion (Status, Arg, Arg->Common.Value.Name, WalkState, &RegionNode); @@ -727,8 +731,8 @@ AcpiDsCreateBankField ( Arg = Arg->Common.Next; Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); @@ -754,11 +758,12 @@ AcpiDsCreateBankField ( /* * Use Info.DataRegisterNode to store BankField Op - * It's safe because DataRegisterNode will never be used when create bank field - * We store AmlStart and AmlLength in the BankField Op for late evaluation - * Used in AcpiExPrepFieldValue(Info) + * It's safe because DataRegisterNode will never be used when create + * bank field \we store AmlStart and AmlLength in the BankField Op for + * late evaluation. Used in AcpiExPrepFieldValue(Info) * - * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like "void *ParentOp"? + * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like + * "void *ParentOp"? */ Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op; @@ -799,8 +804,8 @@ AcpiDsCreateIndexField ( Arg = Op->Common.Value.Arg; Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); @@ -811,8 +816,8 @@ AcpiDsCreateIndexField ( Arg = Arg->Common.Next; Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsinit.c b/sys/contrib/dev/acpica/components/dispatcher/dsinit.c index 62f9bde..e5d9929 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsinit.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -224,7 +224,7 @@ AcpiDsInitializeObjects ( /* Set all init info to zero */ - ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); + memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); Info.OwnerId = OwnerId; Info.TableIndex = TableIndex; @@ -242,7 +242,7 @@ AcpiDsInitializeObjects ( * the namespace reader lock. */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); + ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); @@ -255,12 +255,23 @@ AcpiDsInitializeObjects ( return_ACPI_STATUS (Status); } + /* DSDT is always the first AML table */ + + if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nInitializing Namespace objects:\n")); + } + + /* Summary of objects initialized */ + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Table [%4.4s] (id %4.4X) - %4u Objects with %3u Devices, " - "%3u Regions, %3u Methods (%u/%u/%u Serial/Non/Cvt)\n", - Table->Signature, OwnerId, Info.ObjectCount, Info.DeviceCount, - Info.OpRegionCount, Info.MethodCount, Info.SerialMethodCount, - Info.NonSerialMethodCount, Info.SerializedMethodCount)); + "Table [%4.4s: %-8.8s] (id %.2X) - %4u Objects with %3u Devices, " + "%3u Regions, %4u Methods (%u/%u/%u Serial/Non/Cvt)\n", + Table->Signature, Table->OemTableId, OwnerId, Info.ObjectCount, + Info.DeviceCount,Info.OpRegionCount, Info.MethodCount, + Info.SerialMethodCount, Info.NonSerialMethodCount, + Info.SerializedMethodCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "%u Methods, %u Regions\n", Info.MethodCount, Info.OpRegionCount)); diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c b/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c index 9845025..2c0e7ab 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,9 +46,9 @@ #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/acinterp.h> #include <contrib/dev/acpica/include/acnamesp.h> -#include <contrib/dev/acpica/include/acdisasm.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/amlcode.h> +#include <contrib/dev/acpica/include/acdebug.h> #define _COMPONENT ACPI_DISPATCHER @@ -109,7 +109,7 @@ AcpiDsAutoSerializeMethod ( /* Create/Init a root op for the method parse tree */ - Op = AcpiPsAllocOp (AML_METHOD_OP); + Op = AcpiPsAllocOp (AML_METHOD_OP, ObjDesc->Method.AmlStart); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -127,8 +127,8 @@ AcpiDsAutoSerializeMethod ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitAmlWalk (WalkState, Op, Node, ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, 0); + Status = AcpiDsInitAmlWalk (WalkState, Op, Node, + ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, NULL, 0); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -213,7 +213,7 @@ AcpiDsDetectNamedOpcodes ( * RETURN: Status * * DESCRIPTION: Called on method error. Invoke the global exception handler if - * present, dump the method data if the disassembler is configured + * present, dump the method data if the debugger is configured * * Note: Allows the exception handler to change the status code * @@ -224,6 +224,9 @@ AcpiDsMethodError ( ACPI_STATUS Status, ACPI_WALK_STATE *WalkState) { + UINT32 AmlOffset; + + ACPI_FUNCTION_ENTRY (); @@ -247,23 +250,28 @@ AcpiDsMethodError ( * Handler can map the exception code to anything it wants, including * AE_OK, in which case the executing method will not be aborted. */ + AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml, + WalkState->ParserState.AmlStart); + Status = AcpiGbl_ExceptionHandler (Status, - WalkState->MethodNode ? - WalkState->MethodNode->Name.Integer : 0, - WalkState->Opcode, WalkState->AmlOffset, NULL); + WalkState->MethodNode ? + WalkState->MethodNode->Name.Integer : 0, + WalkState->Opcode, AmlOffset, NULL); AcpiExEnterInterpreter (); } AcpiDsClearImplicitReturn (WalkState); -#ifdef ACPI_DISASSEMBLER if (ACPI_FAILURE (Status)) { - /* Display method locals/args if disassembler is present */ + AcpiDsDumpMethodStack (Status, WalkState, WalkState->Op); - AcpiDmDumpMethodInfo (Status, WalkState, WalkState->Op); - } + /* Display method locals/args if debugger is present */ + +#ifdef ACPI_DEBUGGER + AcpiDbDumpMethodInfo (Status, WalkState); #endif + } return (Status); } @@ -349,6 +357,8 @@ AcpiDsBeginMethodExecution ( return_ACPI_STATUS (AE_NULL_ENTRY); } + AcpiExStartTraceMethod (MethodNode, ObjDesc, WalkState); + /* Prevent wraparound of thread count */ if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX) @@ -390,10 +400,12 @@ AcpiDsBeginMethodExecution ( */ if (WalkState && (!(ObjDesc->Method.InfoFlags & ACPI_METHOD_IGNORE_SYNC_LEVEL)) && - (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) + (WalkState->Thread->CurrentSyncLevel > + ObjDesc->Method.Mutex->Mutex.SyncLevel)) { ACPI_ERROR ((AE_INFO, - "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%u)", + "Cannot acquire Mutex for method [%4.4s]" + ", current SyncLevel is too large (%u)", AcpiUtGetNodeName (MethodNode), WalkState->Thread->CurrentSyncLevel)); @@ -406,14 +418,15 @@ AcpiDsBeginMethodExecution ( */ if (!WalkState || !ObjDesc->Method.Mutex->Mutex.ThreadId || - (WalkState->Thread->ThreadId != ObjDesc->Method.Mutex->Mutex.ThreadId)) + (WalkState->Thread->ThreadId != + ObjDesc->Method.Mutex->Mutex.ThreadId)) { /* * Acquire the method mutex. This releases the interpreter if we * block (and reacquires it before it returns) */ - Status = AcpiExSystemWaitMutex (ObjDesc->Method.Mutex->Mutex.OsMutex, - ACPI_WAIT_FOREVER); + Status = AcpiExSystemWaitMutex ( + ObjDesc->Method.Mutex->Mutex.OsMutex, ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -426,13 +439,30 @@ AcpiDsBeginMethodExecution ( ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; - ObjDesc->Method.Mutex->Mutex.ThreadId = WalkState->Thread->ThreadId; - WalkState->Thread->CurrentSyncLevel = ObjDesc->Method.SyncLevel; + ObjDesc->Method.Mutex->Mutex.ThreadId = + WalkState->Thread->ThreadId; + + /* + * Update the current SyncLevel only if this is not an auto- + * serialized method. In the auto case, we have to ignore + * the sync level for the method mutex (created for the + * auto-serialization) because we have no idea of what the + * sync level should be. Therefore, just ignore it. + */ + if (!(ObjDesc->Method.InfoFlags & + ACPI_METHOD_IGNORE_SYNC_LEVEL)) + { + WalkState->Thread->CurrentSyncLevel = + ObjDesc->Method.SyncLevel; + } } else { ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = ObjDesc->Method.Mutex->Mutex.SyncLevel; + + ObjDesc->Method.Mutex->Mutex.ThreadId = + AcpiOsGetThreadId (); } } @@ -505,7 +535,8 @@ AcpiDsCallControlMethod ( ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Calling method %p, currentstate=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Calling method %p, currentstate=%p\n", ThisWalkState->PrevOp, ThisWalkState)); /* @@ -525,8 +556,8 @@ AcpiDsCallControlMethod ( /* Init for new method, possibly wait on method mutex */ - Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, - ThisWalkState); + Status = AcpiDsBeginMethodExecution ( + MethodNode, ObjDesc, ThisWalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -534,8 +565,8 @@ AcpiDsCallControlMethod ( /* Begin method parse/execution. Create a new walk state */ - NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, - NULL, ObjDesc, Thread); + NextWalkState = AcpiDsCreateWalkState ( + ObjDesc->Method.OwnerId, NULL, ObjDesc, Thread); if (!NextWalkState) { Status = AE_NO_MEMORY; @@ -564,8 +595,8 @@ AcpiDsCallControlMethod ( Info->Parameters = &ThisWalkState->Operands[0]; Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, - ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, - Info, ACPI_IMODE_EXECUTE); + ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, + Info, ACPI_IMODE_EXECUTE); ACPI_FREE (Info); if (ACPI_FAILURE (Status)) @@ -610,10 +641,7 @@ Cleanup: /* On error, we must terminate the method properly */ AcpiDsTerminateControlMethod (ObjDesc, NextWalkState); - if (NextWalkState) - { - AcpiDsDeleteWalkState (NextWalkState); - } + AcpiDsDeleteWalkState (NextWalkState); return_ACPI_STATUS (Status); } @@ -763,7 +791,8 @@ AcpiDsTerminateControlMethod ( WalkState->Thread->CurrentSyncLevel = MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; - AcpiOsReleaseMutex (MethodDesc->Method.Mutex->Mutex.OsMutex); + AcpiOsReleaseMutex ( + MethodDesc->Method.Mutex->Mutex.OsMutex); MethodDesc->Method.Mutex->Mutex.ThreadId = 0; } } @@ -793,7 +822,8 @@ AcpiDsTerminateControlMethod ( if (MethodDesc->Method.InfoFlags & ACPI_METHOD_MODIFIED_NAMESPACE) { AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); - MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_MODIFIED_NAMESPACE; + MethodDesc->Method.InfoFlags &= + ~ACPI_METHOD_MODIFIED_NAMESPACE; } } } @@ -840,8 +870,9 @@ AcpiDsTerminateControlMethod ( { if (WalkState) { - ACPI_INFO ((AE_INFO, - "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error", + ACPI_INFO (( + "Marking method %4.4s as Serialized " + "because of AE_ALREADY_EXISTS error", WalkState->MethodNode->Name.Ascii)); } @@ -856,7 +887,9 @@ AcpiDsTerminateControlMethod ( * marking the method permanently as Serialized when the last * thread exits here. */ - MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_SERIALIZED_PENDING; + MethodDesc->Method.InfoFlags &= + ~ACPI_METHOD_SERIALIZED_PENDING; + MethodDesc->Method.InfoFlags |= (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL); MethodDesc->Method.SyncLevel = 0; @@ -870,5 +903,8 @@ AcpiDsTerminateControlMethod ( } } + AcpiExStopTraceMethod ((ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node, + MethodDesc, WalkState); + return_VOID; } diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c b/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c index 4b998d9..6e0fc7e 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,7 +110,9 @@ AcpiDsMethodDataInit ( for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { - ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE); + ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, + NAMEOF_ARG_NTE); + WalkState->Arguments[i].Name.Integer |= (i << 24); WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED; WalkState->Arguments[i].Type = ACPI_TYPE_ANY; @@ -121,7 +123,8 @@ AcpiDsMethodDataInit ( for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) { - ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE); + ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, + NAMEOF_LOCAL_NTE); WalkState->LocalVariables[i].Name.Integer |= (i << 24); WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED; @@ -163,7 +166,7 @@ AcpiDsMethodDataDeleteAll ( if (WalkState->LocalVariables[Index].Object) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n", - Index, WalkState->LocalVariables[Index].Object)); + Index, WalkState->LocalVariables[Index].Object)); /* Detach object (if present) and remove a reference */ @@ -178,7 +181,7 @@ AcpiDsMethodDataDeleteAll ( if (WalkState->Arguments[Index].Object) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n", - Index, WalkState->Arguments[Index].Object)); + Index, WalkState->Arguments[Index].Object)); /* Detach object (if present) and remove a reference */ @@ -221,7 +224,8 @@ AcpiDsMethodDataInitArgs ( if (!Params) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "No parameter list passed to method\n")); return_ACPI_STATUS (AE_OK); } @@ -236,8 +240,8 @@ AcpiDsMethodDataInitArgs ( * Store the argument in the method/walk descriptor. * Do not copy the arg in order to implement call by reference */ - Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index, - Params[Index], WalkState); + Status = AcpiDsMethodDataSetValue ( + ACPI_REFCLASS_ARG, Index, Params[Index], WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -627,7 +631,8 @@ AcpiDsStoreObjectToLocal ( NewObjDesc = ObjDesc; if (ObjDesc->Common.ReferenceCount > 1) { - Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState); + Status = AcpiUtCopyIobjectToIobject ( + ObjDesc, &NewObjDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -664,13 +669,16 @@ AcpiDsStoreObjectToLocal ( * If we have a valid reference object that came from RefOf(), * do the indirect store */ - if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) && - (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && - (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)) + if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == + ACPI_DESC_TYPE_OPERAND) && + (CurrentObjDesc->Common.Type == + ACPI_TYPE_LOCAL_REFERENCE) && + (CurrentObjDesc->Reference.Class == + ACPI_REFCLASS_REFOF)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Arg (%p) is an ObjRef(Node), storing in node %p\n", - NewObjDesc, CurrentObjDesc)); + "Arg (%p) is an ObjRef(Node), storing in node %p\n", + NewObjDesc, CurrentObjDesc)); /* * Store this object to the Node (perform the indirect store) @@ -678,8 +686,8 @@ AcpiDsStoreObjectToLocal ( * specification rules on storing to Locals/Args. */ Status = AcpiExStoreObjectToNode (NewObjDesc, - CurrentObjDesc->Reference.Object, WalkState, - ACPI_NO_IMPLICIT_CONVERSION); + CurrentObjDesc->Reference.Object, WalkState, + ACPI_NO_IMPLICIT_CONVERSION); /* Remove local reference if we copied the object above */ @@ -687,6 +695,7 @@ AcpiDsStoreObjectToLocal ( { AcpiUtRemoveReference (NewObjDesc); } + return_ACPI_STATUS (Status); } } diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsobject.c b/sys/contrib/dev/acpica/components/dispatcher/dsobject.c index 106c6ab..da9512f 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsobject.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsobject.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -102,10 +102,10 @@ AcpiDsBuildInternalObject ( if (!Op->Common.Node) { Status = AcpiNsLookup (WalkState->ScopeInfo, - Op->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node))); + Op->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node))); if (ACPI_FAILURE (Status)) { /* Check if we are resolving a named reference within a package */ @@ -161,8 +161,8 @@ AcpiDsBuildInternalObject ( ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Op->Common.Node); Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc), - WalkState); + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc), + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -222,14 +222,14 @@ AcpiDsBuildInternalObject ( /* Create and init a new internal ACPI object */ ObjDesc = AcpiUtCreateInternalObject ( - (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); + (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, - &ObjDesc); + Status = AcpiDsInitObjectFromOp ( + WalkState, Op, Op->Common.AmlOpcode, &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); @@ -336,8 +336,8 @@ AcpiDsBuildInternalBufferObj ( } else { - ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED ( - ObjDesc->Buffer.Length); + ObjDesc->Buffer.Pointer = + ACPI_ALLOCATE_ZEROED (ObjDesc->Buffer.Length); if (!ObjDesc->Buffer.Pointer) { AcpiUtDeleteObjectDesc (ObjDesc); @@ -348,8 +348,8 @@ AcpiDsBuildInternalBufferObj ( if (ByteList) { - ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data, - ByteListLength); + memcpy (ObjDesc->Buffer.Pointer, ByteList->Named.Data, + ByteListLength); } } @@ -468,8 +468,8 @@ AcpiDsBuildInternalPackageObj ( * invocation, so we special case it here */ Arg->Common.AmlOpcode = AML_INT_NAMEPATH_OP; - Status = AcpiDsBuildInternalObject (WalkState, Arg, - &ObjDesc->Package.Elements[i]); + Status = AcpiDsBuildInternalObject ( + WalkState, Arg, &ObjDesc->Package.Elements[i]); } else { @@ -481,8 +481,8 @@ AcpiDsBuildInternalPackageObj ( } else { - Status = AcpiDsBuildInternalObject (WalkState, Arg, - &ObjDesc->Package.Elements[i]); + Status = AcpiDsBuildInternalObject ( + WalkState, Arg, &ObjDesc->Package.Elements[i]); } if (*ObjDescPtr) @@ -538,8 +538,9 @@ AcpiDsBuildInternalPackageObj ( Arg = Arg->Common.Next; } - ACPI_INFO ((AE_INFO, - "Actual Package length (%u) is larger than NumElements field (%u), truncated", + ACPI_INFO (( + "Actual Package length (%u) is larger than " + "NumElements field (%u), truncated", i, ElementCount)); } else if (i < ElementCount) @@ -549,7 +550,8 @@ AcpiDsBuildInternalPackageObj ( * Note: this is not an error, the package is padded out with NULLs. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Package List length (%u) smaller than NumElements count (%u), padded with null elements\n", + "Package List length (%u) smaller than NumElements " + "count (%u), padded with null elements\n", i, ElementCount)); } @@ -605,8 +607,8 @@ AcpiDsCreateNode ( /* Build an internal object for the argument(s) */ - Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, - &ObjDesc); + Status = AcpiDsBuildInternalObject ( + WalkState, Op->Common.Value.Arg, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -678,9 +680,9 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Buffer TermArg operand */ - ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, - WalkState->Operands[0]); - ObjDesc->Buffer.AmlStart = Op->Named.Data; + ObjDesc->Buffer.Node = ACPI_CAST_PTR ( + ACPI_NAMESPACE_NODE, WalkState->Operands[0]); + ObjDesc->Buffer.AmlStart = Op->Named.Data; ObjDesc->Buffer.AmlLength = Op->Named.Length; break; @@ -688,9 +690,9 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Package TermArg operand */ - ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, - WalkState->Operands[0]); - ObjDesc->Package.AmlStart = Op->Named.Data; + ObjDesc->Package.Node = ACPI_CAST_PTR ( + ACPI_NAMESPACE_NODE, WalkState->Operands[0]); + ObjDesc->Package.AmlStart = Op->Named.Data; ObjDesc->Package.AmlLength = Op->Named.Length; break; @@ -775,7 +777,7 @@ AcpiDsInitObjectFromOp ( case ACPI_TYPE_STRING: ObjDesc->String.Pointer = Op->Common.Value.String; - ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String); + ObjDesc->String.Length = (UINT32) strlen (Op->Common.Value.String); /* * The string is contained in the ACPI table, don't ever try @@ -800,9 +802,9 @@ AcpiDsInitObjectFromOp ( #ifndef ACPI_NO_METHOD_EXECUTION Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL, - ObjDesc->Reference.Value, WalkState, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, - &ObjDesc->Reference.Object)); + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); #endif break; @@ -815,9 +817,9 @@ AcpiDsInitObjectFromOp ( #ifndef ACPI_NO_METHOD_EXECUTION Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG, - ObjDesc->Reference.Value, WalkState, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, - &ObjDesc->Reference.Object)); + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); #endif break; diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c b/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c index 157e4ce..826866b 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -259,8 +259,8 @@ AcpiDsInitBufferField ( * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), * UPDATE_RULE = 0 (UPDATE_PRESERVE) */ - Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, - BitOffset, BitCount); + Status = AcpiExPrepCommonFieldObject ( + ObjDesc, FieldFlags, 0, BitOffset, BitCount); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -357,8 +357,8 @@ AcpiDsEvalBufferFieldOperands ( /* Resolve the operands */ - Status = AcpiExResolveOperands (Op->Common.AmlOpcode, - ACPI_WALK_OPERANDS, WalkState); + Status = AcpiExResolveOperands ( + Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X", @@ -374,16 +374,16 @@ AcpiDsEvalBufferFieldOperands ( /* NOTE: Slightly different operands for this opcode */ Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, - WalkState->Operands[0], WalkState->Operands[1], - WalkState->Operands[2], WalkState->Operands[3]); + WalkState->Operands[0], WalkState->Operands[1], + WalkState->Operands[2], WalkState->Operands[3]); } else { /* All other, CreateXxxField opcodes */ Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, - WalkState->Operands[0], WalkState->Operands[1], - NULL, WalkState->Operands[2]); + WalkState->Operands[0], WalkState->Operands[1], + NULL, WalkState->Operands[2]); } return_ACPI_STATUS (Status); @@ -443,8 +443,8 @@ AcpiDsEvalRegionOperands ( /* Resolve the length and address operands to numbers */ - Status = AcpiExResolveOperands (Op->Common.AmlOpcode, - ACPI_WALK_OPERANDS, WalkState); + Status = AcpiExResolveOperands ( + Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -472,18 +472,16 @@ AcpiDsEvalRegionOperands ( OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) - OperandDesc->Integer.Value; + OperandDesc->Integer.Value; AcpiUtRemoveReference (OperandDesc); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", - ObjDesc, - ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), + ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), ObjDesc->Region.Length)); /* Now the address and length are valid for this opregion */ ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; - return_ACPI_STATUS (Status); } @@ -513,8 +511,8 @@ AcpiDsEvalTableRegionOperands ( ACPI_OPERAND_OBJECT **Operand; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *NextOp; - UINT32 TableIndex; ACPI_TABLE_HEADER *Table; + UINT32 TableIndex; ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op); @@ -540,57 +538,67 @@ AcpiDsEvalTableRegionOperands ( return_ACPI_STATUS (Status); } + Operand = &WalkState->Operands[0]; + /* * Resolve the Signature string, OemId string, * and OemTableId string operands */ - Status = AcpiExResolveOperands (Op->Common.AmlOpcode, - ACPI_WALK_OPERANDS, WalkState); + Status = AcpiExResolveOperands ( + Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Cleanup; } - Operand = &WalkState->Operands[0]; - /* Find the ACPI table */ - Status = AcpiTbFindTable (Operand[0]->String.Pointer, - Operand[1]->String.Pointer, Operand[2]->String.Pointer, - &TableIndex); + Status = AcpiTbFindTable ( + Operand[0]->String.Pointer, + Operand[1]->String.Pointer, + Operand[2]->String.Pointer, &TableIndex); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + if (Status == AE_NOT_FOUND) + { + ACPI_ERROR ((AE_INFO, + "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT", + Operand[0]->String.Pointer, + Operand[1]->String.Pointer, + Operand[2]->String.Pointer)); + } + goto Cleanup; } - AcpiUtRemoveReference (Operand[0]); - AcpiUtRemoveReference (Operand[1]); - AcpiUtRemoveReference (Operand[2]); - Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Cleanup; } ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { - return_ACPI_STATUS (AE_NOT_EXIST); + Status = AE_NOT_EXIST; + goto Cleanup; } ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table); ObjDesc->Region.Length = Table->Length; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", - ObjDesc, - ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), + ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), ObjDesc->Region.Length)); /* Now the address and length are valid for this opregion */ ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; +Cleanup: + AcpiUtRemoveReference (Operand[0]); + AcpiUtRemoveReference (Operand[1]); + AcpiUtRemoveReference (Operand[2]); + return_ACPI_STATUS (Status); } @@ -639,8 +647,8 @@ AcpiDsEvalDataObjectOperands ( } Status = AcpiExResolveOperands (WalkState->Opcode, - &(WalkState->Operands [WalkState->NumOperands -1]), - WalkState); + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -668,13 +676,15 @@ AcpiDsEvalDataObjectOperands ( { case AML_BUFFER_OP: - Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); + Status = AcpiDsBuildInternalBufferObj ( + WalkState, Op, Length, &ObjDesc); break; case AML_PACKAGE_OP: case AML_VAR_PACKAGE_OP: - Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); + Status = AcpiDsBuildInternalPackageObj ( + WalkState, Op, Length, &ObjDesc); break; default: diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsutils.c b/sys/contrib/dev/acpica/components/dispatcher/dsutils.c index a115b2e..1ffd0cb 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsutils.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -140,9 +140,9 @@ AcpiDsDoImplicitReturn ( } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Result %p will be implicitly returned; Prev=%p\n", - ReturnDesc, - WalkState->ImplicitReturnObj)); + "Result %p will be implicitly returned; Prev=%p\n", + ReturnDesc, + WalkState->ImplicitReturnObj)); /* * Delete any "stale" implicit return value first. However, in @@ -266,7 +266,8 @@ AcpiDsIsResultUsed ( * If we are executing the predicate AND this is the predicate op, * we will use the return value */ - if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && + if ((WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING) && (WalkState->ControlState->Control.PredicateOp == Op)) { goto ResultUsed; @@ -523,8 +524,8 @@ AcpiDsCreateOperand ( /* Get the entire name string from the AML stream */ - Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Common.Value.Buffer, - &NameString, &NameLength); + Status = AcpiExGetNameString (ACPI_TYPE_ANY, + Arg->Common.Value.Buffer, &NameString, &NameLength); if (ACPI_FAILURE (Status)) { @@ -544,10 +545,11 @@ AcpiDsCreateOperand ( */ if ((WalkState->DeferredNode) && (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) && - (ArgIndex == (UINT32) ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2))) + (ArgIndex == (UINT32) + ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2))) { ObjDesc = ACPI_CAST_PTR ( - ACPI_OPERAND_OBJECT, WalkState->DeferredNode); + ACPI_OPERAND_OBJECT, WalkState->DeferredNode); Status = AE_OK; } else /* All other opcodes */ @@ -560,6 +562,7 @@ AcpiDsCreateOperand ( */ ParentOp = Arg->Common.Parent; OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode); + if ((OpInfo->Flags & AML_NSNODE) && (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && (ParentOp->Common.AmlOpcode != AML_REGION_OP) && @@ -577,10 +580,9 @@ AcpiDsCreateOperand ( } Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, - ACPI_TYPE_ANY, InterpreterMode, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); + ACPI_TYPE_ANY, InterpreterMode, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); /* * The only case where we pass through (ignore) a NOT_FOUND * error is for the CondRefOf opcode. @@ -596,17 +598,19 @@ AcpiDsCreateOperand ( * object to the root */ ObjDesc = ACPI_CAST_PTR ( - ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); + ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); Status = AE_OK; } else if (ParentOp->Common.AmlOpcode == AML_EXTERNAL_OP) { - /* TBD: May only be temporary */ - - ObjDesc = AcpiUtCreateStringObject ((ACPI_SIZE) NameLength); - - ACPI_STRNCPY (ObjDesc->String.Pointer, NameString, NameLength); - Status = AE_OK; + /* + * This opcode should never appear here. It is used only + * by AML disassemblers and is surrounded by an If(0) + * by the ASL compiler. + * + * Therefore, if we see it here, it is a serious error. + */ + Status = AE_AML_BAD_OPCODE; } else { @@ -642,7 +646,8 @@ AcpiDsCreateOperand ( { return_ACPI_STATUS (Status); } - ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + + AcpiDbDisplayArgumentObject (ObjDesc, WalkState); } else { @@ -675,13 +680,14 @@ AcpiDsCreateOperand ( return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } - if ((OpInfo->Flags & AML_HAS_RETVAL) || (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + if ((OpInfo->Flags & AML_HAS_RETVAL) || + (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Argument previously created, already stacked\n")); - ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject ( - WalkState->Operands [WalkState->NumOperands - 1], WalkState)); + AcpiDbDisplayArgumentObject ( + WalkState->Operands [WalkState->NumOperands - 1], WalkState); /* * Use value that was already previously returned @@ -712,7 +718,7 @@ AcpiDsCreateOperand ( /* Initialize the new object */ Status = AcpiDsInitObjectFromOp ( - WalkState, Arg, Opcode, &ObjDesc); + WalkState, Arg, Opcode, &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtDeleteObjectDesc (ObjDesc); @@ -728,7 +734,7 @@ AcpiDsCreateOperand ( return_ACPI_STATUS (Status); } - ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + AcpiDbDisplayArgumentObject (ObjDesc, WalkState); } return_ACPI_STATUS (AE_OK); @@ -898,7 +904,8 @@ AcpiDsEvaluateNamePath ( AcpiUtRemoveReference (*Operand); - Status = AcpiUtCopyIobjectToIobject (*Operand, &NewObjDesc, WalkState); + Status = AcpiUtCopyIobjectToIobject ( + *Operand, &NewObjDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Exit; diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswexec.c b/sys/contrib/dev/acpica/components/dispatcher/dswexec.c index f391fe0..5873ed3 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswexec.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswexec.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -189,12 +189,13 @@ AcpiDsGetPredicateValue ( Cleanup: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Completed a predicate eval=%X Op=%p\n", WalkState->ControlState->Common.Value, WalkState->Op)); - /* Break to debugger to display result */ + /* Break to debugger to display result */ - ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (LocalObjDesc, WalkState)); + AcpiDbDisplayResultObject (LocalObjDesc, WalkState); /* * Delete the predicate result object (we know that @@ -286,10 +287,12 @@ AcpiDsExecBeginOp ( (WalkState->ControlState->Common.State == ACPI_CONTROL_CONDITIONAL_EXECUTING)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n", - Op, WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Exec predicate Op=%p State=%p\n", + Op, WalkState)); - WalkState->ControlState->Common.State = ACPI_CONTROL_PREDICATE_EXECUTING; + WalkState->ControlState->Common.State = + ACPI_CONTROL_PREDICATE_EXECUTING; /* Save start of predicate */ @@ -337,8 +340,8 @@ AcpiDsExecBeginOp ( } else { - Status = AcpiDsScopeStackPush (Op->Named.Node, - Op->Named.Node->Type, WalkState); + Status = AcpiDsScopeStackPush ( + Op->Named.Node, Op->Named.Node->Type, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -397,8 +400,8 @@ AcpiDsExecEndOp ( ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState); - Op = WalkState->Op; - OpType = WalkState->OpInfo->Type; + Op = WalkState->Op; + OpType = WalkState->OpInfo->Type; OpClass = WalkState->OpInfo->Class; if (OpClass == AML_CLASS_UNKNOWN) @@ -418,8 +421,11 @@ AcpiDsExecEndOp ( /* Call debugger for single step support (DEBUG build only) */ - ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass)); - ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);}); + Status = AcpiDbSingleStep (WalkState, Op, OpClass); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* Decode the Opcode Class */ @@ -456,8 +462,8 @@ AcpiDsExecEndOp ( /* Resolve all operands */ Status = AcpiExResolveOperands (WalkState->Opcode, - &(WalkState->Operands [WalkState->NumOperands -1]), - WalkState); + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); } if (ACPI_SUCCESS (Status)) @@ -534,7 +540,8 @@ AcpiDsExecEndOp ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method Reference in a Package, Op=%p\n", Op)); - Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node; + Op->Common.Node = (ACPI_NAMESPACE_NODE *) + Op->Asl.Value.Arg->Asl.Node; AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object); return_ACPI_STATUS (AE_OK); } @@ -616,12 +623,12 @@ AcpiDsExecEndOp ( * Put the Node on the object stack (Contains the ACPI Name * of this object) */ - WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node; + WalkState->Operands[0] = (void *) + Op->Common.Parent->Common.Node; WalkState->NumOperands = 1; Status = AcpiDsCreateNode (WalkState, - Op->Common.Parent->Common.Node, - Op->Common.Parent); + Op->Common.Parent->Common.Node, Op->Common.Parent); if (ACPI_FAILURE (Status)) { break; @@ -633,7 +640,7 @@ AcpiDsExecEndOp ( case AML_INT_EVAL_SUBTREE_OP: Status = AcpiDsEvalDataObjectOperands (WalkState, Op, - AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); + AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); break; default: @@ -714,7 +721,8 @@ AcpiDsExecEndOp ( default: ACPI_ERROR ((AE_INFO, - "Unimplemented opcode, class=0x%X type=0x%X Opcode=0x%X Op=%p", + "Unimplemented opcode, class=0x%X " + "type=0x%X Opcode=0x%X Op=%p", OpClass, OpType, Op->Common.AmlOpcode, Op)); Status = AE_NOT_IMPLEMENTED; @@ -749,8 +757,7 @@ Cleanup: { /* Break to debugger to display result */ - ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, - WalkState)); + AcpiDbDisplayResultObject (WalkState->ResultObj,WalkState); /* * Delete the result op if and only if: diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswload.c b/sys/contrib/dev/acpica/components/dispatcher/dswload.c index 8bc425a..ff14300 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswload.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -188,7 +188,8 @@ AcpiDsLoad1BeginOp ( ObjectType = WalkState->OpInfo->ObjectType; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType))); + "State=%p Op=%p [%s]\n", WalkState, Op, + AcpiUtGetTypeName (ObjectType))); switch (WalkState->Opcode) { @@ -199,7 +200,7 @@ AcpiDsLoad1BeginOp ( * Allow search-to-root for single namesegs. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); #ifdef ACPI_ASL_COMPILER if (Status == AE_NOT_FOUND) { @@ -210,8 +211,8 @@ AcpiDsLoad1BeginOp ( */ AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, - WalkState, &Node); + ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, + WalkState, &Node); } #endif if (ACPI_FAILURE (Status)) @@ -325,15 +326,24 @@ AcpiDsLoad1BeginOp ( if ((WalkState->Opcode != AML_SCOPE_OP) && (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) { - Flags |= ACPI_NS_ERROR_IF_FOUND; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", + if (WalkState->NamespaceOverride) + { + Flags |= ACPI_NS_OVERRIDE_IF_FOUND; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n", + AcpiUtGetTypeName (ObjectType))); + } + else + { + Flags |= ACPI_NS_ERROR_IF_FOUND; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", AcpiUtGetTypeName (ObjectType))); + } } else { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Both Find or Create allowed\n", - AcpiUtGetTypeName (ObjectType))); + AcpiUtGetTypeName (ObjectType))); } /* @@ -343,7 +353,7 @@ AcpiDsLoad1BeginOp ( * parse tree later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -363,7 +373,8 @@ AcpiDsLoad1BeginOp ( if (AcpiNsOpensScope (ObjectType)) { - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + Status = AcpiDsScopeStackPush ( + Node, ObjectType, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -389,7 +400,7 @@ AcpiDsLoad1BeginOp ( { /* Create a new op */ - Op = AcpiPsAllocOp (WalkState->Opcode); + Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -485,8 +496,9 @@ AcpiDsLoad1EndOp ( if (Op->Common.AmlOpcode == AML_REGION_OP) { Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), - WalkState); + (ACPI_ADR_SPACE_TYPE) + ((Op->Common.Value.Arg)->Common.Value.Integer), + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -495,7 +507,7 @@ AcpiDsLoad1EndOp ( else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) { Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - ACPI_ADR_SPACE_DATA_TABLE, WalkState); + ACPI_ADR_SPACE_DATA_TABLE, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -547,11 +559,12 @@ AcpiDsLoad1EndOp ( WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); WalkState->NumOperands = 1; - Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + Status = AcpiDsCreateOperands ( + WalkState, Op->Common.Value.Arg); if (ACPI_SUCCESS (Status)) { Status = AcpiExCreateMethod (Op->Named.Data, - Op->Named.Length, WalkState); + Op->Named.Length, WalkState); } WalkState->Operands[0] = NULL; diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswload2.c b/sys/contrib/dev/acpica/components/dispatcher/dswload2.c index 4728774..09fbb88 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswload2.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswload2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -159,8 +159,8 @@ AcpiDsLoad2BeginOp ( * for use later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); break; case AML_SCOPE_OP: @@ -185,8 +185,8 @@ AcpiDsLoad2BeginOp ( * for use later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { #ifdef ACPI_ASL_COMPILER @@ -323,7 +323,7 @@ AcpiDsLoad2BeginOp ( /* Add new entry or lookup existing entry */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); + ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY)) { @@ -344,7 +344,7 @@ AcpiDsLoad2BeginOp ( { /* Create a new op */ - Op = AcpiPsAllocOp (WalkState->Opcode); + Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -401,7 +401,7 @@ AcpiDsLoad2EndOp ( Op = WalkState->Op; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", - WalkState->OpInfo->Name, Op, WalkState)); + WalkState->OpInfo->Name, Op, WalkState)); /* Check if opcode had an associated namespace object */ @@ -507,8 +507,8 @@ AcpiDsLoad2EndOp ( { case AML_INDEX_FIELD_OP: - Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, - WalkState); + Status = AcpiDsCreateIndexField ( + Op, (ACPI_HANDLE) Arg->Common.Node, WalkState); break; case AML_BANK_FIELD_OP: @@ -593,7 +593,7 @@ AcpiDsLoad2EndOp ( if (Op->Common.AmlOpcode == AML_REGION_OP) { RegionSpace = (ACPI_ADR_SPACE_TYPE) - ((Op->Common.Value.Arg)->Common.Value.Integer); + ((Op->Common.Value.Arg)->Common.Value.Integer); } else { @@ -618,8 +618,8 @@ AcpiDsLoad2EndOp ( * Executing a method: initialize the region and unlock * the interpreter */ - Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - RegionSpace, WalkState); + Status = AcpiExCreateRegion (Op->Named.Data, + Op->Named.Length, RegionSpace, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -628,8 +628,8 @@ AcpiDsLoad2EndOp ( AcpiExExitInterpreter (); } - Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), - FALSE); + Status = AcpiEvInitializeRegion ( + AcpiNsGetAttachedObject (Node), FALSE); if (WalkState->MethodNode) { AcpiExEnterInterpreter (); @@ -672,12 +672,14 @@ AcpiDsLoad2EndOp ( WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); WalkState->NumOperands = 1; - Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + Status = AcpiDsCreateOperands ( + WalkState, Op->Common.Value.Arg); if (ACPI_SUCCESS (Status)) { - Status = AcpiExCreateMethod (Op->Named.Data, - Op->Named.Length, WalkState); + Status = AcpiExCreateMethod ( + Op->Named.Data, Op->Named.Length, WalkState); } + WalkState->Operands[0] = NULL; WalkState->NumOperands = 0; @@ -712,9 +714,9 @@ AcpiDsLoad2EndOp ( * Lookup the method name and save the Node */ Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &(NewNode)); + ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &(NewNode)); if (ACPI_SUCCESS (Status)) { /* diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswscope.c b/sys/contrib/dev/acpica/components/dispatcher/dswscope.c index dc1fedc..ba99d1e 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswscope.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswscope.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,6 +82,7 @@ AcpiDsScopeStackClear ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Popped object type (%s)\n", AcpiUtGetTypeName (ScopeInfo->Common.Value))); + AcpiUtDeleteGenericState (ScopeInfo); } } diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswstate.c b/sys/contrib/dev/acpica/components/dispatcher/dswstate.c index 5211666..b19d6a9 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswstate.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswstate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -299,8 +299,8 @@ AcpiDsResultStackPop ( if (WalkState->Results == NULL) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result stack underflow - State=%p\n", - WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Result stack underflow - State=%p\n", WalkState)); return (AE_AML_NO_OPERAND); } @@ -707,7 +707,8 @@ AcpiDsInitAmlWalk ( /* Push start scope on scope stack and make it current */ - Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState); + Status = AcpiDsScopeStackPush ( + MethodNode, ACPI_TYPE_METHOD, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -750,7 +751,7 @@ AcpiDsInitAmlWalk ( /* Push start scope on scope stack and make it current */ Status = AcpiDsScopeStackPush (ParserState->StartNode, - ParserState->StartNode->Type, WalkState); + ParserState->StartNode->Type, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/events/evevent.c b/sys/contrib/dev/acpica/components/events/evevent.c index 45d227c..a4aa037 100644 --- a/sys/contrib/dev/acpica/components/events/evevent.c +++ b/sys/contrib/dev/acpica/components/events/evevent.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -203,8 +203,8 @@ AcpiEvFixedEventInitialize ( if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) { Status = AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[i].EnableRegisterId, - ACPI_DISABLE_EVENT); + AcpiGbl_FixedEventInfo[i].EnableRegisterId, + ACPI_DISABLE_EVENT); if (ACPI_FAILURE (Status)) { return (Status); @@ -307,8 +307,8 @@ AcpiEvFixedEventDispatch ( /* Clear the status bit */ (void) AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].StatusRegisterId, - ACPI_CLEAR_STATUS); + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); /* * Make sure that a handler exists. If not, report an error @@ -317,8 +317,8 @@ AcpiEvFixedEventDispatch ( if (!AcpiGbl_FixedEventHandlers[Event].Handler) { (void) AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - ACPI_DISABLE_EVENT); + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); ACPI_ERROR ((AE_INFO, "No installed handler for fixed event - %s (%u), disabling", @@ -330,7 +330,7 @@ AcpiEvFixedEventDispatch ( /* Invoke the Fixed Event handler */ return ((AcpiGbl_FixedEventHandlers[Event].Handler)( - AcpiGbl_FixedEventHandlers[Event].Context)); + AcpiGbl_FixedEventHandlers[Event].Context)); } #endif /* !ACPI_REDUCED_HARDWARE */ diff --git a/sys/contrib/dev/acpica/components/events/evglock.c b/sys/contrib/dev/acpica/components/events/evglock.c index a9855c9..b8bd0cf 100644 --- a/sys/contrib/dev/acpica/components/events/evglock.c +++ b/sys/contrib/dev/acpica/components/events/evglock.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -90,7 +90,7 @@ AcpiEvInitGlobalLockHandler ( /* Attempt installation of the global lock handler */ Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, - AcpiEvGlobalLockHandler, NULL); + AcpiEvGlobalLockHandler, NULL); /* * If the global lock does not exist on this platform, the attempt to @@ -140,9 +140,10 @@ AcpiEvRemoveGlobalLockHandler ( ACPI_FUNCTION_TRACE (EvRemoveGlobalLockHandler); + AcpiGbl_GlobalLockPresent = FALSE; Status = AcpiRemoveFixedEventHandler (ACPI_EVENT_GLOBAL, - AcpiEvGlobalLockHandler); + AcpiEvGlobalLockHandler); AcpiOsDeleteLock (AcpiGbl_GlobalLockPendingLock); return_ACPI_STATUS (Status); @@ -302,8 +303,8 @@ AcpiEvAcquireGlobalLock ( * Wait for handshake with the global lock interrupt handler. * This interface releases the interpreter if we must wait. */ - Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, - ACPI_WAIT_FOREVER); + Status = AcpiExSystemWaitSemaphore ( + AcpiGbl_GlobalLockSemaphore, ACPI_WAIT_FOREVER); Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock); @@ -361,7 +362,7 @@ AcpiEvReleaseGlobalLock ( if (Pending) { Status = AcpiWriteBitRegister ( - ACPI_BITREG_GLOBAL_LOCK_RELEASE, ACPI_ENABLE_EVENT); + ACPI_BITREG_GLOBAL_LOCK_RELEASE, ACPI_ENABLE_EVENT); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Released hardware Global Lock\n")); diff --git a/sys/contrib/dev/acpica/components/events/evgpe.c b/sys/contrib/dev/acpica/components/events/evgpe.c index 99043ad..9bc5e19 100644 --- a/sys/contrib/dev/acpica/components/events/evgpe.c +++ b/sys/contrib/dev/acpica/components/events/evgpe.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -105,6 +105,7 @@ AcpiEvUpdateGpeEnableMask ( ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, (UINT8) RegisterBit); } + GpeRegisterInfo->EnableMask = GpeRegisterInfo->EnableForRun; return_ACPI_STATUS (AE_OK); } @@ -141,7 +142,7 @@ AcpiEvEnableGpe ( /* Enable the requested GPE */ - Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE_SAVE); + Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE); return_ACPI_STATUS (Status); } @@ -231,7 +232,7 @@ AcpiEvRemoveGpeReference ( Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo); if (ACPI_SUCCESS (Status)) { - Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE_SAVE); + Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE); } if (ACPI_FAILURE (Status)) @@ -326,7 +327,7 @@ AcpiEvGetGpeEventInfo ( for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { GpeInfo = AcpiEvLowGetGpeInfo (GpeNumber, - AcpiGbl_GpeFadtBlocks[i]); + AcpiGbl_GpeFadtBlocks[i]); if (GpeInfo) { return (GpeInfo); @@ -587,8 +588,8 @@ AcpiEvAsynchExecuteGpeMethod ( Notify = GpeEventInfo->Dispatch.NotifyList; while (ACPI_SUCCESS (Status) && Notify) { - Status = AcpiEvQueueNotifyRequest (Notify->DeviceNode, - ACPI_NOTIFY_DEVICE_WAKE); + Status = AcpiEvQueueNotifyRequest ( + Notify->DeviceNode, ACPI_NOTIFY_DEVICE_WAKE); Notify = Notify->Next; } @@ -632,7 +633,7 @@ AcpiEvAsynchExecuteGpeMethod ( /* Defer enabling of GPE until all notify handlers are done */ Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, - AcpiEvAsynchEnableGpe, GpeEventInfo); + AcpiEvAsynchEnableGpe, GpeEventInfo); if (ACPI_SUCCESS (Status)) { return_VOID; @@ -777,8 +778,8 @@ AcpiEvGpeDispatch ( { ACPI_EXCEPTION ((AE_INFO, Status, "Unable to clear GPE %02X", GpeNumber)); - (void) AcpiHwLowSetGpe (GpeEventInfo, - ACPI_GPE_CONDITIONAL_ENABLE); + (void) AcpiHwLowSetGpe ( + GpeEventInfo, ACPI_GPE_CONDITIONAL_ENABLE); return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); } } @@ -815,7 +816,7 @@ AcpiEvGpeDispatch ( * NOTE: Level-triggered GPEs are cleared after the method completes. */ Status = AcpiOsExecute (OSL_GPE_HANDLER, - AcpiEvAsynchExecuteGpeMethod, GpeEventInfo); + AcpiEvAsynchExecuteGpeMethod, GpeEventInfo); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, diff --git a/sys/contrib/dev/acpica/components/events/evgpeblk.c b/sys/contrib/dev/acpica/components/events/evgpeblk.c index 53528c6..e5d3616 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeblk.c +++ b/sys/contrib/dev/acpica/components/events/evgpeblk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -193,6 +193,7 @@ AcpiEvDeleteGpeBlock ( { GpeBlock->Next->Previous = GpeBlock->Previous; } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); } @@ -241,8 +242,8 @@ AcpiEvCreateGpeInfoBlocks ( /* Allocate the GPE register information block */ GpeRegisterInfo = ACPI_ALLOCATE_ZEROED ( - (ACPI_SIZE) GpeBlock->RegisterCount * - sizeof (ACPI_GPE_REGISTER_INFO)); + (ACPI_SIZE) GpeBlock->RegisterCount * + sizeof (ACPI_GPE_REGISTER_INFO)); if (!GpeRegisterInfo) { ACPI_ERROR ((AE_INFO, @@ -255,7 +256,7 @@ AcpiEvCreateGpeInfoBlocks ( * per register. Initialization to zeros is sufficient. */ GpeEventInfo = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) GpeBlock->GpeCount * - sizeof (ACPI_GPE_EVENT_INFO)); + sizeof (ACPI_GPE_EVENT_INFO)); if (!GpeEventInfo) { ACPI_ERROR ((AE_INFO, @@ -267,7 +268,7 @@ AcpiEvCreateGpeInfoBlocks ( /* Save the new Info arrays in the GPE block */ GpeBlock->RegisterInfo = GpeRegisterInfo; - GpeBlock->EventInfo = GpeEventInfo; + GpeBlock->EventInfo = GpeEventInfo; /* * Initialize the GPE Register and Event structures. A goal of these @@ -276,7 +277,7 @@ AcpiEvCreateGpeInfoBlocks ( * first half, and the enable registers occupy the second half. */ ThisRegister = GpeRegisterInfo; - ThisEvent = GpeEventInfo; + ThisEvent = GpeEventInfo; for (i = 0; i < GpeBlock->RegisterCount; i++) { @@ -434,8 +435,8 @@ AcpiEvCreateGpeBlock ( WalkInfo.ExecuteByOwnerId = FALSE; Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, - ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, - AcpiEvMatchGpeMethod, NULL, &WalkInfo, NULL); + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiEvMatchGpeMethod, NULL, &WalkInfo, NULL); /* Return the new block */ @@ -541,7 +542,7 @@ AcpiEvInitializeGpeBlock ( if (GpeEnabledCount) { - ACPI_INFO ((AE_INFO, + ACPI_INFO (( "Enabled %u GPEs in block %02X to %02X", GpeEnabledCount, (UINT32) GpeBlock->BlockBaseNumber, (UINT32) (GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1)))); diff --git a/sys/contrib/dev/acpica/components/events/evgpeinit.c b/sys/contrib/dev/acpica/components/events/evgpeinit.c index 0e53a1d..9e77a22 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeinit.c +++ b/sys/contrib/dev/acpica/components/events/evgpeinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -138,10 +138,10 @@ AcpiEvGpeInitialize ( /* Install GPE Block 0 */ Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - AcpiGbl_FADT.XGpe0Block.Address, - AcpiGbl_FADT.XGpe0Block.SpaceId, - RegisterCount0, 0, - AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); + AcpiGbl_FADT.XGpe0Block.Address, + AcpiGbl_FADT.XGpe0Block.SpaceId, + RegisterCount0, 0, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); if (ACPI_FAILURE (Status)) { @@ -178,11 +178,11 @@ AcpiEvGpeInitialize ( /* Install GPE Block 1 */ Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - AcpiGbl_FADT.XGpe1Block.Address, - AcpiGbl_FADT.XGpe1Block.SpaceId, - RegisterCount1, - AcpiGbl_FADT.Gpe1Base, - AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); + AcpiGbl_FADT.XGpe1Block.Address, + AcpiGbl_FADT.XGpe1Block.SpaceId, + RegisterCount1, + AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); if (ACPI_FAILURE (Status)) { @@ -195,7 +195,7 @@ AcpiEvGpeInitialize ( * space. However, GPE0 always starts at GPE number zero. */ GpeNumberMax = AcpiGbl_FADT.Gpe1Base + - ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); } } @@ -275,9 +275,9 @@ AcpiEvUpdateGpes ( WalkInfo.GpeDevice = GpeBlock->Node; Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, - WalkInfo.GpeDevice, ACPI_UINT32_MAX, - ACPI_NS_WALK_NO_UNLOCK, AcpiEvMatchGpeMethod, - NULL, &WalkInfo, NULL); + WalkInfo.GpeDevice, ACPI_UINT32_MAX, + ACPI_NS_WALK_NO_UNLOCK, AcpiEvMatchGpeMethod, + NULL, &WalkInfo, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, @@ -292,7 +292,7 @@ AcpiEvUpdateGpes ( if (WalkInfo.Count) { - ACPI_INFO ((AE_INFO, "Enabled %u new GPEs", WalkInfo.Count)); + ACPI_INFO (("Enabled %u new GPEs", WalkInfo.Count)); } (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); @@ -395,7 +395,7 @@ AcpiEvMatchGpeMethod ( /* 4) The last two characters of the name are the hex GPE Number */ - GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); + GpeNumber = strtoul (&Name[2], NULL, 16); if (GpeNumber == ACPI_UINT32_MAX) { /* Conversion failed; invalid method, just ignore it */ @@ -430,7 +430,7 @@ AcpiEvMatchGpeMethod ( } if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) == - ACPI_GPE_DISPATCH_METHOD) + ACPI_GPE_DISPATCH_METHOD) { /* * If there is already a method, ignore this method. But check diff --git a/sys/contrib/dev/acpica/components/events/evgpeutil.c b/sys/contrib/dev/acpica/components/events/evgpeutil.c index 1f03859..99cbc28 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeutil.c +++ b/sys/contrib/dev/acpica/components/events/evgpeutil.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -238,7 +238,7 @@ AcpiEvGetGpeXruptBlock ( if (InterruptNumber != AcpiGbl_FADT.SciInterrupt) { Status = AcpiOsInstallInterruptHandler (InterruptNumber, - AcpiEvGpeXruptHandler, GpeXrupt); + AcpiEvGpeXruptHandler, GpeXrupt); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, @@ -288,7 +288,7 @@ AcpiEvDeleteGpeXrupt ( /* Disable this interrupt */ Status = AcpiOsRemoveInterruptHandler ( - GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); + GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -374,7 +374,7 @@ AcpiEvDeleteGpeHandlers ( GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; } else if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) == - ACPI_GPE_DISPATCH_NOTIFY) + ACPI_GPE_DISPATCH_NOTIFY) { /* Delete the implicit notification device list */ @@ -385,6 +385,7 @@ AcpiEvDeleteGpeHandlers ( ACPI_FREE (Notify); Notify = Next; } + GpeEventInfo->Dispatch.NotifyList = NULL; GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; } diff --git a/sys/contrib/dev/acpica/components/events/evhandler.c b/sys/contrib/dev/acpica/components/events/evhandler.c index 419936b..88496d0 100644 --- a/sys/contrib/dev/acpica/components/events/evhandler.c +++ b/sys/contrib/dev/acpica/components/events/evhandler.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,6 +60,7 @@ AcpiEvInstallHandler ( void *Context, void **ReturnValue); + /* These are the address spaces that will get default handlers */ UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = @@ -122,8 +123,8 @@ AcpiEvInstallRegionHandlers ( for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode, - AcpiGbl_DefaultAddressSpaces[i], - ACPI_DEFAULT_HANDLER, NULL, NULL); + AcpiGbl_DefaultAddressSpaces[i], + ACPI_DEFAULT_HANDLER, NULL, NULL); switch (Status) { case AE_OK: @@ -175,7 +176,7 @@ AcpiEvHasDefaultHandler ( ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { - HandlerObj = ObjDesc->Device.Handler; + HandlerObj = ObjDesc->CommonNotify.Handler; /* Walk the linked list of handlers for this object */ @@ -184,7 +185,7 @@ AcpiEvHasDefaultHandler ( if (HandlerObj->AddressSpace.SpaceId == SpaceId) { if (HandlerObj->AddressSpace.HandlerFlags & - ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { return (TRUE); } @@ -276,33 +277,25 @@ AcpiEvInstallHandler ( { /* Check if this Device already has a handler for this address space */ - NextHandlerObj = ObjDesc->Device.Handler; - while (NextHandlerObj) + NextHandlerObj = AcpiEvFindRegionHandler ( + HandlerObj->AddressSpace.SpaceId, ObjDesc->CommonNotify.Handler); + if (NextHandlerObj) { /* Found a handler, is it for the same address space? */ - if (NextHandlerObj->AddressSpace.SpaceId == - HandlerObj->AddressSpace.SpaceId) - { - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Found handler for region [%s] in device %p(%p) " - "handler %p\n", - AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId), - ObjDesc, NextHandlerObj, HandlerObj)); - - /* - * Since the object we found it on was a device, then it - * means that someone has already installed a handler for - * the branch of the namespace from this device on. Just - * bail out telling the walk routine to not traverse this - * branch. This preserves the scoping rule for handlers. - */ - return (AE_CTRL_DEPTH); - } - - /* Walk the linked list of handlers attached to this device */ - - NextHandlerObj = NextHandlerObj->AddressSpace.Next; + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Found handler for region [%s] in device %p(%p) handler %p\n", + AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId), + ObjDesc, NextHandlerObj, HandlerObj)); + + /* + * Since the object we found it on was a device, then it means + * that someone has already installed a handler for the branch + * of the namespace from this device on. Just bail out telling + * the walk routine to not traverse this branch. This preserves + * the scoping rule for handlers. + */ + return (AE_CTRL_DEPTH); } /* @@ -337,6 +330,46 @@ AcpiEvInstallHandler ( /******************************************************************************* * + * FUNCTION: AcpiEvFindRegionHandler + * + * PARAMETERS: SpaceId - The address space ID + * HandlerObj - Head of the handler object list + * + * RETURN: Matching handler object. NULL if space ID not matched + * + * DESCRIPTION: Search a handler object list for a match on the address + * space ID. + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiEvFindRegionHandler ( + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_OPERAND_OBJECT *HandlerObj) +{ + + /* Walk the handler list for this device */ + + while (HandlerObj) + { + /* Same SpaceId indicates a handler is installed */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + return (HandlerObj); + } + + /* Next handler object */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + + return (NULL); +} + + +/******************************************************************************* + * * FUNCTION: AcpiEvInstallSpaceHandler * * PARAMETERS: Node - Namespace node for the device @@ -362,17 +395,17 @@ AcpiEvInstallSpaceHandler ( { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *HandlerObj; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; ACPI_OBJECT_TYPE Type; - UINT8 Flags = 0; + UINT8 Flags = 0; ACPI_FUNCTION_TRACE (EvInstallSpaceHandler); /* - * This registration is valid for only the types below and the root. This - * is where the default handlers get placed. + * This registration is valid for only the types below and the root. + * The root node is where the default handlers get installed. */ if ((Node->Type != ACPI_TYPE_DEVICE) && (Node->Type != ACPI_TYPE_PROCESSOR) && @@ -445,47 +478,39 @@ AcpiEvInstallSpaceHandler ( if (ObjDesc) { /* - * The attached device object already exists. Make sure the handler - * is not already installed. + * The attached device object already exists. Now make sure + * the handler is not already installed. */ - HandlerObj = ObjDesc->Device.Handler; + HandlerObj = AcpiEvFindRegionHandler (SpaceId, + ObjDesc->CommonNotify.Handler); - /* Walk the handler list for this device */ - - while (HandlerObj) + if (HandlerObj) { - /* Same SpaceId indicates a handler already installed */ - - if (HandlerObj->AddressSpace.SpaceId == SpaceId) + if (HandlerObj->AddressSpace.Handler == Handler) { - if (HandlerObj->AddressSpace.Handler == Handler) - { - /* - * It is (relatively) OK to attempt to install the SAME - * handler twice. This can easily happen with the - * PCI_Config space. - */ - Status = AE_SAME_HANDLER; - goto UnlockAndExit; - } - else - { - /* A handler is already installed */ - - Status = AE_ALREADY_EXISTS; - } + /* + * It is (relatively) OK to attempt to install the SAME + * handler twice. This can easily happen with the + * PCI_Config space. + */ + Status = AE_SAME_HANDLER; goto UnlockAndExit; } + else + { + /* A handler is already installed */ - /* Walk the linked list of handlers */ + Status = AE_ALREADY_EXISTS; + } - HandlerObj = HandlerObj->AddressSpace.Next; + goto UnlockAndExit; } } else { ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Creating object on Device %p while installing handler\n", Node)); + "Creating object on Device %p while installing handler\n", + Node)); /* ObjDesc does not exist, create one */ @@ -524,7 +549,8 @@ AcpiEvInstallSpaceHandler ( } ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", + "Installing address handler for region %s(%X) " + "on Device %4.4s %p(%p)\n", AcpiUtGetRegionName (SpaceId), SpaceId, AcpiUtGetNodeName (Node), Node, ObjDesc)); @@ -549,33 +575,31 @@ AcpiEvInstallSpaceHandler ( HandlerObj->AddressSpace.Node = Node; HandlerObj->AddressSpace.Handler = Handler; HandlerObj->AddressSpace.Context = Context; - HandlerObj->AddressSpace.Setup = Setup; + HandlerObj->AddressSpace.Setup = Setup; /* Install at head of Device.AddressSpace list */ - HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; + HandlerObj->AddressSpace.Next = ObjDesc->CommonNotify.Handler; /* * The Device object is the first reference on the HandlerObj. * Each region that uses the handler adds a reference. */ - ObjDesc->Device.Handler = HandlerObj; + ObjDesc->CommonNotify.Handler = HandlerObj; /* - * Walk the namespace finding all of the regions this - * handler will manage. + * Walk the namespace finding all of the regions this handler will + * manage. * - * Start at the device and search the branch toward - * the leaf nodes until either the leaf is encountered or - * a device is detected that has an address handler of the - * same type. + * Start at the device and search the branch toward the leaf nodes + * until either the leaf is encountered or a device is detected that + * has an address handler of the same type. * - * In either case, back up and search down the remainder - * of the branch + * In either case, back up and search down the remainder of the branch */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, NULL, - HandlerObj, NULL); + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + AcpiEvInstallHandler, NULL, HandlerObj, NULL); UnlockAndExit: return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/events/evmisc.c b/sys/contrib/dev/acpica/components/events/evmisc.c index b178543..4bc4786 100644 --- a/sys/contrib/dev/acpica/components/events/evmisc.c +++ b/sys/contrib/dev/acpica/components/events/evmisc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,6 +75,7 @@ BOOLEAN AcpiEvIsNotifyObject ( ACPI_NAMESPACE_NODE *Node) { + switch (Node->Type) { case ACPI_TYPE_DEVICE: @@ -183,8 +184,8 @@ AcpiEvQueueNotifyRequest ( AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), NotifyValue, AcpiUtGetNotifyName (NotifyValue, ACPI_TYPE_ANY), Node)); - Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, - Info); + Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, + AcpiEvNotifyDispatch, Info); if (ACPI_FAILURE (Status)) { AcpiUtDeleteGenericState (Info); diff --git a/sys/contrib/dev/acpica/components/events/evregion.c b/sys/contrib/dev/acpica/components/events/evregion.c index 54171b6..fae3900 100644 --- a/sys/contrib/dev/acpica/components/events/evregion.c +++ b/sys/contrib/dev/acpica/components/events/evregion.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -109,13 +109,11 @@ AcpiEvInitializeOpRegions ( if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode, AcpiGbl_DefaultAddressSpaces[i])) { - Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, - AcpiGbl_DefaultAddressSpaces[i]); + AcpiEvExecuteRegMethods (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i], ACPI_REG_CONNECT); } } - AcpiGbl_RegMethodsExecuted = TRUE; - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } @@ -138,6 +136,12 @@ AcpiEvInitializeOpRegions ( * DESCRIPTION: Dispatch an address space or operation region access to * a previously installed handler. * + * NOTE: During early initialization, we always install the default region + * handlers for Memory, I/O and PCI_Config. This ensures that these operation + * region address spaces are always available as per the ACPI specification. + * This is especially needed in order to support the execution of + * module-level AML code during loading of the ACPI tables. + * ******************************************************************************/ ACPI_STATUS @@ -210,7 +214,7 @@ AcpiEvAddressSpaceDispatch ( AcpiExExitInterpreter (); Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE, - Context, &RegionContext); + Context, &RegionContext); /* Re-enter the interpreter */ @@ -292,7 +296,7 @@ AcpiEvAddressSpaceDispatch ( AcpiUtGetRegionName (RegionObj->Region.SpaceId))); if (!(HandlerDesc->AddressSpace.HandlerFlags & - ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * For handlers other than the default (supplied) handlers, we must @@ -314,13 +318,13 @@ AcpiEvAddressSpaceDispatch ( } if (!(HandlerDesc->AddressSpace.HandlerFlags & - ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * We just returned from a non-default handler, we must re-enter the * interpreter */ - AcpiExEnterInterpreter (); + AcpiExEnterInterpreter (); } return_ACPI_STATUS (Status); @@ -342,7 +346,7 @@ AcpiEvAddressSpaceDispatch ( ******************************************************************************/ void -AcpiEvDetachRegion( +AcpiEvDetachRegion ( ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsIsLocked) { @@ -521,6 +525,13 @@ AcpiEvAttachRegion ( ACPI_FUNCTION_TRACE (EvAttachRegion); + /* Install the region's handler */ + + if (RegionObj->Region.Handler) + { + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Adding Region [%4.4s] %p to address handler %p [%s]\n", AcpiUtGetNodeName (RegionObj->Region.Node), @@ -531,14 +542,6 @@ AcpiEvAttachRegion ( RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList; HandlerObj->AddressSpace.RegionList = RegionObj; - - /* Install the region's handler */ - - if (RegionObj->Region.Handler) - { - return_ACPI_STATUS (AE_ALREADY_EXISTS); - } - RegionObj->Region.Handler = HandlerObj; AcpiUtAddReference (HandlerObj); @@ -567,23 +570,59 @@ AcpiEvExecuteRegMethod ( ACPI_EVALUATE_INFO *Info; ACPI_OPERAND_OBJECT *Args[3]; ACPI_OPERAND_OBJECT *RegionObj2; + const ACPI_NAME *RegNamePtr = ACPI_CAST_PTR (ACPI_NAME, METHOD_NAME__REG); + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (EvExecuteRegMethod); + if (!AcpiGbl_NamespaceInitialized || + RegionObj->Region.Handler == NULL) + { + return_ACPI_STATUS (AE_OK); + } + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); if (!RegionObj2) { return_ACPI_STATUS (AE_NOT_EXIST); } + /* + * Find any "_REG" method associated with this region definition. + * The method should always be updated as this function may be + * invoked after a namespace change. + */ + Node = RegionObj->Region.Node->Parent; + Status = AcpiNsSearchOneScope ( + *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per + * region definition. This will be executed when the handler is + * attached or removed. + */ + RegionObj2->Extra.Method_REG = MethodNode; + } if (RegionObj2->Extra.Method_REG == NULL) { return_ACPI_STATUS (AE_OK); } + /* _REG(DISCONNECT) should be paired with _REG(CONNECT) */ + + if ((Function == ACPI_REG_CONNECT && + RegionObj->Common.Flags & AOPOBJ_REG_CONNECTED) || + (Function == ACPI_REG_DISCONNECT && + !(RegionObj->Common.Flags & AOPOBJ_REG_CONNECTED))) + { + return_ACPI_STATUS (AE_OK); + } + /* Allocate and initialize the evaluation information block */ Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); @@ -631,6 +670,20 @@ AcpiEvExecuteRegMethod ( Status = AcpiNsEvaluate (Info); AcpiUtRemoveReference (Args[1]); + if (ACPI_FAILURE (Status)) + { + goto Cleanup2; + } + + if (Function == ACPI_REG_CONNECT) + { + RegionObj->Common.Flags |= AOPOBJ_REG_CONNECTED; + } + else + { + RegionObj->Common.Flags &= ~AOPOBJ_REG_CONNECTED; + } + Cleanup2: AcpiUtRemoveReference (Args[0]); @@ -646,24 +699,33 @@ Cleanup1: * * PARAMETERS: Node - Namespace node for the device * SpaceId - The address space ID + * Function - Passed to _REG: On (1) or Off (0) * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Run all _REG methods for the input Space ID; * Note: assumes namespace is locked, or system init time. * ******************************************************************************/ -ACPI_STATUS +void AcpiEvExecuteRegMethods ( ACPI_NAMESPACE_NODE *Node, - ACPI_ADR_SPACE_TYPE SpaceId) + ACPI_ADR_SPACE_TYPE SpaceId, + UINT32 Function) { - ACPI_STATUS Status; + ACPI_REG_WALK_INFO Info; ACPI_FUNCTION_TRACE (EvExecuteRegMethods); + Info.SpaceId = SpaceId; + Info.Function = Function; + Info.RegRunCount = 0; + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, + " Running _REG methods for SpaceId %s\n", + AcpiUtGetRegionName (Info.SpaceId))); /* * Run all _REG methods for all Operation Regions for this space ID. This @@ -671,9 +733,8 @@ AcpiEvExecuteRegMethods ( * regions and _REG methods. (i.e. handlers must be installed for all * regions of this Space ID before we can run any _REG methods) */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL, - &SpaceId, NULL); + (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL, &Info, NULL); /* Special case for EC: handle "orphan" _REG methods with no region */ @@ -682,7 +743,11 @@ AcpiEvExecuteRegMethods ( AcpiEvOrphanEcRegMethod (Node); } - return_ACPI_STATUS (Status); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, + " Executed %u _REG methods for SpaceId %s\n", + Info.RegRunCount, AcpiUtGetRegionName (Info.SpaceId))); + + return_VOID; } @@ -705,11 +770,11 @@ AcpiEvRegRun ( { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; - ACPI_ADR_SPACE_TYPE SpaceId; ACPI_STATUS Status; + ACPI_REG_WALK_INFO *Info; - SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context); + Info = ACPI_CAST_PTR (ACPI_REG_WALK_INFO, Context); /* Convert and validate the device handle */ @@ -741,14 +806,15 @@ AcpiEvRegRun ( /* Object is a Region */ - if (ObjDesc->Region.SpaceId != SpaceId) + if (ObjDesc->Region.SpaceId != Info->SpaceId) { /* This region is for a different address space, just ignore it */ return (AE_OK); } - Status = AcpiEvExecuteRegMethod (ObjDesc, ACPI_REG_CONNECT); + Info->RegRunCount++; + Status = AcpiEvExecuteRegMethod (ObjDesc, Info->Function); return (Status); } diff --git a/sys/contrib/dev/acpica/components/events/evrgnini.c b/sys/contrib/dev/acpica/components/events/evrgnini.c index 2984e8c..14976e0 100644 --- a/sys/contrib/dev/acpica/components/events/evrgnini.c +++ b/sys/contrib/dev/acpica/components/events/evrgnini.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -248,9 +248,9 @@ AcpiEvPciConfigRegionSetup ( /* Install a handler for this PCI root bridge */ Status = AcpiInstallAddressSpaceHandler ( - (ACPI_HANDLE) PciRootNode, - ACPI_ADR_SPACE_PCI_CONFIG, - ACPI_DEFAULT_HANDLER, NULL, NULL); + (ACPI_HANDLE) PciRootNode, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); if (ACPI_FAILURE (Status)) { if (Status == AE_SAME_HANDLER) @@ -324,7 +324,7 @@ AcpiEvPciConfigRegionSetup ( * contained in the parent's scope. */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, - PciDeviceNode, &PciValue); + PciDeviceNode, &PciValue); /* * The default is zero, and since the allocation above zeroed the data, @@ -339,7 +339,7 @@ AcpiEvPciConfigRegionSetup ( /* The PCI segment number comes from the _SEG method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, - PciRootNode, &PciValue); + PciRootNode, &PciValue); if (ACPI_SUCCESS (Status)) { PciId->Segment = ACPI_LOWORD (PciValue); @@ -348,7 +348,7 @@ AcpiEvPciConfigRegionSetup ( /* The PCI bus number comes from the _BBN method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, - PciRootNode, &PciValue); + PciRootNode, &PciValue); if (ACPI_SUCCESS (Status)) { PciId->Bus = ACPI_LOWORD (PciValue); @@ -567,9 +567,6 @@ AcpiEvInitializeRegion ( ACPI_ADR_SPACE_TYPE SpaceId; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *MethodNode; - ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; - ACPI_OPERAND_OBJECT *RegionObj2; ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); @@ -585,39 +582,14 @@ AcpiEvInitializeRegion ( return_ACPI_STATUS (AE_OK); } - RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); - if (!RegionObj2) - { - return_ACPI_STATUS (AE_NOT_EXIST); - } + RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; Node = RegionObj->Region.Node->Parent; SpaceId = RegionObj->Region.SpaceId; - /* Setup defaults */ - - RegionObj->Region.Handler = NULL; - RegionObj2->Extra.Method_REG = NULL; - RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE); - RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; - - /* Find any "_REG" method associated with this region definition */ - - Status = AcpiNsSearchOneScope ( - *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); - if (ACPI_SUCCESS (Status)) - { - /* - * The _REG method is optional and there can be only one per region - * definition. This will be executed when the handler is attached - * or removed - */ - RegionObj2->Extra.Method_REG = MethodNode; - } - /* * The following loop depends upon the root Node having no parent - * ie: AcpiGbl_RootNode->ParentEntry being set to NULL + * ie: AcpiGbl_RootNode->Parent being set to NULL */ while (Node) { @@ -632,18 +604,10 @@ AcpiEvInitializeRegion ( switch (Node->Type) { case ACPI_TYPE_DEVICE: - - HandlerObj = ObjDesc->Device.Handler; - break; - case ACPI_TYPE_PROCESSOR: - - HandlerObj = ObjDesc->Processor.Handler; - break; - case ACPI_TYPE_THERMAL: - HandlerObj = ObjDesc->ThermalZone.Handler; + HandlerObj = ObjDesc->CommonNotify.Handler; break; case ACPI_TYPE_METHOD: @@ -667,51 +631,43 @@ AcpiEvInitializeRegion ( break; } - while (HandlerObj) + HandlerObj = AcpiEvFindRegionHandler (SpaceId, HandlerObj); + if (HandlerObj) { - /* Is this handler of the correct type? */ - - if (HandlerObj->AddressSpace.SpaceId == SpaceId) - { - /* Found correct handler */ + /* Found correct handler */ - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Found handler %p for region %p in obj %p\n", - HandlerObj, RegionObj, ObjDesc)); + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Found handler %p for region %p in obj %p\n", + HandlerObj, RegionObj, ObjDesc)); - Status = AcpiEvAttachRegion (HandlerObj, RegionObj, - AcpiNsLocked); + Status = AcpiEvAttachRegion (HandlerObj, RegionObj, + AcpiNsLocked); - /* - * Tell all users that this region is usable by - * running the _REG method - */ - if (AcpiNsLocked) + /* + * Tell all users that this region is usable by + * running the _REG method + */ + if (AcpiNsLocked) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) { - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + return_ACPI_STATUS (Status); } + } - Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT); + Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT); - if (AcpiNsLocked) + if (AcpiNsLocked) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) { - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + return_ACPI_STATUS (Status); } - - return_ACPI_STATUS (AE_OK); } - /* Try next handler in the list */ - - HandlerObj = HandlerObj->AddressSpace.Next; + return_ACPI_STATUS (AE_OK); } } diff --git a/sys/contrib/dev/acpica/components/events/evsci.c b/sys/contrib/dev/acpica/components/events/evsci.c index 70920a5..a4d71db 100644 --- a/sys/contrib/dev/acpica/components/events/evsci.c +++ b/sys/contrib/dev/acpica/components/events/evsci.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -218,7 +218,7 @@ AcpiEvInstallSciHandler ( Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, - AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead); + AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead); return_ACPI_STATUS (Status); } @@ -257,7 +257,7 @@ AcpiEvRemoveAllSciHandlers ( /* Just let the OS remove the handler and disable the level */ Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, - AcpiEvSciXruptHandler); + AcpiEvSciXruptHandler); if (!AcpiGbl_SciHandlerList) { diff --git a/sys/contrib/dev/acpica/components/events/evxface.c b/sys/contrib/dev/acpica/components/events/evxface.c index 6a4b254..6306a578 100644 --- a/sys/contrib/dev/acpica/components/events/evxface.c +++ b/sys/contrib/dev/acpica/components/events/evxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1002,8 +1002,8 @@ AcpiInstallGpeHandler ( ACPI_FUNCTION_TRACE (AcpiInstallGpeHandler); - Status = AcpiEvInstallGpeHandler (GpeDevice, GpeNumber, Type, FALSE, - Address, Context); + Status = AcpiEvInstallGpeHandler (GpeDevice, GpeNumber, Type, + FALSE, Address, Context); return_ACPI_STATUS (Status); } @@ -1043,8 +1043,8 @@ AcpiInstallGpeRawHandler ( ACPI_FUNCTION_TRACE (AcpiInstallGpeRawHandler); - Status = AcpiEvInstallGpeHandler (GpeDevice, GpeNumber, Type, TRUE, - Address, Context); + Status = AcpiEvInstallGpeHandler (GpeDevice, GpeNumber, Type, + TRUE, Address, Context); return_ACPI_STATUS (Status); } @@ -1210,7 +1210,7 @@ AcpiAcquireGlobalLock ( AcpiExEnterInterpreter (); Status = AcpiExAcquireMutexObject (Timeout, - AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); if (ACPI_SUCCESS (Status)) { diff --git a/sys/contrib/dev/acpica/components/events/evxfevnt.c b/sys/contrib/dev/acpica/components/events/evxfevnt.c index 5515922..81d315c 100644 --- a/sys/contrib/dev/acpica/components/events/evxfevnt.c +++ b/sys/contrib/dev/acpica/components/events/evxfevnt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -76,7 +76,7 @@ AcpiEnable ( /* ACPI tables must be present */ - if (!AcpiTbTablesLoaded ()) + if (AcpiGbl_FadtIndex == ACPI_INVALID_TABLE_INDEX) { return_ACPI_STATUS (AE_NO_ACPI_TABLES); } @@ -92,7 +92,8 @@ AcpiEnable ( if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) { - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "System is already in ACPI mode\n")); } else { @@ -162,7 +163,8 @@ AcpiDisable ( return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "ACPI mode disabled\n")); } return_ACPI_STATUS (Status); @@ -208,8 +210,8 @@ AcpiEnableEvent ( * register bit) */ Status = AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - ACPI_ENABLE_EVENT); + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_ENABLE_EVENT); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -218,7 +220,7 @@ AcpiEnableEvent ( /* Make sure that the hardware responded */ Status = AcpiReadBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -274,15 +276,15 @@ AcpiDisableEvent ( * register bit) */ Status = AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - ACPI_DISABLE_EVENT); + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiReadBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -335,8 +337,8 @@ AcpiClearEvent ( * register bit) */ Status = AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].StatusRegisterId, - ACPI_CLEAR_STATUS); + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); return_ACPI_STATUS (Status); } @@ -393,7 +395,7 @@ AcpiGetEventStatus ( /* Fixed event currently enabled? */ Status = AcpiReadBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &InByte); + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &InByte); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -408,7 +410,7 @@ AcpiGetEventStatus ( /* Fixed event currently active? */ Status = AcpiReadBitRegister ( - AcpiGbl_FixedEventInfo[Event].StatusRegisterId, &InByte); + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, &InByte); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/events/evxfgpe.c b/sys/contrib/dev/acpica/components/events/evxfgpe.c index f09d56a..9d3e881 100644 --- a/sys/contrib/dev/acpica/components/events/evxfgpe.c +++ b/sys/contrib/dev/acpica/components/events/evxfgpe.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -440,7 +440,7 @@ AcpiSetupGpeForWake ( * level-triggered (for windows compatibility). */ if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) == - ACPI_GPE_DISPATCH_NONE) + ACPI_GPE_DISPATCH_NONE) { /* * This is the first device for implicit notify on this GPE. @@ -455,7 +455,7 @@ AcpiSetupGpeForWake ( * this device to the notify list. */ if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) == - ACPI_GPE_DISPATCH_NOTIFY) + ACPI_GPE_DISPATCH_NOTIFY) { /* Ensure that the device is not already in the list */ @@ -920,8 +920,8 @@ AcpiInstallGpeBlock ( * is always zero */ Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress->Address, - GpeBlockAddress->SpaceId, RegisterCount, - 0, InterruptNumber, &GpeBlock); + GpeBlockAddress->SpaceId, RegisterCount, + 0, InterruptNumber, &GpeBlock); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; diff --git a/sys/contrib/dev/acpica/components/events/evxfregn.c b/sys/contrib/dev/acpica/components/events/evxfregn.c index 8b0d80e..c8a6edd 100644 --- a/sys/contrib/dev/acpica/components/events/evxfregn.c +++ b/sys/contrib/dev/acpica/components/events/evxfregn.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -114,48 +114,16 @@ AcpiInstallAddressSpaceHandler ( /* Install the handler for all Regions for this Space ID */ - Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context); + Status = AcpiEvInstallSpaceHandler ( + Node, SpaceId, Handler, Setup, Context); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } - /* - * For the default SpaceIDs, (the IDs for which there are default region handlers - * installed) Only execute the _REG methods if the global initialization _REG - * methods have already been run (via AcpiInitializeObjects). In other words, - * we will defer the execution of the _REG methods for these SpaceIDs until - * execution of AcpiInitializeObjects. This is done because we need the handlers - * for the default spaces (mem/io/pci/table) to be installed before we can run - * any control methods (or _REG methods). There is known BIOS code that depends - * on this. - * - * For all other SpaceIDs, we can safely execute the _REG methods immediately. - * This means that for IDs like EmbeddedController, this function should be called - * only after AcpiEnableSubsystem has been called. - */ - switch (SpaceId) - { - case ACPI_ADR_SPACE_SYSTEM_MEMORY: - case ACPI_ADR_SPACE_SYSTEM_IO: - case ACPI_ADR_SPACE_PCI_CONFIG: - case ACPI_ADR_SPACE_DATA_TABLE: - - if (!AcpiGbl_RegMethodsExecuted) - { - /* We will defer execution of the _REG methods for this space */ - goto UnlockAndExit; - } - break; - - default: - - break; - } - /* Run all _REG methods for this address space */ - Status = AcpiEvExecuteRegMethods (Node, SpaceId); + AcpiEvExecuteRegMethods (Node, SpaceId, ACPI_REG_CONNECT); UnlockAndExit: @@ -234,8 +202,8 @@ AcpiRemoveAddressSpaceHandler ( /* Find the address handler the user requested */ - HandlerObj = ObjDesc->Device.Handler; - LastObjPtr = &ObjDesc->Device.Handler; + HandlerObj = ObjDesc->CommonNotify.Handler; + LastObjPtr = &ObjDesc->CommonNotify.Handler; while (HandlerObj) { /* We have a handler, see if user requested this one */ diff --git a/sys/contrib/dev/acpica/components/executer/exconcat.c b/sys/contrib/dev/acpica/components/executer/exconcat.c new file mode 100644 index 0000000..1814a5c --- /dev/null +++ b/sys/contrib/dev/acpica/components/executer/exconcat.c @@ -0,0 +1,460 @@ +/****************************************************************************** + * + * Module Name: exconcat - Concatenate-type AML operators + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/include/amlresrc.h> + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconcat") + +/* Local Prototypes */ + +static ACPI_STATUS +AcpiExConvertToObjectTypeString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoConcatenate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects with the ACPI-defined conversion + * rules as necessary. + * NOTE: + * Per the ACPI spec (up to 6.1), Concatenate only supports Integer, + * String, and Buffer objects. However, we support all objects here + * as an extension. This improves the usefulness of both Concatenate + * and the Printf/Fprintf macros. The extension returns a string + * describing the object type for the other objects. + * 02/2016. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *LocalOperand0 = Operand0; + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_OPERAND_OBJECT *TempOperand1 = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc; + char *Buffer; + ACPI_OBJECT_TYPE Operand0Type; + ACPI_OBJECT_TYPE Operand1Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExDoConcatenate); + + + /* Operand 0 preprocessing */ + + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + Operand0Type = Operand0->Common.Type; + break; + + default: + + /* For all other types, get the "object type" string */ + + Status = AcpiExConvertToObjectTypeString ( + Operand0, &LocalOperand0); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Operand0Type = ACPI_TYPE_STRING; + break; + } + + /* Operand 1 preprocessing */ + + switch (Operand1->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + Operand1Type = Operand1->Common.Type; + break; + + default: + + /* For all other types, get the "object type" string */ + + Status = AcpiExConvertToObjectTypeString ( + Operand1, &LocalOperand1); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Operand1Type = ACPI_TYPE_STRING; + break; + } + + /* + * Convert the second operand if necessary. The first operand (0) + * determines the type of the second operand (1) (See the Data Types + * section of the ACPI specification). Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0Type) + { + case ACPI_TYPE_INTEGER: + + Status = AcpiExConvertToInteger (LocalOperand1, &TempOperand1, 16); + break; + + case ACPI_TYPE_BUFFER: + + Status = AcpiExConvertToBuffer (LocalOperand1, &TempOperand1); + break; + + case ACPI_TYPE_STRING: + + switch (Operand1Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Other types have already been converted to string */ + + Status = AcpiExConvertToString ( + LocalOperand1, &TempOperand1, ACPI_IMPLICIT_CONVERT_HEX); + break; + + default: + + Status = AE_OK; + break; + } + break; + + default: + + ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", + Operand0->Common.Type)); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Take care with any newly created operand objects */ + + if ((LocalOperand1 != Operand1) && + (LocalOperand1 != TempOperand1)) + { + AcpiUtRemoveReference (LocalOperand1); + } + + LocalOperand1 = TempOperand1; + + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform + * the concatenation. + * + * There are three cases to handle, as per the ACPI spec: + * + * 1) Two Integers concatenated to produce a new Buffer + * 2) Two Strings concatenated to produce a new String + * 3) Two Buffers concatenated to produce a new Buffer + */ + switch (Operand0Type) + { + case ACPI_TYPE_INTEGER: + + /* Result of two Integers is a Buffer */ + /* Need enough buffer space for two integers */ + + ReturnDesc = AcpiUtCreateBufferObject ( + (ACPI_SIZE) ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Buffer = (char *) ReturnDesc->Buffer.Pointer; + + /* Copy the first integer, LSB first */ + + memcpy (Buffer, &Operand0->Integer.Value, + AcpiGbl_IntegerByteWidth); + + /* Copy the second integer (LSB first) after the first */ + + memcpy (Buffer + AcpiGbl_IntegerByteWidth, + &LocalOperand1->Integer.Value, AcpiGbl_IntegerByteWidth); + break; + + case ACPI_TYPE_STRING: + + /* Result of two Strings is a String */ + + ReturnDesc = AcpiUtCreateStringObject ( + ((ACPI_SIZE) LocalOperand0->String.Length + + LocalOperand1->String.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Buffer = ReturnDesc->String.Pointer; + + /* Concatenate the strings */ + + strcpy (Buffer, LocalOperand0->String.Pointer); + strcat (Buffer, LocalOperand1->String.Pointer); + break; + + case ACPI_TYPE_BUFFER: + + /* Result of two Buffers is a Buffer */ + + ReturnDesc = AcpiUtCreateBufferObject ( + ((ACPI_SIZE) Operand0->Buffer.Length + + LocalOperand1->Buffer.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Buffer = (char *) ReturnDesc->Buffer.Pointer; + + /* Concatenate the buffers */ + + memcpy (Buffer, Operand0->Buffer.Pointer, + Operand0->Buffer.Length); + memcpy (Buffer + Operand0->Buffer.Length, + LocalOperand1->Buffer.Pointer, + LocalOperand1->Buffer.Length); + break; + + default: + + /* Invalid object type, should not happen here */ + + ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", + Operand0->Common.Type)); + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + *ActualReturnDesc = ReturnDesc; + +Cleanup: + if (LocalOperand0 != Operand0) + { + AcpiUtRemoveReference (LocalOperand0); + } + + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToObjectTypeString + * + * PARAMETERS: ObjDesc - Object to be converted + * ReturnDesc - Where to place the return object + * + * RETURN: Status + * + * DESCRIPTION: Convert an object of arbitrary type to a string object that + * contains the namestring for the object. Used for the + * concatenate operator. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExConvertToObjectTypeString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + const char *TypeString; + + + TypeString = AcpiUtGetTypeName (ObjDesc->Common.Type); + + ReturnDesc = AcpiUtCreateStringObject ( + ((ACPI_SIZE) strlen (TypeString) + 9)); /* 9 For "[ Object]" */ + if (!ReturnDesc) + { + return (AE_NO_MEMORY); + } + + strcpy (ReturnDesc->String.Pointer, "["); + strcat (ReturnDesc->String.Pointer, TypeString); + strcat (ReturnDesc->String.Pointer, " Object]"); + + *ResultDesc = ReturnDesc; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConcatTemplate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two resource templates + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + UINT8 *EndTag; + ACPI_SIZE Length0; + ACPI_SIZE Length1; + ACPI_SIZE NewLength; + + + ACPI_FUNCTION_TRACE (ExConcatTemplate); + + + /* + * Find the EndTag descriptor in each resource template. + * Note1: returned pointers point TO the EndTag, not past it. + * Note2: zero-length buffers are allowed; treated like one EndTag + */ + + /* Get the length of the first resource template */ + + Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); + + /* Get the length of the second resource template */ + + Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); + + /* Combine both lengths, minimum size will be 2 for EndTag */ + + NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); + + /* Create a new buffer object for the result (with one EndTag) */ + + ReturnDesc = AcpiUtCreateBufferObject (NewLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the templates to the new buffer, 0 first, then 1 follows. One + * EndTag descriptor is copied from Operand1. + */ + NewBuf = ReturnDesc->Buffer.Pointer; + memcpy (NewBuf, Operand0->Buffer.Pointer, Length0); + memcpy (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); + + /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ + + NewBuf[NewLength - 1] = 0; + NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; + + /* Return the completed resource template */ + + *ActualReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} diff --git a/sys/contrib/dev/acpica/components/executer/exconfig.c b/sys/contrib/dev/acpica/components/executer/exconfig.c index 0627f99..cf76bf1 100644 --- a/sys/contrib/dev/acpica/components/executer/exconfig.c +++ b/sys/contrib/dev/acpica/components/executer/exconfig.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -129,7 +129,10 @@ AcpiExAddTable ( /* Execute any module-level code that was found in the table */ AcpiExExitInterpreter (); - AcpiNsExecModuleCodeList (); + if (AcpiGbl_GroupModuleLevelCode) + { + AcpiNsExecModuleCodeList (); + } AcpiExEnterInterpreter (); /* @@ -178,21 +181,12 @@ AcpiExLoadTableOp ( ACPI_FUNCTION_TRACE (ExLoadTableOp); - /* Validate lengths for the Signature, OemId, and OemTableId strings */ - - if ((Operand[0]->String.Length > ACPI_NAME_SIZE) || - (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) || - (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE)) - { - return_ACPI_STATUS (AE_AML_STRING_LIMIT); - } - /* Find the ACPI table in the RSDT/XSDT */ Status = AcpiTbFindTable ( - Operand[0]->String.Pointer, - Operand[1]->String.Pointer, - Operand[2]->String.Pointer, &TableIndex); + Operand[0]->String.Pointer, + Operand[1]->String.Pointer, + Operand[2]->String.Pointer, &TableIndex); if (ACPI_FAILURE (Status)) { if (Status != AE_NOT_FOUND) @@ -226,7 +220,7 @@ AcpiExLoadTableOp ( * location within the namespace where the table will be loaded. */ Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer, - ACPI_NS_SEARCH_PARENT, &ParentNode); + ACPI_NS_SEARCH_PARENT, &ParentNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -250,7 +244,7 @@ AcpiExLoadTableOp ( /* Find the node referenced by the ParameterPathString */ Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, - ACPI_NS_SEARCH_PARENT, &ParameterNode); + ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -272,8 +266,7 @@ AcpiExLoadTableOp ( /* Store the parameter data into the optional parameter object */ Status = AcpiExStore (Operand[5], - ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), - WalkState); + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); @@ -286,7 +279,7 @@ AcpiExLoadTableOp ( Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_SUCCESS (Status)) { - ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + ACPI_INFO (("Dynamic OEM Table Load:")); AcpiTbPrintTableHeader (0, Table); } @@ -295,7 +288,7 @@ AcpiExLoadTableOp ( if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); + AcpiGbl_TableHandlerContext); } *ReturnDesc = DdbHandle; @@ -335,7 +328,7 @@ AcpiExRegionRead ( for (i = 0; i < Length; i++) { Status = AcpiEvAddressSpaceDispatch (ObjDesc, NULL, ACPI_READ, - RegionOffset, 8, &Value); + RegionOffset, 8, &Value); if (ACPI_FAILURE (Status)) { return (Status); @@ -405,8 +398,8 @@ AcpiExLoadOp ( } /* - * If the Region Address and Length have not been previously evaluated, - * evaluate them now and save the results. + * If the Region Address and Length have not been previously + * evaluated, evaluate them now and save the results. */ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) { @@ -426,7 +419,7 @@ AcpiExLoadOp ( } Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), - ACPI_CAST_PTR (UINT8, TableHeader)); + ACPI_CAST_PTR (UINT8, TableHeader)); Length = TableHeader->Length; ACPI_FREE (TableHeader); @@ -469,7 +462,7 @@ AcpiExLoadOp ( /* Read the entire table */ Status = AcpiExRegionRead (ObjDesc, Length, - ACPI_CAST_PTR (UINT8, Table)); + ACPI_CAST_PTR (UINT8, Table)); if (ACPI_FAILURE (Status)) { ACPI_FREE (Table); @@ -491,7 +484,8 @@ AcpiExLoadOp ( /* Get the actual table length from the table header */ - TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); + TableHeader = ACPI_CAST_PTR ( + ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); Length = TableHeader->Length; /* Table cannot extend beyond the buffer */ @@ -506,8 +500,8 @@ AcpiExLoadOp ( } /* - * Copy the table from the buffer because the buffer could be modified - * or even deleted in the future + * Copy the table from the buffer because the buffer could be + * modified or even deleted in the future */ Table = ACPI_ALLOCATE (Length); if (!Table) @@ -515,7 +509,7 @@ AcpiExLoadOp ( return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_MEMCPY (Table, TableHeader, Length); + memcpy (Table, TableHeader, Length); break; default: @@ -525,12 +519,12 @@ AcpiExLoadOp ( /* Install the new table into the local data structures */ - ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + ACPI_INFO (("Dynamic OEM Table Load:")); (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), - ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, TRUE, - &TableIndex); + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, TRUE, + &TableIndex); (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) @@ -545,7 +539,8 @@ AcpiExLoadOp ( * Note: Now table is "INSTALLED", it must be validated before * loading. */ - Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + Status = AcpiTbValidateTable ( + &AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -588,7 +583,7 @@ AcpiExLoadOp ( if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); + AcpiGbl_TableHandlerContext); } return_ACPI_STATUS (Status); @@ -665,7 +660,7 @@ AcpiExUnloadTable ( if (ACPI_SUCCESS (Status)) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, - AcpiGbl_TableHandlerContext); + AcpiGbl_TableHandlerContext); } } diff --git a/sys/contrib/dev/acpica/components/executer/exconvrt.c b/sys/contrib/dev/acpica/components/executer/exconvrt.c index 50ccf26..871e1e3 100644 --- a/sys/contrib/dev/acpica/components/executer/exconvrt.c +++ b/sys/contrib/dev/acpica/components/executer/exconvrt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -137,7 +137,8 @@ AcpiExConvertToInteger ( * of ACPI 3.0) is that the ToInteger() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). */ - Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result); + Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, + AcpiGbl_IntegerByteWidth, &Result); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -251,9 +252,7 @@ AcpiExConvertToBuffer ( /* Copy the integer to the buffer, LSB first */ NewBuf = ReturnDesc->Buffer.Pointer; - ACPI_MEMCPY (NewBuf, - &ObjDesc->Integer.Value, - AcpiGbl_IntegerByteWidth); + memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth); break; case ACPI_TYPE_STRING: @@ -266,8 +265,8 @@ AcpiExConvertToBuffer ( * ASL/AML code that depends on the null being transferred to the new * buffer. */ - ReturnDesc = AcpiUtCreateBufferObject ( - (ACPI_SIZE) ObjDesc->String.Length + 1); + ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) + ObjDesc->String.Length + 1); if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -276,7 +275,7 @@ AcpiExConvertToBuffer ( /* Copy the string to the buffer */ NewBuf = ReturnDesc->Buffer.Pointer; - ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, + strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer, ObjDesc->String.Length); break; @@ -390,7 +389,8 @@ AcpiExConvertToAscii ( { /* Get one hex digit, most significant digits first */ - String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); + String[k] = (UINT8) + AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); k++; } break; @@ -491,8 +491,8 @@ AcpiExConvertToString ( /* Convert integer to string */ - StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, - NewBuf, AcpiGbl_IntegerByteWidth); + StringLength = AcpiExConvertToAscii ( + ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth); /* Null terminate at the correct place */ @@ -581,8 +581,7 @@ AcpiExConvertToString ( for (i = 0; i < ObjDesc->Buffer.Length; i++) { NewBuf += AcpiExConvertToAscii ( - (UINT64) ObjDesc->Buffer.Pointer[i], Base, - NewBuf, 1); + (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1); *NewBuf++ = Separator; /* each separated by a comma or space */ } @@ -673,6 +672,7 @@ AcpiExConvertToTargetType ( break; case ARGI_TARGETREF: + case ARGI_STORE_TARGET: switch (DestinationType) { @@ -684,8 +684,7 @@ AcpiExConvertToTargetType ( * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ - Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, - 16); + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, 16); break; case ACPI_TYPE_STRING: @@ -694,7 +693,7 @@ AcpiExConvertToTargetType ( * Integer or Buffer if necessary */ Status = AcpiExConvertToString (SourceDesc, ResultDesc, - ACPI_IMPLICIT_CONVERT_HEX); + ACPI_IMPLICIT_CONVERT_HEX); break; case ACPI_TYPE_BUFFER: @@ -707,7 +706,8 @@ AcpiExConvertToTargetType ( default: - ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: 0x%X", + ACPI_ERROR ((AE_INFO, + "Bad destination type during conversion: 0x%X", DestinationType)); Status = AE_AML_INTERNAL; break; diff --git a/sys/contrib/dev/acpica/components/executer/excreate.c b/sys/contrib/dev/acpica/components/executer/excreate.c index a855f20..5c38a44 100644 --- a/sys/contrib/dev/acpica/components/executer/excreate.c +++ b/sys/contrib/dev/acpica/components/executer/excreate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -147,7 +147,7 @@ AcpiExCreateAlias ( * target node or the alias Node */ Status = AcpiNsAttachObject (AliasNode, - AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); + AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); break; } @@ -192,7 +192,7 @@ AcpiExCreateEvent ( * that the event is created in an unsignalled state */ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &ObjDesc->Event.OsSemaphore); + &ObjDesc->Event.OsSemaphore); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -200,8 +200,9 @@ AcpiExCreateEvent ( /* Attach object to the Node */ - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], - ObjDesc, ACPI_TYPE_EVENT); + Status = AcpiNsAttachObject ( + (ACPI_NAMESPACE_NODE *) WalkState->Operands[0], + ObjDesc, ACPI_TYPE_EVENT); Cleanup: /* @@ -260,7 +261,8 @@ AcpiExCreateMutex ( ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); + Status = AcpiNsAttachObject ( + ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); Cleanup: @@ -328,7 +330,8 @@ AcpiExCreateRegion ( * a table load for this exception. Instead, if the region is * actually used at runtime, abort the executing method. */ - ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); + ACPI_ERROR ((AE_INFO, + "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); } ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n", @@ -347,9 +350,10 @@ AcpiExCreateRegion ( * Remember location in AML stream of address & length * operands since they need to be evaluated at run time. */ - RegionObj2 = ObjDesc->Common.NextObject; + RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc); RegionObj2->Extra.AmlStart = AmlStart; RegionObj2->Extra.AmlLength = AmlLength; + RegionObj2->Extra.Method_REG = NULL; if (WalkState->ScopeInfo) { RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node; @@ -365,6 +369,10 @@ AcpiExCreateRegion ( ObjDesc->Region.Address = 0; ObjDesc->Region.Length = 0; ObjDesc->Region.Node = Node; + ObjDesc->Region.Handler = NULL; + ObjDesc->Common.Flags &= + ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED | + AOPOBJ_OBJECT_INITIALIZED); /* Install the new region object in the parent Node */ @@ -423,7 +431,7 @@ AcpiExCreateProcessor ( /* Install the processor object in the parent Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_PROCESSOR); + ObjDesc, ACPI_TYPE_PROCESSOR); /* Remove local reference to the object */ @@ -474,7 +482,7 @@ AcpiExCreatePowerResource ( /* Install the power resource object in the parent Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_POWER); + ObjDesc, ACPI_TYPE_POWER); /* Remove local reference to the object */ @@ -526,13 +534,15 @@ AcpiExCreateMethod ( ObjDesc->Method.AmlStart = AmlStart; ObjDesc->Method.AmlLength = AmlLength; + ObjDesc->Method.Node = Operand[0]; /* * Disassemble the method flags. Split off the ArgCount, Serialized * flag, and SyncLevel for efficiency. */ MethodFlags = (UINT8) Operand[1]->Integer.Value; - ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); + ObjDesc->Method.ParamCount = (UINT8) + (MethodFlags & AML_METHOD_ARG_COUNT); /* * Get the SyncLevel. If method is serialized, a mutex will be @@ -553,7 +563,7 @@ AcpiExCreateMethod ( /* Attach the new object to the method Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_METHOD); + ObjDesc, ACPI_TYPE_METHOD); /* Remove local reference to the object */ diff --git a/sys/contrib/dev/acpica/components/executer/exdebug.c b/sys/contrib/dev/acpica/components/executer/exdebug.c index 5e98fd5..24273f8 100644 --- a/sys/contrib/dev/acpica/components/executer/exdebug.c +++ b/sys/contrib/dev/acpica/components/executer/exdebug.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,6 +81,8 @@ AcpiExDoDebugObject ( { UINT32 i; UINT32 Timer; + ACPI_OPERAND_OBJECT *ObjectDesc; + UINT32 Value; ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); @@ -94,13 +96,20 @@ AcpiExDoDebugObject ( return_VOID; } - /* - * We will emit the current timer value (in microseconds) with each - * debug output. Only need the lower 26 bits. This allows for 67 - * million microseconds or 67 seconds before rollover. - */ - Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */ - Timer &= 0x03FFFFFF; + /* Null string or newline -- don't emit the line header */ + + if (SourceDesc && + (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) && + (SourceDesc->Common.Type == ACPI_TYPE_STRING)) + { + if ((SourceDesc->String.Length == 0) || + ((SourceDesc->String.Length == 1) && + (*SourceDesc->String.Pointer == '\n'))) + { + AcpiOsPrintf ("\n"); + return_VOID; + } + } /* * Print line header as long as we are not in the middle of an @@ -108,14 +117,31 @@ AcpiExDoDebugObject ( */ if (!((Level > 0) && Index == 0)) { - AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " "); + if (AcpiGbl_DisplayDebugTimer) + { + /* + * We will emit the current timer value (in microseconds) with each + * debug output. Only need the lower 26 bits. This allows for 67 + * million microseconds or 67 seconds before rollover. + * + * Convert 100 nanosecond units to microseconds + */ + Timer = ((UINT32) AcpiOsGetTimer () / 10); + Timer &= 0x03FFFFFF; + + AcpiOsPrintf ("[ACPI Debug T=0x%8.8X] %*s", Timer, Level, " "); + } + else + { + AcpiOsPrintf ("[ACPI Debug] %*s", Level, " "); + } } /* Display the index for package output only */ if (Index > 0) { - AcpiOsPrintf ("(%.2u) ", Index-1); + AcpiOsPrintf ("(%.2u) ", Index - 1); } if (!SourceDesc) @@ -126,7 +152,13 @@ AcpiExDoDebugObject ( if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) { - AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc)); + /* No object type prefix needed for integers and strings */ + + if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && + (SourceDesc->Common.Type != ACPI_TYPE_STRING)) + { + AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc)); + } if (!AcpiUtValidInternalObject (SourceDesc)) { @@ -136,9 +168,9 @@ AcpiExDoDebugObject ( } else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) { - AcpiOsPrintf ("%s: %p\n", + AcpiOsPrintf ("%s (Node %p)\n", AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), - SourceDesc); + SourceDesc); return_VOID; } else @@ -176,13 +208,12 @@ AcpiExDoDebugObject ( case ACPI_TYPE_STRING: - AcpiOsPrintf ("[0x%.2X] \"%s\"\n", - SourceDesc->String.Length, SourceDesc->String.Pointer); + AcpiOsPrintf ("\"%s\"\n", SourceDesc->String.Pointer); break; case ACPI_TYPE_PACKAGE: - AcpiOsPrintf ("[Contains 0x%.2X Elements]\n", + AcpiOsPrintf ("(Contains 0x%.2X Elements):\n", SourceDesc->Package.Count); /* Output the entire contents of the package */ @@ -190,7 +221,7 @@ AcpiExDoDebugObject ( for (i = 0; i < SourceDesc->Package.Count; i++) { AcpiExDoDebugObject (SourceDesc->Package.Elements[i], - Level+4, i+1); + Level + 4, i + 1); } break; @@ -226,7 +257,7 @@ AcpiExDoDebugObject ( if (SourceDesc->Reference.Node) { if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != - ACPI_DESC_TYPE_NAMED) + ACPI_DESC_TYPE_NAMED) { AcpiOsPrintf (" %p - Not a valid namespace node\n", SourceDesc->Reference.Node); @@ -251,7 +282,7 @@ AcpiExDoDebugObject ( default: AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, - Level+4, 0); + Level + 4, 0); break; } } @@ -259,23 +290,61 @@ AcpiExDoDebugObject ( else if (SourceDesc->Reference.Object) { if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == - ACPI_DESC_TYPE_NAMED) + ACPI_DESC_TYPE_NAMED) { - AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) - SourceDesc->Reference.Object)->Object, - Level+4, 0); + /* Reference object is a namespace node */ + + AcpiExDoDebugObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, + SourceDesc->Reference.Object), + Level + 4, 0); } else { - AcpiExDoDebugObject (SourceDesc->Reference.Object, - Level+4, 0); + ObjectDesc = SourceDesc->Reference.Object; + Value = SourceDesc->Reference.Value; + + switch (ObjectDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n", + Value, *SourceDesc->Reference.IndexPointer); + break; + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n", + Value, *SourceDesc->Reference.IndexPointer, + *SourceDesc->Reference.IndexPointer); + break; + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("Package[%u] = ", Value); + if (!(*SourceDesc->Reference.Where)) + { + AcpiOsPrintf ("[Uninitialized Package Element]\n"); + } + else + { + AcpiExDoDebugObject (*SourceDesc->Reference.Where, + Level+4, 0); + } + break; + + default: + + AcpiOsPrintf ("Unknown Reference object type %X\n", + ObjectDesc->Common.Type); + break; + } } } break; default: - AcpiOsPrintf ("%p\n", SourceDesc); + AcpiOsPrintf ("(Descriptor %p)\n", SourceDesc); break; } diff --git a/sys/contrib/dev/acpica/components/executer/exdump.c b/sys/contrib/dev/acpica/components/executer/exdump.c index 622dc14..3e6c089 100644 --- a/sys/contrib/dev/acpica/components/executer/exdump.c +++ b/sys/contrib/dev/acpica/components/executer/exdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,13 +60,13 @@ static void AcpiExOutString ( - char *Title, - char *Value); + const char *Title, + const char *Value); static void AcpiExOutPointer ( - char *Title, - void *Value); + const char *Title, + const void *Value); static void AcpiExDumpObject ( @@ -238,7 +238,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"} }; -static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = +static ACPI_EXDUMP_INFO AcpiExDumpReference[9] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"}, @@ -247,6 +247,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"}, {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Reference.Node), "Node"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.IndexPointer), "Index Pointer"}, {ACPI_EXD_REFERENCE,0, NULL} }; @@ -379,8 +380,7 @@ AcpiExDumpObject ( ACPI_EXDUMP_INFO *Info) { UINT8 *Target; - char *Name; - const char *ReferenceName; + const char *Name; UINT8 Count; ACPI_OPERAND_OBJECT *Start; ACPI_OPERAND_OBJECT *Data = NULL; @@ -452,7 +452,8 @@ AcpiExDumpObject ( case ACPI_EXD_BUFFER: - ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); + ACPI_DUMP_BUFFER ( + ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); break; case ACPI_EXD_PACKAGE: @@ -470,8 +471,7 @@ AcpiExDumpObject ( case ACPI_EXD_REFERENCE: - ReferenceName = AcpiUtGetReferenceName (ObjDesc); - AcpiExOutString ("Class Name", ACPI_CAST_PTR (char, ReferenceName)); + AcpiExOutString ("Class Name", AcpiUtGetReferenceName (ObjDesc)); AcpiExDumpReferenceObj (ObjDesc); break; @@ -500,7 +500,8 @@ AcpiExDumpObject ( if ((Next == Start) || (Next == Data)) { - AcpiOsPrintf ("\n**** Error: Object list appears to be circular linked"); + AcpiOsPrintf ( + "\n**** Error: Object list appears to be circular linked"); break; } } @@ -518,7 +519,8 @@ AcpiExDumpObject ( if (Next) { AcpiOsPrintf ("(%s %2.2X)", - AcpiUtGetObjectTypeName (Next), Next->Common.Type); + AcpiUtGetObjectTypeName (Next), + Next->AddressSpace.SpaceId); while (Next->AddressSpace.Next) { @@ -530,11 +532,13 @@ AcpiExDumpObject ( Next = Next->AddressSpace.Next; AcpiOsPrintf ("->%p(%s %2.2X)", Next, - AcpiUtGetObjectTypeName (Next), Next->Common.Type); + AcpiUtGetObjectTypeName (Next), + Next->AddressSpace.SpaceId); if ((Next == Start) || (Next == Data)) { - AcpiOsPrintf ("\n**** Error: Handler list appears to be circular linked"); + AcpiOsPrintf ( + "\n**** Error: Handler list appears to be circular linked"); break; } } @@ -568,7 +572,8 @@ AcpiExDumpObject ( if ((Next == Start) || (Next == Data)) { - AcpiOsPrintf ("\n**** Error: Region list appears to be circular linked"); + AcpiOsPrintf ( + "\n**** Error: Region list appears to be circular linked"); break; } } @@ -676,7 +681,8 @@ AcpiExDumpOperand ( { case ACPI_TYPE_LOCAL_REFERENCE: - AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc)); + AcpiOsPrintf ("Reference: [%s] ", + AcpiUtGetReferenceName (ObjDesc)); switch (ObjDesc->Reference.Class) { @@ -704,7 +710,8 @@ AcpiExDumpOperand ( case ACPI_REFCLASS_NAME: - AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii); + AcpiOsPrintf ("- [%4.4s]\n", + ObjDesc->Reference.Node->Name.Ascii); break; case ACPI_REFCLASS_ARG: @@ -735,8 +742,8 @@ AcpiExDumpOperand ( Length = 128; } - AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n", - Length); + AcpiOsPrintf ( + "Buffer Contents: (displaying length 0x%.2X)\n", Length); ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length); } break; @@ -762,7 +769,8 @@ AcpiExDumpOperand ( { for (Index = 0; Index < ObjDesc->Package.Count; Index++) { - AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1); + AcpiExDumpOperand ( + ObjDesc->Package.Elements[Index], Depth + 1); } } break; @@ -815,7 +823,7 @@ AcpiExDumpOperand ( ObjDesc->Field.BaseByteOffset, ObjDesc->Field.StartFieldBitOffset); - AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1); + AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth + 1); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: @@ -835,13 +843,13 @@ AcpiExDumpOperand ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n")); } else if ((ObjDesc->BufferField.BufferObj)->Common.Type != - ACPI_TYPE_BUFFER) + ACPI_TYPE_BUFFER) { AcpiOsPrintf ("*not a Buffer*\n"); } else { - AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1); + AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth + 1); } break; @@ -960,16 +968,16 @@ AcpiExDumpOperands ( static void AcpiExOutString ( - char *Title, - char *Value) + const char *Title, + const char *Value) { AcpiOsPrintf ("%20s : %s\n", Title, Value); } static void AcpiExOutPointer ( - char *Title, - void *Value) + const char *Title, + const void *Value) { AcpiOsPrintf ("%20s : %p\n", Title, Value); } @@ -1038,7 +1046,8 @@ AcpiExDumpReferenceObj ( { AcpiOsPrintf (" %p ", ObjDesc->Reference.Node); - Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf); + Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, + &RetBuf, TRUE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf (" Could not convert name to pathname\n"); @@ -1053,16 +1062,18 @@ AcpiExDumpReferenceObj ( { if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) { - AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object); + AcpiOsPrintf ("%22s %p", "Target :", + ObjDesc->Reference.Object); if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE) { - AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value); + AcpiOsPrintf (" Table Index: %X\n", + ObjDesc->Reference.Value); } else { - AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object, + AcpiOsPrintf (" [%s]\n", AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) - ObjDesc->Reference.Object)->Common.Type)); + ObjDesc->Reference.Object)->Common.Type)); } } else @@ -1138,7 +1149,8 @@ AcpiExDumpPackageObj ( AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); if (ObjDesc->Buffer.Length) { - AcpiUtDebugDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), + AcpiUtDebugDumpBuffer ( + ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); } else @@ -1154,7 +1166,8 @@ AcpiExDumpPackageObj ( for (i = 0; i < ObjDesc->Package.Count; i++) { - AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i); + AcpiExDumpPackageObj ( + ObjDesc->Package.Elements[i], Level + 1, i); } break; @@ -1252,7 +1265,8 @@ DumpObject: ObjDesc = ObjDesc->Common.NextObject; if (ObjDesc->Common.Type > ACPI_TYPE_LOCAL_MAX) { - AcpiOsPrintf ("Secondary object is not a known object type: %2.2X\n", + AcpiOsPrintf ( + "Secondary object is not a known object type: %2.2X\n", ObjDesc->Common.Type); return_VOID; diff --git a/sys/contrib/dev/acpica/components/executer/exfield.c b/sys/contrib/dev/acpica/components/executer/exfield.c index 836a378..aa71d6e 100644 --- a/sys/contrib/dev/acpica/components/executer/exfield.c +++ b/sys/contrib/dev/acpica/components/executer/exfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -184,28 +184,31 @@ AcpiExReadDataFromField ( ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) { /* - * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold - * the data and then directly access the region handler. + * This is an SMBus, GSBus or IPMI read. We must create a buffer to + * hold the data and then directly access the region handler. * - * Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function + * Note: SMBus and GSBus protocol value is passed in upper 16-bits + * of Function */ - if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + if (ObjDesc->Field.RegionObj->Region.SpaceId == + ACPI_ADR_SPACE_SMBUS) { Length = ACPI_SMBUS_BUFFER_SIZE; Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); } - else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) + else if (ObjDesc->Field.RegionObj->Region.SpaceId == + ACPI_ADR_SPACE_GSBUS) { AccessorType = ObjDesc->Field.Attribute; - Length = AcpiExGetSerialAccessLength (AccessorType, - ObjDesc->Field.AccessLength); + Length = AcpiExGetSerialAccessLength ( + AccessorType, ObjDesc->Field.AccessLength); /* * Add additional 2 bytes for the GenericSerialBus data buffer: * - * Status; (Byte 0 of the data buffer) - * Length; (Byte 1 of the data buffer) - * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) + * Status; (Byte 0 of the data buffer) + * Length; (Byte 1 of the data buffer) + * Data[x-1]: (Bytes 2-x of the arbitrary length data buffer) */ Length += 2; Function = ACPI_READ | (AccessorType << 16); @@ -229,8 +232,8 @@ AcpiExReadDataFromField ( /* Call the region handler for the read */ Status = AcpiExAccessRegion (ObjDesc, 0, - ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer), - Function); + ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer), Function); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); goto Exit; } @@ -245,7 +248,9 @@ AcpiExReadDataFromField ( * * Note: Field.length is in bits. */ - Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength); + Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->Field.BitLength); + if (Length > AcpiGbl_IntegerByteWidth) { /* Field is too large for an Integer, create a Buffer instead */ @@ -290,8 +295,9 @@ AcpiExReadDataFromField ( /* Perform the write */ - Status = AcpiExAccessRegion (ObjDesc, 0, - (UINT64 *) Buffer, ACPI_READ); + Status = AcpiExAccessRegion ( + ObjDesc, 0, (UINT64 *) Buffer, ACPI_READ); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); if (ACPI_FAILURE (Status)) { @@ -396,42 +402,47 @@ AcpiExWriteDataToField ( ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) { /* - * This is an SMBus, GSBus or IPMI write. We will bypass the entire field - * mechanism and handoff the buffer directly to the handler. For - * these address spaces, the buffer is bi-directional; on a write, - * return data is returned in the same buffer. + * This is an SMBus, GSBus or IPMI write. We will bypass the entire + * field mechanism and handoff the buffer directly to the handler. + * For these address spaces, the buffer is bi-directional; on a + * write, return data is returned in the same buffer. * * Source must be a buffer of sufficient size: - * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE. + * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or + * ACPI_IPMI_BUFFER_SIZE. * - * Note: SMBus and GSBus protocol type is passed in upper 16-bits of Function + * Note: SMBus and GSBus protocol type is passed in upper 16-bits + * of Function */ if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) { ACPI_ERROR ((AE_INFO, - "SMBus/IPMI/GenericSerialBus write requires Buffer, found type %s", + "SMBus/IPMI/GenericSerialBus write requires " + "Buffer, found type %s", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + if (ObjDesc->Field.RegionObj->Region.SpaceId == + ACPI_ADR_SPACE_SMBUS) { Length = ACPI_SMBUS_BUFFER_SIZE; Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); } - else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) + else if (ObjDesc->Field.RegionObj->Region.SpaceId == + ACPI_ADR_SPACE_GSBUS) { AccessorType = ObjDesc->Field.Attribute; - Length = AcpiExGetSerialAccessLength (AccessorType, - ObjDesc->Field.AccessLength); + Length = AcpiExGetSerialAccessLength ( + AccessorType, ObjDesc->Field.AccessLength); /* * Add additional 2 bytes for the GenericSerialBus data buffer: * - * Status; (Byte 0 of the data buffer) - * Length; (Byte 1 of the data buffer) - * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) + * Status; (Byte 0 of the data buffer) + * Length; (Byte 1 of the data buffer) + * Data[x-1]: (Bytes 2-x of the arbitrary length data buffer) */ Length += 2; Function = ACPI_WRITE | (AccessorType << 16); @@ -445,7 +456,8 @@ AcpiExWriteDataToField ( if (SourceDesc->Buffer.Length < Length) { ACPI_ERROR ((AE_INFO, - "SMBus/IPMI/GenericSerialBus write requires Buffer of length %u, found length %u", + "SMBus/IPMI/GenericSerialBus write requires " + "Buffer of length %u, found length %u", Length, SourceDesc->Buffer.Length)); return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); @@ -460,7 +472,7 @@ AcpiExWriteDataToField ( } Buffer = BufferDesc->Buffer.Pointer; - ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length); + memcpy (Buffer, SourceDesc->Buffer.Pointer, Length); /* Lock entire transaction if requested */ @@ -470,8 +482,8 @@ AcpiExWriteDataToField ( * Perform the write (returns status and perhaps data in the * same buffer) */ - Status = AcpiExAccessRegion (ObjDesc, 0, - (UINT64 *) Buffer, Function); + Status = AcpiExAccessRegion ( + ObjDesc, 0, (UINT64 *) Buffer, Function); AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); *ResultDesc = BufferDesc; @@ -494,7 +506,7 @@ AcpiExWriteDataToField ( } ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "GPIO FieldWrite [FROM]: (%s:%X), Val %.8X [TO]: Pin %u Bits %u\n", + "GPIO FieldWrite [FROM]: (%s:%X), Val %.8X [TO]: Pin %u Bits %u\n", AcpiUtGetTypeName (SourceDesc->Common.Type), SourceDesc->Common.Type, (UINT32) SourceDesc->Integer.Value, ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength)); @@ -507,8 +519,8 @@ AcpiExWriteDataToField ( /* Perform the write */ - Status = AcpiExAccessRegion (ObjDesc, 0, - (UINT64 *) Buffer, ACPI_WRITE); + Status = AcpiExAccessRegion ( + ObjDesc, 0, (UINT64 *) Buffer, ACPI_WRITE); AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/executer/exfldio.c b/sys/contrib/dev/acpica/components/executer/exfldio.c index 2908da4..e928881 100644 --- a/sys/contrib/dev/acpica/components/executer/exfldio.c +++ b/sys/contrib/dev/acpica/components/executer/exfldio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -120,7 +120,8 @@ AcpiExSetupRegion ( if (!AcpiIsValidSpaceId (SpaceId)) { - ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); + ACPI_ERROR ((AE_INFO, + "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); } @@ -170,8 +171,8 @@ AcpiExSetupRegion ( * (Region length is specified in bytes) */ if (RgnDesc->Region.Length < - (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset + - ObjDesc->CommonField.AccessByteWidth)) + (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset + + ObjDesc->CommonField.AccessByteWidth)) { if (AcpiGbl_EnableInterpreterSlack) { @@ -198,7 +199,8 @@ AcpiExSetupRegion ( * byte, and a field with Dword access specified. */ ACPI_ERROR ((AE_INFO, - "Field [%4.4s] access width (%u bytes) too large for region [%4.4s] (length %u)", + "Field [%4.4s] access width (%u bytes) " + "too large for region [%4.4s] (length %u)", AcpiUtGetNodeName (ObjDesc->CommonField.Node), ObjDesc->CommonField.AccessByteWidth, AcpiUtGetNodeName (RgnDesc->Region.Node), @@ -210,7 +212,8 @@ AcpiExSetupRegion ( * exceeds region length, indicate an error */ ACPI_ERROR ((AE_INFO, - "Field [%4.4s] Base+Offset+Width %u+%u+%u is beyond end of region [%4.4s] (length %u)", + "Field [%4.4s] Base+Offset+Width %u+%u+%u " + "is beyond end of region [%4.4s] (length %u)", AcpiUtGetNodeName (ObjDesc->CommonField.Node), ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, @@ -300,8 +303,8 @@ AcpiExAccessRegion ( /* Invoke the appropriate AddressSpace/OpRegion handler */ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ObjDesc, - Function, RegionOffset, - ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); + Function, RegionOffset, + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); if (ACPI_FAILURE (Status)) { @@ -456,7 +459,7 @@ AcpiExFieldDatumIo ( * Copy the data from the source buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY (Value, + memcpy (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + ObjDesc->BufferField.BaseByteOffset + FieldDatumByteOffset, @@ -468,7 +471,7 @@ AcpiExFieldDatumIo ( * Copy the data to the target buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + memcpy ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + ObjDesc->BufferField.BaseByteOffset + FieldDatumByteOffset, Value, ObjDesc->CommonField.AccessByteWidth); @@ -512,8 +515,8 @@ AcpiExFieldDatumIo ( * For simple RegionFields, we just directly access the owning * Operation Region. */ - Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value, - ReadWrite); + Status = AcpiExAccessRegion ( + ObjDesc, FieldDatumByteOffset, Value, ReadWrite); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: @@ -536,8 +539,7 @@ AcpiExFieldDatumIo ( FieldDatumByteOffset)); Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj, - &FieldDatumByteOffset, - sizeof (FieldDatumByteOffset)); + &FieldDatumByteOffset, sizeof (FieldDatumByteOffset)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -550,8 +552,8 @@ AcpiExFieldDatumIo ( ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Read from Data Register\n")); - Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, - Value, sizeof (UINT64)); + Status = AcpiExExtractFromField ( + ObjDesc->IndexField.DataObj, Value, sizeof (UINT64)); } else { @@ -561,8 +563,8 @@ AcpiExFieldDatumIo ( "Write to Data Register: Value %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (*Value))); - Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, - Value, sizeof (UINT64)); + Status = AcpiExInsertIntoField ( + ObjDesc->IndexField.DataObj, Value, sizeof (UINT64)); } break; @@ -644,14 +646,14 @@ AcpiExWriteWithUpdateRule ( * ones) The left shift drops the bits we want to ignore. */ if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) - - ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0) + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0) { /* * Read the current contents of the byte/word/dword containing * the field, and merge with the new field value. */ - Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &CurrentValue, ACPI_READ); + Status = AcpiExFieldDatumIo ( + ObjDesc, FieldDatumByteOffset, &CurrentValue, ACPI_READ); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -679,13 +681,15 @@ AcpiExWriteWithUpdateRule ( ACPI_ERROR ((AE_INFO, "Unknown UpdateRule value: 0x%X", - (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK))); + (ObjDesc->CommonField.FieldFlags & + AML_FIELD_UPDATE_RULE_MASK))); return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } } ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", + "Mask %8.8X%8.8X, DatumOffset %X, Width %X, " + "Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Mask), FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, @@ -694,8 +698,8 @@ AcpiExWriteWithUpdateRule ( /* Write the merged value */ - Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &MergedValue, ACPI_WRITE); + Status = AcpiExFieldDatumIo ( + ObjDesc, FieldDatumByteOffset, &MergedValue, ACPI_WRITE); return_ACPI_STATUS (Status); } @@ -748,7 +752,7 @@ AcpiExExtractFromField ( return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } - ACPI_MEMSET (Buffer, 0, BufferLength); + memset (Buffer, 0, BufferLength); AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth); /* Handle the simple case here */ @@ -765,7 +769,7 @@ AcpiExExtractFromField ( /* Use RawDatum (UINT64) to handle buffers < 64 bits */ Status = AcpiExFieldDatumIo (ObjDesc, 0, &RawDatum, ACPI_READ); - ACPI_MEMCPY (Buffer, &RawDatum, BufferLength); + memcpy (Buffer, &RawDatum, BufferLength); } return_ACPI_STATUS (Status); @@ -806,8 +810,8 @@ AcpiExExtractFromField ( /* Get next input datum from the field */ FieldOffset += ObjDesc->CommonField.AccessByteWidth; - Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, - &RawDatum, ACPI_READ); + Status = AcpiExFieldDatumIo ( + ObjDesc, FieldOffset, &RawDatum, ACPI_READ); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -835,7 +839,7 @@ AcpiExExtractFromField ( /* Write merged datum to target buffer */ - ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + memcpy (((char *) Buffer) + BufferOffset, &MergedDatum, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); @@ -853,7 +857,7 @@ AcpiExExtractFromField ( /* Write the last datum to the buffer */ - ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + memcpy (((char *) Buffer) + BufferOffset, &MergedDatum, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); @@ -904,7 +908,8 @@ AcpiExInsertIntoField ( NewBuffer = NULL; RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.BitLength); + ObjDesc->CommonField.BitLength); + /* * We must have a buffer that is at least as long as the field * we are writing to. This is because individual fields are @@ -926,7 +931,7 @@ AcpiExInsertIntoField ( * at Byte zero. All unused (upper) bytes of the * buffer will be 0. */ - ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength); + memcpy ((char *) NewBuffer, (char *) Buffer, BufferLength); Buffer = NewBuffer; BufferLength = RequiredLength; } @@ -969,7 +974,7 @@ AcpiExInsertIntoField ( /* Get initial Datum from the input buffer */ - ACPI_MEMCPY (&RawDatum, Buffer, + memcpy (&RawDatum, Buffer, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); @@ -982,8 +987,8 @@ AcpiExInsertIntoField ( /* Write merged datum to the target field */ MergedDatum &= Mask; - Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, - MergedDatum, FieldOffset); + Status = AcpiExWriteWithUpdateRule ( + ObjDesc, Mask, MergedDatum, FieldOffset); if (ACPI_FAILURE (Status)) { goto Exit; @@ -1021,7 +1026,7 @@ AcpiExInsertIntoField ( /* Get the next input datum from the buffer */ BufferOffset += ObjDesc->CommonField.AccessByteWidth; - ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset, + memcpy (&RawDatum, ((char *) Buffer) + BufferOffset, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); @@ -1040,8 +1045,8 @@ AcpiExInsertIntoField ( /* Write the last datum to the field */ MergedDatum &= Mask; - Status = AcpiExWriteWithUpdateRule (ObjDesc, - Mask, MergedDatum, FieldOffset); + Status = AcpiExWriteWithUpdateRule ( + ObjDesc, Mask, MergedDatum, FieldOffset); Exit: /* Free temporary buffer if we used one */ diff --git a/sys/contrib/dev/acpica/components/executer/exmisc.c b/sys/contrib/dev/acpica/components/executer/exmisc.c index d4e1a3b..1ba30f4 100644 --- a/sys/contrib/dev/acpica/components/executer/exmisc.c +++ b/sys/contrib/dev/acpica/components/executer/exmisc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acinterp.h> #include <contrib/dev/acpica/include/amlcode.h> -#include <contrib/dev/acpica/include/amlresrc.h> #define _COMPONENT ACPI_EXECUTER @@ -107,9 +106,9 @@ AcpiExGetObjectReference ( default: - ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X", + ACPI_ERROR ((AE_INFO, "Invalid Reference Class 0x%2.2X", ObjDesc->Reference.Class)); - return_ACPI_STATUS (AE_AML_INTERNAL); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } break; @@ -150,275 +149,6 @@ AcpiExGetObjectReference ( /******************************************************************************* * - * FUNCTION: AcpiExConcatTemplate - * - * PARAMETERS: Operand0 - First source object - * Operand1 - Second source object - * ActualReturnDesc - Where to place the return object - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two resource templates - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExConcatTemplate ( - ACPI_OPERAND_OBJECT *Operand0, - ACPI_OPERAND_OBJECT *Operand1, - ACPI_OPERAND_OBJECT **ActualReturnDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ReturnDesc; - UINT8 *NewBuf; - UINT8 *EndTag; - ACPI_SIZE Length0; - ACPI_SIZE Length1; - ACPI_SIZE NewLength; - - - ACPI_FUNCTION_TRACE (ExConcatTemplate); - - - /* - * Find the EndTag descriptor in each resource template. - * Note1: returned pointers point TO the EndTag, not past it. - * Note2: zero-length buffers are allowed; treated like one EndTag - */ - - /* Get the length of the first resource template */ - - Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); - - /* Get the length of the second resource template */ - - Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); - - /* Combine both lengths, minimum size will be 2 for EndTag */ - - NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); - - /* Create a new buffer object for the result (with one EndTag) */ - - ReturnDesc = AcpiUtCreateBufferObject (NewLength); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* - * Copy the templates to the new buffer, 0 first, then 1 follows. One - * EndTag descriptor is copied from Operand1. - */ - NewBuf = ReturnDesc->Buffer.Pointer; - ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0); - ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); - - /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ - - NewBuf[NewLength - 1] = 0; - NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; - - /* Return the completed resource template */ - - *ActualReturnDesc = ReturnDesc; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDoConcatenate - * - * PARAMETERS: Operand0 - First source object - * Operand1 - Second source object - * ActualReturnDesc - Where to place the return object - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExDoConcatenate ( - ACPI_OPERAND_OBJECT *Operand0, - ACPI_OPERAND_OBJECT *Operand1, - ACPI_OPERAND_OBJECT **ActualReturnDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; - ACPI_OPERAND_OBJECT *ReturnDesc; - char *NewBuf; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExDoConcatenate); - - - /* - * Convert the second operand if necessary. The first operand - * determines the type of the second operand, (See the Data Types - * section of the ACPI specification.) Both object types are - * guaranteed to be either Integer/String/Buffer by the operand - * resolution mechanism. - */ - switch (Operand0->Common.Type) - { - case ACPI_TYPE_INTEGER: - - Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); - break; - - case ACPI_TYPE_STRING: - - Status = AcpiExConvertToString (Operand1, &LocalOperand1, - ACPI_IMPLICIT_CONVERT_HEX); - break; - - case ACPI_TYPE_BUFFER: - - Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); - break; - - default: - - ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", - Operand0->Common.Type)); - Status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * Both operands are now known to be the same object type - * (Both are Integer, String, or Buffer), and we can now perform the - * concatenation. - */ - - /* - * There are three cases to handle: - * - * 1) Two Integers concatenated to produce a new Buffer - * 2) Two Strings concatenated to produce a new String - * 3) Two Buffers concatenated to produce a new Buffer - */ - switch (Operand0->Common.Type) - { - case ACPI_TYPE_INTEGER: - - /* Result of two Integers is a Buffer */ - /* Need enough buffer space for two integers */ - - ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) - ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - NewBuf = (char *) ReturnDesc->Buffer.Pointer; - - /* Copy the first integer, LSB first */ - - ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value, - AcpiGbl_IntegerByteWidth); - - /* Copy the second integer (LSB first) after the first */ - - ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth, - &LocalOperand1->Integer.Value, - AcpiGbl_IntegerByteWidth); - break; - - case ACPI_TYPE_STRING: - - /* Result of two Strings is a String */ - - ReturnDesc = AcpiUtCreateStringObject ( - ((ACPI_SIZE) Operand0->String.Length + - LocalOperand1->String.Length)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - NewBuf = ReturnDesc->String.Pointer; - - /* Concatenate the strings */ - - ACPI_STRCPY (NewBuf, Operand0->String.Pointer); - ACPI_STRCPY (NewBuf + Operand0->String.Length, - LocalOperand1->String.Pointer); - break; - - case ACPI_TYPE_BUFFER: - - /* Result of two Buffers is a Buffer */ - - ReturnDesc = AcpiUtCreateBufferObject ( - ((ACPI_SIZE) Operand0->Buffer.Length + - LocalOperand1->Buffer.Length)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - NewBuf = (char *) ReturnDesc->Buffer.Pointer; - - /* Concatenate the buffers */ - - ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, - Operand0->Buffer.Length); - ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length, - LocalOperand1->Buffer.Pointer, - LocalOperand1->Buffer.Length); - break; - - default: - - /* Invalid object type, should not happen here */ - - ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", - Operand0->Common.Type)); - Status =AE_AML_INTERNAL; - goto Cleanup; - } - - *ActualReturnDesc = ReturnDesc; - -Cleanup: - if (LocalOperand1 != Operand1) - { - AcpiUtRemoveReference (LocalOperand1); - } - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * * FUNCTION: AcpiExDoMathOp * * PARAMETERS: Opcode - AML opcode @@ -635,8 +365,8 @@ AcpiExDoLogicalOp ( case ACPI_TYPE_STRING: - Status = AcpiExConvertToString (Operand1, &LocalOperand1, - ACPI_IMPLICIT_CONVERT_HEX); + Status = AcpiExConvertToString ( + Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX); break; case ACPI_TYPE_BUFFER: @@ -712,9 +442,9 @@ AcpiExDoLogicalOp ( /* Lexicographic compare: compare the data bytes */ - Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer, - LocalOperand1->Buffer.Pointer, - (Length0 > Length1) ? Length1 : Length0); + Compare = memcmp (Operand0->Buffer.Pointer, + LocalOperand1->Buffer.Pointer, + (Length0 > Length1) ? Length1 : Length0); switch (Opcode) { diff --git a/sys/contrib/dev/acpica/components/executer/exmutex.c b/sys/contrib/dev/acpica/components/executer/exmutex.c index cf82b04..989cb29 100644 --- a/sys/contrib/dev/acpica/components/executer/exmutex.c +++ b/sys/contrib/dev/acpica/components/executer/exmutex.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -209,8 +209,7 @@ AcpiExAcquireMutexObject ( } else { - Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, - Timeout); + Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, Timeout); } if (ACPI_FAILURE (Status)) @@ -273,33 +272,48 @@ AcpiExAcquireMutex ( } /* - * Current sync level must be less than or equal to the sync level of the - * mutex. This mechanism provides some deadlock prevention + * Current sync level must be less than or equal to the sync level + * of the mutex. This mechanism provides some deadlock prevention. */ if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) { ACPI_ERROR ((AE_INFO, - "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%u)", + "Cannot acquire Mutex [%4.4s], " + "current SyncLevel is too large (%u)", AcpiUtGetNodeName (ObjDesc->Mutex.Node), WalkState->Thread->CurrentSyncLevel)); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Acquiring: Mutex SyncLevel %u, Thread SyncLevel %u, " + "Depth %u TID %p\n", + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel, + ObjDesc->Mutex.AcquisitionDepth, WalkState->Thread)); + Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value, - ObjDesc, WalkState->Thread->ThreadId); + ObjDesc, WalkState->Thread->ThreadId); + if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1) { /* Save Thread object, original/current sync levels */ ObjDesc->Mutex.OwnerThread = WalkState->Thread; - ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; - WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; + ObjDesc->Mutex.OriginalSyncLevel = + WalkState->Thread->CurrentSyncLevel; + WalkState->Thread->CurrentSyncLevel = + ObjDesc->Mutex.SyncLevel; /* Link the mutex to the current thread for force-unlock at method exit */ AcpiExLinkMutex (ObjDesc, WalkState->Thread); } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Acquired: Mutex SyncLevel %u, Thread SyncLevel %u, Depth %u\n", + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel, + ObjDesc->Mutex.AcquisitionDepth)); + return_ACPI_STATUS (Status); } @@ -395,9 +409,9 @@ AcpiExReleaseMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status = AE_OK; UINT8 PreviousSyncLevel; ACPI_THREAD_STATE *OwnerThread; + ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (ExReleaseMutex); @@ -455,7 +469,8 @@ AcpiExReleaseMutex ( if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel) { ACPI_ERROR ((AE_INFO, - "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %u current %u", + "Cannot release Mutex [%4.4s], SyncLevel mismatch: " + "mutex %u current %u", AcpiUtGetNodeName (ObjDesc->Mutex.Node), ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel)); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); @@ -469,6 +484,13 @@ AcpiExReleaseMutex ( PreviousSyncLevel = OwnerThread->AcquiredMutexList->Mutex.OriginalSyncLevel; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Releasing: Object SyncLevel %u, Thread SyncLevel %u, " + "Prev SyncLevel %u, Depth %u TID %p\n", + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel, + PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth, + WalkState->Thread)); + Status = AcpiExReleaseMutexObject (ObjDesc); if (ACPI_FAILURE (Status)) { @@ -482,6 +504,12 @@ AcpiExReleaseMutex ( OwnerThread->CurrentSyncLevel = PreviousSyncLevel; } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Released: Object SyncLevel %u, Thread SyncLevel, %u, " + "Prev SyncLevel %u, Depth %u\n", + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel, + PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth)); + return_ACPI_STATUS (Status); } @@ -512,7 +540,7 @@ AcpiExReleaseAllMutexes ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_NAME (ExReleaseAllMutexes); + ACPI_FUNCTION_TRACE (ExReleaseAllMutexes); /* Traverse the list of owned mutexes, releasing each one */ @@ -520,14 +548,10 @@ AcpiExReleaseAllMutexes ( while (Next) { ObjDesc = Next; - Next = ObjDesc->Mutex.Next; - - ObjDesc->Mutex.Prev = NULL; - ObjDesc->Mutex.Next = NULL; - ObjDesc->Mutex.AcquisitionDepth = 0; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Force-releasing held mutex: %p\n", ObjDesc)); + "Mutex [%4.4s] force-release, SyncLevel %u Depth %u\n", + ObjDesc->Mutex.Node->Name.Ascii, ObjDesc->Mutex.SyncLevel, + ObjDesc->Mutex.AcquisitionDepth)); /* Release the mutex, special case for Global Lock */ @@ -542,13 +566,20 @@ AcpiExReleaseAllMutexes ( AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); } + /* Update Thread SyncLevel (Last mutex is the important one) */ + + Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; + /* Mark mutex unowned */ + Next = ObjDesc->Mutex.Next; + + ObjDesc->Mutex.Prev = NULL; + ObjDesc->Mutex.Next = NULL; + ObjDesc->Mutex.AcquisitionDepth = 0; ObjDesc->Mutex.OwnerThread = NULL; ObjDesc->Mutex.ThreadId = 0; - - /* Update Thread SyncLevel (Last mutex is the important one) */ - - Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; } + + return_VOID; } diff --git a/sys/contrib/dev/acpica/components/executer/exnames.c b/sys/contrib/dev/acpica/components/executer/exnames.c index b213165..13fe83f 100644 --- a/sys/contrib/dev/acpica/components/executer/exnames.c +++ b/sys/contrib/dev/acpica/components/executer/exnames.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -160,6 +160,7 @@ AcpiExAllocateNameString ( return_PTR (NameString); } + /******************************************************************************* * * FUNCTION: AcpiExNameSegment @@ -189,8 +190,8 @@ AcpiExNameSegment ( /* - * If first character is a digit, then we know that we aren't looking at a - * valid name segment + * If first character is a digit, then we know that we aren't looking + * at a valid name segment */ CharBuf[0] = *AmlAddress; @@ -203,7 +204,7 @@ AcpiExNameSegment ( ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); for (Index = 0; - (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0)); + (Index < ACPI_NAME_SIZE) && (AcpiUtValidNameChar (*AmlAddress, 0)); Index++) { CharBuf[Index] = *AmlAddress++; @@ -221,7 +222,7 @@ AcpiExNameSegment ( if (NameString) { - ACPI_STRCAT (NameString, CharBuf); + strcat (NameString, CharBuf); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Appended to - %s\n", NameString)); } @@ -394,7 +395,8 @@ AcpiExGetNameString ( AmlAddress++; NumSegments = *AmlAddress; - NameString = AcpiExAllocateNameString (PrefixCount, NumSegments); + NameString = AcpiExAllocateNameString ( + PrefixCount, NumSegments); if (!NameString) { Status = AE_NO_MEMORY; diff --git a/sys/contrib/dev/acpica/components/executer/exoparg1.c b/sys/contrib/dev/acpica/components/executer/exoparg1.c index dc35c171..5028fa2 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg1.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg1.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -331,7 +331,7 @@ AcpiExOpcode_1A_1T_1R ( * endian unsigned value, so this boundary condition is valid. */ for (Temp32 = 0; ReturnDesc->Integer.Value && - Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value >>= 1; } @@ -348,7 +348,7 @@ AcpiExOpcode_1A_1T_1R ( * endian unsigned value, so this boundary condition is valid. */ for (Temp32 = 0; ReturnDesc->Integer.Value && - Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value <<= 1; } @@ -454,7 +454,7 @@ AcpiExOpcode_1A_1T_1R ( /* Get the object reference, store it, and remove our reference */ Status = AcpiExGetObjectReference (Operand[0], - &ReturnDesc2, WalkState); + &ReturnDesc2, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -509,28 +509,30 @@ AcpiExOpcode_1A_1T_1R ( */ case AML_COPY_OP: /* Copy (Source, Target) */ - Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, - WalkState); + Status = AcpiUtCopyIobjectToIobject ( + Operand[0], &ReturnDesc, WalkState); break; case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ - Status = AcpiExConvertToString (Operand[0], &ReturnDesc, - ACPI_EXPLICIT_CONVERT_DECIMAL); + Status = AcpiExConvertToString ( + Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_DECIMAL); if (ReturnDesc == Operand[0]) { /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); } break; case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */ - Status = AcpiExConvertToString (Operand[0], &ReturnDesc, - ACPI_EXPLICIT_CONVERT_HEX); + Status = AcpiExConvertToString ( + Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_HEX); if (ReturnDesc == Operand[0]) { /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); } break; @@ -541,17 +543,19 @@ AcpiExOpcode_1A_1T_1R ( if (ReturnDesc == Operand[0]) { /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); } break; case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ - Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, - ACPI_ANY_BASE); + Status = AcpiExConvertToInteger ( + Operand[0], &ReturnDesc, ACPI_ANY_BASE); if (ReturnDesc == Operand[0]) { /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); } break; @@ -702,11 +706,11 @@ AcpiExOpcode_1A_0T_1R ( */ if (WalkState->Opcode == AML_INCREMENT_OP) { - ReturnDesc->Integer.Value = TempDesc->Integer.Value +1; + ReturnDesc->Integer.Value = TempDesc->Integer.Value + 1; } else { - ReturnDesc->Integer.Value = TempDesc->Integer.Value -1; + ReturnDesc->Integer.Value = TempDesc->Integer.Value - 1; } /* Finished with this Integer object */ @@ -720,7 +724,7 @@ AcpiExOpcode_1A_0T_1R ( Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); break; - case AML_TYPE_OP: /* ObjectType (SourceObject) */ + case AML_OBJECT_TYPE_OP: /* ObjectType (SourceObject) */ /* * Note: The operand is not resolved at this point because we want to * get the associated object, not its value. For example, we don't @@ -754,8 +758,8 @@ AcpiExOpcode_1A_0T_1R ( /* Get the base object */ - Status = AcpiExResolveMultiple (WalkState, - Operand[0], &Type, &TempDesc); + Status = AcpiExResolveMultiple ( + WalkState, Operand[0], &Type, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -801,8 +805,10 @@ AcpiExOpcode_1A_0T_1R ( default: ACPI_ERROR ((AE_INFO, - "Operand must be Buffer/Integer/String/Package - found type %s", + "Operand must be Buffer/Integer/String/Package" + " - found type %s", AcpiUtGetTypeName (Type))); + Status = AE_AML_OPERAND_TYPE; goto Cleanup; } @@ -827,7 +833,8 @@ AcpiExOpcode_1A_0T_1R ( case AML_REF_OF_OP: /* RefOf (SourceObject) */ - Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState); + Status = AcpiExGetObjectReference ( + Operand[0], &ReturnDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -874,9 +881,9 @@ AcpiExOpcode_1A_0T_1R ( /* Set Operand[0] to the value of the local/arg */ Status = AcpiDsMethodDataGetValue ( - Operand[0]->Reference.Class, - Operand[0]->Reference.Value, - WalkState, &TempDesc); + Operand[0]->Reference.Class, + Operand[0]->Reference.Value, + WalkState, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -930,19 +937,19 @@ AcpiExOpcode_1A_0T_1R ( * Field, so we need to resolve the node to a value. */ Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node, - Operand[0]->String.Pointer, - ACPI_NS_SEARCH_PARENT, - ACPI_CAST_INDIRECT_PTR ( - ACPI_NAMESPACE_NODE, &ReturnDesc)); + Operand[0]->String.Pointer, + ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc)); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR ( - ACPI_NAMESPACE_NODE, &ReturnDesc), - WalkState); + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc), + WalkState); goto Cleanup; } } @@ -958,7 +965,7 @@ AcpiExOpcode_1A_0T_1R ( * dereferenced above. */ ReturnDesc = AcpiNsGetAttachedObject ( - (ACPI_NAMESPACE_NODE *) Operand[0]); + (ACPI_NAMESPACE_NODE *) Operand[0]); AcpiUtAddReference (ReturnDesc); } else @@ -1025,6 +1032,7 @@ AcpiExOpcode_1A_0T_1R ( ACPI_ERROR ((AE_INFO, "Unknown Index TargetType 0x%X in reference object %p", Operand[0]->Reference.TargetType, Operand[0])); + Status = AE_AML_OPERAND_TYPE; goto Cleanup; } @@ -1055,8 +1063,8 @@ AcpiExOpcode_1A_0T_1R ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - Status = AcpiExReadDataFromField (WalkState, - ReturnDesc, &TempDesc); + Status = AcpiExReadDataFromField ( + WalkState, ReturnDesc, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -1091,6 +1099,7 @@ AcpiExOpcode_1A_0T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } diff --git a/sys/contrib/dev/acpica/components/executer/exoparg2.c b/sys/contrib/dev/acpica/components/executer/exoparg2.c index da1eb6c..f223c8d 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg2.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -203,10 +203,11 @@ AcpiExOpcode_2A_2T_1R ( /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ - Status = AcpiUtDivide (Operand[0]->Integer.Value, - Operand[1]->Integer.Value, - &ReturnDesc1->Integer.Value, - &ReturnDesc2->Integer.Value); + Status = AcpiUtDivide ( + Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + &ReturnDesc1->Integer.Value, + &ReturnDesc2->Integer.Value); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -217,6 +218,7 @@ AcpiExOpcode_2A_2T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -301,9 +303,10 @@ AcpiExOpcode_2A_1T_1R ( goto Cleanup; } - ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode, - Operand[0]->Integer.Value, - Operand[1]->Integer.Value); + ReturnDesc->Integer.Value = AcpiExDoMathOp ( + WalkState->Opcode, + Operand[0]->Integer.Value, + Operand[1]->Integer.Value); goto StoreResultToTarget; } @@ -320,16 +323,17 @@ AcpiExOpcode_2A_1T_1R ( /* ReturnDesc will contain the remainder */ - Status = AcpiUtDivide (Operand[0]->Integer.Value, - Operand[1]->Integer.Value, - NULL, - &ReturnDesc->Integer.Value); + Status = AcpiUtDivide ( + Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + NULL, + &ReturnDesc->Integer.Value); break; case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ - Status = AcpiExDoConcatenate (Operand[0], Operand[1], - &ReturnDesc, WalkState); + Status = AcpiExDoConcatenate ( + Operand[0], Operand[1], &ReturnDesc, WalkState); break; case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ @@ -368,7 +372,7 @@ AcpiExOpcode_2A_1T_1R ( * Copy the raw buffer data with no transform. * (NULL terminated already) */ - ACPI_MEMCPY (ReturnDesc->String.Pointer, + memcpy (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length); break; @@ -376,8 +380,8 @@ AcpiExOpcode_2A_1T_1R ( /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ - Status = AcpiExConcatTemplate (Operand[0], Operand[1], - &ReturnDesc, WalkState); + Status = AcpiExConcatTemplate ( + Operand[0], Operand[1], &ReturnDesc, WalkState); break; case AML_INDEX_OP: /* Index (Source Index Result) */ @@ -412,6 +416,8 @@ AcpiExOpcode_2A_1T_1R ( } ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + ReturnDesc->Reference.IndexPointer = + &(Operand[0]->Buffer.Pointer [Index]); break; case ACPI_TYPE_BUFFER: @@ -423,6 +429,8 @@ AcpiExOpcode_2A_1T_1R ( } ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + ReturnDesc->Reference.IndexPointer = + &(Operand[0]->Buffer.Pointer [Index]); break; case ACPI_TYPE_PACKAGE: @@ -434,7 +442,8 @@ AcpiExOpcode_2A_1T_1R ( } ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; - ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; + ReturnDesc->Reference.Where = + &Operand[0]->Package.Elements [Index]; break; default: @@ -555,8 +564,8 @@ AcpiExOpcode_2A_0T_1R ( /* LogicalOp (Operand0, Operand1) */ Status = AcpiExDoLogicalNumericOp (WalkState->Opcode, - Operand[0]->Integer.Value, Operand[1]->Integer.Value, - &LogicalResult); + Operand[0]->Integer.Value, Operand[1]->Integer.Value, + &LogicalResult); goto StoreLogicalResult; } else if (WalkState->OpInfo->Flags & AML_LOGICAL) @@ -564,7 +573,7 @@ AcpiExOpcode_2A_0T_1R ( /* LogicalOp (Operand0, Operand1) */ Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], - Operand[1], &LogicalResult); + Operand[1], &LogicalResult); goto StoreLogicalResult; } @@ -595,6 +604,7 @@ AcpiExOpcode_2A_0T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } diff --git a/sys/contrib/dev/acpica/components/executer/exoparg3.c b/sys/contrib/dev/acpica/components/executer/exoparg3.c index da873c3..8be4d59 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg3.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg3.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -105,7 +105,8 @@ AcpiExOpcode_3A_0T_0R ( case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + "FatalOp: Type %X Code %X Arg %X " + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", (UINT32) Operand[0]->Integer.Value, (UINT32) Operand[1]->Integer.Value, (UINT32) Operand[2]->Integer.Value)); @@ -113,8 +114,8 @@ AcpiExOpcode_3A_0T_0R ( Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); if (Fatal) { - Fatal->Type = (UINT32) Operand[0]->Integer.Value; - Fatal->Code = (UINT32) Operand[1]->Integer.Value; + Fatal->Type = (UINT32) Operand[0]->Integer.Value; + Fatal->Code = (UINT32) Operand[1]->Integer.Value; Fatal->Argument = (UINT32) Operand[2]->Integer.Value; } @@ -133,8 +134,10 @@ AcpiExOpcode_3A_0T_0R ( * op is intended for use by disassemblers in order to properly * disassemble control method invocations. The opcode or group of * opcodes should be surrounded by an "if (0)" clause to ensure that - * AML interpreters never see the opcode. + * AML interpreters never see the opcode. Thus, something is + * wrong if an external opcode ever gets here. */ + ACPI_ERROR ((AE_INFO, "Executed External Op")); Status = AE_OK; goto Cleanup; @@ -142,6 +145,7 @@ AcpiExOpcode_3A_0T_0R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -189,7 +193,7 @@ AcpiExOpcode_3A_1T_1R ( * either a String or a Buffer, so just use its type. */ ReturnDesc = AcpiUtCreateInternalObject ( - (Operand[0])->Common.Type); + (Operand[0])->Common.Type); if (!ReturnDesc) { Status = AE_NO_MEMORY; @@ -214,8 +218,8 @@ AcpiExOpcode_3A_1T_1R ( else if ((Index + Length) > Operand[0]->String.Length) { - Length = (ACPI_SIZE) Operand[0]->String.Length - - (ACPI_SIZE) Index; + Length = + (ACPI_SIZE) Operand[0]->String.Length - (ACPI_SIZE) Index; } /* Strings always have a sub-pointer, not so for buffers */ @@ -261,8 +265,8 @@ AcpiExOpcode_3A_1T_1R ( { /* We have a buffer, copy the portion requested */ - ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index, - Length); + memcpy (Buffer, + Operand[0]->String.Pointer + Index, Length); } /* Set the length of the new String/Buffer */ @@ -279,6 +283,7 @@ AcpiExOpcode_3A_1T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -296,12 +301,12 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc); WalkState->ResultObj = NULL; } - - /* Set the return object and exit */ - else { + /* Set the return object and exit */ + WalkState->ResultObj = ReturnDesc; } + return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/executer/exoparg6.c b/sys/contrib/dev/acpica/components/executer/exoparg6.c index 4ff355c..09f0336 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg6.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg6.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -132,8 +132,8 @@ AcpiExDoMatch ( * True if equal: (P[i] == M) * Change to: (M == P[i]) */ - Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LEQUAL_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -145,8 +145,8 @@ AcpiExDoMatch ( * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) * Change to: (M >= P[i]) (M NotLess than P[i]) */ - Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LLESS_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -159,8 +159,8 @@ AcpiExDoMatch ( * True if less than: (P[i] < M) * Change to: (M > P[i]) */ - Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LGREATER_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -172,8 +172,8 @@ AcpiExDoMatch ( * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) * Change to: (M <= P[i]) (M NotGreater than P[i]) */ - Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LGREATER_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -186,8 +186,8 @@ AcpiExDoMatch ( * True if greater than: (P[i] > M) * Change to: (M < P[i]) */ - Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LLESS_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -303,13 +303,13 @@ AcpiExOpcode_6A_0T_1R ( * non-match. */ if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, - ThisElement, Operand[2])) + ThisElement, Operand[2])) { continue; } if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, - ThisElement, Operand[4])) + ThisElement, Operand[4])) { continue; } @@ -330,6 +330,7 @@ AcpiExOpcode_6A_0T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } diff --git a/sys/contrib/dev/acpica/components/executer/exprep.c b/sys/contrib/dev/acpica/components/executer/exprep.c index c949d8a..9f59df3 100644 --- a/sys/contrib/dev/acpica/components/executer/exprep.c +++ b/sys/contrib/dev/acpica/components/executer/exprep.c @@ -1,11 +1,11 @@ /****************************************************************************** * - * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities + * Module Name: exprep - ACPI AML field prep utilities * *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,6 +69,7 @@ AcpiExGenerateAccess ( UINT32 FieldBitLength, UINT32 RegionLength); + /******************************************************************************* * * FUNCTION: AcpiExGenerateAccess @@ -113,10 +114,13 @@ AcpiExGenerateAccess ( /* Round Field start offset and length to "minimal" byte boundaries */ - FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8)); - FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + - FieldBitOffset, 8)); - FieldByteLength = FieldByteEndOffset - FieldByteOffset; + FieldByteOffset = ACPI_DIV_8 ( + ACPI_ROUND_DOWN (FieldBitOffset, 8)); + + FieldByteEndOffset = ACPI_DIV_8 ( + ACPI_ROUND_UP (FieldBitLength + FieldBitOffset, 8)); + + FieldByteLength = FieldByteEndOffset - FieldByteOffset; ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Bit length %u, Bit offset %u\n", @@ -141,7 +145,8 @@ AcpiExGenerateAccess ( * are done. (This does not optimize for the perfectly aligned * case yet). */ - if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) + if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= + RegionLength) { FieldStartOffset = ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / @@ -165,7 +170,8 @@ AcpiExGenerateAccess ( if (Accesses <= 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Entire field can be accessed with one operation of size %u\n", + "Entire field can be accessed " + "with one operation of size %u\n", AccessByteWidth)); return_VALUE (AccessByteWidth); } @@ -176,14 +182,15 @@ AcpiExGenerateAccess ( */ if (Accesses < MinimumAccesses) { - MinimumAccesses = Accesses; + MinimumAccesses = Accesses; MinimumAccessWidth = AccessByteWidth; } } else { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "AccessWidth %u end is NOT within region\n", AccessByteWidth)); + "AccessWidth %u end is NOT within region\n", + AccessByteWidth)); if (AccessByteWidth == 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, @@ -211,6 +218,7 @@ AcpiExGenerateAccess ( */ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Cannot access field in one operation, using width 8\n")); + return_VALUE (8); } #endif /* ACPI_UNDER_DEVELOPMENT */ @@ -295,6 +303,7 @@ AcpiExDecodeFieldAccess ( ACPI_ERROR ((AE_INFO, "Unknown field access type 0x%X", Access)); + return_UINT32 (0); } @@ -374,8 +383,8 @@ AcpiExPrepCommonFieldObject ( * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is * the same (equivalent) as the ByteAlignment. */ - AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, - &ByteAlignment); + AccessBitWidth = AcpiExDecodeFieldAccess ( + ObjDesc, FieldFlags, &ByteAlignment); if (!AccessBitWidth) { return_ACPI_STATUS (AE_AML_OPERAND_VALUE); @@ -471,8 +480,8 @@ AcpiExPrepFieldValue ( ObjDesc->CommonField.Node = Info->FieldNode; Status = AcpiExPrepCommonFieldObject (ObjDesc, - Info->FieldFlags, Info->Attribute, - Info->FieldBitPosition, Info->FieldBitLength); + Info->FieldFlags, Info->Attribute, + Info->FieldBitPosition, Info->FieldBitLength); if (ACPI_FAILURE (Status)) { AcpiUtDeleteObjectDesc (ObjDesc); @@ -504,8 +513,10 @@ AcpiExPrepFieldValue ( } } - ObjDesc->Field.ResourceBuffer = SecondDesc->Buffer.Pointer; - ObjDesc->Field.ResourceLength = (UINT16) SecondDesc->Buffer.Length; + ObjDesc->Field.ResourceBuffer = + SecondDesc->Buffer.Pointer; + ObjDesc->Field.ResourceLength = + (UINT16) SecondDesc->Buffer.Length; } else if (Info->ResourceBuffer) { @@ -527,7 +538,8 @@ AcpiExPrepFieldValue ( if (AccessByteWidth < 256) { - ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth; + ObjDesc->CommonField.AccessByteWidth = + (UINT8) AccessByteWidth; } } @@ -537,8 +549,10 @@ AcpiExPrepFieldValue ( ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", - ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset, - ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj)); + ObjDesc->Field.StartFieldBitOffset, + ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.AccessByteWidth, + ObjDesc->Field.RegionObj)); break; case ACPI_TYPE_LOCAL_BANK_FIELD: @@ -618,7 +632,8 @@ AcpiExPrepFieldValue ( ObjDesc->IndexField.AccessByteWidth); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", + "IndexField: BitOff %X, Off %X, Value %X, " + "Gran %X, Index %p, Data %p\n", ObjDesc->IndexField.StartFieldBitOffset, ObjDesc->IndexField.BaseByteOffset, ObjDesc->IndexField.Value, @@ -638,10 +653,11 @@ AcpiExPrepFieldValue ( * Store the constructed descriptor (ObjDesc) into the parent Node, * preserving the current type of that NamedObj. */ - Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, - AcpiNsGetType (Info->FieldNode)); + Status = AcpiNsAttachObject ( + Info->FieldNode, ObjDesc, AcpiNsGetType (Info->FieldNode)); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Set NamedObj %p [%4.4s], ObjDesc %p\n", Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); /* Remove local reference to the object */ diff --git a/sys/contrib/dev/acpica/components/executer/exregion.c b/sys/contrib/dev/acpica/components/executer/exregion.c index 59b4612..6f44915 100644 --- a/sys/contrib/dev/acpica/components/executer/exregion.c +++ b/sys/contrib/dev/acpica/components/executer/exregion.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -417,7 +417,8 @@ AcpiExPciConfigSpaceHandler ( PciRegister = (UINT16) (UINT32) Address; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", + "Pci-Config %u (%u) Seg(%04x) Bus(%04x) " + "Dev(%04x) Func(%04x) Reg(%04x)\n", Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device, PciId->Function, PciRegister)); @@ -426,14 +427,14 @@ AcpiExPciConfigSpaceHandler ( case ACPI_READ: *Value = 0; - Status = AcpiOsReadPciConfiguration (PciId, PciRegister, - Value, BitWidth); + Status = AcpiOsReadPciConfiguration ( + PciId, PciRegister, Value, BitWidth); break; case ACPI_WRITE: - Status = AcpiOsWritePciConfiguration (PciId, PciRegister, - *Value, BitWidth); + Status = AcpiOsWritePciConfiguration ( + PciId, PciRegister, *Value, BitWidth); break; default: @@ -558,13 +559,13 @@ AcpiExDataTableSpaceHandler ( { case ACPI_READ: - ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), + memcpy (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), ACPI_DIV_8 (BitWidth)); break; case ACPI_WRITE: - ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value), + memcpy (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value), ACPI_DIV_8 (BitWidth)); break; diff --git a/sys/contrib/dev/acpica/components/executer/exresnte.c b/sys/contrib/dev/acpica/components/executer/exresnte.c index 99b64c2..3e878f6 100644 --- a/sys/contrib/dev/acpica/components/executer/exresnte.c +++ b/sys/contrib/dev/acpica/components/executer/exresnte.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,9 +98,9 @@ AcpiExResolveNodeToValue ( * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the * object that is attached to the Node. */ - Node = *ObjectPtr; + Node = *ObjectPtr; SourceDesc = AcpiNsGetAttachedObject (Node); - EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", Node, SourceDesc, AcpiUtGetTypeName (EntryType))); @@ -110,15 +110,15 @@ AcpiExResolveNodeToValue ( { /* There is always exactly one level of indirection */ - Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); SourceDesc = AcpiNsGetAttachedObject (Node); - EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); *ObjectPtr = Node; } /* * Several object types require no further processing: - * 1) Device/Thermal objects don't have a "real" subobject, return the Node + * 1) Device/Thermal objects don't have a "real" subobject, return Node * 2) Method locals and arguments have a pseudo-Node * 3) 10/2007: Added method type to assist with Package construction. */ @@ -134,7 +134,7 @@ AcpiExResolveNodeToValue ( { ACPI_ERROR ((AE_INFO, "No object attached to node [%4.4s] %p", Node->Name.Ascii, Node)); - return_ACPI_STATUS (AE_AML_NO_OPERAND); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE); } /* diff --git a/sys/contrib/dev/acpica/components/executer/exresolv.c b/sys/contrib/dev/acpica/components/executer/exresolv.c index 32862a9..75c65d6 100644 --- a/sys/contrib/dev/acpica/components/executer/exresolv.c +++ b/sys/contrib/dev/acpica/components/executer/exresolv.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -119,8 +119,8 @@ AcpiExResolveToValue ( if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) { Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), - WalkState); + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -179,7 +179,7 @@ AcpiExResolveObjectToValue ( * Note: this increments the local's object reference count */ Status = AcpiDsMethodDataGetValue (RefType, - StackDesc->Reference.Value, WalkState, &ObjDesc); + StackDesc->Reference.Value, WalkState, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -225,7 +225,6 @@ AcpiExResolveObjectToValue ( * (i.e., dereference the package index) * Delete the ref object, increment the returned object */ - AcpiUtRemoveReference (StackDesc); AcpiUtAddReference (ObjDesc); *StackPtr = ObjDesc; } @@ -236,7 +235,8 @@ AcpiExResolveObjectToValue ( * the package, can't dereference it */ ACPI_ERROR ((AE_INFO, - "Attempt to dereference an Index to NULL package element Idx=%p", + "Attempt to dereference an Index to " + "NULL package element Idx=%p", StackDesc)); Status = AE_AML_UNINITIALIZED_ELEMENT; } @@ -287,7 +287,8 @@ AcpiExResolveObjectToValue ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference type 0x%X in %p", RefType, StackDesc)); + "Unknown Reference type 0x%X in %p", + RefType, StackDesc)); Status = AE_AML_INTERNAL; break; } @@ -308,7 +309,8 @@ AcpiExResolveObjectToValue ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "FieldRead SourceDesc=%p Type=%X\n", StackDesc, StackDesc->Common.Type)); Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); @@ -351,8 +353,8 @@ AcpiExResolveMultiple ( ACPI_OBJECT_TYPE *ReturnType, ACPI_OPERAND_OBJECT **ReturnDesc) { - ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; - ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *ObjDesc = ACPI_CAST_PTR (void, Operand); + ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Operand); ACPI_OBJECT_TYPE Type; ACPI_STATUS Status; @@ -372,14 +374,23 @@ AcpiExResolveMultiple ( case ACPI_DESC_TYPE_NAMED: Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; - ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + ObjDesc = AcpiNsGetAttachedObject (Node); /* If we had an Alias node, use the attached object for type info */ if (Type == ACPI_TYPE_LOCAL_ALIAS) { Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; - ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + ObjDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ObjDesc); + } + + if (!ObjDesc) + { + ACPI_ERROR ((AE_INFO, + "[%4.4s] Node is unresolved or uninitialized", + AcpiUtGetNodeName (Node))); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE); } break; @@ -485,7 +496,7 @@ AcpiExResolveMultiple ( if (ReturnDesc) { Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, - ObjDesc->Reference.Value, WalkState, &ObjDesc); + ObjDesc->Reference.Value, WalkState, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -495,7 +506,7 @@ AcpiExResolveMultiple ( else { Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, - ObjDesc->Reference.Value, WalkState, &Node); + ObjDesc->Reference.Value, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -520,7 +531,8 @@ AcpiExResolveMultiple ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class)); + "Unknown Reference Class 0x%2.2X", + ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_AML_INTERNAL); } } diff --git a/sys/contrib/dev/acpica/components/executer/exresop.c b/sys/contrib/dev/acpica/components/executer/exresop.c index 5171f56..7f7425f 100644 --- a/sys/contrib/dev/acpica/components/executer/exresop.c +++ b/sys/contrib/dev/acpica/components/executer/exresop.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,8 @@ AcpiExCheckObjectType ( * specification, a store to a constant is a noop.) */ if ((ThisType == ACPI_TYPE_INTEGER) && - (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT)) + (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & + AOPOBJ_AML_CONSTANT)) { return (AE_OK); } @@ -216,7 +217,8 @@ AcpiExResolveOperands ( */ if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) { - ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + ObjDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ObjDesc); *StackPtr = ObjDesc; ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; } @@ -297,7 +299,8 @@ AcpiExResolveOperands ( { case ARGI_REF_OR_STRING: /* Can be a String or Reference */ - if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) && + if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == + ACPI_DESC_TYPE_OPERAND) && (ObjDesc->Common.Type == ACPI_TYPE_STRING)) { /* @@ -320,6 +323,8 @@ AcpiExResolveOperands ( case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ + case ARGI_STORE_TARGET: + /* * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE * A Namespace Node is OK as-is @@ -329,8 +334,8 @@ AcpiExResolveOperands ( goto NextOperand; } - Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE, - ObjectType, ObjDesc); + Status = AcpiExCheckObjectType ( + ACPI_TYPE_LOCAL_REFERENCE, ObjectType, ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -481,8 +486,8 @@ AcpiExResolveOperands ( * But we can implicitly convert from a BUFFER or INTEGER * Aka - "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToString (ObjDesc, StackPtr, - ACPI_IMPLICIT_CONVERT_HEX); + Status = AcpiExConvertToString ( + ObjDesc, StackPtr, ACPI_IMPLICIT_CONVERT_HEX); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) @@ -615,8 +620,10 @@ AcpiExResolveOperands ( case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ - /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ - + /* + * Need an operand of type REGION or a BUFFER + * (which could be a resolved region field) + */ switch (ObjDesc->Common.Type) { case ACPI_TYPE_BUFFER: @@ -660,9 +667,9 @@ AcpiExResolveOperands ( if (AcpiGbl_EnableInterpreterSlack) { /* - * Enable original behavior of Store(), allowing any and all - * objects as the source operand. The ACPI spec does not - * allow this, however. + * Enable original behavior of Store(), allowing any + * and all objects as the source operand. The ACPI + * spec does not allow this, however. */ break; } @@ -675,7 +682,8 @@ AcpiExResolveOperands ( } ACPI_ERROR ((AE_INFO, - "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", + "Needed Integer/Buffer/String/Package/Ref/Ddb]" + ", found [%s] %p", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -697,8 +705,8 @@ AcpiExResolveOperands ( * Make sure that the original object was resolved to the * required object type (Simple cases only). */ - Status = AcpiExCheckObjectType (TypeNeeded, - (*StackPtr)->Common.Type, *StackPtr); + Status = AcpiExCheckObjectType ( + TypeNeeded, (*StackPtr)->Common.Type, *StackPtr); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/executer/exstore.c b/sys/contrib/dev/acpica/components/executer/exstore.c index e14ab94..eb474a9 100644 --- a/sys/contrib/dev/acpica/components/executer/exstore.c +++ b/sys/contrib/dev/acpica/components/executer/exstore.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -117,8 +117,8 @@ AcpiExStore ( * Storing an object into a Named node. */ Status = AcpiExStoreObjectToNode (SourceDesc, - (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, - ACPI_IMPLICIT_CONVERSION); + (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, + ACPI_IMPLICIT_CONVERSION); return_ACPI_STATUS (Status); } @@ -147,7 +147,7 @@ AcpiExStore ( /* Destination is not a Reference object */ ACPI_ERROR ((AE_INFO, - "Target is not a Reference or Constant object - %s [%p]", + "Target is not a Reference or Constant object - [%s] %p", AcpiUtGetObjectTypeName (DestDesc), DestDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -168,8 +168,8 @@ AcpiExStore ( /* Storing an object into a Name "container" */ Status = AcpiExStoreObjectToNode (SourceDesc, - RefDesc->Reference.Object, - WalkState, ACPI_IMPLICIT_CONVERSION); + RefDesc->Reference.Object, + WalkState, ACPI_IMPLICIT_CONVERSION); break; case ACPI_REFCLASS_INDEX: @@ -185,7 +185,7 @@ AcpiExStore ( /* Store to a method local/arg */ Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, - RefDesc->Reference.Value, SourceDesc, WalkState); + RefDesc->Reference.Value, SourceDesc, WalkState); break; case ACPI_REFCLASS_DEBUG: @@ -194,7 +194,7 @@ AcpiExStore ( * displayed and otherwise has no effect -- see ACPI Specification */ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "**** Write to Debug Object: Object %p %s ****:\n\n", + "**** Write to Debug Object: Object %p [%s] ****:\n\n", SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); ACPI_DEBUG_OBJECT (SourceDesc, 0, 0); @@ -274,7 +274,8 @@ AcpiExStoreObjectToIndex ( { /* Normal object, copy it */ - Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); + Status = AcpiUtCopyIobjectToIobject ( + SourceDesc, &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -356,7 +357,7 @@ AcpiExStoreObjectToIndex ( /* All other types are invalid */ ACPI_ERROR ((AE_INFO, - "Source must be Integer/Buffer/String type, not %s", + "Source must be type [Integer/Buffer/String], found [%s]", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -368,8 +369,8 @@ AcpiExStoreObjectToIndex ( default: ACPI_ERROR ((AE_INFO, - "Target is not a Package or BufferField")); - Status = AE_AML_OPERAND_TYPE; + "Target is not of type [Package/BufferField]")); + Status = AE_AML_TARGET_TYPE; break; } @@ -390,20 +391,20 @@ AcpiExStoreObjectToIndex ( * * DESCRIPTION: Store the object to the named object. * - * The Assignment of an object to a named object is handled here - * The value passed in will replace the current value (if any) - * with the input value. + * The assignment of an object to a named object is handled here. + * The value passed in will replace the current value (if any) + * with the input value. * - * When storing into an object the data is converted to the - * target object type then stored in the object. This means - * that the target object type (for an initialized target) will - * not be changed by a store operation. A CopyObject can change - * the target type, however. + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. A CopyObject can change + * the target type, however. * - * The ImplicitConversion flag is set to NO/FALSE only when - * storing to an ArgX -- as per the rules of the ACPI spec. + * The ImplicitConversion flag is set to NO/FALSE only when + * storing to an ArgX -- as per the rules of the ACPI spec. * - * Assumes parameters are already validated. + * Assumes parameters are already validated. * ******************************************************************************/ @@ -428,9 +429,75 @@ AcpiExStoreObjectToNode ( TargetType = AcpiNsGetType (Node); TargetDesc = AcpiNsGetAttachedObject (Node); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p (%s) to node %p (%s)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p [%s] to node %p [%s]\n", SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), - Node, AcpiUtGetTypeName (TargetType))); + Node, AcpiUtGetTypeName (TargetType))); + + /* Only limited target types possible for everything except CopyObject */ + + if (WalkState->Opcode != AML_COPY_OP) + { + /* + * Only CopyObject allows all object types to be overwritten. For + * TargetRef(s), there are restrictions on the object types that + * are allowed. + * + * Allowable operations/typing for Store: + * + * 1) Simple Store + * Integer --> Integer (Named/Local/Arg) + * String --> String (Named/Local/Arg) + * Buffer --> Buffer (Named/Local/Arg) + * Package --> Package (Named/Local/Arg) + * + * 2) Store with implicit conversion + * Integer --> String or Buffer (Named) + * String --> Integer or Buffer (Named) + * Buffer --> Integer or String (Named) + */ + switch (TargetType) + { + case ACPI_TYPE_PACKAGE: + /* + * Here, can only store a package to an existing package. + * Storing a package to a Local/Arg is OK, and handled + * elsewhere. + */ + if (WalkState->Opcode == AML_STORE_OP) + { + if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, + "Cannot assign type [%s] to [Package] " + "(source must be type Pkg)", + AcpiUtGetObjectTypeName (SourceDesc))); + + return_ACPI_STATUS (AE_AML_TARGET_TYPE); + } + break; + } + + /* Fallthrough */ + + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_REGION: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + ACPI_ERROR ((AE_INFO, + "Target must be [Buffer/Integer/String/Reference]" + ", found [%s] (%4.4s)", + AcpiUtGetTypeName (Node->Type), Node->Name.Ascii)); + + return_ACPI_STATUS (AE_AML_TARGET_TYPE); + + default: + break; + } + } /* * Resolve the source object to an actual value @@ -446,13 +513,13 @@ AcpiExStoreObjectToNode ( switch (TargetType) { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: /* * The simple data types all support implicit source operand * conversion before the store. */ + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: if ((WalkState->Opcode == AML_COPY_OP) || !ImplicitConversion) @@ -462,8 +529,7 @@ AcpiExStoreObjectToNode ( * an implicit conversion, as per the ACPI specification. * A direct store is performed instead. */ - Status = AcpiExStoreDirectToNode (SourceDesc, Node, - WalkState); + Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState); break; } @@ -487,11 +553,11 @@ AcpiExStoreObjectToNode ( * store has been performed such that the node/object type * has been changed. */ - Status = AcpiNsAttachObject (Node, NewDesc, - NewDesc->Common.Type); + Status = AcpiNsAttachObject ( + Node, NewDesc, NewDesc->Common.Type); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Store %s into %s via Convert/Attach\n", + "Store type [%s] into [%s] via Convert/Attach\n", AcpiUtGetObjectTypeName (SourceDesc), AcpiUtGetObjectTypeName (NewDesc))); } @@ -513,18 +579,14 @@ AcpiExStoreObjectToNode ( default: /* - * No conversions for all other types. Directly store a copy of - * the source object. This is the ACPI spec-defined behavior for - * the CopyObject operator. + * CopyObject operator: No conversions for all other types. + * Instead, directly store a copy of the source object. * - * NOTE: For the Store operator, this is a departure from the - * ACPI spec, which states "If conversion is impossible, abort - * the running control method". Instead, this code implements - * "If conversion is impossible, treat the Store operation as - * a CopyObject". + * This is the ACPI spec-defined behavior for the CopyObject + * operator. (Note, for this default case, all normal + * Store/Target operations exited above with an error). */ - Status = AcpiExStoreDirectToNode (SourceDesc, Node, - WalkState); + Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState); break; } diff --git a/sys/contrib/dev/acpica/components/executer/exstoren.c b/sys/contrib/dev/acpica/components/executer/exstoren.c index cc56fbd..25a499b86 100644 --- a/sys/contrib/dev/acpica/components/executer/exstoren.c +++ b/sys/contrib/dev/acpica/components/executer/exstoren.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,14 +124,15 @@ AcpiExResolveObject ( (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && (SourceDesc->Common.Type != ACPI_TYPE_STRING) && !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && - (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) + (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) { /* Conversion successful but still not a valid type */ ACPI_ERROR ((AE_INFO, - "Cannot assign type %s to %s (must be type Int/Str/Buf)", + "Cannot assign type [%s] to [%s] (must be type Int/Str/Buf)", AcpiUtGetObjectTypeName (SourceDesc), AcpiUtGetTypeName (TargetType))); + Status = AE_AML_OPERAND_TYPE; } break; @@ -232,7 +233,7 @@ AcpiExStoreObjectToObject ( * converted object. */ Status = AcpiExConvertToTargetType (DestDesc->Common.Type, - SourceDesc, &ActualSrcDesc, WalkState); + SourceDesc, &ActualSrcDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -284,7 +285,7 @@ AcpiExStoreObjectToObject ( /* * All other types come here. */ - ACPI_WARNING ((AE_INFO, "Store into type %s not implemented", + ACPI_WARNING ((AE_INFO, "Store into type [%s] not implemented", AcpiUtGetObjectTypeName (DestDesc))); Status = AE_NOT_IMPLEMENTED; diff --git a/sys/contrib/dev/acpica/components/executer/exstorob.c b/sys/contrib/dev/acpica/components/executer/exstorob.c index c238310..981e261 100644 --- a/sys/contrib/dev/acpica/components/executer/exstorob.c +++ b/sys/contrib/dev/acpica/components/executer/exstorob.c @@ -1,11 +1,11 @@ /****************************************************************************** * - * Module Name: exstorob - AML Interpreter object store support, store to object + * Module Name: exstorob - AML object store support, store to object * *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -109,8 +109,8 @@ AcpiExStoreBufferToBuffer ( { /* Clear existing buffer and copy in the new one */ - ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); - ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length); + memset (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); + memcpy (TargetDesc->Buffer.Pointer, Buffer, Length); #ifdef ACPI_OBSOLETE_BEHAVIOR /* @@ -139,7 +139,7 @@ AcpiExStoreBufferToBuffer ( { /* Truncate the source, copy only what will fit */ - ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, + memcpy (TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, @@ -203,9 +203,9 @@ AcpiExStoreStringToString ( * String will fit in existing non-static buffer. * Clear old string and copy in the new one */ - ACPI_MEMSET (TargetDesc->String.Pointer, 0, + memset (TargetDesc->String.Pointer, 0, (ACPI_SIZE) TargetDesc->String.Length + 1); - ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + memcpy (TargetDesc->String.Pointer, Buffer, Length); } else { @@ -221,15 +221,16 @@ AcpiExStoreStringToString ( ACPI_FREE (TargetDesc->String.Pointer); } - TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED ( - (ACPI_SIZE) Length + 1); + TargetDesc->String.Pointer = + ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1); + if (!TargetDesc->String.Pointer) { return_ACPI_STATUS (AE_NO_MEMORY); } TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; - ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + memcpy (TargetDesc->String.Pointer, Buffer, Length); } /* Set the new target length */ diff --git a/sys/contrib/dev/acpica/components/executer/exsystem.c b/sys/contrib/dev/acpica/components/executer/exsystem.c index aa661e7..6c1dcd3 100644 --- a/sys/contrib/dev/acpica/components/executer/exsystem.c +++ b/sys/contrib/dev/acpica/components/executer/exsystem.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,7 +86,6 @@ AcpiExSystemWaitSemaphore ( /* We must wait, so unlock the interpreter */ AcpiExExitInterpreter (); - Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -95,7 +94,7 @@ AcpiExSystemWaitSemaphore ( /* Reacquire the interpreter */ - AcpiExEnterInterpreter (); + AcpiExEnterInterpreter (); } return_ACPI_STATUS (Status); @@ -139,7 +138,6 @@ AcpiExSystemWaitMutex ( /* We must wait, so unlock the interpreter */ AcpiExExitInterpreter (); - Status = AcpiOsAcquireMutex (Mutex, Timeout); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -190,8 +188,8 @@ AcpiExSystemDoStall ( * (ACPI specifies 100 usec as max, but this gives some slack in * order to support existing BIOSs) */ - ACPI_ERROR ((AE_INFO, "Time parameter is too large (%u)", - HowLong)); + ACPI_ERROR ((AE_INFO, + "Time parameter is too large (%u)", HowLong)); Status = AE_AML_OPERAND_VALUE; } else @@ -306,7 +304,7 @@ AcpiExSystemWaitEvent ( if (ObjDesc) { Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, - (UINT16) TimeDesc->Integer.Value); + (UINT16) TimeDesc->Integer.Value); } return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/executer/extrace.c b/sys/contrib/dev/acpica/components/executer/extrace.c new file mode 100644 index 0000000..ea675d9 --- /dev/null +++ b/sys/contrib/dev/acpica/components/executer/extrace.c @@ -0,0 +1,427 @@ +/****************************************************************************** + * + * Module Name: extrace - Support for interpreter execution tracing + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/include/acinterp.h> + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("extrace") + + +static ACPI_OPERAND_OBJECT *AcpiGbl_TraceMethodObject = NULL; + +/* Local prototypes */ + +#ifdef ACPI_DEBUG_OUTPUT +static const char * +AcpiExGetTraceEventName ( + ACPI_TRACE_EVENT_TYPE Type); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiExInterpreterTraceEnabled + * + * PARAMETERS: Name - Whether method name should be matched, + * this should be checked before starting + * the tracer + * + * RETURN: TRUE if interpreter trace is enabled. + * + * DESCRIPTION: Check whether interpreter trace is enabled + * + ******************************************************************************/ + +static BOOLEAN +AcpiExInterpreterTraceEnabled ( + char *Name) +{ + + /* Check if tracing is enabled */ + + if (!(AcpiGbl_TraceFlags & ACPI_TRACE_ENABLED)) + { + return (FALSE); + } + + /* + * Check if tracing is filtered: + * + * 1. If the tracer is started, AcpiGbl_TraceMethodObject should have + * been filled by the trace starter + * 2. If the tracer is not started, AcpiGbl_TraceMethodName should be + * matched if it is specified + * 3. If the tracer is oneshot style, AcpiGbl_TraceMethodName should + * not be cleared by the trace stopper during the first match + */ + if (AcpiGbl_TraceMethodObject) + { + return (TRUE); + } + + if (Name && + (AcpiGbl_TraceMethodName && + strcmp (AcpiGbl_TraceMethodName, Name))) + { + return (FALSE); + } + + if ((AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT) && + !AcpiGbl_TraceMethodName) + { + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetTraceEventName + * + * PARAMETERS: Type - Trace event type + * + * RETURN: Trace event name. + * + * DESCRIPTION: Used to obtain the full trace event name. + * + ******************************************************************************/ + +#ifdef ACPI_DEBUG_OUTPUT + +static const char * +AcpiExGetTraceEventName ( + ACPI_TRACE_EVENT_TYPE Type) +{ + + switch (Type) + { + case ACPI_TRACE_AML_METHOD: + + return "Method"; + + case ACPI_TRACE_AML_OPCODE: + + return "Opcode"; + + case ACPI_TRACE_AML_REGION: + + return "Region"; + + default: + + return ""; + } +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiExTracePoint + * + * PARAMETERS: Type - Trace event type + * Begin - TRUE if before execution + * Aml - Executed AML address + * Pathname - Object path + * + * RETURN: None + * + * DESCRIPTION: Internal interpreter execution trace. + * + ******************************************************************************/ + +void +AcpiExTracePoint ( + ACPI_TRACE_EVENT_TYPE Type, + BOOLEAN Begin, + UINT8 *Aml, + char *Pathname) +{ + + ACPI_FUNCTION_NAME (ExTracePoint); + + + if (Pathname) + { + ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT, + "%s %s [0x%p:%s] execution.\n", + AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End", + Aml, Pathname)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT, + "%s %s [0x%p] execution.\n", + AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End", + Aml)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStartTraceMethod + * + * PARAMETERS: MethodNode - Node of the method + * ObjDesc - The method object + * WalkState - current state, NULL if not yet executing + * a method. + * + * RETURN: None + * + * DESCRIPTION: Start control method execution trace + * + ******************************************************************************/ + +void +AcpiExStartTraceMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + char *Pathname = NULL; + BOOLEAN Enabled = FALSE; + + + ACPI_FUNCTION_NAME (ExStartTraceMethod); + + + if (MethodNode) + { + Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + Enabled = AcpiExInterpreterTraceEnabled (Pathname); + if (Enabled && !AcpiGbl_TraceMethodObject) + { + AcpiGbl_TraceMethodObject = ObjDesc; + AcpiGbl_OriginalDbgLevel = AcpiDbgLevel; + AcpiGbl_OriginalDbgLayer = AcpiDbgLayer; + AcpiDbgLevel = ACPI_TRACE_LEVEL_ALL; + AcpiDbgLayer = ACPI_TRACE_LAYER_ALL; + + if (AcpiGbl_TraceDbgLevel) + { + AcpiDbgLevel = AcpiGbl_TraceDbgLevel; + } + + if (AcpiGbl_TraceDbgLayer) + { + AcpiDbgLayer = AcpiGbl_TraceDbgLayer; + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +Exit: + if (Enabled) + { + ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, TRUE, + ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname); + } + + if (Pathname) + { + ACPI_FREE (Pathname); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStopTraceMethod + * + * PARAMETERS: MethodNode - Node of the method + * ObjDesc - The method object + * WalkState - current state, NULL if not yet executing + * a method. + * + * RETURN: None + * + * DESCRIPTION: Stop control method execution trace + * + ******************************************************************************/ + +void +AcpiExStopTraceMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + char *Pathname = NULL; + BOOLEAN Enabled; + + + ACPI_FUNCTION_NAME (ExStopTraceMethod); + + + if (MethodNode) + { + Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto ExitPath; + } + + Enabled = AcpiExInterpreterTraceEnabled (NULL); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (Enabled) + { + ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE, + ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto ExitPath; + } + + /* Check whether the tracer should be stopped */ + + if (AcpiGbl_TraceMethodObject == ObjDesc) + { + /* Disable further tracing if type is one-shot */ + + if (AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT) + { + AcpiGbl_TraceMethodName = NULL; + } + + AcpiDbgLevel = AcpiGbl_OriginalDbgLevel; + AcpiDbgLayer = AcpiGbl_OriginalDbgLayer; + AcpiGbl_TraceMethodObject = NULL; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +ExitPath: + if (Pathname) + { + ACPI_FREE (Pathname); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStartTraceOpcode + * + * PARAMETERS: Op - The parser opcode object + * WalkState - current state, NULL if not yet executing + * a method. + * + * RETURN: None + * + * DESCRIPTION: Start opcode execution trace + * + ******************************************************************************/ + +void +AcpiExStartTraceOpcode ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_NAME (ExStartTraceOpcode); + + + if (AcpiExInterpreterTraceEnabled (NULL) && + (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE)) + { + ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, TRUE, + Op->Common.Aml, Op->Common.AmlOpName); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStopTraceOpcode + * + * PARAMETERS: Op - The parser opcode object + * WalkState - current state, NULL if not yet executing + * a method. + * + * RETURN: None + * + * DESCRIPTION: Stop opcode execution trace + * + ******************************************************************************/ + +void +AcpiExStopTraceOpcode ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_NAME (ExStopTraceOpcode); + + + if (AcpiExInterpreterTraceEnabled (NULL) && + (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE)) + { + ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, FALSE, + Op->Common.Aml, Op->Common.AmlOpName); + } +} diff --git a/sys/contrib/dev/acpica/components/executer/exutils.c b/sys/contrib/dev/acpica/components/executer/exutils.c index a55b171..cfe5d04 100644 --- a/sys/contrib/dev/acpica/components/executer/exutils.c +++ b/sys/contrib/dev/acpica/components/executer/exutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -187,8 +187,8 @@ AcpiExTruncateFor32bitTable ( (ObjDesc->Integer.Value > (UINT64) ACPI_UINT32_MAX)) { /* - * We are executing in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper 32-bit field + * We are executing in a 32-bit ACPI table. Truncate + * the value to 32 bits by zeroing out the upper 32-bit field */ ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX; return (TRUE); @@ -232,7 +232,7 @@ AcpiExAcquireGlobalLock ( /* Attempt to get the global lock, wait forever */ Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, - AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); if (ACPI_FAILURE (Status)) { @@ -341,8 +341,8 @@ AcpiExDigitsNeeded ( * * FUNCTION: AcpiExEisaIdToString * - * PARAMETERS: CompressedId - EISAID to be converted - * OutString - Where to put the converted string (8 bytes) + * PARAMETERS: OutString - Where to put the converted string (8 bytes) + * CompressedId - EISAID to be converted * * RETURN: None * @@ -369,7 +369,8 @@ AcpiExEisaIdToString ( if (CompressedId > ACPI_UINT32_MAX) { ACPI_WARNING ((AE_INFO, - "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating", + "Expected EISAID is larger than 32 bits: " + "0x%8.8X%8.8X, truncating", ACPI_FORMAT_UINT64 (CompressedId))); } @@ -399,7 +400,7 @@ AcpiExEisaIdToString ( * possible 64-bit integer. * Value - Value to be converted * - * RETURN: None, string + * RETURN: Converted string in OutString * * DESCRIPTION: Convert a 64-bit integer to decimal string representation. * Assumes string buffer is large enough to hold the string. The @@ -433,11 +434,48 @@ AcpiExIntegerToString ( /******************************************************************************* * + * FUNCTION: AcpiExPciClsToString + * + * PARAMETERS: OutString - Where to put the converted string (7 bytes) + * ClassCode - PCI class code to be converted (3 bytes) + * + * RETURN: Converted string in OutString + * + * DESCRIPTION: Convert 3-bytes PCI class code to string representation. + * Return buffer must be large enough to hold the string. The + * string returned is always exactly of length + * ACPI_PCICLS_STRING_SIZE (includes null terminator). + * + ******************************************************************************/ + +void +AcpiExPciClsToString ( + char *OutString, + UINT8 ClassCode[3]) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* All 3 bytes are hexadecimal */ + + OutString[0] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[0], 4); + OutString[1] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[0], 0); + OutString[2] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[1], 4); + OutString[3] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[1], 0); + OutString[4] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[2], 4); + OutString[5] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[2], 0); + OutString[6] = 0; +} + + +/******************************************************************************* + * * FUNCTION: AcpiIsValidSpaceId * * PARAMETERS: SpaceId - ID to be validated * - * RETURN: TRUE if valid/supported ID. + * RETURN: TRUE if SpaceId is a valid/supported ID. * * DESCRIPTION: Validate an operation region SpaceID. * @@ -459,5 +497,4 @@ AcpiIsValidSpaceId ( return (TRUE); } - #endif diff --git a/sys/contrib/dev/acpica/components/hardware/hwacpi.c b/sys/contrib/dev/acpica/components/hardware/hwacpi.c index a91b66f..54b4416 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwacpi.c +++ b/sys/contrib/dev/acpica/components/hardware/hwacpi.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -113,7 +113,7 @@ AcpiHwSetMode ( /* BIOS should have disabled ALL fixed and GP events */ Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, - (UINT32) AcpiGbl_FADT.AcpiEnable, 8); + (UINT32) AcpiGbl_FADT.AcpiEnable, 8); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); break; @@ -123,9 +123,9 @@ AcpiHwSetMode ( * enable bits to default */ Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, - (UINT32) AcpiGbl_FADT.AcpiDisable, 8); + (UINT32) AcpiGbl_FADT.AcpiDisable, 8); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Attempting to enable Legacy (non-ACPI) mode\n")); + "Attempting to enable Legacy (non-ACPI) mode\n")); break; default: @@ -149,8 +149,8 @@ AcpiHwSetMode ( { if (AcpiHwGetMode () == Mode) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", - Mode)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Mode %X successfully enabled\n", Mode)); return_ACPI_STATUS (AE_OK); } AcpiOsStall (ACPI_USEC_PER_MSEC); diff --git a/sys/contrib/dev/acpica/components/hardware/hwesleep.c b/sys/contrib/dev/acpica/components/hardware/hwesleep.c index 460b6ff..c65c8c2 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwesleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwesleep.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -130,7 +130,8 @@ AcpiHwExtendedSleep ( /* Clear wake status (WAK_STS) */ - Status = AcpiWrite ((UINT64) ACPI_X_WAKE_STATUS, &AcpiGbl_FADT.SleepStatus); + Status = AcpiWrite ((UINT64) ACPI_X_WAKE_STATUS, + &AcpiGbl_FADT.SleepStatus); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -202,7 +203,7 @@ AcpiHwExtendedWakePrep ( Status = AcpiGetSleepTypeData (ACPI_STATE_S0, - &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); if (ACPI_SUCCESS (Status)) { SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & diff --git a/sys/contrib/dev/acpica/components/hardware/hwgpe.c b/sys/contrib/dev/acpica/components/hardware/hwgpe.c index 093ba80..d58a8f4 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwgpe.c +++ b/sys/contrib/dev/acpica/components/hardware/hwgpe.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,6 +97,8 @@ AcpiHwGetGpeRegisterBit ( * RETURN: Status * * DESCRIPTION: Enable or disable a single GPE in the parent enable register. + * The EnableMask field of the involved GPE register must be + * updated by the caller if necessary. * ******************************************************************************/ @@ -133,7 +135,7 @@ AcpiHwLowSetGpe ( /* Set or clear just the bit that corresponds to this GPE */ RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo); - switch (Action & ~ACPI_GPE_SAVE_MASK) + switch (Action) { case ACPI_GPE_CONDITIONAL_ENABLE: @@ -165,10 +167,6 @@ AcpiHwLowSetGpe ( /* Write the updated enable mask */ Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); - if (ACPI_SUCCESS (Status) && (Action & ACPI_GPE_SAVE_MASK)) - { - GpeRegisterInfo->EnableMask = (UINT8) EnableMask; - } return (Status); } @@ -210,9 +208,7 @@ AcpiHwClearGpe ( */ RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo); - Status = AcpiHwWrite (RegisterBit, - &GpeRegisterInfo->StatusAddress); - + Status = AcpiHwWrite (RegisterBit, &GpeRegisterInfo->StatusAddress); return (Status); } @@ -253,7 +249,7 @@ AcpiHwGetGpeStatus ( /* GPE currently handled? */ if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) != - ACPI_GPE_DISPATCH_NONE) + ACPI_GPE_DISPATCH_NONE) { LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER; } @@ -334,12 +330,9 @@ AcpiHwGpeEnableWrite ( ACPI_STATUS Status; - Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); - if (ACPI_SUCCESS (Status)) - { - GpeRegisterInfo->EnableMask = EnableMask; - } + GpeRegisterInfo->EnableMask = EnableMask; + Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); return (Status); } @@ -464,7 +457,7 @@ AcpiHwEnableRuntimeGpeBlock ( /* Enable all "runtime" GPEs in this register */ Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForRun, - GpeRegisterInfo); + GpeRegisterInfo); if (ACPI_FAILURE (Status)) { return (Status); @@ -511,7 +504,7 @@ AcpiHwEnableWakeupGpeBlock ( * remaining ones. */ Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForWake, - GpeRegisterInfo); + GpeRegisterInfo); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/sys/contrib/dev/acpica/components/hardware/hwpci.c b/sys/contrib/dev/acpica/components/hardware/hwpci.c index c19100b..3abb424 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwpci.c +++ b/sys/contrib/dev/acpica/components/hardware/hwpci.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/hardware/hwregs.c b/sys/contrib/dev/acpica/components/hardware/hwregs.c index 9d601c5..6363bba 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwregs.c +++ b/sys/contrib/dev/acpica/components/hardware/hwregs.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,6 +68,7 @@ AcpiHwWriteMultiple ( #endif /* !ACPI_REDUCED_HARDWARE */ + /****************************************************************************** * * FUNCTION: AcpiHwValidateRegister @@ -196,14 +197,14 @@ AcpiHwRead ( if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address, &Value64, Reg->BitWidth); + Address, &Value64, Reg->BitWidth); *Value = (UINT32) Value64; } else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ { Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + Address, Value, Reg->BitWidth); } ACPI_DEBUG_PRINT ((ACPI_DB_IO, @@ -257,12 +258,12 @@ AcpiHwWrite ( if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) - Address, (UINT64) Value, Reg->BitWidth); + Address, (UINT64) Value, Reg->BitWidth); } else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ { Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + Address, Value, Reg->BitWidth); } ACPI_DEBUG_PRINT ((ACPI_DB_IO, @@ -307,7 +308,7 @@ AcpiHwClearAcpiStatus ( /* Clear the fixed events in PM1 A/B */ Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, - ACPI_BITMASK_ALL_FIXED_STATUS); + ACPI_BITMASK_ALL_FIXED_STATUS); AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); @@ -426,22 +427,22 @@ AcpiHwRegisterRead ( case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ Status = AcpiHwReadMultiple (&Value, - &AcpiGbl_XPm1aStatus, - &AcpiGbl_XPm1bStatus); + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); break; case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ Status = AcpiHwReadMultiple (&Value, - &AcpiGbl_XPm1aEnable, - &AcpiGbl_XPm1bEnable); + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); break; case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ Status = AcpiHwReadMultiple (&Value, - &AcpiGbl_FADT.XPm1aControlBlock, - &AcpiGbl_FADT.XPm1bControlBlock); + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); /* * Zero the write-only bits. From the ACPI specification, "Hardware @@ -537,15 +538,15 @@ AcpiHwRegisterWrite ( Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS; Status = AcpiHwWriteMultiple (Value, - &AcpiGbl_XPm1aStatus, - &AcpiGbl_XPm1bStatus); + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); break; case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ Status = AcpiHwWriteMultiple (Value, - &AcpiGbl_XPm1aEnable, - &AcpiGbl_XPm1bEnable); + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); break; case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ @@ -554,8 +555,8 @@ AcpiHwRegisterWrite ( * Note: This includes SCI_EN, we never want to change this bit */ Status = AcpiHwReadMultiple (&ReadValue, - &AcpiGbl_FADT.XPm1aControlBlock, - &AcpiGbl_FADT.XPm1bControlBlock); + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); if (ACPI_FAILURE (Status)) { goto Exit; @@ -568,8 +569,8 @@ AcpiHwRegisterWrite ( /* Now we can write the data */ Status = AcpiHwWriteMultiple (Value, - &AcpiGbl_FADT.XPm1aControlBlock, - &AcpiGbl_FADT.XPm1bControlBlock); + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); break; case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ diff --git a/sys/contrib/dev/acpica/components/hardware/hwsleep.c b/sys/contrib/dev/acpica/components/hardware/hwsleep.c index 2bc434e..a20143c 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwsleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwsleep.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -83,7 +83,8 @@ AcpiHwLegacySleep ( /* Clear wake status */ - Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, + ACPI_CLEAR_STATUS); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -117,7 +118,7 @@ AcpiHwLegacySleep ( /* Get current value of PM1A control */ Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, - &Pm1aControl); + &Pm1aControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -128,7 +129,7 @@ AcpiHwLegacySleep ( /* Clear the SLP_EN and SLP_TYP fields */ Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | - SleepEnableRegInfo->AccessBitMask); + SleepEnableRegInfo->AccessBitMask); Pm1bControl = Pm1aControl; /* Insert the SLP_TYP bits */ @@ -182,7 +183,7 @@ AcpiHwLegacySleep ( AcpiOsStall (10 * ACPI_USEC_PER_SEC); Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL, - SleepEnableRegInfo->AccessBitMask); + SleepEnableRegInfo->AccessBitMask); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -238,7 +239,7 @@ AcpiHwLegacyWakePrep ( * by some machines. */ Status = AcpiGetSleepTypeData (ACPI_STATE_S0, - &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); if (ACPI_SUCCESS (Status)) { SleepTypeRegInfo = @@ -249,7 +250,7 @@ AcpiHwLegacyWakePrep ( /* Get current value of PM1A control */ Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, - &Pm1aControl); + &Pm1aControl); if (ACPI_SUCCESS (Status)) { /* Clear the SLP_EN and SLP_TYP fields */ @@ -334,7 +335,8 @@ AcpiHwLegacyWake ( * and use it to determine whether the system is rebooting or * resuming. Clear WAK_STS for compatibility. */ - (void) AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + (void) AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, + ACPI_CLEAR_STATUS); AcpiGbl_SystemAwakeAndRunning = TRUE; /* Enable power button */ diff --git a/sys/contrib/dev/acpica/components/hardware/hwtimer.c b/sys/contrib/dev/acpica/components/hardware/hwtimer.c index 39c9e57..2c53dc9 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwtimer.c +++ b/sys/contrib/dev/acpica/components/hardware/hwtimer.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/hardware/hwvalid.c b/sys/contrib/dev/acpica/components/hardware/hwvalid.c index 3b6b567..c8237f8 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwvalid.c +++ b/sys/contrib/dev/acpica/components/hardware/hwvalid.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/hardware/hwxface.c b/sys/contrib/dev/acpica/components/hardware/hwxface.c index fcd5c9e..734dfc2 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwxface.c +++ b/sys/contrib/dev/acpica/components/hardware/hwxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -169,7 +169,7 @@ AcpiRead ( if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address, ReturnValue, Reg->BitWidth); + Address, ReturnValue, Reg->BitWidth); if (ACPI_FAILURE (Status)) { return (Status); @@ -187,7 +187,7 @@ AcpiRead ( } Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address, &ValueLo, Width); + Address, &ValueLo, Width); if (ACPI_FAILURE (Status)) { return (Status); @@ -198,7 +198,7 @@ AcpiRead ( /* Read the top 32 bits */ Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - (Address + 4), &ValueHi, 32); + (Address + 4), &ValueHi, 32); if (ACPI_FAILURE (Status)) { return (Status); @@ -263,7 +263,7 @@ AcpiWrite ( if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) - Address, Value, Reg->BitWidth); + Address, Value, Reg->BitWidth); if (ACPI_FAILURE (Status)) { return (Status); @@ -278,7 +278,7 @@ AcpiWrite ( } Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - Address, ACPI_LODWORD (Value), Width); + Address, ACPI_LODWORD (Value), Width); if (ACPI_FAILURE (Status)) { return (Status); @@ -287,7 +287,7 @@ AcpiWrite ( if (Reg->BitWidth == 64) { Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - (Address + 4), ACPI_HIDWORD (Value), 32); + (Address + 4), ACPI_HIDWORD (Value), 32); if (ACPI_FAILURE (Status)) { return (Status); @@ -358,7 +358,7 @@ AcpiReadBitRegister ( /* Read the entire parent register */ Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, - &RegisterValue); + &RegisterValue); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -367,7 +367,7 @@ AcpiReadBitRegister ( /* Normalize the value that was read, mask off other bits */ Value = ((RegisterValue & BitRegInfo->AccessBitMask) - >> BitRegInfo->BitPosition); + >> BitRegInfo->BitPosition); ACPI_DEBUG_PRINT ((ACPI_DB_IO, "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n", @@ -439,7 +439,7 @@ AcpiWriteBitRegister ( * interested in */ Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, - &RegisterValue); + &RegisterValue); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -453,7 +453,7 @@ AcpiWriteBitRegister ( BitRegInfo->AccessBitMask, Value); Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister, - RegisterValue); + RegisterValue); } else { @@ -473,7 +473,7 @@ AcpiWriteBitRegister ( if (RegisterValue) { Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, - RegisterValue); + RegisterValue); } } @@ -565,12 +565,19 @@ AcpiGetSleepTypeData ( * Evaluate the \_Sx namespace object containing the register values * for this state */ - Info->RelativePathname = ACPI_CAST_PTR ( - char, AcpiGbl_SleepStateNames[SleepState]); + Info->RelativePathname = AcpiGbl_SleepStateNames[SleepState]; + Status = AcpiNsEvaluate (Info); if (ACPI_FAILURE (Status)) { - goto Cleanup; + if (Status == AE_NOT_FOUND) + { + /* The _Sx states are optional, ignore NOT_FOUND */ + + goto FinalCleanup; + } + + goto WarningCleanup; } /* Must have a return object */ @@ -580,7 +587,7 @@ AcpiGetSleepTypeData ( ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]", Info->RelativePathname)); Status = AE_AML_NO_RETURN_VALUE; - goto Cleanup; + goto WarningCleanup; } /* Return object must be of type Package */ @@ -589,7 +596,7 @@ AcpiGetSleepTypeData ( { ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package")); Status = AE_AML_OPERAND_TYPE; - goto Cleanup1; + goto ReturnValueCleanup; } /* @@ -636,16 +643,18 @@ AcpiGetSleepTypeData ( break; } -Cleanup1: +ReturnValueCleanup: AcpiUtRemoveReference (Info->ReturnObject); -Cleanup: +WarningCleanup: if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "While evaluating Sleep State [%s]", Info->RelativePathname)); + "While evaluating Sleep State [%s]", + Info->RelativePathname)); } +FinalCleanup: ACPI_FREE (Info); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c b/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c index 8d5ba97..c75bec4 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,14 @@ /* Local prototypes */ +#if (!ACPI_REDUCED_HARDWARE) +static ACPI_STATUS +AcpiHwSetFirmwareWakingVector ( + ACPI_TABLE_FACS *Facs, + ACPI_PHYSICAL_ADDRESS PhysicalAddress, + ACPI_PHYSICAL_ADDRESS PhysicalAddress64); +#endif + static ACPI_STATUS AcpiHwSleepDispatch ( UINT8 SleepState, @@ -77,29 +85,33 @@ static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[] = /* * These functions are removed for the ACPI_REDUCED_HARDWARE case: * AcpiSetFirmwareWakingVector - * AcpiSetFirmwareWakingVector64 * AcpiEnterSleepStateS4bios */ #if (!ACPI_REDUCED_HARDWARE) /******************************************************************************* * - * FUNCTION: AcpiSetFirmwareWakingVector + * FUNCTION: AcpiHwSetFirmwareWakingVector * - * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode - * entry point. + * PARAMETERS: Facs - Pointer to FACS table + * PhysicalAddress - 32-bit physical address of ACPI real mode + * entry point + * PhysicalAddress64 - 64-bit physical address of ACPI protected + * mode entry point * * RETURN: Status * - * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS + * DESCRIPTION: Sets the FirmwareWakingVector fields of the FACS * ******************************************************************************/ -ACPI_STATUS -AcpiSetFirmwareWakingVector ( - UINT32 PhysicalAddress) +static ACPI_STATUS +AcpiHwSetFirmwareWakingVector ( + ACPI_TABLE_FACS *Facs, + ACPI_PHYSICAL_ADDRESS PhysicalAddress, + ACPI_PHYSICAL_ADDRESS PhysicalAddress64) { - ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); + ACPI_FUNCTION_TRACE (AcpiHwSetFirmwareWakingVector); /* @@ -112,60 +124,61 @@ AcpiSetFirmwareWakingVector ( /* Set the 32-bit vector */ - AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; - - /* Clear the 64-bit vector if it exists */ + Facs->FirmwareWakingVector = (UINT32) PhysicalAddress; - if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) + if (Facs->Length > 32) { - AcpiGbl_FACS->XFirmwareWakingVector = 0; + if (Facs->Version >= 1) + { + /* Set the 64-bit vector */ + + Facs->XFirmwareWakingVector = PhysicalAddress64; + } + else + { + /* Clear the 64-bit vector if it exists */ + + Facs->XFirmwareWakingVector = 0; + } } return_ACPI_STATUS (AE_OK); } -ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) - -#if ACPI_MACHINE_WIDTH == 64 /******************************************************************************* * - * FUNCTION: AcpiSetFirmwareWakingVector64 + * FUNCTION: AcpiSetFirmwareWakingVector * - * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected - * mode entry point. + * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode + * entry point + * PhysicalAddress64 - 64-bit physical address of ACPI protected + * mode entry point * * RETURN: Status * - * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if - * it exists in the table. This function is intended for use with - * 64-bit host operating systems. + * DESCRIPTION: Sets the FirmwareWakingVector fields of the FACS * ******************************************************************************/ ACPI_STATUS -AcpiSetFirmwareWakingVector64 ( - UINT64 PhysicalAddress) +AcpiSetFirmwareWakingVector ( + ACPI_PHYSICAL_ADDRESS PhysicalAddress, + ACPI_PHYSICAL_ADDRESS PhysicalAddress64) { - ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); - - /* Determine if the 64-bit vector actually exists */ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); - if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) + if (AcpiGbl_FACS) { - return_ACPI_STATUS (AE_NOT_EXIST); + (void) AcpiHwSetFirmwareWakingVector (AcpiGbl_FACS, + PhysicalAddress, PhysicalAddress64); } - /* Clear 32-bit vector, set the 64-bit X_ vector */ - - AcpiGbl_FACS->FirmwareWakingVector = 0; - AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; return_ACPI_STATUS (AE_OK); } -ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) -#endif +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) /******************************************************************************* @@ -226,7 +239,7 @@ AcpiEnterSleepStateS4bios ( ACPI_FLUSH_CPU_CACHE (); Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, - (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); + (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); do { AcpiOsStall (ACPI_USEC_PER_MSEC); @@ -235,6 +248,7 @@ AcpiEnterSleepStateS4bios ( { return_ACPI_STATUS (Status); } + } while (!InValue); return_ACPI_STATUS (AE_OK); @@ -330,7 +344,7 @@ AcpiEnterSleepStatePrep ( Status = AcpiGetSleepTypeData (SleepState, - &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/namespace/nsaccess.c b/sys/contrib/dev/acpica/components/namespace/nsaccess.c index 667b5af..bf32269 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsaccess.c +++ b/sys/contrib/dev/acpica/components/namespace/nsaccess.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,14 +111,14 @@ AcpiNsRootInitialize ( { /* _OSI is optional for now, will be permanent later */ - if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) + if (!strcmp (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) { continue; } - Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, - ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, - NULL, &NewNode); + Status = AcpiNsLookup (NULL, ACPI_CAST_PTR (char, InitVal->Name), + InitVal->Type, ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + NULL, &NewNode); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, @@ -191,7 +191,7 @@ AcpiNsRootInitialize ( /* Build an object around the static string */ - ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val); + ObjDesc->String.Length = (UINT32) strlen (Val); ObjDesc->String.Pointer = Val; ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; break; @@ -212,14 +212,14 @@ AcpiNsRootInitialize ( /* Special case for ACPI Global Lock */ - if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) + if (strcmp (InitVal->Name, "_GL_") == 0) { AcpiGbl_GlobalLockMutex = ObjDesc; /* Create additional counting semaphore for global lock */ Status = AcpiOsCreateSemaphore ( - 1, 0, &AcpiGbl_GlobalLockSemaphore); + 1, 0, &AcpiGbl_GlobalLockSemaphore); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); @@ -240,7 +240,7 @@ AcpiNsRootInitialize ( /* Store pointer to value descriptor in the Node */ Status = AcpiNsAttachObject (NewNode, ObjDesc, - ObjDesc->Common.Type); + ObjDesc->Common.Type); /* Remove local reference to the object */ @@ -257,7 +257,7 @@ UnlockAndExit: if (ACPI_SUCCESS (Status)) { Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, - &AcpiGbl_FadtGpeDevice); + &AcpiGbl_FadtGpeDevice); } return_ACPI_STATUS (Status); @@ -319,7 +319,9 @@ AcpiNsLookup ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); + LocalFlags = Flags & + ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND | + ACPI_NS_SEARCH_PARENT); *ReturnNode = ACPI_ENTRY_NOT_FOUND; AcpiGbl_NsLookupCount++; @@ -571,6 +573,13 @@ AcpiNsLookup ( { LocalFlags |= ACPI_NS_ERROR_IF_FOUND; } + + /* Set override flag according to caller */ + + if (Flags & ACPI_NS_OVERRIDE_IF_FOUND) + { + LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND; + } } /* Extract one ACPI name from the front of the pathname */ @@ -580,7 +589,7 @@ AcpiNsLookup ( /* Try to find the single (4 character) ACPI name */ Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, - InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); + InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) diff --git a/sys/contrib/dev/acpica/components/namespace/nsalloc.c b/sys/contrib/dev/acpica/components/namespace/nsalloc.c index 2a1e09e..c85593d 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsalloc.c +++ b/sys/contrib/dev/acpica/components/namespace/nsalloc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,7 +85,7 @@ AcpiNsCreateNode ( #ifdef ACPI_DBG_TRACK_ALLOCATIONS Temp = AcpiGbl_NsNodeList->TotalAllocated - - AcpiGbl_NsNodeList->TotalFreed; + AcpiGbl_NsNodeList->TotalFreed; if (Temp > AcpiGbl_NsNodeList->MaxOccupied) { AcpiGbl_NsNodeList->MaxOccupied = Temp; @@ -277,7 +277,8 @@ AcpiNsInstallNode ( * modified the namespace. This is used for cleanup when the * method exits. */ - WalkState->MethodDesc->Method.InfoFlags |= ACPI_METHOD_MODIFIED_NAMESPACE; + WalkState->MethodDesc->Method.InfoFlags |= + ACPI_METHOD_MODIFIED_NAMESPACE; } } diff --git a/sys/contrib/dev/acpica/components/namespace/nsarguments.c b/sys/contrib/dev/acpica/components/namespace/nsarguments.c index 5d41bb0..46d6eb91b 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsarguments.c +++ b/sys/contrib/dev/acpica/components/namespace/nsarguments.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -137,7 +137,8 @@ AcpiNsCheckAcpiCompliance ( /* Get the ACPI-required arg count from the predefined info table */ - RequiredParamCount = METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); + RequiredParamCount = + METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); /* * If this object is not a control method, we can check if the ACPI @@ -283,7 +284,8 @@ AcpiNsCheckArgumentCount ( * Some methods are allowed to have a "minimum" number of args (_SCP) * because their definition in ACPI has changed over time. */ - RequiredParamCount = METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); + RequiredParamCount = + METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); if (UserParamCount < RequiredParamCount) { diff --git a/sys/contrib/dev/acpica/components/namespace/nsconvert.c b/sys/contrib/dev/acpica/components/namespace/nsconvert.c index 091c5cc..441710b 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsconvert.c +++ b/sys/contrib/dev/acpica/components/namespace/nsconvert.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,7 +84,7 @@ AcpiNsConvertToInteger ( /* String-to-Integer conversion */ Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, - ACPI_ANY_BASE, &Value); + ACPI_ANY_BASE, AcpiGbl_IntegerByteWidth, &Value); if (ACPI_FAILURE (Status)) { return (Status); @@ -104,7 +104,8 @@ AcpiNsConvertToInteger ( for (i = 0; i < OriginalObject->Buffer.Length; i++) { - Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8)); + Value |= ((UINT64) + OriginalObject->Buffer.Pointer[i] << (i * 8)); } break; @@ -167,8 +168,8 @@ AcpiNsConvertToString ( } else { - Status = AcpiExConvertToString (OriginalObject, &NewObject, - ACPI_IMPLICIT_CONVERT_HEX); + Status = AcpiExConvertToString (OriginalObject, + &NewObject, ACPI_IMPLICIT_CONVERT_HEX); if (ACPI_FAILURE (Status)) { return (Status); @@ -202,7 +203,7 @@ AcpiNsConvertToString ( * Copy the raw buffer data with no transform. String is already NULL * terminated at Length+1. */ - ACPI_MEMCPY (NewObject->String.Pointer, + memcpy (NewObject->String.Pointer, OriginalObject->Buffer.Pointer, Length); break; @@ -263,13 +264,14 @@ AcpiNsConvertToBuffer ( /* String-to-Buffer conversion. Simple data copy */ - NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length); + NewObject = AcpiUtCreateBufferObject + (OriginalObject->String.Length); if (!NewObject) { return (AE_NO_MEMORY); } - ACPI_MEMCPY (NewObject->Buffer.Pointer, + memcpy (NewObject->Buffer.Pointer, OriginalObject->String.Pointer, OriginalObject->String.Length); break; @@ -330,7 +332,8 @@ AcpiNsConvertToBuffer ( * * FUNCTION: AcpiNsConvertToUnicode * - * PARAMETERS: OriginalObject - ASCII String Object to be converted + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - ASCII String Object to be converted * ReturnObject - Where the new converted object is returned * * RETURN: Status. AE_OK if conversion was successful. @@ -341,6 +344,7 @@ AcpiNsConvertToBuffer ( ACPI_STATUS AcpiNsConvertToUnicode ( + ACPI_NAMESPACE_NODE *Scope, ACPI_OPERAND_OBJECT *OriginalObject, ACPI_OPERAND_OBJECT **ReturnObject) { @@ -402,7 +406,8 @@ AcpiNsConvertToUnicode ( * * FUNCTION: AcpiNsConvertToResource * - * PARAMETERS: OriginalObject - Object to be converted + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - Object to be converted * ReturnObject - Where the new converted object is returned * * RETURN: Status. AE_OK if conversion was successful @@ -414,6 +419,7 @@ AcpiNsConvertToUnicode ( ACPI_STATUS AcpiNsConvertToResource ( + ACPI_NAMESPACE_NODE *Scope, ACPI_OPERAND_OBJECT *OriginalObject, ACPI_OPERAND_OBJECT **ReturnObject) { @@ -480,3 +486,81 @@ AcpiNsConvertToResource ( *ReturnObject = NewObject; return (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToReference + * + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful + * + * DESCRIPTION: Attempt to convert a Integer object to a ObjectReference. + * Buffer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsConvertToReference ( + ACPI_NAMESPACE_NODE *Scope, + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject = NULL; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_GENERIC_STATE ScopeInfo; + char *Name; + + + ACPI_FUNCTION_NAME (NsConvertToReference); + + + /* Convert path into internal presentation */ + + Status = AcpiNsInternalizeName (OriginalObject->String.Pointer, &Name); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Find the namespace node */ + + ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Scope); + Status = AcpiNsLookup (&ScopeInfo, Name, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + if (ACPI_FAILURE (Status)) + { + /* Check if we are resolving a named reference within a package */ + + ACPI_ERROR_NAMESPACE (OriginalObject->String.Pointer, Status); + goto ErrorExit; + } + + /* Create and init a new internal ACPI object */ + + NewObject = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!NewObject) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } + NewObject->Reference.Node = Node; + NewObject->Reference.Object = Node->Object; + NewObject->Reference.Class = ACPI_REFCLASS_NAME; + + /* + * Increase reference of the object if needed (the object is likely a + * null for device nodes). + */ + AcpiUtAddReference (Node->Object); + +ErrorExit: + ACPI_FREE (Name); + *ReturnObject = NewObject; + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/components/namespace/nsdump.c b/sys/contrib/dev/acpica/components/namespace/nsdump.c index 77fb279..d34ff11 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsdump.c +++ b/sys/contrib/dev/acpica/components/namespace/nsdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,7 @@ AcpiNsGetMaxDepth ( void AcpiNsPrintPathname ( UINT32 NumSegments, - char *Pathname) + const char *Pathname) { UINT32 i; @@ -122,7 +122,7 @@ AcpiNsPrintPathname ( { for (i = 0; i < 4; i++) { - ACPI_IS_PRINT (Pathname[i]) ? + isprint ((int) Pathname[i]) ? AcpiOsPrintf ("%c", Pathname[i]) : AcpiOsPrintf ("?"); } @@ -139,6 +139,9 @@ AcpiNsPrintPathname ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/* Not used at this time, perhaps later */ + /******************************************************************************* * * FUNCTION: AcpiNsDumpPathname @@ -158,7 +161,7 @@ AcpiNsPrintPathname ( void AcpiNsDumpPathname ( ACPI_HANDLE Handle, - char *Msg, + const char *Msg, UINT32 Level, UINT32 Component) { @@ -179,7 +182,7 @@ AcpiNsDumpPathname ( AcpiOsPrintf ("\n"); return_VOID; } - +#endif /******************************************************************************* * @@ -258,7 +261,8 @@ AcpiNsDumpOneObject ( if (Type > ACPI_TYPE_LOCAL_MAX) { - ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type)); + ACPI_WARNING ((AE_INFO, + "Invalid ACPI Object Type 0x%08X", Type)); } AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); @@ -267,7 +271,7 @@ AcpiNsDumpOneObject ( /* Now we can print out the pertinent information */ AcpiOsPrintf (" %-12s %p %2.2X ", - AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); + AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); DbgLevel = AcpiDbgLevel; AcpiDbgLevel = 0; @@ -354,7 +358,7 @@ AcpiNsDumpOneObject ( if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { AcpiOsPrintf ("Len %.2X", - ObjDesc->Buffer.Length); + ObjDesc->Buffer.Length); /* Dump some of the buffer */ @@ -377,7 +381,7 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_STRING: AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length); - AcpiUtPrintString (ObjDesc->String.Pointer, 32); + AcpiUtPrintString (ObjDesc->String.Pointer, 80); AcpiOsPrintf ("\n"); break; @@ -535,9 +539,9 @@ AcpiNsDumpOneObject ( /* If there is an attached object, display it */ - DbgLevel = AcpiDbgLevel; + DbgLevel = AcpiDbgLevel; AcpiDbgLevel = 0; - ObjDesc = AcpiNsGetAttachedObject (ThisNode); + ObjDesc = AcpiNsGetAttachedObject (ThisNode); AcpiDbgLevel = DbgLevel; /* Dump attached objects */ @@ -564,14 +568,18 @@ AcpiNsDumpOneObject ( if (ObjType > ACPI_TYPE_LOCAL_MAX) { - AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n", + AcpiOsPrintf ( + "(Pointer to ACPI Object type %.2X [UNKNOWN])\n", ObjType); + BytesToDump = 32; } else { - AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n", + AcpiOsPrintf ( + "(Pointer to ACPI Object type %.2X [%s])\n", ObjType, AcpiUtGetTypeName (ObjType)); + BytesToDump = sizeof (ACPI_OPERAND_OBJECT); } @@ -601,7 +609,8 @@ AcpiNsDumpOneObject ( */ BytesToDump = ObjDesc->String.Length; ObjDesc = (void *) ObjDesc->String.Pointer; - AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n", + + AcpiOsPrintf ("(Buffer/String pointer %p length %X)\n", ObjDesc, BytesToDump); ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); goto Cleanup; @@ -702,8 +711,8 @@ AcpiNsDumpObjects ( Info.DisplayType = DisplayType; (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); } @@ -753,7 +762,7 @@ AcpiNsDumpOneObjectPath ( return (AE_OK); } - Pathname = AcpiNsGetExternalPathname (Node); + Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); PathIndent = 1; if (Level <= MaxLevel) @@ -839,14 +848,14 @@ AcpiNsDumpObjectPaths ( /* Get the max depth of the namespace tree, for formatting later */ (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL); + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL); /* Now dump the entire namespace */ (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL); + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); } @@ -917,7 +926,8 @@ AcpiNsDumpTables ( * If the name space has not been initialized, * there is nothing to dump. */ - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "namespace not initialized!\n")); return_VOID; } @@ -930,7 +940,7 @@ AcpiNsDumpTables ( } AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth, - ACPI_OWNER_ID_MAX, SearchHandle); + ACPI_OWNER_ID_MAX, SearchHandle); return_VOID; } #endif diff --git a/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c b/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c index 05daaab..8adb76a 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c +++ b/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -149,8 +149,8 @@ AcpiNsDumpRootDevices ( "Display of all devices in the namespace:\n")); Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, - ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, - AcpiNsDumpOneDevice, NULL, NULL, NULL); + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiNsDumpOneDevice, NULL, NULL, NULL); } #endif diff --git a/sys/contrib/dev/acpica/components/namespace/nseval.c b/sys/contrib/dev/acpica/components/namespace/nseval.c index ac1d9a9..ea1cceb 100644 --- a/sys/contrib/dev/acpica/components/namespace/nseval.c +++ b/sys/contrib/dev/acpica/components/namespace/nseval.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,15 +63,14 @@ AcpiNsExecModuleCode ( * * FUNCTION: AcpiNsEvaluate * - * PARAMETERS: Info - Evaluation info block, contains: + * PARAMETERS: Info - Evaluation info block, contains these fields + * and more: * PrefixNode - Prefix or Method/Object Node to execute * RelativePath - Name of method to execute, If NULL, the * Node is the object to execute * Parameters - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. * ParameterType - Type of Parameter list * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. @@ -145,7 +144,7 @@ AcpiNsEvaluate ( /* Get the full pathname to the object, for use in warning messages */ - Info->FullPathname = AcpiNsGetExternalPathname (Info->Node); + Info->FullPathname = AcpiNsGetNormalizedPathname (Info->Node, TRUE); if (!Info->FullPathname) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -285,6 +284,7 @@ AcpiNsEvaluate ( if (ACPI_FAILURE (Status)) { + Info->ReturnObject = NULL; goto Cleanup; } @@ -396,7 +396,7 @@ AcpiNsExecModuleCodeList ( AcpiUtRemoveReference (Prev); } - ACPI_INFO ((AE_INFO, + ACPI_INFO (( "Executed %u blocks of module-level executable AML code", MethodCount)); @@ -440,8 +440,8 @@ AcpiNsExecModuleCode ( * Get the parent node. We cheat by using the NextObject field * of the method object descriptor. */ - ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, - MethodObj->Method.NextObject); + ParentNode = ACPI_CAST_PTR ( + ACPI_NAMESPACE_NODE, MethodObj->Method.NextObject); Type = AcpiNsGetType (ParentNode); /* @@ -463,13 +463,13 @@ AcpiNsExecModuleCode ( /* Initialize the evaluation information block */ - ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); Info->PrefixNode = ParentNode; /* - * Get the currently attached parent object. Add a reference, because the - * ref count will be decreased when the method object is installed to - * the parent node. + * Get the currently attached parent object. Add a reference, + * because the ref count will be decreased when the method object + * is installed to the parent node. */ ParentObj = AcpiNsGetAttachedObject (ParentNode); if (ParentObj) @@ -479,8 +479,7 @@ AcpiNsExecModuleCode ( /* Install the method (module-level code) in the parent node */ - Status = AcpiNsAttachObject (ParentNode, MethodObj, - ACPI_TYPE_METHOD); + Status = AcpiNsAttachObject (ParentNode, MethodObj, ACPI_TYPE_METHOD); if (ACPI_FAILURE (Status)) { goto Exit; @@ -490,7 +489,8 @@ AcpiNsExecModuleCode ( Status = AcpiNsEvaluate (Info); - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_INIT_NAMES, + "Executed module-level code at %p\n", MethodObj->Method.AmlStart)); /* Delete a possible implicit return value (in slack mode) */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsinit.c b/sys/contrib/dev/acpica/components/namespace/nsinit.c index 847bf72..a208469 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsinit.c +++ b/sys/contrib/dev/acpica/components/namespace/nsinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,6 +46,7 @@ #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/include/acevents.h> #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsinit") @@ -98,6 +99,8 @@ AcpiNsInitializeObjects ( ACPI_FUNCTION_TRACE (NsInitializeObjects); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, @@ -105,13 +108,13 @@ AcpiNsInitializeObjects ( /* Set all init info to zero */ - ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); + memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); /* Walk entire namespace from the supplied root */ Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, - &Info, NULL); + ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, + &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); @@ -151,84 +154,140 @@ AcpiNsInitializeObjects ( ACPI_STATUS AcpiNsInitializeDevices ( - void) + UINT32 Flags) { - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; ACPI_DEVICE_WALK_INFO Info; + ACPI_HANDLE Handle; ACPI_FUNCTION_TRACE (NsInitializeDevices); - /* Init counters */ + if (!(Flags & ACPI_NO_DEVICE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); - Info.DeviceCount = 0; - Info.Num_STA = 0; - Info.Num_INI = 0; + /* Init counters */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Initializing Device/Processor/Thermal objects " - "and executing _INI/_STA methods:\n")); + Info.DeviceCount = 0; + Info.Num_STA = 0; + Info.Num_INI = 0; - /* Tree analysis: find all subtrees that contain _INI methods */ + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Initializing Device/Processor/Thermal objects " + "and executing _INI/_STA methods:\n")); - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - /* Allocate the evaluation information block */ + /* Tree analysis: find all subtrees that contain _INI methods */ - Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); - if (!Info.EvaluateInfo) - { - Status = AE_NO_MEMORY; - goto ErrorExit; - } + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } - /* - * Execute the "global" _INI method that may appear at the root. This - * support is provided for Windows compatibility (Vista+) and is not - * part of the ACPI specification. - */ - Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; - Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; - Info.EvaluateInfo->Parameters = NULL; - Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + /* Allocate the evaluation information block */ - Status = AcpiNsEvaluate (Info.EvaluateInfo); - if (ACPI_SUCCESS (Status)) - { - Info.Num_INI++; - } + Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info.EvaluateInfo) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } - /* Walk namespace to execute all _INIs on present devices */ + /* + * Execute the "global" _INI method that may appear at the root. + * This support is provided for Windows compatibility (Vista+) and + * is not part of the ACPI specification. + */ + Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; + Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); + /* + * Execute \_SB._INI. + * There appears to be a strict order requirement for \_SB._INI, + * which should be evaluated before any _REG evaluations. + */ + Status = AcpiGetHandle (NULL, "\\_SB", &Handle); + if (ACPI_SUCCESS (Status)) + { + memset (Info.EvaluateInfo, 0, sizeof (ACPI_EVALUATE_INFO)); + Info.EvaluateInfo->PrefixNode = Handle; + Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + } + } /* - * Any _OSI requests should be completed by now. If the BIOS has - * requested any Windows OSI strings, we will always truncate - * I/O addresses to 16 bits -- for Windows compatibility. + * Run all _REG methods + * + * Note: Any objects accessed by the _REG methods will be automatically + * initialized, even if they contain executable AML (see the call to + * AcpiNsInitializeObjects below). + * + * Note: According to the ACPI specification, we actually needn't execute + * _REG for SystemMemory/SystemIo operation regions, but for PCI_Config + * operation regions, it is required to evaluate _REG for those on a PCI + * root bus that doesn't contain _BBN object. So this code is kept here + * in order not to break things. */ - if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000) + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - AcpiGbl_TruncateIoAddresses = TRUE; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Executing _REG OpRegion methods\n")); + + Status = AcpiEvInitializeOpRegions (); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } } - ACPI_FREE (Info.EvaluateInfo); - if (ACPI_FAILURE (Status)) + if (!(Flags & ACPI_NO_DEVICE_INIT)) { - goto ErrorExit; - } + /* Walk namespace to execute all _INIs on present devices */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - " Executed %u _INI methods requiring %u _STA executions " - "(examined %u objects)\n", - Info.Num_INI, Info.Num_STA, Info.DeviceCount)); + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); + + /* + * Any _OSI requests should be completed by now. If the BIOS has + * requested any Windows OSI strings, we will always truncate + * I/O addresses to 16 bits -- for Windows compatibility. + */ + if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000) + { + AcpiGbl_TruncateIoAddresses = TRUE; + } + + ACPI_FREE (Info.EvaluateInfo); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + " Executed %u _INI methods requiring %u _STA executions " + "(examined %u objects)\n", + Info.Num_INI, Info.Num_STA, Info.DeviceCount)); + } return_ACPI_STATUS (Status); @@ -611,33 +670,37 @@ AcpiNsInitOneDevice ( * Note: We know there is an _INI within this subtree, but it may not be * under this particular device, it may be lower in the branch. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( - ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); + if (!ACPI_COMPARE_NAME (DeviceNode->Name.Ascii, "_SB_") || + DeviceNode->Parent != AcpiGbl_RootNode) + { + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); - ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); - Info->PrefixNode = DeviceNode; - Info->RelativePathname = METHOD_NAME__INI; - Info->Parameters = NULL; - Info->Flags = ACPI_IGNORE_RETURN_VALUE; + memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + Info->PrefixNode = DeviceNode; + Info->RelativePathname = METHOD_NAME__INI; + Info->Parameters = NULL; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; - Status = AcpiNsEvaluate (Info); - if (ACPI_SUCCESS (Status)) - { - WalkInfo->Num_INI++; - } + Status = AcpiNsEvaluate (Info); + if (ACPI_SUCCESS (Status)) + { + WalkInfo->Num_INI++; + } #ifdef ACPI_DEBUG_OUTPUT - else if (Status != AE_NOT_FOUND) - { - /* Ignore error and move on to next device */ + else if (Status != AE_NOT_FOUND) + { + /* Ignore error and move on to next device */ - char *ScopeName = AcpiNsGetExternalPathname (Info->Node); + char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE); - ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", - ScopeName)); - ACPI_FREE (ScopeName); - } + ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", + ScopeName)); + ACPI_FREE (ScopeName); + } #endif + } /* Ignore errors from above */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsload.c b/sys/contrib/dev/acpica/components/namespace/nsload.c index c9b1174..4c8c6bf 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsload.c +++ b/sys/contrib/dev/acpica/components/namespace/nsload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -128,7 +128,21 @@ AcpiNsLoadTable ( } else { - (void) AcpiTbReleaseOwnerId (TableIndex); + /* + * On error, delete any namespace objects created by this table. + * We cannot initialize these objects, so delete them. There are + * a couple of expecially bad cases: + * AE_ALREADY_EXISTS - namespace collision. + * AE_NOT_FOUND - the target of a Scope operator does not + * exist. This target of Scope must already exist in the + * namespace, as per the ACPI specification. + */ + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + AcpiNsDeleteNamespaceByOwner ( + AcpiGbl_RootTableList.Tables[TableIndex].OwnerId); + + AcpiTbReleaseOwnerId (TableIndex); + return_ACPI_STATUS (Status); } Unlock: @@ -153,6 +167,24 @@ Unlock: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Completed Table Object Initialization\n")); + /* + * Execute any module-level code that was detected during the table load + * phase. Although illegal since ACPI 2.0, there are many machines that + * contain this type of code. Each block of detected executable AML code + * outside of any control method is wrapped with a temporary control + * method object and placed on a global list. The methods on this list + * are executed below. + * + * This case executes the module-level code for each table immediately + * after the table has been loaded. This provides compatibility with + * other ACPI implementations. Optionally, the execution can be deferred + * until later, see AcpiInitializeObjects. + */ + if (!AcpiGbl_GroupModuleLevelCode) + { + AcpiNsExecModuleCodeList (); + } + return_ACPI_STATUS (Status); } @@ -245,8 +277,8 @@ AcpiNsDeleteSubtree ( ParentHandle = StartHandle; - ChildHandle = NULL; - Level = 1; + ChildHandle = NULL; + Level = 1; /* * Traverse the tree of objects until we bubble back up @@ -257,7 +289,7 @@ AcpiNsDeleteSubtree ( /* Attempt to get the next object in this scope */ Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle, - ChildHandle, &NextChildHandle); + ChildHandle, &NextChildHandle); ChildHandle = NextChildHandle; @@ -268,7 +300,7 @@ AcpiNsDeleteSubtree ( /* Check if this object has any children */ if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle, - NULL, &Dummy))) + NULL, &Dummy))) { /* * There is at least one child of this object, @@ -346,7 +378,6 @@ AcpiNsUnloadNamespace ( /* This function does the real work */ Status = AcpiNsDeleteSubtree (Handle); - return_ACPI_STATUS (Status); } #endif diff --git a/sys/contrib/dev/acpica/components/namespace/nsnames.c b/sys/contrib/dev/acpica/components/namespace/nsnames.c index edd6517..f558c59 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsnames.c +++ b/sys/contrib/dev/acpica/components/namespace/nsnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,82 +53,6 @@ /******************************************************************************* * - * FUNCTION: AcpiNsBuildExternalPath - * - * PARAMETERS: Node - NS node whose pathname is needed - * Size - Size of the pathname - * *NameBuffer - Where to return the pathname - * - * RETURN: Status - * Places the pathname into the NameBuffer, in external format - * (name segments separated by path separators) - * - * DESCRIPTION: Generate a full pathaname - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsBuildExternalPath ( - ACPI_NAMESPACE_NODE *Node, - ACPI_SIZE Size, - char *NameBuffer) -{ - ACPI_SIZE Index; - ACPI_NAMESPACE_NODE *ParentNode; - - - ACPI_FUNCTION_ENTRY (); - - - /* Special case for root */ - - Index = Size - 1; - if (Index < ACPI_NAME_SIZE) - { - NameBuffer[0] = AML_ROOT_PREFIX; - NameBuffer[1] = 0; - return (AE_OK); - } - - /* Store terminator byte, then build name backwards */ - - ParentNode = Node; - NameBuffer[Index] = 0; - - while ((Index > ACPI_NAME_SIZE) && (ParentNode != AcpiGbl_RootNode)) - { - Index -= ACPI_NAME_SIZE; - - /* Put the name into the buffer */ - - ACPI_MOVE_32_TO_32 ((NameBuffer + Index), &ParentNode->Name); - ParentNode = ParentNode->Parent; - - /* Prefix name with the path separator */ - - Index--; - NameBuffer[Index] = ACPI_PATH_SEPARATOR; - } - - /* Overwrite final separator with the root prefix character */ - - NameBuffer[Index] = AML_ROOT_PREFIX; - - if (Index != 0) - { - ACPI_ERROR ((AE_INFO, - "Could not construct external pathname; index=%u, size=%u, Path=%s", - (UINT32) Index, (UINT32) Size, &NameBuffer[Size])); - - return (AE_BAD_PARAMETER); - } - - return (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AcpiNsGetExternalPathname * * PARAMETERS: Node - Namespace node whose pathname is needed @@ -146,40 +70,13 @@ char * AcpiNsGetExternalPathname ( ACPI_NAMESPACE_NODE *Node) { - ACPI_STATUS Status; char *NameBuffer; - ACPI_SIZE Size; ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node); - /* Calculate required buffer size based on depth below root */ - - Size = AcpiNsGetPathnameLength (Node); - if (!Size) - { - return_PTR (NULL); - } - - /* Allocate a buffer to be returned to caller */ - - NameBuffer = ACPI_ALLOCATE_ZEROED (Size); - if (!NameBuffer) - { - ACPI_ERROR ((AE_INFO, "Could not allocate %u bytes", (UINT32) Size)); - return_PTR (NULL); - } - - /* Build the path in the allocated buffer */ - - Status = AcpiNsBuildExternalPath (Node, Size, NameBuffer); - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (NameBuffer); - return_PTR (NULL); - } - + NameBuffer = AcpiNsGetNormalizedPathname (Node, FALSE); return_PTR (NameBuffer); } @@ -201,38 +98,13 @@ AcpiNsGetPathnameLength ( ACPI_NAMESPACE_NODE *Node) { ACPI_SIZE Size; - ACPI_NAMESPACE_NODE *NextNode; ACPI_FUNCTION_ENTRY (); - /* - * Compute length of pathname as 5 * number of name segments. - * Go back up the parent tree to the root - */ - Size = 0; - NextNode = Node; - - while (NextNode && (NextNode != AcpiGbl_RootNode)) - { - if (ACPI_GET_DESCRIPTOR_TYPE (NextNode) != ACPI_DESC_TYPE_NAMED) - { - ACPI_ERROR ((AE_INFO, - "Invalid Namespace Node (%p) while traversing namespace", - NextNode)); - return (0); - } - Size += ACPI_PATH_SEGMENT_LENGTH; - NextNode = NextNode->Parent; - } - - if (!Size) - { - Size = 1; /* Root node case */ - } - - return (Size + 1); /* +1 for null string terminator */ + Size = AcpiNsBuildNormalizedPath (Node, NULL, 0, FALSE); + return (Size); } @@ -243,6 +115,8 @@ AcpiNsGetPathnameLength ( * PARAMETERS: TargetHandle - Handle of named object whose name is * to be found * Buffer - Where the pathname is returned + * NoTrailing - Remove trailing '_' for each name + * segment * * RETURN: Status, Buffer is filled with pathname if status is AE_OK * @@ -253,7 +127,8 @@ AcpiNsGetPathnameLength ( ACPI_STATUS AcpiNsHandleToPathname ( ACPI_HANDLE TargetHandle, - ACPI_BUFFER *Buffer) + ACPI_BUFFER *Buffer, + BOOLEAN NoTrailing) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; @@ -271,7 +146,7 @@ AcpiNsHandleToPathname ( /* Determine size required for the caller buffer */ - RequiredSize = AcpiNsGetPathnameLength (Node); + RequiredSize = AcpiNsBuildNormalizedPath (Node, NULL, 0, NoTrailing); if (!RequiredSize) { return_ACPI_STATUS (AE_BAD_PARAMETER); @@ -287,7 +162,8 @@ AcpiNsHandleToPathname ( /* Build the path in the caller buffer */ - Status = AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); + (void) AcpiNsBuildNormalizedPath (Node, Buffer->Pointer, + RequiredSize, NoTrailing); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -297,3 +173,174 @@ AcpiNsHandleToPathname ( (char *) Buffer->Pointer, (UINT32) RequiredSize)); return_ACPI_STATUS (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildNormalizedPath + * + * PARAMETERS: Node - Namespace node + * FullPath - Where the path name is returned + * PathSize - Size of returned path name buffer + * NoTrailing - Remove trailing '_' from each name segment + * + * RETURN: Return 1 if the AML path is empty, otherwise returning (length + * of pathname + 1) which means the 'FullPath' contains a trailing + * null. + * + * DESCRIPTION: Build and return a full namespace pathname. + * Note that if the size of 'FullPath' isn't large enough to + * contain the namespace node's path name, the actual required + * buffer length is returned, and it should be greater than + * 'PathSize'. So callers are able to check the returning value + * to determine the buffer size of 'FullPath'. + * + ******************************************************************************/ + +UINT32 +AcpiNsBuildNormalizedPath ( + ACPI_NAMESPACE_NODE *Node, + char *FullPath, + UINT32 PathSize, + BOOLEAN NoTrailing) +{ + UINT32 Length = 0, i; + char Name[ACPI_NAME_SIZE]; + BOOLEAN DoNoTrailing; + char c, *Left, *Right; + ACPI_NAMESPACE_NODE *NextNode; + + + ACPI_FUNCTION_TRACE_PTR (NsBuildNormalizedPath, Node); + + +#define ACPI_PATH_PUT8(Path, Size, Byte, Length) \ + do { \ + if ((Length) < (Size)) \ + { \ + (Path)[(Length)] = (Byte); \ + } \ + (Length)++; \ + } while (0) + + /* + * Make sure the PathSize is correct, so that we don't need to + * validate both FullPath and PathSize. + */ + if (!FullPath) + { + PathSize = 0; + } + + if (!Node) + { + goto BuildTrailingNull; + } + + NextNode = Node; + while (NextNode && NextNode != AcpiGbl_RootNode) + { + if (NextNode != Node) + { + ACPI_PATH_PUT8(FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length); + } + + ACPI_MOVE_32_TO_32 (Name, &NextNode->Name); + DoNoTrailing = NoTrailing; + for (i = 0; i < 4; i++) + { + c = Name[4-i-1]; + if (DoNoTrailing && c != '_') + { + DoNoTrailing = FALSE; + } + if (!DoNoTrailing) + { + ACPI_PATH_PUT8(FullPath, PathSize, c, Length); + } + } + + NextNode = NextNode->Parent; + } + + ACPI_PATH_PUT8(FullPath, PathSize, AML_ROOT_PREFIX, Length); + + /* Reverse the path string */ + + if (Length <= PathSize) + { + Left = FullPath; + Right = FullPath+Length - 1; + + while (Left < Right) + { + c = *Left; + *Left++ = *Right; + *Right-- = c; + } + } + + /* Append the trailing null */ + +BuildTrailingNull: + ACPI_PATH_PUT8 (FullPath, PathSize, '\0', Length); + +#undef ACPI_PATH_PUT8 + + return_UINT32 (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNormalizedPathname + * + * PARAMETERS: Node - Namespace node whose pathname is needed + * NoTrailing - Remove trailing '_' from each name segment + * + * RETURN: Pointer to storage containing the fully qualified name of + * the node, In external format (name segments separated by path + * separators.) + * + * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually + * for error and debug statements. All trailing '_' will be + * removed from the full pathname if 'NoTrailing' is specified.. + * + ******************************************************************************/ + +char * +AcpiNsGetNormalizedPathname ( + ACPI_NAMESPACE_NODE *Node, + BOOLEAN NoTrailing) +{ + char *NameBuffer; + ACPI_SIZE Size; + + + ACPI_FUNCTION_TRACE_PTR (NsGetNormalizedPathname, Node); + + + /* Calculate required buffer size based on depth below root */ + + Size = AcpiNsBuildNormalizedPath (Node, NULL, 0, NoTrailing); + if (!Size) + { + return_PTR (NULL); + } + + /* Allocate a buffer to be returned to caller */ + + NameBuffer = ACPI_ALLOCATE_ZEROED (Size); + if (!NameBuffer) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate %u bytes", (UINT32) Size)); + return_PTR (NULL); + } + + /* Build the path in the allocated buffer */ + + (void) AcpiNsBuildNormalizedPath (Node, NameBuffer, Size, NoTrailing); + + return_PTR (NameBuffer); +} diff --git a/sys/contrib/dev/acpica/components/namespace/nsobject.c b/sys/contrib/dev/acpica/components/namespace/nsobject.c index 8327b76..1e555d9 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsobject.c +++ b/sys/contrib/dev/acpica/components/namespace/nsobject.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -145,7 +145,7 @@ AcpiNsAttachObject ( * Value passed is a name handle and that name has a * non-null value. Use that name's value and type. */ - ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; + ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; } @@ -195,8 +195,8 @@ AcpiNsAttachObject ( LastObjDesc->Common.NextObject = Node->Object; } - Node->Type = (UINT8) ObjectType; - Node->Object = ObjDesc; + Node->Type = (UINT8) ObjectType; + Node->Object = ObjDesc; return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/namespace/nsparse.c b/sys/contrib/dev/acpica/components/namespace/nsparse.c index 0f87fa1..d0f9e95 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsparse.c +++ b/sys/contrib/dev/acpica/components/namespace/nsparse.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,6 +84,22 @@ AcpiNsOneCompleteParse ( ACPI_FUNCTION_TRACE (NsOneCompleteParse); + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Table must consist of at least a complete header */ + + if (Table->Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_BAD_HEADER); + } + + AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); if (ACPI_FAILURE (Status)) { @@ -92,7 +108,7 @@ AcpiNsOneCompleteParse ( /* Create and init a Root Node */ - ParseRoot = AcpiPsCreateScopeOp (); + ParseRoot = AcpiPsCreateScopeOp (AmlStart); if (!ParseRoot) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -107,39 +123,28 @@ AcpiNsOneCompleteParse ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiGetTableByIndex (TableIndex, &Table); + Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, + AmlStart, AmlLength, NULL, (UINT8) PassNumber); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); - AcpiPsFreeOp (ParseRoot); - return_ACPI_STATUS (Status); + goto Cleanup; } - /* Table must consist of at least a complete header */ - - if (Table->Length < sizeof (ACPI_TABLE_HEADER)) - { - Status = AE_BAD_HEADER; - } - else - { - AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); - AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); - Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, - AmlStart, AmlLength, NULL, (UINT8) PassNumber); - } + /* Found OSDT table, enable the namespace override feature */ - if (ACPI_FAILURE (Status)) + if (ACPI_COMPARE_NAME(Table->Signature, ACPI_SIG_OSDT) && + PassNumber == ACPI_IMODE_LOAD_PASS1) { - AcpiDsDeleteWalkState (WalkState); - goto Cleanup; + WalkState->NamespaceOverride = TRUE; } /* StartNode is the default location to load the table */ if (StartNode && StartNode != AcpiGbl_RootNode) { - Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + Status = AcpiDsScopeStackPush ( + StartNode, ACPI_TYPE_METHOD, WalkState); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -149,7 +154,8 @@ AcpiNsOneCompleteParse ( /* Parse the AML */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %u parse\n", PassNumber)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "*PARSE* pass %u parse\n", PassNumber)); Status = AcpiPsParseAml (WalkState); Cleanup: @@ -193,8 +199,9 @@ AcpiNsParseTable ( * performs another complete parse of the AML. */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, - TableIndex, StartNode); + TableIndex, StartNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -211,7 +218,7 @@ AcpiNsParseTable ( */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, - TableIndex, StartNode); + TableIndex, StartNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/namespace/nspredef.c b/sys/contrib/dev/acpica/components/namespace/nspredef.c index d885e5a..606b23d 100644 --- a/sys/contrib/dev/acpica/components/namespace/nspredef.c +++ b/sys/contrib/dev/acpica/components/namespace/nspredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -249,7 +249,7 @@ AcpiNsCheckObjectType ( { ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; ACPI_STATUS Status = AE_OK; - char TypeBuffer[48]; /* Room for 5 types */ + char TypeBuffer[96]; /* Room for 10 types */ /* A Namespace node should not get here, but make sure */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c index 905fe64..e4ea077 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c +++ b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -70,6 +70,12 @@ AcpiNsCheckPackageElements ( UINT32 Count2, UINT32 StartIndex); +static ACPI_STATUS +AcpiNsCustomPackage ( + ACPI_EVALUATE_INFO *Info, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count); + /******************************************************************************* * @@ -148,6 +154,11 @@ AcpiNsCheckPackage ( */ switch (Package->RetInfo.Type) { + case ACPI_PTYPE_CUSTOM: + + Status = AcpiNsCustomPackage (Info, Elements, Count); + break; + case ACPI_PTYPE1_FIXED: /* * The package count is fixed and there are no subpackages @@ -171,8 +182,8 @@ AcpiNsCheckPackage ( /* Validate all elements of the returned package */ Status = AcpiNsCheckPackageElements (Info, Elements, - Package->RetInfo.ObjectType1, Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); + Package->RetInfo.ObjectType1, Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); break; case ACPI_PTYPE1_VAR: @@ -183,11 +194,12 @@ AcpiNsCheckPackage ( for (i = 0; i < Count; i++) { Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo.ObjectType1, i); + Package->RetInfo.ObjectType1, i); if (ACPI_FAILURE (Status)) { return (Status); } + Elements++; } break; @@ -215,7 +227,7 @@ AcpiNsCheckPackage ( /* These are the required package elements (0, 1, or 2) */ Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo3.ObjectType[i], i); + Package->RetInfo3.ObjectType[i], i); if (ACPI_FAILURE (Status)) { return (Status); @@ -226,12 +238,13 @@ AcpiNsCheckPackage ( /* These are the optional package elements */ Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo3.TailObjectType, i); + Package->RetInfo3.TailObjectType, i); if (ACPI_FAILURE (Status)) { return (Status); } } + Elements++; } break; @@ -240,8 +253,8 @@ AcpiNsCheckPackage ( /* First element is the (Integer) revision */ - Status = AcpiNsCheckObjectType (Info, Elements, - ACPI_RTYPE_INTEGER, 0); + Status = AcpiNsCheckObjectType ( + Info, Elements, ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -259,8 +272,8 @@ AcpiNsCheckPackage ( /* First element is the (Integer) count of subpackages to follow */ - Status = AcpiNsCheckObjectType (Info, Elements, - ACPI_RTYPE_INTEGER, 0); + Status = AcpiNsCheckObjectType ( + Info, Elements, ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -303,7 +316,8 @@ AcpiNsCheckPackage ( { /* Create the new outer package and populate it */ - Status = AcpiNsWrapWithPackage (Info, ReturnObject, ReturnObjectPtr); + Status = AcpiNsWrapWithPackage ( + Info, ReturnObject, ReturnObjectPtr); if (ACPI_FAILURE (Status)) { return (Status); @@ -341,7 +355,7 @@ AcpiNsCheckPackage ( while (Count > 0) { Status = AcpiNsCheckObjectType(Info, Elements, - Package->RetInfo.ObjectType1, 0); + Package->RetInfo.ObjectType1, 0); if (ACPI_FAILURE(Status)) { return (Status); @@ -357,7 +371,7 @@ AcpiNsCheckPackage ( } Status = AcpiNsCheckObjectType(Info, Elements + 1, - Package->RetInfo.ObjectType2, 0); + Package->RetInfo.ObjectType2, 0); if (ACPI_FAILURE(Status)) { return (Status); @@ -365,8 +379,8 @@ AcpiNsCheckPackage ( Elements += 2; Count -= 2; - } - break; + } + break; default: @@ -441,7 +455,7 @@ AcpiNsCheckPackageList ( /* Each sub-object must be of type Package */ Status = AcpiNsCheckObjectType (Info, &SubPackage, - ACPI_RTYPE_PACKAGE, i); + ACPI_RTYPE_PACKAGE, i); if (ACPI_FAILURE (Status)) { return (Status); @@ -465,10 +479,10 @@ AcpiNsCheckPackageList ( } Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - Package->RetInfo.Count2, 0); + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + Package->RetInfo.Count2, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -487,10 +501,10 @@ AcpiNsCheckPackageList ( } Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - SubPackage->Package.Count - Package->RetInfo.Count1, 0); + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + SubPackage->Package.Count - Package->RetInfo.Count1, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -518,7 +532,7 @@ AcpiNsCheckPackageList ( for (j = 0; j < ExpectedCount; j++) { Status = AcpiNsCheckObjectType (Info, &SubElements[j], - Package->RetInfo2.ObjectType[j], j); + Package->RetInfo2.ObjectType[j], j); if (ACPI_FAILURE (Status)) { return (Status); @@ -539,8 +553,8 @@ AcpiNsCheckPackageList ( /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - SubPackage->Package.Count, 0, 0, 0); + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -553,7 +567,7 @@ AcpiNsCheckPackageList ( * the count field (the ACPI name is NumElements) */ Status = AcpiNsCheckObjectType (Info, SubElements, - ACPI_RTYPE_INTEGER, 0); + ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -568,11 +582,13 @@ AcpiNsCheckPackageList ( { goto PackageTooSmall; } + if (SubPackage->Package.Count < Package->RetInfo.Count1) { ExpectedCount = Package->RetInfo.Count1; goto PackageTooSmall; } + if (ExpectedCount == 0) { /* @@ -588,8 +604,8 @@ AcpiNsCheckPackageList ( /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, (SubElements + 1), - Package->RetInfo.ObjectType1, - (ExpectedCount - 1), 0, 0, 1); + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); if (ACPI_FAILURE (Status)) { return (Status); @@ -621,6 +637,92 @@ PackageTooSmall: /******************************************************************************* * + * FUNCTION: AcpiNsCustomPackage + * + * PARAMETERS: Info - Method execution information block + * Elements - Pointer to the package elements array + * Count - Element count for the package + * + * RETURN: Status + * + * DESCRIPTION: Check a returned package object for the correct count and + * correct type of all sub-objects. + * + * NOTE: Currently used for the _BIX method only. When needed for two or more + * methods, probably a detect/dispatch mechanism will be required. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCustomPackage ( + ACPI_EVALUATE_INFO *Info, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count) +{ + UINT32 ExpectedCount; + UINT32 Version; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_NAME (NsCustomPackage); + + + /* Get version number, must be Integer */ + + if ((*Elements)->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + "Return Package has invalid object type for version number")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + Version = (UINT32) (*Elements)->Integer.Value; + ExpectedCount = 21; /* Version 1 */ + + if (Version == 0) + { + ExpectedCount = 20; /* Version 0 */ + } + + if (Count < ExpectedCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + "Return Package is too small - found %u elements, expected %u", + Count, ExpectedCount)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + else if (Count > ExpectedCount) + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Return Package is larger than needed - " + "found %u, expected %u\n", + Info->FullPathname, Count, ExpectedCount)); + } + + /* Validate all elements of the returned package */ + + Status = AcpiNsCheckPackageElements (Info, Elements, + ACPI_RTYPE_INTEGER, 16, + ACPI_RTYPE_STRING, 4, 0); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Version 1 has a single trailing integer */ + + if (Version > 0) + { + Status = AcpiNsCheckPackageElements (Info, Elements + 20, + ACPI_RTYPE_INTEGER, 1, 0, 0, 20); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiNsCheckPackageElements * * PARAMETERS: Info - Method execution information block @@ -661,22 +763,24 @@ AcpiNsCheckPackageElements ( for (i = 0; i < Count1; i++) { Status = AcpiNsCheckObjectType (Info, ThisElement, - Type1, i + StartIndex); + Type1, i + StartIndex); if (ACPI_FAILURE (Status)) { return (Status); } + ThisElement++; } for (i = 0; i < Count2; i++) { Status = AcpiNsCheckObjectType (Info, ThisElement, - Type2, (i + Count1 + StartIndex)); + Type2, (i + Count1 + StartIndex)); if (ACPI_FAILURE (Status)) { return (Status); } + ThisElement++; } diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair.c b/sys/contrib/dev/acpica/components/namespace/nsrepair.c index b4c2c99..a0d4935 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsrepair.c +++ b/sys/contrib/dev/acpica/components/namespace/nsrepair.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -114,6 +114,11 @@ static const ACPI_SIMPLE_REPAIR_INFO AcpiObjectRepairInfo[] = ACPI_NOT_PACKAGE_ELEMENT, AcpiNsConvertToResource }, + /* Object reference conversions */ + + { "_DEP", ACPI_RTYPE_STRING, ACPI_ALL_PACKAGE_ELEMENTS, + AcpiNsConvertToReference }, + /* Unicode conversions */ { "_MLS", ACPI_RTYPE_STRING, 1, @@ -174,7 +179,8 @@ AcpiNsSimpleRepair ( ACPI_WARN_ALWAYS, "Missing expected return value")); } - Status = Predefined->ObjectConverter (ReturnObject, &NewObject); + Status = Predefined->ObjectConverter (Info->Node, ReturnObject, + &NewObject); if (ACPI_FAILURE (Status)) { /* A fatal error occurred during a conversion */ @@ -222,7 +228,7 @@ AcpiNsSimpleRepair ( ACPI_WARN_ALWAYS, "Found unexpected NULL package element")); Status = AcpiNsRepairNullElement (Info, ExpectedBtypes, - PackageIndex, ReturnObjectPtr); + PackageIndex, ReturnObjectPtr); if (ACPI_SUCCESS (Status)) { return (AE_OK); /* Repair was successful */ @@ -373,13 +379,15 @@ AcpiNsMatchSimpleRepair ( /* Check if we can actually repair this name/type combination */ if ((ReturnBtype & ThisName->UnexpectedBtypes) && - (PackageIndex == ThisName->PackageIndex)) + (ThisName->PackageIndex == ACPI_ALL_PACKAGE_ELEMENTS || + PackageIndex == ThisName->PackageIndex)) { return (ThisName); } return (NULL); } + ThisName++; } @@ -464,11 +472,13 @@ AcpiNsRepairNullElement ( /* Set the reference count according to the parent Package object */ - NewObject->Common.ReferenceCount = Info->ParentPackage->Common.ReferenceCount; + NewObject->Common.ReferenceCount = + Info->ParentPackage->Common.ReferenceCount; ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, "%s: Converted NULL package element to expected %s at index %u\n", - Info->FullPathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex)); + Info->FullPathname, AcpiUtGetObjectTypeName (NewObject), + PackageIndex)); *ReturnObjectPtr = NewObject; Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; @@ -551,6 +561,7 @@ AcpiNsRemoveNullElements ( *Dest = *Source; Dest++; } + Source++; } @@ -607,8 +618,8 @@ AcpiNsWrapWithPackage ( /* - * Create the new outer package and populate it. The new package will - * have a single element, the lone sub-object. + * Create the new outer package and populate it. The new + * package will have a single element, the lone sub-object. */ PkgObjDesc = AcpiUtCreatePackageObject (1); if (!PkgObjDesc) diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c index 410b009..4873c7f 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c +++ b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -254,6 +254,7 @@ AcpiNsMatchComplexRepair ( { return (ThisName); } + ThisName++; } @@ -286,7 +287,7 @@ AcpiNsRepair_ALR ( Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 2, 1, - ACPI_SORT_ASCENDING, "AmbientIlluminance"); + ACPI_SORT_ASCENDING, "AmbientIlluminance"); return (Status); } @@ -339,7 +340,8 @@ AcpiNsRepair_FDE ( if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "Incorrect return buffer length %u, expected %u", ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE)); @@ -348,7 +350,8 @@ AcpiNsRepair_FDE ( /* Create the new (larger) buffer object */ - BufferObject = AcpiUtCreateBufferObject (ACPI_FDE_DWORD_BUFFER_SIZE); + BufferObject = AcpiUtCreateBufferObject ( + ACPI_FDE_DWORD_BUFFER_SIZE); if (!BufferObject) { return (AE_NO_MEMORY); @@ -357,7 +360,8 @@ AcpiNsRepair_FDE ( /* Expand each byte to a DWORD */ ByteBuffer = ReturnObject->Buffer.Pointer; - DwordBuffer = ACPI_CAST_PTR (UINT32, BufferObject->Buffer.Pointer); + DwordBuffer = ACPI_CAST_PTR (UINT32, + BufferObject->Buffer.Pointer); for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) { @@ -510,7 +514,8 @@ AcpiNsRepair_CST ( if ((*OuterElements)->Package.Count == 0) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "SubPackage[%u] - removing entry due to zero count", i)); Removing = TRUE; goto RemoveElement; @@ -519,7 +524,8 @@ AcpiNsRepair_CST ( ObjDesc = (*OuterElements)->Package.Elements[1]; /* Index1 = Type */ if ((UINT32) ObjDesc->Integer.Value == 0) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "SubPackage[%u] - removing entry due to invalid Type(0)", i)); Removing = TRUE; } @@ -546,7 +552,7 @@ RemoveElement: * C-state type, in ascending order. */ Status = AcpiNsCheckSortedList (Info, ReturnObject, 1, 4, 1, - ACPI_SORT_ASCENDING, "C-State Type"); + ACPI_SORT_ASCENDING, "C-State Type"); if (ACPI_FAILURE (Status)) { return (Status); @@ -594,7 +600,8 @@ AcpiNsRepair_HID ( if (ReturnObject->String.Length == 0) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "Invalid zero-length _HID or _CID string")); /* Return AE_OK anyway, let driver handle it */ @@ -637,7 +644,7 @@ AcpiNsRepair_HID ( */ for (Dest = NewString->String.Pointer; *Source; Dest++, Source++) { - *Dest = (char) ACPI_TOUPPER (*Source); + *Dest = (char) toupper ((int) *Source); } AcpiUtRemoveReference (ReturnObject); @@ -756,8 +763,8 @@ AcpiNsRepair_PSS ( * incorrectly sorted, sort it. We sort by CpuFrequency, since this * should be proportional to the power. */ - Status =AcpiNsCheckSortedList (Info, ReturnObject, 0, 6, 0, - ACPI_SORT_DESCENDING, "CpuFrequency"); + Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 6, 0, + ACPI_SORT_DESCENDING, "CpuFrequency"); if (ACPI_FAILURE (Status)) { return (Status); @@ -778,7 +785,8 @@ AcpiNsRepair_PSS ( if ((UINT32) ObjDesc->Integer.Value > PreviousValue) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "SubPackage[%u,%u] - suspicious power dissipation values", i-1, i)); } @@ -832,7 +840,7 @@ AcpiNsRepair_TSS ( } Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 5, 1, - ACPI_SORT_DESCENDING, "PowerDissipation"); + ACPI_SORT_DESCENDING, "PowerDissipation"); return (Status); } @@ -1064,6 +1072,7 @@ AcpiNsRemoveElement ( *Dest = *Source; Dest++; } + Source++; } diff --git a/sys/contrib/dev/acpica/components/namespace/nssearch.c b/sys/contrib/dev/acpica/components/namespace/nssearch.c index 9f24f1c..85514aa 100644 --- a/sys/contrib/dev/acpica/components/namespace/nssearch.c +++ b/sys/contrib/dev/acpica/components/namespace/nssearch.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -112,7 +112,7 @@ AcpiNsSearchOneScope ( { char *ScopeName; - ScopeName = AcpiNsGetExternalPathname (ParentNode); + ScopeName = AcpiNsGetNormalizedPathname (ParentNode, TRUE); if (ScopeName) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, @@ -248,7 +248,7 @@ AcpiNsSearchParentTree ( * the actual name we are searching for. Typechecking comes later. */ Status = AcpiNsSearchOneScope ( - TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); + TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); @@ -338,10 +338,42 @@ AcpiNsSearchAndEnter ( * If we found it AND the request specifies that a find is an error, * return the error */ - if ((Status == AE_OK) && - (Flags & ACPI_NS_ERROR_IF_FOUND)) + if (Status == AE_OK) { - Status = AE_ALREADY_EXISTS; + /* The node was found in the namespace */ + + /* + * If the namespace override feature is enabled for this node, + * delete any existing attached sub-object and make the node + * look like a new node that is owned by the override table. + */ + if (Flags & ACPI_NS_OVERRIDE_IF_FOUND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Namespace override: %4.4s pass %u type %X Owner %X\n", + ACPI_CAST_PTR(char, &TargetName), InterpreterMode, + (*ReturnNode)->Type, WalkState->OwnerId)); + + AcpiNsDeleteChildren (*ReturnNode); + if (AcpiGbl_RuntimeNamespaceOverride) + { + AcpiUtRemoveReference ((*ReturnNode)->Object); + (*ReturnNode)->Object = NULL; + (*ReturnNode)->OwnerId = WalkState->OwnerId; + } + else + { + AcpiNsRemoveNode (*ReturnNode); + *ReturnNode = ACPI_ENTRY_NOT_FOUND; + } + } + + /* Return an error if we don't expect to find the object */ + + else if (Flags & ACPI_NS_ERROR_IF_FOUND) + { + Status = AE_ALREADY_EXISTS; + } } #ifdef ACPI_ASL_COMPILER diff --git a/sys/contrib/dev/acpica/components/namespace/nsutils.c b/sys/contrib/dev/acpica/components/namespace/nsutils.c index d7320a6..220ad90 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsutils.c +++ b/sys/contrib/dev/acpica/components/namespace/nsutils.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -90,7 +90,7 @@ AcpiNsPrintNodePathname ( Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (Node, &Buffer); + Status = AcpiNsHandleToPathname (Node, &Buffer, TRUE); if (ACPI_SUCCESS (Status)) { if (Message) @@ -196,9 +196,10 @@ AcpiNsGetInternalNameLength ( Info->FullyQualified = FALSE; /* - * For the internal name, the required length is 4 bytes per segment, plus - * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null - * (which is not really needed, but no there's harm in putting it there) + * For the internal name, the required length is 4 bytes per segment, + * plus 1 each for RootPrefix, MultiNamePrefixOp, segment count, + * trailing null (which is not really needed, but no there's harm in + * putting it there) * * strlen() + 1 covers the first NameSeg, which has no path separator */ @@ -243,7 +244,7 @@ AcpiNsGetInternalNameLength ( } Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) + - 4 + Info->NumCarats; + 4 + Info->NumCarats; Info->NextExternalChar = NextExternalChar; } @@ -347,7 +348,7 @@ AcpiNsBuildInternalName ( { /* Convert the character to uppercase and save it */ - Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName); + Result[i] = (char) toupper ((int) *ExternalName); ExternalName++; } } @@ -574,7 +575,7 @@ AcpiNsExternalizeName ( * punctuation ('.') between object names, plus the NULL terminator. */ RequiredLength = PrefixLength + (4 * NumSegments) + - ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; + ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; /* * Check to see if we're still in bounds. If not, there's a problem @@ -612,7 +613,8 @@ AcpiNsExternalizeName ( /* Copy and validate the 4-char name segment */ - ACPI_MOVE_NAME (&(*ConvertedName)[j], &InternalName[NamesIndex]); + ACPI_MOVE_NAME (&(*ConvertedName)[j], + &InternalName[NamesIndex]); AcpiUtRepairName (&(*ConvertedName)[j]); j += ACPI_NAME_SIZE; @@ -697,6 +699,24 @@ AcpiNsTerminate ( ACPI_FUNCTION_TRACE (NsTerminate); +#ifdef ACPI_EXEC_APP + { + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + + /* Delete any module-level code blocks */ + + Next = AcpiGbl_ModuleCodeList; + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + Prev->Method.Mutex = NULL; /* Clear the Mutex (cheated) field */ + AcpiUtRemoveReference (Prev); + } + } +#endif + /* * Free the entire namespace -- all nodes and all objects * attached to the nodes @@ -795,6 +815,7 @@ AcpiNsGetNode ( { *ReturnNode = AcpiGbl_RootNode; } + return_ACPI_STATUS (AE_OK); } @@ -829,12 +850,12 @@ AcpiNsGetNode ( /* Lookup the name in the namespace */ Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), - NULL, ReturnNode); + ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), + NULL, ReturnNode); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n", - Pathname, AcpiFormatException (Status))); + Pathname, AcpiFormatException (Status))); } (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); diff --git a/sys/contrib/dev/acpica/components/namespace/nswalk.c b/sys/contrib/dev/acpica/components/namespace/nswalk.c index 1674998..bdbfa76 100644 --- a/sys/contrib/dev/acpica/components/namespace/nswalk.c +++ b/sys/contrib/dev/acpica/components/namespace/nswalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -218,10 +218,10 @@ AcpiNsWalkNamespace ( /* Null child means "get first node" */ - ParentNode = StartNode; - ChildNode = AcpiNsGetNextNode (ParentNode, NULL); - ChildType = ACPI_TYPE_ANY; - Level = 1; + ParentNode = StartNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + ChildType = ACPI_TYPE_ANY; + Level = 1; /* * Traverse the tree of nodes until we bubble back up to where we @@ -279,7 +279,7 @@ AcpiNsWalkNamespace ( if (DescendingCallback) { Status = DescendingCallback (ChildNode, Level, - Context, ReturnValue); + Context, ReturnValue); } } else @@ -287,7 +287,7 @@ AcpiNsWalkNamespace ( if (AscendingCallback) { Status = AscendingCallback (ChildNode, Level, - Context, ReturnValue); + Context, ReturnValue); } } diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c index 93226ef..6467d7e 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -305,13 +305,12 @@ AcpiEvaluateObject ( } -#if 0 +#ifdef _FUTURE_FEATURE /* * Begin incoming argument count analysis. Check for too few args * and too many args. */ - switch (AcpiNsGetType (Info->Node)) { case ACPI_TYPE_METHOD: @@ -399,69 +398,74 @@ AcpiEvaluateObject ( * If we are expecting a return value, and all went well above, * copy the return value to an external object. */ - if (ReturnBuffer) + if (!ReturnBuffer) + { + goto CleanupReturnObject; + } + + if (!Info->ReturnObject) + { + ReturnBuffer->Length = 0; + goto Cleanup; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == + ACPI_DESC_TYPE_NAMED) { - if (!Info->ReturnObject) + /* + * If we received a NS Node as a return object, this means that + * the object we are evaluating has nothing interesting to + * return (such as a mutex, etc.) We return an error because + * these types are essentially unsupported by this interface. + * We don't check up front because this makes it easier to add + * support for various types at a later date if necessary. + */ + Status = AE_TYPE; + Info->ReturnObject = NULL; /* No need to delete a NS Node */ + ReturnBuffer->Length = 0; + } + + if (ACPI_FAILURE (Status)) + { + goto CleanupReturnObject; + } + + /* Dereference Index and RefOf references */ + + AcpiNsResolveReferences (Info); + + /* Get the size of the returned object */ + + Status = AcpiUtGetObjectSize (Info->ReturnObject, + &BufferSpaceNeeded); + if (ACPI_SUCCESS (Status)) + { + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (ReturnBuffer, + BufferSpaceNeeded); + if (ACPI_FAILURE (Status)) { - ReturnBuffer->Length = 0; + /* + * Caller's buffer is too small or a new one can't + * be allocated + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Needed buffer size %X, %s\n", + (UINT32) BufferSpaceNeeded, + AcpiFormatException (Status))); } else { - if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == - ACPI_DESC_TYPE_NAMED) - { - /* - * If we received a NS Node as a return object, this means that - * the object we are evaluating has nothing interesting to - * return (such as a mutex, etc.) We return an error because - * these types are essentially unsupported by this interface. - * We don't check up front because this makes it easier to add - * support for various types at a later date if necessary. - */ - Status = AE_TYPE; - Info->ReturnObject = NULL; /* No need to delete a NS Node */ - ReturnBuffer->Length = 0; - } + /* We have enough space for the object, build it */ - if (ACPI_SUCCESS (Status)) - { - /* Dereference Index and RefOf references */ - - AcpiNsResolveReferences (Info); - - /* Get the size of the returned object */ - - Status = AcpiUtGetObjectSize (Info->ReturnObject, - &BufferSpaceNeeded); - if (ACPI_SUCCESS (Status)) - { - /* Validate/Allocate/Clear caller buffer */ - - Status = AcpiUtInitializeBuffer (ReturnBuffer, - BufferSpaceNeeded); - if (ACPI_FAILURE (Status)) - { - /* - * Caller's buffer is too small or a new one can't - * be allocated - */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Needed buffer size %X, %s\n", - (UINT32) BufferSpaceNeeded, - AcpiFormatException (Status))); - } - else - { - /* We have enough space for the object, build it */ - - Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject, - ReturnBuffer); - } - } - } + Status = AcpiUtCopyIobjectToEobject ( + Info->ReturnObject, ReturnBuffer); } } +CleanupReturnObject: + if (Info->ReturnObject) { /* @@ -668,8 +672,8 @@ AcpiWalkNamespace ( } Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, - ACPI_NS_WALK_UNLOCK, DescendingCallback, - AscendingCallback, Context, ReturnValue); + ACPI_NS_WALK_UNLOCK, DescendingCallback, + AscendingCallback, Context, ReturnValue); UnlockAndExit2: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -758,7 +762,7 @@ AcpiNsGetDeviceCallback ( return (AE_CTRL_DEPTH); } - NoMatch = ACPI_STRCMP (Hid->String, Info->Hid); + NoMatch = strcmp (Hid->String, Info->Hid); ACPI_FREE (Hid); if (NoMatch) @@ -782,7 +786,7 @@ AcpiNsGetDeviceCallback ( Found = FALSE; for (i = 0; i < Cid->Count; i++) { - if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0) + if (strcmp (Cid->Ids[i].String, Info->Hid) == 0) { /* Found a matching CID */ @@ -820,8 +824,8 @@ AcpiNsGetDeviceCallback ( /* We have a valid device, invoke the user function */ - Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, - ReturnValue); + Status = Info->UserFunction (ObjHandle, NestingLevel, + Info->Context, ReturnValue); return (Status); } @@ -876,8 +880,8 @@ AcpiGetDevices ( * We're going to call their callback from OUR callback, so we need * to know what it is, and their context parameter. */ - Info.Hid = HID; - Info.Context = Context; + Info.Hid = HID; + Info.Context = Context; Info.UserFunction = UserFunction; /* @@ -893,8 +897,8 @@ AcpiGetDevices ( } Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, - AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfname.c b/sys/contrib/dev/acpica/components/namespace/nsxfname.c index 804ea94..55c515f 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfname.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfname.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -126,7 +126,7 @@ AcpiGetHandle ( /* Special case for root-only, since we can't search for it */ - if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH)) + if (!strcmp (Pathname, ACPI_NS_ROOT_PATH)) { *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); return (AE_OK); @@ -177,7 +177,7 @@ AcpiGetName ( { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; - char *NodeName; + const char *NodeName; /* Parameter validation */ @@ -193,11 +193,13 @@ AcpiGetName ( return (Status); } - if (NameType == ACPI_FULL_PATHNAME) + if (NameType == ACPI_FULL_PATHNAME || + NameType == ACPI_FULL_PATHNAME_NO_TRAILING) { /* Get the full pathname (From the namespace root) */ - Status = AcpiNsHandleToPathname (Handle, Buffer); + Status = AcpiNsHandleToPathname (Handle, Buffer, + NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); return (Status); } @@ -263,7 +265,6 @@ AcpiNsCopyDeviceId ( ACPI_PNP_DEVICE_ID *Source, char *StringArea) { - /* Create the destination PNP_DEVICE_ID */ Dest->String = StringArea; @@ -271,7 +272,7 @@ AcpiNsCopyDeviceId ( /* Copy actual string and return a pointer to the next string area */ - ACPI_MEMCPY (StringArea, Source->String, Source->Length); + memcpy (StringArea, Source->String, Source->Length); return (StringArea + Source->Length); } @@ -289,11 +290,18 @@ AcpiNsCopyDeviceId ( * namespace node and possibly by running several standard * control methods (Such as in the case of a device.) * - * For Device and Processor objects, run the Device _HID, _UID, _CID, _SUB, - * _STA, _ADR, _SxW, and _SxD methods. + * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, + * _CLS, _ADR, _SxW, and _SxD methods. * * Note: Allocates the return buffer, must be freed by the caller. * + * Note: This interface is intended to be used during the initial device + * discovery namespace traversal. Therefore, no complex methods can be + * executed, especially those that access operation regions. Therefore, do + * not add any additional methods that could cause problems in this area. + * this was the fate of the _SUB method which was found to cause such + * problems and was removed (11/2015). + * ******************************************************************************/ ACPI_STATUS @@ -306,12 +314,12 @@ AcpiGetObjectInfo ( ACPI_PNP_DEVICE_ID_LIST *CidList = NULL; ACPI_PNP_DEVICE_ID *Hid = NULL; ACPI_PNP_DEVICE_ID *Uid = NULL; - ACPI_PNP_DEVICE_ID *Sub = NULL; + ACPI_PNP_DEVICE_ID *Cls = NULL; char *NextIdString; ACPI_OBJECT_TYPE Type; ACPI_NAME Name; UINT8 ParamCount= 0; - UINT8 Valid = 0; + UINT16 Valid = 0; UINT32 InfoSize; UINT32 i; ACPI_STATUS Status; @@ -359,7 +367,7 @@ AcpiGetObjectInfo ( { /* * Get extra info for ACPI Device/Processor objects only: - * Run the Device _HID, _UID, _SUB, and _CID methods. + * Run the Device _HID, _UID, _CLS, and _CID methods. * * Note: none of these methods are required, so they may or may * not be present for this device. The Info->Valid bitfield is used @@ -384,15 +392,6 @@ AcpiGetObjectInfo ( Valid |= ACPI_VALID_UID; } - /* Execute the Device._SUB method */ - - Status = AcpiUtExecute_SUB (Node, &Sub); - if (ACPI_SUCCESS (Status)) - { - InfoSize += Sub->Length; - Valid |= ACPI_VALID_SUB; - } - /* Execute the Device._CID method */ Status = AcpiUtExecute_CID (Node, &CidList); @@ -403,6 +402,15 @@ AcpiGetObjectInfo ( InfoSize += (CidList->ListSize - sizeof (ACPI_PNP_DEVICE_ID_LIST)); Valid |= ACPI_VALID_CID; } + + /* Execute the Device._CLS method */ + + Status = AcpiUtExecute_CLS (Node, &Cls); + if (ACPI_SUCCESS (Status)) + { + InfoSize += Cls->Length; + Valid |= ACPI_VALID_CLS; + } } /* @@ -446,7 +454,7 @@ AcpiGetObjectInfo ( /* Execute the Device._ADR method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, - &Info->Address); + &Info->Address); if (ACPI_SUCCESS (Status)) { Valid |= ACPI_VALID_ADR; @@ -455,8 +463,8 @@ AcpiGetObjectInfo ( /* Execute the Device._SxW methods */ Status = AcpiUtExecutePowerMethods (Node, - AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, - Info->LowestDstates); + AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, + Info->LowestDstates); if (ACPI_SUCCESS (Status)) { Valid |= ACPI_VALID_SXWS; @@ -465,8 +473,8 @@ AcpiGetObjectInfo ( /* Execute the Device._SxD methods */ Status = AcpiUtExecutePowerMethods (Node, - AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, - Info->HighestDstates); + AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, + Info->HighestDstates); if (ACPI_SUCCESS (Status)) { Valid |= ACPI_VALID_SXDS; @@ -486,9 +494,8 @@ AcpiGetObjectInfo ( } /* - * Copy the HID, UID, SUB, and CIDs to the return buffer. - * The variable-length strings are copied to the reserved area - * at the end of the buffer. + * Copy the HID, UID, and CIDs to the return buffer. The variable-length + * strings are copied to the reserved area at the end of the buffer. * * For HID and CID, check if the ID is a PCI Root Bridge. */ @@ -509,12 +516,6 @@ AcpiGetObjectInfo ( Uid, NextIdString); } - if (Sub) - { - NextIdString = AcpiNsCopyDeviceId (&Info->SubsystemId, - Sub, NextIdString); - } - if (CidList) { Info->CompatibleIdList.Count = CidList->Count; @@ -534,6 +535,12 @@ AcpiGetObjectInfo ( } } + if (Cls) + { + NextIdString = AcpiNsCopyDeviceId (&Info->ClassCode, + Cls, NextIdString); + } + /* Copy the fixed-length data */ Info->InfoSize = InfoSize; @@ -555,14 +562,14 @@ Cleanup: { ACPI_FREE (Uid); } - if (Sub) - { - ACPI_FREE (Sub); - } if (CidList) { ACPI_FREE (CidList); } + if (Cls) + { + ACPI_FREE (Cls); + } return (Status); } @@ -630,6 +637,7 @@ AcpiInstallMethod ( ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); Path = AcpiPsGetNextNamestring (&ParserState); + MethodFlags = *ParserState.Aml++; AmlStart = ParserState.Aml; AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); @@ -662,7 +670,7 @@ AcpiInstallMethod ( /* The lookup either returns an existing node or creates a new one */ Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); + ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -684,7 +692,7 @@ AcpiInstallMethod ( /* Copy the method AML to the local buffer */ - ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength); + memcpy (AmlBuffer, AmlStart, AmlLength); /* Initialize the method object with the new method's information */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfobj.c b/sys/contrib/dev/acpica/components/namespace/nsxfobj.c index 2481e7a..81a4756 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfobj.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfobj.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,10 +81,8 @@ AcpiGetType ( return (AE_BAD_PARAMETER); } - /* - * Special case for the predefined Root Node - * (return type ANY) - */ + /* Special case for the predefined Root Node (return type ANY) */ + if (Handle == ACPI_ROOT_OBJECT) { *RetType = ACPI_TYPE_ANY; @@ -108,7 +106,6 @@ AcpiGetType ( *RetType = Node->Type; - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } diff --git a/sys/contrib/dev/acpica/components/parser/psargs.c b/sys/contrib/dev/acpica/components/parser/psargs.c index b2a86fe..9c49ea6 100644 --- a/sys/contrib/dev/acpica/components/parser/psargs.c +++ b/sys/contrib/dev/acpica/components/parser/psargs.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -287,8 +287,8 @@ AcpiPsGetNextNamepath ( * the upsearch) */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); /* * If this name is a control method invocation, we must @@ -316,7 +316,7 @@ AcpiPsGetNextNamepath ( ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path)); - NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Start); if (!NameOp) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -359,7 +359,7 @@ AcpiPsGetNextNamepath ( /* 1) NotFound is ok during load pass 1/2 (allow forward references) */ if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) != - ACPI_PARSE_EXECUTE) + ACPI_PARSE_EXECUTE) { Status = AE_OK; } @@ -391,7 +391,7 @@ AcpiPsGetNextNamepath ( ACPI_ERROR_NAMESPACE (Path, Status); if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == - ACPI_PARSE_EXECUTE) + ACPI_PARSE_EXECUTE) { /* Report a control method execution error */ @@ -524,7 +524,7 @@ static ACPI_PARSE_OBJECT * AcpiPsGetNextField ( ACPI_PARSE_STATE *ParserState) { - UINT32 AmlOffset; + UINT8 *Aml; ACPI_PARSE_OBJECT *Field; ACPI_PARSE_OBJECT *Arg = NULL; UINT16 Opcode; @@ -540,8 +540,7 @@ AcpiPsGetNextField ( ACPI_FUNCTION_TRACE (PsGetNextField); - AmlOffset = (UINT32) ACPI_PTR_DIFF ( - ParserState->Aml, ParserState->AmlStart); + Aml = ParserState->Aml; /* Determine field type */ @@ -579,14 +578,12 @@ AcpiPsGetNextField ( /* Allocate a new field op */ - Field = AcpiPsAllocOp (Opcode); + Field = AcpiPsAllocOp (Opcode, Aml); if (!Field) { return_PTR (NULL); } - Field->Common.AmlOffset = AmlOffset; - /* Decode the field type */ switch (Opcode) @@ -650,6 +647,7 @@ AcpiPsGetNextField ( * Argument for Connection operator can be either a Buffer * (resource descriptor), or a NameString. */ + Aml = ParserState->Aml; if (ACPI_GET8 (ParserState->Aml) == AML_BUFFER_OP) { ParserState->Aml++; @@ -662,7 +660,7 @@ AcpiPsGetNextField ( { /* Non-empty list */ - Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); + Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP, Aml); if (!Arg) { AcpiPsFreeOp (Field); @@ -712,7 +710,7 @@ AcpiPsGetNextField ( } else { - Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Aml); if (!Arg) { AcpiPsFreeOp (Field); @@ -784,11 +782,12 @@ AcpiPsGetNextArg ( /* Constants, strings, and namestrings are all the same size */ - Arg = AcpiPsAllocOp (AML_BYTE_OP); + Arg = AcpiPsAllocOp (AML_BYTE_OP, ParserState->Aml); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); } + AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); break; @@ -836,7 +835,8 @@ AcpiPsGetNextArg ( { /* Non-empty list */ - Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); + Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP, + ParserState->Aml); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -857,6 +857,7 @@ AcpiPsGetNextArg ( case ARGP_TARGET: case ARGP_SUPERNAME: case ARGP_SIMPLENAME: + case ARGP_NAME_OR_REF: Subop = AcpiPsPeekOpcode (ParserState); if (Subop == 0 || @@ -866,7 +867,7 @@ AcpiPsGetNextArg ( { /* NullName or NameString */ - Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -876,11 +877,12 @@ AcpiPsGetNextArg ( if (WalkState->Opcode == AML_UNLOAD_OP) { - Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1); + Status = AcpiPsGetNextNamepath (WalkState, ParserState, + Arg, ACPI_POSSIBLE_METHOD_CALL); /* - * If the SuperName arg of Unload is a method call, - * we have restored the AML pointer, just free this Arg + * If the SuperName argument is a method call, we have + * already restored the AML pointer, just free this Arg */ if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) { @@ -890,7 +892,8 @@ AcpiPsGetNextArg ( } else { - Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); + Status = AcpiPsGetNextNamepath (WalkState, ParserState, + Arg, ACPI_NOT_METHOD_CALL); } } else diff --git a/sys/contrib/dev/acpica/components/parser/psloop.c b/sys/contrib/dev/acpica/components/parser/psloop.c index 63b64ab..cbcca10 100644 --- a/sys/contrib/dev/acpica/components/parser/psloop.c +++ b/sys/contrib/dev/acpica/components/parser/psloop.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,7 @@ #include <contrib/dev/acpica/include/acpi.h> #include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acinterp.h> #include <contrib/dev/acpica/include/acparser.h> #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/amlcode.h> @@ -119,7 +120,8 @@ AcpiPsGetArguments ( case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ - Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1); + Status = AcpiPsGetNextNamepath (WalkState, + &(WalkState->ParserState), Op, ACPI_POSSIBLE_METHOD_CALL); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -132,13 +134,13 @@ AcpiPsGetArguments ( /* * Op is not a constant or string, append each argument to the Op */ - while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount) + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && + !WalkState->ArgCount) { - WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, - WalkState->ParserState.AmlStart); + WalkState->Aml = WalkState->ParserState.Aml; Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -146,7 +148,6 @@ AcpiPsGetArguments ( if (Arg) { - Arg->Common.AmlOffset = WalkState->AmlOffset; AcpiPsAppendArg (Op, Arg); } @@ -319,6 +320,9 @@ AcpiPsLinkModuleCode ( ACPI_NAMESPACE_NODE *ParentNode; + ACPI_FUNCTION_TRACE (PsLinkModuleCode); + + /* Get the tail of the list */ Prev = Next = AcpiGbl_ModuleCodeList; @@ -340,9 +344,12 @@ AcpiPsLinkModuleCode ( MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); if (!MethodObj) { - return; + return_VOID; } + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Create/Link new code block: %p\n", MethodObj)); + if (ParentOp->Common.Node) { ParentNode = ParentOp->Common.Node; @@ -375,8 +382,13 @@ AcpiPsLinkModuleCode ( } else { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Appending to existing code block: %p\n", Prev)); + Prev->Method.AmlLength += AmlLength; } + + return_VOID; } /******************************************************************************* @@ -502,15 +514,7 @@ AcpiPsParseLoop ( continue; } - Op->Common.AmlOffset = WalkState->AmlOffset; - - if (WalkState->OpInfo) - { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", - (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name, - Op, ParserState->Aml, Op->Common.AmlOffset)); - } + AcpiExStartTraceOpcode (Op, WalkState); } @@ -548,7 +552,7 @@ AcpiPsParseLoop ( * prepare for argument */ Status = AcpiPsPushScope (ParserState, Op, - WalkState->ArgTypes, WalkState->ArgCount); + WalkState->ArgTypes, WalkState->ArgCount); if (ACPI_FAILURE (Status)) { Status = AcpiPsCompleteOp (WalkState, &Op, Status); diff --git a/sys/contrib/dev/acpica/components/parser/psobject.c b/sys/contrib/dev/acpica/components/parser/psobject.c index 0ad37b9..3b94e2c 100644 --- a/sys/contrib/dev/acpica/components/parser/psobject.c +++ b/sys/contrib/dev/acpica/components/parser/psobject.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,12 +73,13 @@ static ACPI_STATUS AcpiPsGetAmlOpcode ( ACPI_WALK_STATE *WalkState) { + UINT32 AmlOffset; + ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState); - WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, - WalkState->ParserState.AmlStart); + WalkState->Aml = WalkState->ParserState.Aml; WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState)); /* @@ -107,10 +108,13 @@ AcpiPsGetAmlOpcode ( if (WalkState->PassNumber == 2) { + AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml, + WalkState->ParserState.AmlStart); + ACPI_ERROR ((AE_INFO, "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring", WalkState->Opcode, - (UINT32) (WalkState->AmlOffset + sizeof (ACPI_TABLE_HEADER)))); + (UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER)))); ACPI_DUMP_BUFFER ((WalkState->ParserState.Aml - 16), 48); @@ -122,13 +126,13 @@ AcpiPsGetAmlOpcode ( AcpiOsPrintf ( "/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n", WalkState->Opcode, - (UINT32) (WalkState->AmlOffset + sizeof (ACPI_TABLE_HEADER))); + (UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER))); /* Dump the context surrounding the invalid opcode */ AcpiUtDumpBuffer (((UINT8 *) WalkState->ParserState.Aml - 16), 48, DB_BYTE_DISPLAY, - (WalkState->AmlOffset + sizeof (ACPI_TABLE_HEADER) - 16)); + (AmlOffset + sizeof (ACPI_TABLE_HEADER) - 16)); AcpiOsPrintf (" */\n"); #endif } @@ -147,7 +151,8 @@ AcpiPsGetAmlOpcode ( /* Found opcode info, this is a normal opcode */ - WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode); + WalkState->ParserState.Aml += + AcpiPsGetOpcodeSize (WalkState->Opcode); WalkState->ArgTypes = WalkState->OpInfo->ParseArgs; break; } @@ -197,7 +202,7 @@ AcpiPsBuildNamedOp ( (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)) { Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -313,7 +318,7 @@ AcpiPsCreateOp ( /* Create Op structure and append to parent's argument list */ WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); - Op = AcpiPsAllocOp (WalkState->Opcode); + Op = AcpiPsAllocOp (WalkState->Opcode, AmlOpStart); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); diff --git a/sys/contrib/dev/acpica/components/parser/psopcode.c b/sys/contrib/dev/acpica/components/parser/psopcode.c index e351e4c..9f53d1e 100644 --- a/sys/contrib/dev/acpica/components/parser/psopcode.c +++ b/sys/contrib/dev/acpica/components/parser/psopcode.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -245,7 +245,7 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), -/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 37 */ ACPI_OP ("ObjectType", ARGP_OBJECT_TYPE_OP, ARGI_OBJECT_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), /* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), /* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), /* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), diff --git a/sys/contrib/dev/acpica/components/parser/psopinfo.c b/sys/contrib/dev/acpica/components/parser/psopinfo.c index f7f6248..6ffd7d2 100644 --- a/sys/contrib/dev/acpica/components/parser/psopinfo.c +++ b/sys/contrib/dev/acpica/components/parser/psopinfo.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -165,7 +165,7 @@ AcpiPsGetOpcodeInfo ( * ******************************************************************************/ -char * +const char * AcpiPsGetOpcodeName ( UINT16 Opcode) { diff --git a/sys/contrib/dev/acpica/components/parser/psparse.c b/sys/contrib/dev/acpica/components/parser/psparse.c index aa978cc..caf2a0e 100644 --- a/sys/contrib/dev/acpica/components/parser/psparse.c +++ b/sys/contrib/dev/acpica/components/parser/psparse.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -161,6 +161,8 @@ AcpiPsCompleteThisOp ( return_ACPI_STATUS (AE_OK); /* OK for now */ } + AcpiExStopTraceOpcode (Op, WalkState); + /* Delete this op and the subtree below it if asked to */ if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || @@ -198,7 +200,8 @@ AcpiPsCompleteThisOp ( * These opcodes contain TermArg operands. The current * op must be replaced by a placeholder return op */ - ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + ReplacementOp = AcpiPsAllocOp ( + AML_INT_RETURN_VALUE_OP, Op->Common.Aml); if (!ReplacementOp) { Status = AE_NO_MEMORY; @@ -217,7 +220,8 @@ AcpiPsCompleteThisOp ( (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) || (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) { - ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + ReplacementOp = AcpiPsAllocOp ( + AML_INT_RETURN_VALUE_OP, Op->Common.Aml); if (!ReplacementOp) { Status = AE_NO_MEMORY; @@ -230,7 +234,8 @@ AcpiPsCompleteThisOp ( (Op->Common.AmlOpcode == AML_PACKAGE_OP) || (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) { - ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); + ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode, + Op->Common.Aml); if (!ReplacementOp) { Status = AE_NO_MEMORY; @@ -246,7 +251,8 @@ AcpiPsCompleteThisOp ( default: - ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + ReplacementOp = AcpiPsAllocOp ( + AML_INT_RETURN_VALUE_OP, Op->Common.Aml); if (!ReplacementOp) { Status = AE_NO_MEMORY; @@ -261,11 +267,11 @@ AcpiPsCompleteThisOp ( if (ReplacementOp) { - ReplacementOp->Common.Parent = Op->Common.Parent; - ReplacementOp->Common.Value.Arg = NULL; - ReplacementOp->Common.Node = Op->Common.Node; + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; Op->Common.Parent->Common.Value.Arg = ReplacementOp; - ReplacementOp->Common.Next = Op->Common.Next; + ReplacementOp->Common.Next = Op->Common.Next; } else { @@ -284,11 +290,11 @@ AcpiPsCompleteThisOp ( { if (ReplacementOp) { - ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Parent = Op->Common.Parent; ReplacementOp->Common.Value.Arg = NULL; - ReplacementOp->Common.Node = Op->Common.Node; - Prev->Common.Next = ReplacementOp; - ReplacementOp->Common.Next = Op->Common.Next; + ReplacementOp->Common.Node = Op->Common.Node; + Prev->Common.Next = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; Next = NULL; } else @@ -488,7 +494,8 @@ AcpiPsParseAml ( */ if (WalkState->MethodDesc) { - WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel; + WalkState->Thread->CurrentSyncLevel = + WalkState->MethodDesc->Method.SyncLevel; } AcpiDsPushWalkState (WalkState, Thread); @@ -534,8 +541,8 @@ AcpiPsParseAml ( } /* - * If the transfer to the new method method call worked, a new walk - * state was created -- get it + * If the transfer to the new method method call worked + *, a new walk state was created -- get it */ WalkState = AcpiDsGetCurrentWalkState (Thread); continue; @@ -554,7 +561,8 @@ AcpiPsParseAml ( /* Check for possible multi-thread reentrancy problem */ if ((Status == AE_ALREADY_EXISTS) && - (!(WalkState->MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED))) + (!(WalkState->MethodDesc->Method.InfoFlags & + ACPI_METHOD_SERIALIZED))) { /* * Method is not serialized and tried to create an object @@ -580,7 +588,8 @@ AcpiPsParseAml ( * encountered an error during the method parse phase, there's lots of * cleanup to do */ - if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) || + if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) || (ACPI_FAILURE (Status))) { AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); @@ -627,7 +636,7 @@ AcpiPsParseAml ( /* Restart the calling control method */ Status = AcpiDsRestartControlMethod (WalkState, - PreviousWalkState->ImplicitReturnObj); + PreviousWalkState->ImplicitReturnObj); } else { @@ -638,7 +647,7 @@ AcpiPsParseAml ( AcpiDsClearImplicitReturn (PreviousWalkState); Status = AcpiDsRestartControlMethod (WalkState, - PreviousWalkState->ReturnDesc); + PreviousWalkState->ReturnDesc); } if (ACPI_SUCCESS (Status)) { diff --git a/sys/contrib/dev/acpica/components/parser/psscope.c b/sys/contrib/dev/acpica/components/parser/psscope.c index 87e897e..9ad7a58 100644 --- a/sys/contrib/dev/acpica/components/parser/psscope.c +++ b/sys/contrib/dev/acpica/components/parser/psscope.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -236,9 +236,9 @@ AcpiPsPopScope ( /* Return to parsing previous op */ - *Op = Scope->ParseScope.Op; - *ArgList = Scope->ParseScope.ArgList; - *ArgCount = Scope->ParseScope.ArgCount; + *Op = Scope->ParseScope.Op; + *ArgList = Scope->ParseScope.ArgList; + *ArgCount = Scope->ParseScope.ArgCount; ParserState->PkgEnd = Scope->ParseScope.PkgEnd; /* All done with this scope state structure */ @@ -249,8 +249,8 @@ AcpiPsPopScope ( { /* Empty parse stack, prepare to fetch next opcode */ - *Op = NULL; - *ArgList = 0; + *Op = NULL; + *ArgList = 0; *ArgCount = 0; } diff --git a/sys/contrib/dev/acpica/components/parser/pstree.c b/sys/contrib/dev/acpica/components/parser/pstree.c index daec8f3..dd2d5e0 100644 --- a/sys/contrib/dev/acpica/components/parser/pstree.c +++ b/sys/contrib/dev/acpica/components/parser/pstree.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/parser/psutils.c b/sys/contrib/dev/acpica/components/parser/psutils.c index 1a269a6..ca3830e 100644 --- a/sys/contrib/dev/acpica/components/parser/psutils.c +++ b/sys/contrib/dev/acpica/components/parser/psutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -64,12 +64,12 @@ ACPI_PARSE_OBJECT * AcpiPsCreateScopeOp ( - void) + UINT8 *Aml) { ACPI_PARSE_OBJECT *ScopeOp; - ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP); + ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP, Aml); if (!ScopeOp) { return (NULL); @@ -104,9 +104,9 @@ AcpiPsInitOp ( Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER; Op->Common.AmlOpcode = Opcode; - ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName, - (AcpiPsGetOpcodeInfo (Opcode))->Name, - sizeof (Op->Common.AmlOpName))); + ACPI_DISASM_ONLY_MEMBERS (strncpy (Op->Common.AmlOpName, + (AcpiPsGetOpcodeInfo (Opcode))->Name, + sizeof (Op->Common.AmlOpName))); } @@ -115,6 +115,7 @@ AcpiPsInitOp ( * FUNCTION: AcpiPsAllocOp * * PARAMETERS: Opcode - Opcode that will be stored in the new Op + * Aml - Address of the opcode * * RETURN: Pointer to the new Op, null on failure * @@ -126,7 +127,8 @@ AcpiPsInitOp ( ACPI_PARSE_OBJECT* AcpiPsAllocOp ( - UINT16 Opcode) + UINT16 Opcode, + UINT8 *Aml) { ACPI_PARSE_OBJECT *Op; const ACPI_OPCODE_INFO *OpInfo; @@ -146,7 +148,7 @@ AcpiPsAllocOp ( } else if (OpInfo->Flags & AML_NAMED) { - Flags = ACPI_PARSEOP_NAMED; + Flags = ACPI_PARSEOP_NAMED_OBJECT; } else if (Opcode == AML_INT_BYTELIST_OP) { @@ -173,6 +175,7 @@ AcpiPsAllocOp ( if (Op) { AcpiPsInitOp (Op, Opcode); + Op->Common.Aml = Aml; Op->Common.Flags = Flags; } @@ -202,7 +205,8 @@ AcpiPsFreeOp ( if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Free retval op: %p\n", Op)); } if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) diff --git a/sys/contrib/dev/acpica/components/parser/pswalk.c b/sys/contrib/dev/acpica/components/parser/pswalk.c index 044b068..1a9e55e 100644 --- a/sys/contrib/dev/acpica/components/parser/pswalk.c +++ b/sys/contrib/dev/acpica/components/parser/pswalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -106,6 +106,7 @@ AcpiPsDeleteParseTree ( { return_VOID; } + if (Next) { Op = Next; diff --git a/sys/contrib/dev/acpica/components/parser/psxface.c b/sys/contrib/dev/acpica/components/parser/psxface.c index 2927f4c..b99cee0 100644 --- a/sys/contrib/dev/acpica/components/parser/psxface.c +++ b/sys/contrib/dev/acpica/components/parser/psxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/acinterp.h> #include <contrib/dev/acpica/include/actables.h> +#include <contrib/dev/acpica/include/acnamesp.h> #define _COMPONENT ACPI_PARSER @@ -55,14 +56,6 @@ /* Local Prototypes */ static void -AcpiPsStartTrace ( - ACPI_EVALUATE_INFO *Info); - -static void -AcpiPsStopTrace ( - ACPI_EVALUATE_INFO *Info); - -static void AcpiPsUpdateParameterList ( ACPI_EVALUATE_INFO *Info, UINT16 Action); @@ -86,7 +79,7 @@ AcpiPsUpdateParameterList ( ACPI_STATUS AcpiDebugTrace ( - char *Name, + const char *Name, UINT32 DebugLevel, UINT32 DebugLayer, UINT32 Flags) @@ -100,128 +93,14 @@ AcpiDebugTrace ( return (Status); } - /* TBDs: Validate name, allow full path or just nameseg */ - - AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name); + AcpiGbl_TraceMethodName = Name; AcpiGbl_TraceFlags = Flags; - - if (DebugLevel) - { - AcpiGbl_TraceDbgLevel = DebugLevel; - } - if (DebugLayer) - { - AcpiGbl_TraceDbgLayer = DebugLayer; - } + AcpiGbl_TraceDbgLevel = DebugLevel; + AcpiGbl_TraceDbgLayer = DebugLayer; + Status = AE_OK; (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiPsStartTrace - * - * PARAMETERS: Info - Method info struct - * - * RETURN: None - * - * DESCRIPTION: Start control method execution trace - * - ******************************************************************************/ - -static void -AcpiPsStartTrace ( - ACPI_EVALUATE_INFO *Info) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_ENTRY (); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return; - } - - if ((!AcpiGbl_TraceMethodName) || - (AcpiGbl_TraceMethodName != Info->Node->Name.Integer)) - { - goto Exit; - } - - AcpiGbl_OriginalDbgLevel = AcpiDbgLevel; - AcpiGbl_OriginalDbgLayer = AcpiDbgLayer; - - AcpiDbgLevel = 0x00FFFFFF; - AcpiDbgLayer = ACPI_UINT32_MAX; - - if (AcpiGbl_TraceDbgLevel) - { - AcpiDbgLevel = AcpiGbl_TraceDbgLevel; - } - if (AcpiGbl_TraceDbgLayer) - { - AcpiDbgLayer = AcpiGbl_TraceDbgLayer; - } - - -Exit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiPsStopTrace - * - * PARAMETERS: Info - Method info struct - * - * RETURN: None - * - * DESCRIPTION: Stop control method execution trace - * - ******************************************************************************/ - -static void -AcpiPsStopTrace ( - ACPI_EVALUATE_INFO *Info) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_ENTRY (); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return; - } - - if ((!AcpiGbl_TraceMethodName) || - (AcpiGbl_TraceMethodName != Info->Node->Name.Integer)) - { - goto Exit; - } - - /* Disable further tracing if type is one-shot */ - - if (AcpiGbl_TraceFlags & 1) - { - AcpiGbl_TraceMethodName = 0; - AcpiGbl_TraceDbgLevel = 0; - AcpiGbl_TraceDbgLayer = 0; - } - - AcpiDbgLevel = AcpiGbl_OriginalDbgLevel; - AcpiDbgLayer = AcpiGbl_OriginalDbgLayer; - -Exit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); } @@ -284,10 +163,6 @@ AcpiPsExecuteMethod ( */ AcpiPsUpdateParameterList (Info, REF_INCREMENT); - /* Begin tracing if requested */ - - AcpiPsStartTrace (Info); - /* * Execute the method. Performs parse simultaneously */ @@ -297,7 +172,7 @@ AcpiPsExecuteMethod ( /* Create and init a Root Node */ - Op = AcpiPsCreateScopeOp (); + Op = AcpiPsCreateScopeOp (Info->ObjDesc->Method.AmlStart); if (!Op) { Status = AE_NO_MEMORY; @@ -308,7 +183,7 @@ AcpiPsExecuteMethod ( Info->PassNumber = ACPI_IMODE_EXECUTE; WalkState = AcpiDsCreateWalkState ( - Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); + Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); if (!WalkState) { Status = AE_NO_MEMORY; @@ -316,8 +191,8 @@ AcpiPsExecuteMethod ( } Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, - Info->ObjDesc->Method.AmlStart, - Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber); + Info->ObjDesc->Method.AmlStart, + Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -370,10 +245,6 @@ AcpiPsExecuteMethod ( Cleanup: AcpiPsDeleteParseTree (Op); - /* End optional tracing */ - - AcpiPsStopTrace (Info); - /* Take away the extra reference that we gave the parameters above */ AcpiPsUpdateParameterList (Info, REF_DECREMENT); @@ -432,7 +303,8 @@ AcpiPsUpdateParameterList ( { /* Ignore errors, just do them all */ - (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action); + (void) AcpiUtUpdateObjectReference ( + Info->Parameters[i], Action); } } } diff --git a/sys/contrib/dev/acpica/components/resources/rsaddr.c b/sys/contrib/dev/acpica/components/resources/rsaddr.c index decd9a6..ca9e290 100644 --- a/sys/contrib/dev/acpica/components/resources/rsaddr.c +++ b/sys/contrib/dev/acpica/components/resources/rsaddr.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -328,30 +328,35 @@ AcpiRsGetAddressCommon ( /* Validate the Resource Type */ - if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0)) + if ((Aml->Address.ResourceType > 2) && + (Aml->Address.ResourceType < 0xC0)) { return (FALSE); } /* Get the Resource Type and General Flags */ - (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags); + (void) AcpiRsConvertAmlToResource ( + Resource, Aml, AcpiRsConvertGeneralFlags); /* Get the Type-Specific Flags (Memory and I/O descriptors only) */ if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) { - (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags); + (void) AcpiRsConvertAmlToResource ( + Resource, Aml, AcpiRsConvertMemFlags); } else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) { - (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags); + (void) AcpiRsConvertAmlToResource ( + Resource, Aml, AcpiRsConvertIoFlags); } else { /* Generic resource type, just grab the TypeSpecific byte */ - Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags; + Resource->Data.Address.Info.TypeSpecific = + Aml->Address.SpecificFlags; } return (TRUE); @@ -382,22 +387,26 @@ AcpiRsSetAddressCommon ( /* Set the Resource Type and General Flags */ - (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags); + (void) AcpiRsConvertResourceToAml ( + Resource, Aml, AcpiRsConvertGeneralFlags); /* Set the Type-Specific Flags (Memory and I/O descriptors only) */ if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) { - (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags); + (void) AcpiRsConvertResourceToAml ( + Resource, Aml, AcpiRsConvertMemFlags); } else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) { - (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags); + (void) AcpiRsConvertResourceToAml ( + Resource, Aml, AcpiRsConvertIoFlags); } else { /* Generic resource type, just copy the TypeSpecific byte */ - Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific; + Aml->Address.SpecificFlags = + Resource->Data.Address.Info.TypeSpecific; } } diff --git a/sys/contrib/dev/acpica/components/resources/rscalc.c b/sys/contrib/dev/acpica/components/resources/rscalc.c index 38db8c1..9cc9638 100644 --- a/sys/contrib/dev/acpica/components/resources/rscalc.c +++ b/sys/contrib/dev/acpica/components/resources/rscalc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -164,16 +164,17 @@ AcpiRsStreamOptionLength ( /* - * The ResourceSourceIndex and ResourceSource are optional elements of some - * Large-type resource descriptors. + * The ResourceSourceIndex and ResourceSource are optional elements of + * some Large-type resource descriptors. */ /* - * If the length of the actual resource descriptor is greater than the ACPI - * spec-defined minimum length, it means that a ResourceSourceIndex exists - * and is followed by a (required) null terminated string. The string length - * (including the null terminator) is the resource length minus the minimum - * length, minus one byte for the ResourceSourceIndex itself. + * If the length of the actual resource descriptor is greater than the + * ACPI spec-defined minimum length, it means that a ResourceSourceIndex + * exists and is followed by a (required) null terminated string. The + * string length (including the null terminator) is the resource length + * minus the minimum length, minus one byte for the ResourceSourceIndex + * itself. */ if (ResourceLength > MinimumAmlResourceLength) { @@ -309,9 +310,9 @@ AcpiRsGetAmlLength ( * 16-Bit Address Resource: * Add the size of the optional ResourceSource info */ - TotalSize = (ACPI_RS_LENGTH) - (TotalSize + AcpiRsStructOptionLength ( - &Resource->Data.Address16.ResourceSource)); + TotalSize = (ACPI_RS_LENGTH) (TotalSize + + AcpiRsStructOptionLength ( + &Resource->Data.Address16.ResourceSource)); break; @@ -320,9 +321,9 @@ AcpiRsGetAmlLength ( * 32-Bit Address Resource: * Add the size of the optional ResourceSource info */ - TotalSize = (ACPI_RS_LENGTH) - (TotalSize + AcpiRsStructOptionLength ( - &Resource->Data.Address32.ResourceSource)); + TotalSize = (ACPI_RS_LENGTH) (TotalSize + + AcpiRsStructOptionLength ( + &Resource->Data.Address32.ResourceSource)); break; @@ -331,9 +332,9 @@ AcpiRsGetAmlLength ( * 64-Bit Address Resource: * Add the size of the optional ResourceSource info */ - TotalSize = (ACPI_RS_LENGTH) - (TotalSize + AcpiRsStructOptionLength ( - &Resource->Data.Address64.ResourceSource)); + TotalSize = (ACPI_RS_LENGTH) (TotalSize + + AcpiRsStructOptionLength ( + &Resource->Data.Address64.ResourceSource)); break; @@ -343,8 +344,7 @@ AcpiRsGetAmlLength ( * Add the size of each additional optional interrupt beyond the * required 1 (4 bytes for each UINT32 interrupt number) */ - TotalSize = (ACPI_RS_LENGTH) - (TotalSize + + TotalSize = (ACPI_RS_LENGTH) (TotalSize + ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) + /* Add the size of the optional ResourceSource info */ @@ -356,7 +356,8 @@ AcpiRsGetAmlLength ( case ACPI_RESOURCE_TYPE_GPIO: - TotalSize = (ACPI_RS_LENGTH) (TotalSize + (Resource->Data.Gpio.PinTableLength * 2) + + TotalSize = (ACPI_RS_LENGTH) (TotalSize + + (Resource->Data.Gpio.PinTableLength * 2) + Resource->Data.Gpio.ResourceSource.StringLength + Resource->Data.Gpio.VendorLength); @@ -365,7 +366,8 @@ AcpiRsGetAmlLength ( case ACPI_RESOURCE_TYPE_SERIAL_BUS: - TotalSize = AcpiGbl_AmlResourceSerialBusSizes [Resource->Data.CommonSerialBus.Type]; + TotalSize = AcpiGbl_AmlResourceSerialBusSizes [ + Resource->Data.CommonSerialBus.Type]; TotalSize = (ACPI_RS_LENGTH) (TotalSize + Resource->Data.I2cSerialBus.ResourceSource.StringLength + @@ -544,12 +546,15 @@ AcpiRsGetListLength ( if (AmlResource->Gpio.VendorLength) { - ExtraStructBytes += AmlResource->Gpio.VendorOffset - - AmlResource->Gpio.PinTableOffset + AmlResource->Gpio.VendorLength; + ExtraStructBytes += + AmlResource->Gpio.VendorOffset - + AmlResource->Gpio.PinTableOffset + + AmlResource->Gpio.VendorLength; } else { - ExtraStructBytes += AmlResource->LargeHeader.ResourceLength + + ExtraStructBytes += + AmlResource->LargeHeader.ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER) - AmlResource->Gpio.PinTableOffset; } @@ -559,7 +564,8 @@ AcpiRsGetListLength ( MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[ AmlResource->CommonSerialBus.Type]; - ExtraStructBytes += AmlResource->CommonSerialBus.ResourceLength - + ExtraStructBytes += + AmlResource->CommonSerialBus.ResourceLength - MinimumAmlResourceLength; break; @@ -574,7 +580,8 @@ AcpiRsGetListLength ( * Important: Round the size up for the appropriate alignment. This * is a requirement on IA64. */ - if (AcpiUtGetResourceType (AmlBuffer) == ACPI_RESOURCE_NAME_SERIAL_BUS) + if (AcpiUtGetResourceType (AmlBuffer) == + ACPI_RESOURCE_NAME_SERIAL_BUS) { BufferSize = AcpiGbl_ResourceStructSerialBusSizes[ AmlResource->CommonSerialBus.Type] + ExtraStructBytes; @@ -582,10 +589,10 @@ AcpiRsGetListLength ( else { BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] + - ExtraStructBytes; + ExtraStructBytes; } - BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); + BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); *SizeNeeded += BufferSize; ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, @@ -722,7 +729,7 @@ AcpiRsGetPciRoutingTableLength ( else { TempSizeNeeded += AcpiNsGetPathnameLength ( - (*SubObjectList)->Reference.Node); + (*SubObjectList)->Reference.Node); } } else diff --git a/sys/contrib/dev/acpica/components/resources/rscreate.c b/sys/contrib/dev/acpica/components/resources/rscreate.c index c646129..c9b4b12 100644 --- a/sys/contrib/dev/acpica/components/resources/rscreate.c +++ b/sys/contrib/dev/acpica/components/resources/rscreate.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,8 +86,8 @@ AcpiBufferToResource ( /* Get the required length for the converted resource */ - Status = AcpiRsGetListLength (AmlBuffer, AmlBufferLength, - &ListSizeNeeded); + Status = AcpiRsGetListLength ( + AmlBuffer, AmlBufferLength, &ListSizeNeeded); if (Status == AE_AML_NO_RESOURCE_END_TAG) { Status = AE_OK; @@ -109,7 +109,7 @@ AcpiBufferToResource ( /* Perform the AML-to-Resource conversion */ Status = AcpiUtWalkAmlResources (NULL, AmlBuffer, AmlBufferLength, - AcpiRsConvertAmlToResources, &CurrentResourcePtr); + AcpiRsConvertAmlToResources, &CurrentResourcePtr); if (Status == AE_AML_NO_RESOURCE_END_TAG) { Status = AE_OK; @@ -197,14 +197,14 @@ AcpiRsCreateResourceList ( Resource = OutputBuffer->Pointer; Status = AcpiUtWalkAmlResources (NULL, AmlStart, AmlBufferLength, - AcpiRsConvertAmlToResources, &Resource); + AcpiRsConvertAmlToResources, &Resource); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", - OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); } @@ -255,8 +255,8 @@ AcpiRsCreatePciRoutingTable ( /* Get the required buffer length */ - Status = AcpiRsGetPciRoutingTableLength (PackageObject, - &BufferSizeNeeded); + Status = AcpiRsGetPciRoutingTableLength ( + PackageObject,&BufferSizeNeeded); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -278,10 +278,10 @@ AcpiRsCreatePciRoutingTable ( * package that in turn contains an UINT64 Address, a UINT8 Pin, * a Name, and a UINT8 SourceIndex. */ - TopObjectList = PackageObject->Package.Elements; + TopObjectList = PackageObject->Package.Elements; NumberOfElements = PackageObject->Package.Count; - Buffer = OutputBuffer->Pointer; - UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); + Buffer = OutputBuffer->Pointer; + UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); for (Index = 0; Index < NumberOfElements; Index++) { @@ -295,9 +295,9 @@ AcpiRsCreatePciRoutingTable ( UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); /* - * Fill in the Length field with the information we have at this point. - * The minus four is to subtract the size of the UINT8 Source[4] member - * because it is added below. + * Fill in the Length field with the information we have at this + * point. The minus four is to subtract the size of the UINT8 + * Source[4] member because it is added below. */ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); @@ -323,7 +323,8 @@ AcpiRsCreatePciRoutingTable ( ObjDesc = SubObjectList[0]; if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { - ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s", + ACPI_ERROR ((AE_INFO, + "(PRT[%u].Address) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } @@ -366,20 +367,21 @@ AcpiRsCreatePciRoutingTable ( /* Use *remaining* length of the buffer as max for pathname */ PathBuffer.Length = OutputBuffer->Length - - (UINT32) ((UINT8 *) UserPrt->Source - - (UINT8 *) OutputBuffer->Pointer); + (UINT32) ((UINT8 *) UserPrt->Source - + (UINT8 *) OutputBuffer->Pointer); PathBuffer.Pointer = UserPrt->Source; - Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); + Status = AcpiNsHandleToPathname ( + (ACPI_HANDLE) Node, &PathBuffer, FALSE); /* +1 to include null terminator */ - UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; + UserPrt->Length += (UINT32) strlen (UserPrt->Source) + 1; break; case ACPI_TYPE_STRING: - ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); + strcpy (UserPrt->Source, ObjDesc->String.Pointer); /* * Add to the Length field the length of the string @@ -390,8 +392,8 @@ AcpiRsCreatePciRoutingTable ( case ACPI_TYPE_INTEGER: /* - * If this is a number, then the Source Name is NULL, since the - * entire buffer was zeroed out, we can leave this alone. + * If this is a number, then the Source Name is NULL, since + * the entire buffer was zeroed out, we can leave this alone. * * Add to the Length field the length of the UINT32 NULL */ @@ -430,7 +432,7 @@ AcpiRsCreatePciRoutingTable ( } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", - OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); } @@ -471,8 +473,8 @@ AcpiRsCreateAmlResources ( /* Get the buffer size needed for the AML byte stream */ - Status = AcpiRsGetAmlLength (ResourceList->Pointer, - ResourceList->Length, &AmlSizeNeeded); + Status = AcpiRsGetAmlLength ( + ResourceList->Pointer, ResourceList->Length, &AmlSizeNeeded); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); @@ -492,7 +494,7 @@ AcpiRsCreateAmlResources ( /* Do the conversion */ Status = AcpiRsConvertResourcesToAml (ResourceList->Pointer, - AmlSizeNeeded, OutputBuffer->Pointer); + AmlSizeNeeded, OutputBuffer->Pointer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/resources/rsdump.c b/sys/contrib/dev/acpica/components/resources/rsdump.c index 9c1a7ec..8699730 100644 --- a/sys/contrib/dev/acpica/components/resources/rsdump.c +++ b/sys/contrib/dev/acpica/components/resources/rsdump.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,38 +51,37 @@ /* * All functions in this module are used by the AML Debugger only */ -#if defined(ACPI_DEBUGGER) /* Local prototypes */ static void AcpiRsOutString ( - char *Title, - char *Value); + const char *Title, + const char *Value); static void AcpiRsOutInteger8 ( - char *Title, + const char *Title, UINT8 Value); static void AcpiRsOutInteger16 ( - char *Title, + const char *Title, UINT16 Value); static void AcpiRsOutInteger32 ( - char *Title, + const char *Title, UINT32 Value); static void AcpiRsOutInteger64 ( - char *Title, + const char *Title, UINT64 Value); static void AcpiRsOutTitle ( - char *Title); + const char *Title); static void AcpiRsDumpByteList ( @@ -264,8 +263,8 @@ AcpiRsDumpDescriptor ( { UINT8 *Target = NULL; UINT8 *PreviousTarget; - char *Name; - UINT8 Count; + const char *Name; + UINT8 Count; /* First table entry must contain the table length (# of table entries) */ @@ -308,8 +307,7 @@ AcpiRsDumpDescriptor ( if (Table->Pointer) { - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target])); + AcpiRsOutString (Name, Table->Pointer [*Target]); } else { @@ -336,20 +334,17 @@ AcpiRsDumpDescriptor ( case ACPI_RSD_1BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x01])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x01]); break; case ACPI_RSD_2BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x03])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x03]); break; case ACPI_RSD_3BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x07])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x07]); break; case ACPI_RSD_SHORTLIST: @@ -543,9 +538,10 @@ AcpiRsDumpAddressCommon ( static void AcpiRsOutString ( - char *Title, - char *Value) + const char *Title, + const char *Value) { + AcpiOsPrintf ("%27s : %s", Title, Value); if (!*Value) { @@ -556,7 +552,7 @@ AcpiRsOutString ( static void AcpiRsOutInteger8 ( - char *Title, + const char *Title, UINT8 Value) { AcpiOsPrintf ("%27s : %2.2X\n", Title, Value); @@ -564,33 +560,37 @@ AcpiRsOutInteger8 ( static void AcpiRsOutInteger16 ( - char *Title, + const char *Title, UINT16 Value) { + AcpiOsPrintf ("%27s : %4.4X\n", Title, Value); } static void AcpiRsOutInteger32 ( - char *Title, + const char *Title, UINT32 Value) { + AcpiOsPrintf ("%27s : %8.8X\n", Title, Value); } static void AcpiRsOutInteger64 ( - char *Title, + const char *Title, UINT64 Value) { + AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title, ACPI_FORMAT_UINT64 (Value)); } static void AcpiRsOutTitle ( - char *Title) + const char *Title) { + AcpiOsPrintf ("%27s : ", Title); } @@ -618,8 +618,7 @@ AcpiRsDumpByteList ( for (i = 0; i < Length; i++) { - AcpiOsPrintf ("%25s%2.2X : %2.2X\n", - "Byte", i, Data[i]); + AcpiOsPrintf ("%25s%2.2X : %2.2X\n", "Byte", i, Data[i]); } } @@ -635,6 +634,7 @@ AcpiRsDumpShortByteList ( { AcpiOsPrintf ("%X ", Data[i]); } + AcpiOsPrintf ("\n"); } @@ -648,8 +648,7 @@ AcpiRsDumpDwordList ( for (i = 0; i < Length; i++) { - AcpiOsPrintf ("%25s%2.2X : %8.8X\n", - "Dword", i, Data[i]); + AcpiOsPrintf ("%25s%2.2X : %8.8X\n", "Dword", i, Data[i]); } } @@ -663,9 +662,6 @@ AcpiRsDumpWordList ( for (i = 0; i < Length; i++) { - AcpiOsPrintf ("%25s%2.2X : %4.4X\n", - "Word", i, Data[i]); + AcpiOsPrintf ("%25s%2.2X : %4.4X\n", "Word", i, Data[i]); } } - -#endif diff --git a/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c b/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c index dfa1a84..2173fe3 100644 --- a/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c +++ b/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -265,19 +265,20 @@ ACPI_RSDUMP_INFO AcpiRsDumpFixedDma[4] = {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (CommonSerialBus.Type), "Type", AcpiGbl_SbtDecode}, \ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (CommonSerialBus.ProducerConsumer), "ProducerConsumer", AcpiGbl_ConsumeDecode}, \ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (CommonSerialBus.SlaveMode), "SlaveMode", AcpiGbl_SmDecode}, \ + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (CommonSerialBus.ConnectionSharing),"ConnectionSharing", AcpiGbl_ShrDecode}, \ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (CommonSerialBus.TypeRevisionId), "TypeRevisionId", NULL}, \ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (CommonSerialBus.TypeDataLength), "TypeDataLength", NULL}, \ {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (CommonSerialBus.ResourceSource), "ResourceSource", NULL}, \ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (CommonSerialBus.VendorLength), "VendorLength", NULL}, \ {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (CommonSerialBus.VendorData), "VendorData", NULL}, -ACPI_RSDUMP_INFO AcpiRsDumpCommonSerialBus[10] = +ACPI_RSDUMP_INFO AcpiRsDumpCommonSerialBus[11] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpCommonSerialBus), "Common Serial Bus", NULL}, ACPI_RS_DUMP_COMMON_SERIAL_BUS }; -ACPI_RSDUMP_INFO AcpiRsDumpI2cSerialBus[13] = +ACPI_RSDUMP_INFO AcpiRsDumpI2cSerialBus[14] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpI2cSerialBus), "I2C Serial Bus", NULL}, ACPI_RS_DUMP_COMMON_SERIAL_BUS @@ -286,7 +287,7 @@ ACPI_RSDUMP_INFO AcpiRsDumpI2cSerialBus[13] = {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (I2cSerialBus.SlaveAddress), "SlaveAddress", NULL}, }; -ACPI_RSDUMP_INFO AcpiRsDumpSpiSerialBus[17] = +ACPI_RSDUMP_INFO AcpiRsDumpSpiSerialBus[18] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpSpiSerialBus), "Spi Serial Bus", NULL}, ACPI_RS_DUMP_COMMON_SERIAL_BUS @@ -299,7 +300,7 @@ ACPI_RSDUMP_INFO AcpiRsDumpSpiSerialBus[17] = {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (SpiSerialBus.ConnectionSpeed), "ConnectionSpeed", NULL}, }; -ACPI_RSDUMP_INFO AcpiRsDumpUartSerialBus[19] = +ACPI_RSDUMP_INFO AcpiRsDumpUartSerialBus[20] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpUartSerialBus), "Uart Serial Bus", NULL}, ACPI_RS_DUMP_COMMON_SERIAL_BUS diff --git a/sys/contrib/dev/acpica/components/resources/rsinfo.c b/sys/contrib/dev/acpica/components/resources/rsinfo.c index f34b905..6268b73 100644 --- a/sys/contrib/dev/acpica/components/resources/rsinfo.c +++ b/sys/contrib/dev/acpica/components/resources/rsinfo.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsio.c b/sys/contrib/dev/acpica/components/resources/rsio.c index 473fe36..5cf5f34 100644 --- a/sys/contrib/dev/acpica/components/resources/rsio.c +++ b/sys/contrib/dev/acpica/components/resources/rsio.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsirq.c b/sys/contrib/dev/acpica/components/resources/rsirq.c index cf91f3d..fa591ea 100644 --- a/sys/contrib/dev/acpica/components/resources/rsirq.c +++ b/sys/contrib/dev/acpica/components/resources/rsirq.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rslist.c b/sys/contrib/dev/acpica/components/resources/rslist.c index 8261058..216d40b 100644 --- a/sys/contrib/dev/acpica/components/resources/rslist.c +++ b/sys/contrib/dev/acpica/components/resources/rslist.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,9 +97,12 @@ AcpiRsConvertAmlToResources ( /* Get the appropriate conversion info table */ AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml); - if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_SERIAL_BUS) + + if (AcpiUtGetResourceType (Aml) == + ACPI_RESOURCE_NAME_SERIAL_BUS) { - if (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE) + if (AmlResource->CommonSerialBus.Type > + AML_RESOURCE_MAX_SERIALBUSTYPE) { ConversionTable = NULL; } @@ -107,15 +110,13 @@ AcpiRsConvertAmlToResources ( { /* This is an I2C, SPI, or UART SerialBus descriptor */ - ConversionTable = - AcpiGbl_ConvertResourceSerialBusDispatch[ - AmlResource->CommonSerialBus.Type]; + ConversionTable = AcpiGbl_ConvertResourceSerialBusDispatch [ + AmlResource->CommonSerialBus.Type]; } } else { - ConversionTable = - AcpiGbl_GetResourceDispatch[ResourceIndex]; + ConversionTable = AcpiGbl_GetResourceDispatch[ResourceIndex]; } if (!ConversionTable) @@ -210,7 +211,8 @@ AcpiRsConvertResourcesToAml ( if (Resource->Type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { - if (Resource->Data.CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE) + if (Resource->Data.CommonSerialBus.Type > + AML_RESOURCE_MAX_SERIALBUSTYPE) { ConversionTable = NULL; } @@ -236,8 +238,7 @@ AcpiRsConvertResourcesToAml ( } Status = AcpiRsConvertResourceToAml (Resource, - ACPI_CAST_PTR (AML_RESOURCE, Aml), - ConversionTable); + ACPI_CAST_PTR (AML_RESOURCE, Aml), ConversionTable); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, @@ -248,8 +249,8 @@ AcpiRsConvertResourcesToAml ( /* Perform final sanity check on the new AML resource descriptor */ - Status = AcpiUtValidateResource (NULL, - ACPI_CAST_PTR (AML_RESOURCE, Aml), NULL); + Status = AcpiUtValidateResource ( + NULL, ACPI_CAST_PTR (AML_RESOURCE, Aml), NULL); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/resources/rsmemory.c b/sys/contrib/dev/acpica/components/resources/rsmemory.c index 761a000..bb4bae3 100644 --- a/sys/contrib/dev/acpica/components/resources/rsmemory.c +++ b/sys/contrib/dev/acpica/components/resources/rsmemory.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsmisc.c b/sys/contrib/dev/acpica/components/resources/rsmisc.c index bc5b803..57e85dd 100644 --- a/sys/contrib/dev/acpica/components/resources/rsmisc.c +++ b/sys/contrib/dev/acpica/components/resources/rsmisc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -121,7 +121,7 @@ AcpiRsConvertAmlToResource ( * Source is the external AML byte stream buffer, * destination is the internal resource descriptor */ - Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); + Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); switch (Info->Opcode) @@ -130,7 +130,7 @@ AcpiRsConvertAmlToResource ( /* * Get the resource type and the initial (minimum) length */ - ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info)); + memset (Resource, 0, INIT_RESOURCE_LENGTH (Info)); Resource->Type = INIT_RESOURCE_TYPE (Info); Resource->Length = INIT_RESOURCE_LENGTH (Info); break; @@ -200,8 +200,7 @@ AcpiRsConvertAmlToResource ( ItemCount = ACPI_GET8 (Source); ACPI_SET8 (Destination, ItemCount); - Resource->Length = Resource->Length + - (Info->Value * ItemCount); + Resource->Length = Resource->Length + (Info->Value * ItemCount); break; case ACPI_RSC_COUNT_GPIO_RES: @@ -273,7 +272,7 @@ AcpiRsConvertAmlToResource ( /* Generate and set the PIN data pointer */ Target = (char *) ACPI_ADD_PTR (void, Resource, - (Resource->Length - ItemCount * 2)); + (Resource->Length - ItemCount * 2)); *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target); /* Copy the PIN data */ @@ -287,7 +286,7 @@ AcpiRsConvertAmlToResource ( /* Generate and set the ResourceSource string pointer */ Target = (char *) ACPI_ADD_PTR (void, Resource, - (Resource->Length - ItemCount)); + (Resource->Length - ItemCount)); *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); /* Copy the ResourceSource string */ @@ -301,7 +300,7 @@ AcpiRsConvertAmlToResource ( /* Generate and set the Vendor Data pointer */ Target = (char *) ACPI_ADD_PTR (void, Resource, - (Resource->Length - ItemCount)); + (Resource->Length - ItemCount)); *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); /* Copy the Vendor Data */ @@ -315,24 +314,25 @@ AcpiRsConvertAmlToResource ( /* Generate and set the ResourceSource string pointer */ Target = (char *) ACPI_ADD_PTR (void, Resource, - (Resource->Length - ItemCount)); + (Resource->Length - ItemCount)); *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); /* Copy the ResourceSource string */ - Source = ACPI_ADD_PTR (void, Aml, (ACPI_GET16 (Source) + Info->Value)); + Source = ACPI_ADD_PTR ( + void, Aml, (ACPI_GET16 (Source) + Info->Value)); AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); break; case ACPI_RSC_SET8: - ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value); + memset (Destination, Info->AmlOffset, Info->Value); break; case ACPI_RSC_DATA8: Target = ACPI_ADD_PTR (char, Resource, Info->Value); - ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target)); + memcpy (Destination, Source, ACPI_GET16 (Target)); break; case ACPI_RSC_ADDRESS: @@ -442,7 +442,8 @@ Exit: { /* Round the resource struct length up to the next boundary (32 or 64) */ - Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length); + Resource->Length = (UINT32) + ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length); } return_ACPI_STATUS (AE_OK); } @@ -498,16 +499,17 @@ AcpiRsConvertResourceToAml ( * Source is the internal resource descriptor, * destination is the external AML byte stream buffer */ - Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); + Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); switch (Info->Opcode) { case ACPI_RSC_INITSET: - ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info)); + memset (Aml, 0, INIT_RESOURCE_LENGTH (Info)); AmlLength = INIT_RESOURCE_LENGTH (Info); - AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml); + AcpiRsSetResourceHeader ( + INIT_RESOURCE_TYPE (Info), AmlLength, Aml); break; case ACPI_RSC_INITGET: @@ -549,7 +551,8 @@ AcpiRsConvertResourceToAml ( ItemCount = ACPI_GET8 (Source); ACPI_SET8 (Destination, ItemCount); - AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1))); + AmlLength = (UINT16) + (AmlLength + (Info->Value * (ItemCount - 1))); break; case ACPI_RSC_COUNT16: @@ -575,7 +578,8 @@ AcpiRsConvertResourceToAml ( ItemCount = ACPI_GET16 (Source); ACPI_SET16 (Destination, ItemCount); - AmlLength = (UINT16) (AmlLength + (Info->Value * ItemCount)); + AmlLength = (UINT16) ( + AmlLength + (Info->Value * ItemCount)); AcpiRsSetResourceLength (AmlLength, Aml); break; @@ -636,7 +640,7 @@ AcpiRsConvertResourceToAml ( case ACPI_RSC_MOVE_GPIO_PIN: Destination = (char *) ACPI_ADD_PTR (void, Aml, - ACPI_GET16 (Destination)); + ACPI_GET16 (Destination)); Source = * (UINT16 **) Source; AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); break; @@ -646,7 +650,7 @@ AcpiRsConvertResourceToAml ( /* Used for both ResourceSource string and VendorData */ Destination = (char *) ACPI_ADD_PTR (void, Aml, - ACPI_GET16 (Destination)); + ACPI_GET16 (Destination)); Source = * (UINT8 **) Source; AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); break; @@ -654,7 +658,7 @@ AcpiRsConvertResourceToAml ( case ACPI_RSC_MOVE_SERIAL_VEN: Destination = (char *) ACPI_ADD_PTR (void, Aml, - (AmlLength - ItemCount)); + (AmlLength - ItemCount)); Source = * (UINT8 **) Source; AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); break; @@ -662,7 +666,7 @@ AcpiRsConvertResourceToAml ( case ACPI_RSC_MOVE_SERIAL_RES: Destination = (char *) ACPI_ADD_PTR (void, Aml, - (AmlLength - ItemCount)); + (AmlLength - ItemCount)); Source = * (UINT8 **) Source; AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); break; @@ -679,7 +683,7 @@ AcpiRsConvertResourceToAml ( * Optional ResourceSource (Index and String) */ AmlLength = AcpiRsSetResourceSource ( - Aml, (ACPI_RS_LENGTH) AmlLength, Source); + Aml, (ACPI_RS_LENGTH) AmlLength, Source); AcpiRsSetResourceLength (AmlLength, Aml); break; @@ -705,8 +709,8 @@ AcpiRsConvertResourceToAml ( /* * 16-bit encoded bitmask (IRQ macro) */ - Temp16 = AcpiRsEncodeBitmask (Source, - *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); + Temp16 = AcpiRsEncodeBitmask ( + Source, *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); ACPI_MOVE_16_TO_16 (Destination, &Temp16); break; @@ -729,7 +733,7 @@ AcpiRsConvertResourceToAml ( case ACPI_RSC_COMPARE_VALUE: if (*ACPI_ADD_PTR (UINT8, Resource, - COMPARE_TARGET (Info)) != COMPARE_VALUE (Info)) + COMPARE_TARGET (Info)) != COMPARE_VALUE (Info)) { goto Exit; } @@ -747,7 +751,7 @@ AcpiRsConvertResourceToAml ( * Control - Exit conversion if equal */ if (*ACPI_ADD_PTR (UINT8, Resource, - COMPARE_TARGET (Info)) == COMPARE_VALUE (Info)) + COMPARE_TARGET (Info)) == COMPARE_VALUE (Info)) { goto Exit; } @@ -771,7 +775,8 @@ Exit: #if 0 /* Previous resource validations */ - if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) + if (Aml->ExtAddress64.RevisionID != + AML_RESOURCE_EXTENDED_ADDRESS_REVISION) { return_ACPI_STATUS (AE_SUPPORT); } diff --git a/sys/contrib/dev/acpica/components/resources/rsserial.c b/sys/contrib/dev/acpica/components/resources/rsserial.c index 00e1887..27b3c9e 100644 --- a/sys/contrib/dev/acpica/components/resources/rsserial.c +++ b/sys/contrib/dev/acpica/components/resources/rsserial.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -153,7 +153,7 @@ ACPI_RSCONVERT_INFO AcpiRsConvertGpio[18] = * ******************************************************************************/ -ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[16] = +ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[17] = { {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS), @@ -179,6 +179,10 @@ ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[16] = AML_OFFSET (CommonSerialBus.Flags), 1}, + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing), + AML_OFFSET (CommonSerialBus.Flags), + 2}, + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), AML_OFFSET (CommonSerialBus.TypeRevisionId), 1}, @@ -233,7 +237,7 @@ ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[16] = * ******************************************************************************/ -ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[20] = +ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[21] = { {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS), @@ -259,6 +263,10 @@ ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[20] = AML_OFFSET (CommonSerialBus.Flags), 1}, + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing), + AML_OFFSET (CommonSerialBus.Flags), + 2}, + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), AML_OFFSET (CommonSerialBus.TypeRevisionId), 1}, @@ -329,7 +337,7 @@ ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[20] = * ******************************************************************************/ -ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[22] = +ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[23] = { {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS), @@ -355,6 +363,10 @@ ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[22] = AML_OFFSET (CommonSerialBus.Flags), 1}, + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ConnectionSharing), + AML_OFFSET (CommonSerialBus.Flags), + 2}, + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), AML_OFFSET (CommonSerialBus.TypeRevisionId), 1}, diff --git a/sys/contrib/dev/acpica/components/resources/rsutils.c b/sys/contrib/dev/acpica/components/resources/rsutils.c index c0e7b78..a3a7ed3 100644 --- a/sys/contrib/dev/acpica/components/resources/rsutils.c +++ b/sys/contrib/dev/acpica/components/resources/rsutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -174,7 +174,7 @@ AcpiRsMoveData ( case ACPI_RSC_MOVE_SERIAL_VEN: case ACPI_RSC_MOVE_SERIAL_RES: - ACPI_MEMCPY (Destination, Source, ItemCount); + memcpy (Destination, Source, ItemCount); return; /* @@ -185,20 +185,23 @@ AcpiRsMoveData ( case ACPI_RSC_MOVE16: case ACPI_RSC_MOVE_GPIO_PIN: - ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], - &ACPI_CAST_PTR (UINT16, Source)[i]); + ACPI_MOVE_16_TO_16 ( + &ACPI_CAST_PTR (UINT16, Destination)[i], + &ACPI_CAST_PTR (UINT16, Source)[i]); break; case ACPI_RSC_MOVE32: - ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], - &ACPI_CAST_PTR (UINT32, Source)[i]); + ACPI_MOVE_32_TO_32 ( + &ACPI_CAST_PTR (UINT32, Destination)[i], + &ACPI_CAST_PTR (UINT32, Source)[i]); break; case ACPI_RSC_MOVE64: - ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], - &ACPI_CAST_PTR (UINT64, Source)[i]); + ACPI_MOVE_64_TO_64 ( + &ACPI_CAST_PTR (UINT64, Destination)[i], + &ACPI_CAST_PTR (UINT64, Source)[i]); break; default: @@ -248,18 +251,18 @@ AcpiRsSetResourceLength ( { /* Large descriptor -- bytes 1-2 contain the 16-bit length */ - ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); + ACPI_MOVE_16_TO_16 ( + &Aml->LargeHeader.ResourceLength, &ResourceLength); } else { - /* Small descriptor -- bits 2:0 of byte 0 contain the length */ - + /* + * Small descriptor -- bits 2:0 of byte 0 contain the length + * Clear any existing length, preserving descriptor type bits + */ Aml->SmallHeader.DescriptorType = (UINT8) - - /* Clear any existing length, preserving descriptor type bits */ - - ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) - + ((Aml->SmallHeader.DescriptorType & + ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) | ResourceLength); } } @@ -378,8 +381,8 @@ AcpiRsGetResourceSource ( AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); /* - * ResourceSource is present if the length of the descriptor is longer than - * the minimum length. + * ResourceSource is present if the length of the descriptor is longer + * than the minimum length. * * Note: Some resource descriptors will have an additional null, so * we add 1 to the minimum length. @@ -397,8 +400,8 @@ AcpiRsGetResourceSource ( * String destination pointer is not specified; Set the String * pointer to the end of the current ResourceSource structure. */ - ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource, - sizeof (ACPI_RESOURCE_SOURCE)); + ResourceSource->StringPtr = ACPI_ADD_PTR ( + char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE)); } /* @@ -408,15 +411,17 @@ AcpiRsGetResourceSource ( * * Zero the entire area of the buffer. */ - TotalLength = (UINT32) ACPI_STRLEN ( + TotalLength = (UINT32) strlen ( ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; + TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); - ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); + memset (ResourceSource->StringPtr, 0, TotalLength); /* Copy the ResourceSource string to the destination */ - ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, + ResourceSource->StringLength = AcpiRsStrcpy ( + ResourceSource->StringPtr, ACPI_CAST_PTR (char, &AmlResourceSource[1])); return ((ACPI_RS_LENGTH) TotalLength); @@ -477,14 +482,15 @@ AcpiRsSetResourceSource ( /* Copy the ResourceSource string */ - ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), + strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]), ResourceSource->StringPtr); /* * Add the length of the string (+ 1 for null terminator) to the * final descriptor length */ - DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); + DescriptorLength += ((ACPI_RSDESC_SIZE) + ResourceSource->StringLength + 1); } /* Return the new total length of the AML descriptor */ @@ -527,8 +533,8 @@ AcpiRsGetPrtMethodData ( /* Execute the method, no parameters */ - Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, - ACPI_BTYPE_PACKAGE, &ObjDesc); + Status = AcpiUtEvaluateObject ( + Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -581,8 +587,8 @@ AcpiRsGetCrsMethodData ( /* Execute the method, no parameters */ - Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, - ACPI_BTYPE_BUFFER, &ObjDesc); + Status = AcpiUtEvaluateObject ( + Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -636,8 +642,8 @@ AcpiRsGetPrsMethodData ( /* Execute the method, no parameters */ - Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, - ACPI_BTYPE_BUFFER, &ObjDesc); + Status = AcpiUtEvaluateObject ( + Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -691,8 +697,8 @@ AcpiRsGetAeiMethodData ( /* Execute the method, no parameters */ - Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI, - ACPI_BTYPE_BUFFER, &ObjDesc); + Status = AcpiUtEvaluateObject ( + Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -734,7 +740,7 @@ AcpiRsGetAeiMethodData ( ACPI_STATUS AcpiRsGetMethodData ( ACPI_HANDLE Handle, - char *Path, + const char *Path, ACPI_BUFFER *RetBuffer) { ACPI_OPERAND_OBJECT *ObjDesc; @@ -748,7 +754,8 @@ AcpiRsGetMethodData ( /* Execute the method, no parameters */ - Status = AcpiUtEvaluateObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle), + Status = AcpiUtEvaluateObject ( + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle), Path, ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { diff --git a/sys/contrib/dev/acpica/components/resources/rsxface.c b/sys/contrib/dev/acpica/components/resources/rsxface.c index a477f20..c362a1a 100644 --- a/sys/contrib/dev/acpica/components/resources/rsxface.c +++ b/sys/contrib/dev/acpica/components/resources/rsxface.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ /* Local macros for 16,32-bit to 64-bit conversion */ #define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) -#define ACPI_COPY_ADDRESS(Out, In) \ +#define ACPI_COPY_ADDRESS(Out, In) \ ACPI_COPY_FIELD(Out, In, ResourceType); \ ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ ACPI_COPY_FIELD(Out, In, Decode); \ @@ -433,13 +433,15 @@ AcpiResourceToAddress64 ( { case ACPI_RESOURCE_TYPE_ADDRESS16: - Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data); + Address16 = ACPI_CAST_PTR ( + ACPI_RESOURCE_ADDRESS16, &Resource->Data); ACPI_COPY_ADDRESS (Out, Address16); break; case ACPI_RESOURCE_TYPE_ADDRESS32: - Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data); + Address32 = ACPI_CAST_PTR ( + ACPI_RESOURCE_ADDRESS32, &Resource->Data); ACPI_COPY_ADDRESS (Out, Address32); break; @@ -447,7 +449,7 @@ AcpiResourceToAddress64 ( /* Simple copy for 64 bit source */ - ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64)); + memcpy (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64)); break; default: @@ -504,8 +506,8 @@ AcpiGetVendorResource ( /* Walk the _CRS or _PRS resource list for this device */ - Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource, - &Info); + Status = AcpiWalkResources ( + DeviceHandle, Name, AcpiRsMatchVendorResource, &Info); if (ACPI_FAILURE (Status)) { return (Status); @@ -558,7 +560,7 @@ AcpiRsMatchVendorResource ( */ if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) || (Vendor->UuidSubtype != Info->Uuid->Subtype) || - (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH))) + (memcmp (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH))) { return (AE_OK); } @@ -574,7 +576,7 @@ AcpiRsMatchVendorResource ( /* Found the correct resource, copy and return it */ - ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length); + memcpy (Buffer->Pointer, Resource, Resource->Length); Buffer->Length = Resource->Length; /* Found the desired descriptor, terminate resource walk */ @@ -624,7 +626,8 @@ AcpiWalkResourceBuffer ( /* Buffer contains the resource list and length */ Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer->Pointer); - ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer->Pointer, Buffer->Length); + ResourceEnd = ACPI_ADD_PTR ( + ACPI_RESOURCE, Buffer->Pointer, Buffer->Length); /* Walk the resource list until the EndTag is found (or buffer end) */ diff --git a/sys/contrib/dev/acpica/components/tables/tbdata.c b/sys/contrib/dev/acpica/components/tables/tbdata.c index 70bac2c..fc3c58c 100644 --- a/sys/contrib/dev/acpica/components/tables/tbdata.c +++ b/sys/contrib/dev/acpica/components/tables/tbdata.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -77,7 +77,7 @@ AcpiTbInitTableDescriptor ( * Initialize the table descriptor. Set the pointer to NULL, since the * table is not fully mapped at this time. */ - ACPI_MEMSET (TableDesc, 0, sizeof (ACPI_TABLE_DESC)); + memset (TableDesc, 0, sizeof (ACPI_TABLE_DESC)); TableDesc->Address = Address; TableDesc->Length = Table->Length; TableDesc->Flags = Flags; @@ -122,7 +122,7 @@ AcpiTbAcquireTable ( case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, - ACPI_PHYSADDR_TO_PTR (TableDesc->Address)); + ACPI_PHYSADDR_TO_PTR (TableDesc->Address)); break; default: @@ -229,7 +229,7 @@ AcpiTbAcquireTempTable ( case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, - ACPI_PHYSADDR_TO_PTR (Address)); + ACPI_PHYSADDR_TO_PTR (Address)); if (!TableHeader) { return (AE_NO_MEMORY); @@ -303,7 +303,7 @@ AcpiTbValidateTable ( if (!TableDesc->Pointer) { Status = AcpiTbAcquireTable (TableDesc, &TableDesc->Pointer, - &TableDesc->Length, &TableDesc->Flags); + &TableDesc->Length, &TableDesc->Flags); if (!TableDesc->Pointer) { Status = AE_NO_MEMORY; @@ -441,9 +441,10 @@ AcpiTbVerifyTempTable ( ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, "%4.4s 0x%8.8X%8.8X" " Attempted table install failed", - AcpiUtValidAcpiName (TableDesc->Signature.Ascii) ? + AcpiUtValidNameseg (TableDesc->Signature.Ascii) ? TableDesc->Signature.Ascii : "????", ACPI_FORMAT_UINT64 (TableDesc->Address))); + goto InvalidateAndExit; } } @@ -511,7 +512,7 @@ AcpiTbResizeRootTableList ( if (AcpiGbl_RootTableList.Tables) { - ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, + memcpy (Tables, AcpiGbl_RootTableList.Tables, (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC)); if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) @@ -721,7 +722,7 @@ AcpiTbAllocateOwnerId ( if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { Status = AcpiUtAllocateOwnerId ( - &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); } (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); diff --git a/sys/contrib/dev/acpica/components/tables/tbfadt.c b/sys/contrib/dev/acpica/components/tables/tbfadt.c index f35e217..0dfa7d6 100644 --- a/sys/contrib/dev/acpica/components/tables/tbfadt.c +++ b/sys/contrib/dev/acpica/components/tables/tbfadt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,7 +56,7 @@ AcpiTbInitGenericAddress ( UINT8 SpaceId, UINT8 ByteWidth, UINT64 Address, - char *RegisterName, + const char *RegisterName, UINT8 Flags); static void @@ -78,7 +78,7 @@ AcpiTbSelectAddress ( typedef struct acpi_fadt_info { - char *Name; + const char *Name; UINT16 Address64; UINT16 Address32; UINT16 Length; @@ -212,7 +212,7 @@ AcpiTbInitGenericAddress ( UINT8 SpaceId, UINT8 ByteWidth, UINT64 Address, - char *RegisterName, + const char *RegisterName, UINT8 Flags) { UINT8 BitWidth; @@ -326,7 +326,7 @@ AcpiTbSelectAddress ( * * FUNCTION: AcpiTbParseFadt * - * PARAMETERS: TableIndex - Index for the FADT + * PARAMETERS: None * * RETURN: None * @@ -337,7 +337,7 @@ AcpiTbSelectAddress ( void AcpiTbParseFadt ( - UINT32 TableIndex) + void) { UINT32 Length; ACPI_TABLE_HEADER *Table; @@ -350,10 +350,10 @@ AcpiTbParseFadt ( * Get a local copy of the FADT and convert it to a common format * Map entire FADT, assumed to be smaller than one page. */ - Length = AcpiGbl_RootTableList.Tables[TableIndex].Length; + Length = AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex].Length; Table = AcpiOsMapMemory ( - AcpiGbl_RootTableList.Tables[TableIndex].Address, Length); + AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex].Address, Length); if (!Table) { return; @@ -376,14 +376,22 @@ AcpiTbParseFadt ( /* Obtain the DSDT and FACS tables via their addresses within the FADT */ AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, - ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); + ACPI_SIG_DSDT, &AcpiGbl_DsdtIndex); /* If Hardware Reduced flag is set, there is no FACS */ if (!AcpiGbl_ReducedHardware) { - AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, - ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); + if (AcpiGbl_FADT.Facs) + { + AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.Facs, + ACPI_SIG_FACS, &AcpiGbl_FacsIndex); + } + if (AcpiGbl_FADT.XFacs) + { + AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, + ACPI_SIG_FACS, &AcpiGbl_XFacsIndex); + } } } @@ -412,24 +420,25 @@ AcpiTbCreateLocalFadt ( /* * Check if the FADT is larger than the largest table that we expect - * (the ACPI 5.0 version). If so, truncate the table, and issue - * a warning. + * (typically the current ACPI specification version). If so, truncate + * the table, and issue a warning. */ if (Length > sizeof (ACPI_TABLE_FADT)) { ACPI_BIOS_WARNING ((AE_INFO, - "FADT (revision %u) is longer than ACPI 5.0 version, " + "FADT (revision %u) is longer than %s length, " "truncating length %u to %u", - Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT))); + Table->Revision, ACPI_FADT_CONFORMANCE, Length, + (UINT32) sizeof (ACPI_TABLE_FADT))); } /* Clear the entire local FADT */ - ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT)); + memset (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT)); /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */ - ACPI_MEMCPY (&AcpiGbl_FADT, Table, + memcpy (&AcpiGbl_FADT, Table, ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT))); /* Take a copy of the Hardware Reduced flag */ @@ -498,7 +507,7 @@ static void AcpiTbConvertFadt ( void) { - char *Name; + const char *Name; ACPI_GENERIC_ADDRESS *Address64; UINT32 Address32; UINT8 Length; @@ -533,12 +542,9 @@ AcpiTbConvertFadt ( AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT); /* - * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. + * Expand the 32-bit DSDT addresses to 64-bit as necessary. * Later ACPICA code will always use the X 64-bit field. */ - AcpiGbl_FADT.XFacs = AcpiTbSelectAddress ("FACS", - AcpiGbl_FADT.Facs, AcpiGbl_FADT.XFacs); - AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT", AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt); @@ -671,9 +677,11 @@ AcpiTbConvertFadt ( (!Address64->Address && Length)) { ACPI_BIOS_WARNING ((AE_INFO, - "Optional FADT field %s has zero address or length: " - "0x%8.8X%8.8X/0x%X", - Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + "Optional FADT field %s has valid %s but zero %s: " + "0x%8.8X%8.8X/0x%X", Name, + (Length ? "Length" : "Address"), + (Length ? "Address": "Length"), + ACPI_FORMAT_UINT64 (Address64->Address), Length)); } } } diff --git a/sys/contrib/dev/acpica/components/tables/tbfind.c b/sys/contrib/dev/acpica/components/tables/tbfind.c index 30a5750..33d6a40 100644 --- a/sys/contrib/dev/acpica/components/tables/tbfind.c +++ b/sys/contrib/dev/acpica/components/tables/tbfind.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,27 +73,42 @@ AcpiTbFindTable ( char *OemTableId, UINT32 *TableIndex) { - UINT32 i; ACPI_STATUS Status; ACPI_TABLE_HEADER Header; + UINT32 i; ACPI_FUNCTION_TRACE (TbFindTable); + /* Validate the input table signature */ + + if (!AcpiUtValidNameseg (Signature)) + { + return_ACPI_STATUS (AE_BAD_SIGNATURE); + } + + /* Don't allow the OEM strings to be too long */ + + if ((strlen (OemId) > ACPI_OEM_ID_SIZE) || + (strlen (OemTableId) > ACPI_OEM_TABLE_ID_SIZE)) + { + return_ACPI_STATUS (AE_AML_STRING_LIMIT); + } + /* Normalize the input strings */ - ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER)); + memset (&Header, 0, sizeof (ACPI_TABLE_HEADER)); ACPI_MOVE_NAME (Header.Signature, Signature); - ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE); - ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE); + strncpy (Header.OemId, OemId, ACPI_OEM_ID_SIZE); + strncpy (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE); /* Search for the table */ for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { - if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature), - Header.Signature, ACPI_NAME_SIZE)) + if (memcmp (&(AcpiGbl_RootTableList.Tables[i].Signature), + Header.Signature, ACPI_NAME_SIZE)) { /* Not the requested table */ @@ -120,14 +135,14 @@ AcpiTbFindTable ( /* Check for table match on all IDs */ - if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature, - Header.Signature, ACPI_NAME_SIZE) && + if (!memcmp (AcpiGbl_RootTableList.Tables[i].Pointer->Signature, + Header.Signature, ACPI_NAME_SIZE) && (!OemId[0] || - !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId, - Header.OemId, ACPI_OEM_ID_SIZE)) && + !memcmp (AcpiGbl_RootTableList.Tables[i].Pointer->OemId, + Header.OemId, ACPI_OEM_ID_SIZE)) && (!OemTableId[0] || - !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId, - Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE))) + !memcmp (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId, + Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE))) { *TableIndex = i; diff --git a/sys/contrib/dev/acpica/components/tables/tbinstal.c b/sys/contrib/dev/acpica/components/tables/tbinstal.c index d77d2c8..bc105a6 100644 --- a/sys/contrib/dev/acpica/components/tables/tbinstal.c +++ b/sys/contrib/dev/acpica/components/tables/tbinstal.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -83,7 +83,7 @@ AcpiTbCompareTables ( Status = AcpiTbAcquireTable (&AcpiGbl_RootTableList.Tables[TableIndex], - &Table, &TableLength, &TableFlags); + &Table, &TableLength, &TableFlags); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -94,7 +94,7 @@ AcpiTbCompareTables ( * not just the header. */ IsIdentical = (BOOLEAN)((TableDesc->Length != TableLength || - ACPI_MEMCMP (TableDesc->Pointer, Table, TableLength)) ? + memcmp (TableDesc->Pointer, Table, TableLength)) ? FALSE : TRUE); /* Release the acquired table */ @@ -108,9 +108,9 @@ AcpiTbCompareTables ( * * FUNCTION: AcpiTbInstallTableWithOverride * - * PARAMETERS: TableIndex - Index into root table array - * NewTableDesc - New table descriptor to install + * PARAMETERS: NewTableDesc - New table descriptor to install * Override - Whether override should be performed + * TableIndex - Where the table index is returned * * RETURN: None * @@ -123,12 +123,16 @@ AcpiTbCompareTables ( void AcpiTbInstallTableWithOverride ( - UINT32 TableIndex, ACPI_TABLE_DESC *NewTableDesc, - BOOLEAN Override) + BOOLEAN Override, + UINT32 *TableIndex) { + UINT32 i; + ACPI_STATUS Status; + - if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) + Status = AcpiTbGetNextTableDescriptor (&i, NULL); + if (ACPI_FAILURE (Status)) { return; } @@ -145,14 +149,18 @@ AcpiTbInstallTableWithOverride ( AcpiTbOverrideTable (NewTableDesc); } - AcpiTbInitTableDescriptor (&AcpiGbl_RootTableList.Tables[TableIndex], + AcpiTbInitTableDescriptor (&AcpiGbl_RootTableList.Tables[i], NewTableDesc->Address, NewTableDesc->Flags, NewTableDesc->Pointer); AcpiTbPrintTableHeader (NewTableDesc->Address, NewTableDesc->Pointer); + /* This synchronizes AcpiGbl_DsdtIndex */ + + *TableIndex = i; + /* Set the global integer width (based upon revision of the DSDT) */ - if (TableIndex == ACPI_TABLE_INDEX_DSDT) + if (i == AcpiGbl_DsdtIndex) { AcpiUtSetIntegerWidth (NewTableDesc->Pointer->Revision); } @@ -166,7 +174,7 @@ AcpiTbInstallTableWithOverride ( * PARAMETERS: Address - Physical address of DSDT or FACS * Signature - Table signature, NULL if no need to * match - * TableIndex - Index into root table array + * TableIndex - Where the table index is returned * * RETURN: Status * @@ -179,7 +187,7 @@ ACPI_STATUS AcpiTbInstallFixedTable ( ACPI_PHYSICAL_ADDRESS Address, char *Signature, - UINT32 TableIndex) + UINT32 *TableIndex) { ACPI_TABLE_DESC NewTableDesc; ACPI_STATUS Status; @@ -198,7 +206,7 @@ AcpiTbInstallFixedTable ( /* Fill a table descriptor for validation */ Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, - ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, "Could not acquire table length at %8.8X%8.8X", @@ -214,7 +222,9 @@ AcpiTbInstallFixedTable ( goto ReleaseAndExit; } - AcpiTbInstallTableWithOverride (TableIndex, &NewTableDesc, TRUE); + /* Add the table to the global root table list */ + + AcpiTbInstallTableWithOverride (&NewTableDesc, TRUE, TableIndex); ReleaseAndExit: @@ -268,7 +278,8 @@ AcpiTbInstallStandardTable ( Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, Flags); if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, "Could not acquire table length at %8.8X%8.8X", + ACPI_ERROR ((AE_INFO, + "Could not acquire table length at %8.8X%8.8X", ACPI_FORMAT_UINT64 (Address))); return_ACPI_STATUS (Status); } @@ -281,7 +292,8 @@ AcpiTbInstallStandardTable ( AcpiGbl_DisableSsdtTableInstall && ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) { - ACPI_INFO ((AE_INFO, "Ignoring installation of %4.4s at %8.8X%8.8X", + ACPI_INFO (( + "Ignoring installation of %4.4s at %8.8X%8.8X", NewTableDesc.Signature.Ascii, ACPI_FORMAT_UINT64 (Address))); goto ReleaseAndExit; } @@ -309,12 +321,12 @@ AcpiTbInstallStandardTable ( */ if ((NewTableDesc.Signature.Ascii[0] != 0x00) && (!ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) && - (ACPI_STRNCMP (NewTableDesc.Signature.Ascii, "OEM", 3))) + (strncmp (NewTableDesc.Signature.Ascii, "OEM", 3))) { ACPI_BIOS_ERROR ((AE_INFO, "Table has invalid signature [%4.4s] (0x%8.8X), " "must be SSDT or OEMx", - AcpiUtValidAcpiName (NewTableDesc.Signature.Ascii) ? + AcpiUtValidNameseg (NewTableDesc.Signature.Ascii) ? NewTableDesc.Signature.Ascii : "????", NewTableDesc.Signature.Integer)); @@ -349,7 +361,8 @@ AcpiTbInstallStandardTable ( * need to be unregistered when they are unloaded, and slots in the * root table list should be reused when empty. */ - if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) + if (AcpiGbl_RootTableList.Tables[i].Flags & + ACPI_TABLE_IS_LOADED) { /* Table is still loaded, this is an error */ @@ -375,14 +388,7 @@ AcpiTbInstallStandardTable ( /* Add the table to the global root table list */ - Status = AcpiTbGetNextTableDescriptor (&i, NULL); - if (ACPI_FAILURE (Status)) - { - goto ReleaseAndExit; - } - - *TableIndex = i; - AcpiTbInstallTableWithOverride (i, &NewTableDesc, Override); + AcpiTbInstallTableWithOverride (&NewTableDesc, Override, TableIndex); ReleaseAndExit: @@ -458,7 +464,7 @@ FinishOverride: return; } - ACPI_INFO ((AE_INFO, "%4.4s 0x%8.8X%8.8X" + ACPI_INFO (("%4.4s 0x%8.8X%8.8X" " %s table override, new table: 0x%8.8X%8.8X", OldTableDesc->Signature.Ascii, ACPI_FORMAT_UINT64 (OldTableDesc->Address), diff --git a/sys/contrib/dev/acpica/components/tables/tbprint.c b/sys/contrib/dev/acpica/components/tables/tbprint.c index f0ea090..cbdd562 100644 --- a/sys/contrib/dev/acpica/components/tables/tbprint.c +++ b/sys/contrib/dev/acpica/components/tables/tbprint.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,10 +84,11 @@ AcpiTbFixString ( while (Length && *String) { - if (!ACPI_IS_PRINT (*String)) + if (!isprint ((int) *String)) { *String = '?'; } + String++; Length--; } @@ -114,7 +115,7 @@ AcpiTbCleanupTableHeader ( ACPI_TABLE_HEADER *Header) { - ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER)); + memcpy (OutHeader, Header, sizeof (ACPI_TABLE_HEADER)); AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE); AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE); @@ -148,7 +149,7 @@ AcpiTbPrintTableHeader ( { /* FACS only has signature and length fields */ - ACPI_INFO ((AE_INFO, "%-4.4s 0x%8.8X%8.8X %06X", + ACPI_INFO (("%-4.4s 0x%8.8X%8.8X %06X", Header->Signature, ACPI_FORMAT_UINT64 (Address), Header->Length)); } @@ -156,11 +157,11 @@ AcpiTbPrintTableHeader ( { /* RSDP has no common fields */ - ACPI_MEMCPY (LocalHeader.OemId, - ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE); + memcpy (LocalHeader.OemId, ACPI_CAST_PTR (ACPI_TABLE_RSDP, + Header)->OemId, ACPI_OEM_ID_SIZE); AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE); - ACPI_INFO ((AE_INFO, "RSDP 0x%8.8X%8.8X %06X (v%.2d %-6.6s)", + ACPI_INFO (("RSDP 0x%8.8X%8.8X %06X (v%.2d %-6.6s)", ACPI_FORMAT_UINT64 (Address), (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ? ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20, @@ -173,7 +174,7 @@ AcpiTbPrintTableHeader ( AcpiTbCleanupTableHeader (&LocalHeader, Header); - ACPI_INFO ((AE_INFO, + ACPI_INFO (( "%-4.4s 0x%8.8X%8.8X" " %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)", LocalHeader.Signature, ACPI_FORMAT_UINT64 (Address), diff --git a/sys/contrib/dev/acpica/components/tables/tbutils.c b/sys/contrib/dev/acpica/components/tables/tbutils.c index 8b80025..e99f1b9 100644 --- a/sys/contrib/dev/acpica/components/tables/tbutils.c +++ b/sys/contrib/dev/acpica/components/tables/tbutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,7 +75,7 @@ ACPI_STATUS AcpiTbInitializeFacs ( void) { - ACPI_STATUS Status; + ACPI_TABLE_FACS *Facs; /* If Hardware Reduced flag is set, there is no FACS */ @@ -85,39 +85,25 @@ AcpiTbInitializeFacs ( AcpiGbl_FACS = NULL; return (AE_OK); } - - Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, - ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_FACS)); - return (Status); -} -#endif /* !ACPI_REDUCED_HARDWARE */ - - -/******************************************************************************* - * - * FUNCTION: AcpiTbTablesLoaded - * - * PARAMETERS: None - * - * RETURN: TRUE if required ACPI tables are loaded - * - * DESCRIPTION: Determine if the minimum required ACPI tables are present - * (FADT, FACS, DSDT) - * - ******************************************************************************/ - -BOOLEAN -AcpiTbTablesLoaded ( - void) -{ - - if (AcpiGbl_RootTableList.CurrentTableCount >= 3) + else if (AcpiGbl_FADT.XFacs && + (!AcpiGbl_FADT.Facs || !AcpiGbl_Use32BitFacsAddresses)) { - return (TRUE); + (void) AcpiGetTableByIndex (AcpiGbl_XFacsIndex, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs)); + AcpiGbl_FACS = Facs; } + else if (AcpiGbl_FADT.Facs) + { + (void) AcpiGetTableByIndex (AcpiGbl_FacsIndex, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs)); + AcpiGbl_FACS = Facs; + } + + /* If there is no FACS, just continue. There was already an error msg */ - return (FALSE); + return (AE_OK); } +#endif /* !ACPI_REDUCED_HARDWARE */ /******************************************************************************* @@ -147,6 +133,7 @@ AcpiTbCheckDsdtHeader ( ACPI_BIOS_ERROR ((AE_INFO, "The DSDT has been corrupted or replaced - " "old, new headers below")); + AcpiTbPrintTableHeader (0, &AcpiGbl_OriginalDsdtHeader); AcpiTbPrintTableHeader (0, AcpiGbl_DSDT); @@ -190,15 +177,15 @@ AcpiTbCopyDsdt ( return (NULL); } - ACPI_MEMCPY (NewTable, TableDesc->Pointer, TableDesc->Length); + memcpy (NewTable, TableDesc->Pointer, TableDesc->Length); AcpiTbUninstallTable (TableDesc); AcpiTbInitTableDescriptor ( - &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT], - ACPI_PTR_TO_PHYSADDR (NewTable), ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, - NewTable); + &AcpiGbl_RootTableList.Tables[AcpiGbl_DsdtIndex], + ACPI_PTR_TO_PHYSADDR (NewTable), + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, NewTable); - ACPI_INFO ((AE_INFO, + ACPI_INFO (( "Forced DSDT copy: length 0x%05X copied locally, original unmapped", NewTable->Length)); @@ -241,7 +228,8 @@ AcpiTbGetRootTableEntry ( * 32-bit platform, RSDT: Return 32-bit table entry * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return */ - return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (UINT32, TableEntry))); + return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR ( + UINT32, TableEntry))); } else { @@ -388,13 +376,6 @@ AcpiTbParseRootTable ( TableEntrySize); TableEntry = ACPI_ADD_PTR (UINT8, Table, sizeof (ACPI_TABLE_HEADER)); - /* - * First two entries in the table array are reserved for the DSDT - * and FACS, which are not actually present in the RSDT/XSDT - they - * come from the FADT - */ - AcpiGbl_RootTableList.CurrentTableCount = 2; - /* Initialize the root table array from the RSDT/XSDT */ for (i = 0; i < TableCount; i++) @@ -414,10 +395,12 @@ AcpiTbParseRootTable ( ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE, &TableIndex); if (ACPI_SUCCESS (Status) && - ACPI_COMPARE_NAME (&AcpiGbl_RootTableList.Tables[TableIndex].Signature, + ACPI_COMPARE_NAME ( + &AcpiGbl_RootTableList.Tables[TableIndex].Signature, ACPI_SIG_FADT)) { - AcpiTbParseFadt (TableIndex); + AcpiGbl_FadtIndex = TableIndex; + AcpiTbParseFadt (); } NextTable: @@ -426,6 +409,5 @@ NextTable: } AcpiOsUnmapMemory (Table, Length); - return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/tables/tbxface.c b/sys/contrib/dev/acpica/components/tables/tbxface.c index 7336b18..d61b406 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxface.c +++ b/sys/contrib/dev/acpica/components/tables/tbxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -132,7 +132,7 @@ AcpiInitializeTables ( { /* Root Table Array has been statically allocated by the host */ - ACPI_MEMSET (InitialTableArray, 0, + memset (InitialTableArray, 0, (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); AcpiGbl_RootTableList.Tables = InitialTableArray; @@ -246,8 +246,8 @@ AcpiGetTableHeader ( for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { - if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), - Signature)) + if (!ACPI_COMPARE_NAME ( + &(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) { continue; } @@ -264,15 +264,14 @@ AcpiGetTableHeader ( ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) { Header = AcpiOsMapMemory ( - AcpiGbl_RootTableList.Tables[i].Address, - sizeof (ACPI_TABLE_HEADER)); + AcpiGbl_RootTableList.Tables[i].Address, + sizeof (ACPI_TABLE_HEADER)); if (!Header) { return (AE_NO_MEMORY); } - ACPI_MEMCPY (OutTableHeader, Header, - sizeof (ACPI_TABLE_HEADER)); + memcpy (OutTableHeader, Header, sizeof (ACPI_TABLE_HEADER)); AcpiOsUnmapMemory (Header, sizeof (ACPI_TABLE_HEADER)); } else @@ -282,7 +281,7 @@ AcpiGetTableHeader ( } else { - ACPI_MEMCPY (OutTableHeader, + memcpy (OutTableHeader, AcpiGbl_RootTableList.Tables[i].Pointer, sizeof (ACPI_TABLE_HEADER)); } @@ -333,8 +332,8 @@ AcpiGetTable ( for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { - if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), - Signature)) + if (!ACPI_COMPARE_NAME ( + &(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) { continue; } @@ -405,7 +404,8 @@ AcpiGetTableByIndex ( { /* Table is not mapped, map it */ - Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + Status = AcpiTbValidateTable ( + &AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); diff --git a/sys/contrib/dev/acpica/components/tables/tbxfload.c b/sys/contrib/dev/acpica/components/tables/tbxfload.c index 805bbad..c2203e5 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxfload.c +++ b/sys/contrib/dev/acpica/components/tables/tbxfload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,16 +47,11 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/actables.h> +#include <contrib/dev/acpica/include/acevents.h> #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbxfload") -/* Local prototypes */ - -static ACPI_STATUS -AcpiTbLoadNamespace ( - void); - /******************************************************************************* * @@ -80,15 +75,58 @@ AcpiLoadTables ( ACPI_FUNCTION_TRACE (AcpiLoadTables); + /* + * Install the default operation region handlers. These are the + * handlers that are defined by the ACPI specification to be + * "always accessible" -- namely, SystemMemory, SystemIO, and + * PCI_Config. This also means that no _REG methods need to be + * run for these address spaces. We need to have these handlers + * installed before any AML code can be executed, especially any + * module-level code (11/2015). + * Note that we allow OSPMs to install their own region handlers + * between AcpiInitializeSubsystem() and AcpiLoadTables() to use + * their customized default region handlers. + */ + Status = AcpiEvInstallRegionHandlers (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization")); + return_ACPI_STATUS (Status); + } + /* Load the namespace from the tables */ Status = AcpiTbLoadNamespace (); + + /* Don't let single failures abort the load */ + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + } + if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While loading namespace from ACPI tables")); } + if (!AcpiGbl_GroupModuleLevelCode) + { + /* + * Initialize the objects that remain uninitialized. This + * runs the executable AML that may be part of the + * declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + AcpiGbl_NamespaceInitialized = TRUE; return_ACPI_STATUS (Status); } @@ -108,13 +146,16 @@ ACPI_EXPORT_SYMBOL_INIT (AcpiLoadTables) * ******************************************************************************/ -static ACPI_STATUS +ACPI_STATUS AcpiTbLoadNamespace ( void) { ACPI_STATUS Status; UINT32 i; ACPI_TABLE_HEADER *NewDsdt; + ACPI_TABLE_DESC *Table; + UINT32 TablesLoaded = 0; + UINT32 TablesFailed = 0; ACPI_FUNCTION_TRACE (TbLoadNamespace); @@ -126,12 +167,11 @@ AcpiTbLoadNamespace ( * Load the namespace. The DSDT is required, but any SSDT and * PSDT tables are optional. Verify the DSDT. */ + Table = &AcpiGbl_RootTableList.Tables[AcpiGbl_DsdtIndex]; + if (!AcpiGbl_RootTableList.CurrentTableCount || - !ACPI_COMPARE_NAME ( - &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), - ACPI_SIG_DSDT) || - ACPI_FAILURE (AcpiTbValidateTable ( - &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) + !ACPI_COMPARE_NAME (Table->Signature.Ascii, ACPI_SIG_DSDT) || + ACPI_FAILURE (AcpiTbValidateTable (Table))) { Status = AE_NO_ACPI_TABLES; goto UnlockAndExit; @@ -143,7 +183,7 @@ AcpiTbLoadNamespace ( * array can change dynamically as tables are loaded at run-time. Note: * .Pointer field is not validated until after call to AcpiTbValidateTable. */ - AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer; + AcpiGbl_DSDT = Table->Pointer; /* * Optionally copy the entire DSDT to local memory (instead of simply @@ -153,7 +193,7 @@ AcpiTbLoadNamespace ( */ if (AcpiGbl_CopyDsdtLocally) { - NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT); + NewDsdt = AcpiTbCopyDsdt (AcpiGbl_DsdtIndex); if (NewDsdt) { AcpiGbl_DSDT = NewDsdt; @@ -164,17 +204,22 @@ AcpiTbLoadNamespace ( * Save the original DSDT header for detection of table corruption * and/or replacement of the DSDT from outside the OS. */ - ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT, + memcpy (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER)); (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); /* Load and parse tables */ - Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode); + Status = AcpiNsLoadTable (AcpiGbl_DsdtIndex, AcpiGbl_RootNode); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + ACPI_EXCEPTION ((AE_INFO, Status, "[DSDT] table load failed")); + TablesFailed++; + } + else + { + TablesLoaded++; } /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ @@ -182,12 +227,13 @@ AcpiTbLoadNamespace ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { - if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), - ACPI_SIG_SSDT) && - !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), - ACPI_SIG_PSDT)) || - ACPI_FAILURE (AcpiTbValidateTable ( - &AcpiGbl_RootTableList.Tables[i]))) + Table = &AcpiGbl_RootTableList.Tables[i]; + + if (!AcpiGbl_RootTableList.Tables[i].Address || + (!ACPI_COMPARE_NAME (Table->Signature.Ascii, ACPI_SIG_SSDT) && + !ACPI_COMPARE_NAME (Table->Signature.Ascii, ACPI_SIG_PSDT) && + !ACPI_COMPARE_NAME (Table->Signature.Ascii, ACPI_SIG_OSDT)) || + ACPI_FAILURE (AcpiTbValidateTable (Table))) { continue; } @@ -195,11 +241,42 @@ AcpiTbLoadNamespace ( /* Ignore errors while loading tables, get as many as possible */ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - (void) AcpiNsLoadTable (i, AcpiGbl_RootNode); + Status = AcpiNsLoadTable (i, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "(%4.4s:%8.8s) while loading table", + Table->Signature.Ascii, Table->Pointer->OemTableId)); + + TablesFailed++; + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Table [%4.4s:%8.8s] (id FF) - Table namespace load failed\n\n", + Table->Signature.Ascii, Table->Pointer->OemTableId)); + } + else + { + TablesLoaded++; + } + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); } - ACPI_INFO ((AE_INFO, "All ACPI Tables successfully acquired")); + if (!TablesFailed) + { + ACPI_INFO (( + "%u ACPI AML tables successfully acquired and loaded\n", + TablesLoaded)); + } + else + { + ACPI_ERROR ((AE_INFO, + "%u table load failures, %u successful", + TablesFailed, TablesLoaded)); + + /* Indicate at least one failure */ + + Status = AE_CTRL_TERMINATE; + } UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); @@ -238,11 +315,11 @@ AcpiInstallTable ( if (Physical) { - Flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL; + Flags = ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL; } else { - Flags = ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL; + Flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL; } Status = AcpiTbInstallStandardTable (Address, Flags, @@ -299,12 +376,12 @@ AcpiLoadTable ( /* Install the table and load it into the namespace */ - ACPI_INFO ((AE_INFO, "Host-directed Dynamic ACPI Table Load:")); + ACPI_INFO (("Host-directed Dynamic ACPI Table Load:")); (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), - ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, TRUE, FALSE, - &TableIndex); + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, TRUE, FALSE, + &TableIndex); (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) @@ -316,7 +393,8 @@ AcpiLoadTable ( * Note: Now table is "INSTALLED", it must be validated before * using. */ - Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + Status = AcpiTbValidateTable ( + &AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -329,7 +407,7 @@ AcpiLoadTable ( if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); + AcpiGbl_TableHandlerContext); } UnlockAndExit: @@ -412,8 +490,8 @@ AcpiUnloadParentTable ( * that can create namespace objects. */ if (ACPI_COMPARE_NAME ( - AcpiGbl_RootTableList.Tables[i].Signature.Ascii, - ACPI_SIG_DSDT)) + AcpiGbl_RootTableList.Tables[i].Signature.Ascii, + ACPI_SIG_DSDT)) { Status = AE_TYPE; break; @@ -432,8 +510,8 @@ AcpiUnloadParentTable ( if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, - AcpiGbl_RootTableList.Tables[i].Pointer, - AcpiGbl_TableHandlerContext); + AcpiGbl_RootTableList.Tables[i].Pointer, + AcpiGbl_TableHandlerContext); } /* diff --git a/sys/contrib/dev/acpica/components/tables/tbxfroot.c b/sys/contrib/dev/acpica/components/tables/tbxfroot.c index e3b93d3..5c12261 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxfroot.c +++ b/sys/contrib/dev/acpica/components/tables/tbxfroot.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -171,8 +171,8 @@ AcpiFindRootPointer ( /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ TablePtr = AcpiOsMapMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, - ACPI_EBDA_PTR_LENGTH); + (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH); if (!TablePtr) { ACPI_ERROR ((AE_INFO, @@ -198,8 +198,8 @@ AcpiFindRootPointer ( * minimum of 1K length) */ TablePtr = AcpiOsMapMemory ( - (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, - ACPI_EBDA_WINDOW_SIZE); + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, + ACPI_EBDA_WINDOW_SIZE); if (!TablePtr) { ACPI_ERROR ((AE_INFO, @@ -209,14 +209,16 @@ AcpiFindRootPointer ( return_ACPI_STATUS (AE_NO_MEMORY); } - MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE); + MemRover = AcpiTbScanMemoryForRsdp ( + TablePtr, ACPI_EBDA_WINDOW_SIZE); AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); if (MemRover) { /* Return the physical address */ - PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr); + PhysicalAddress += + (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr); *TableAddress = (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; return_ACPI_STATUS (AE_OK); @@ -227,8 +229,8 @@ AcpiFindRootPointer ( * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ TablePtr = AcpiOsMapMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, - ACPI_HI_RSDP_WINDOW_SIZE); + (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE); if (!TablePtr) { @@ -239,7 +241,8 @@ AcpiFindRootPointer ( return_ACPI_STATUS (AE_NO_MEMORY); } - MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); + MemRover = AcpiTbScanMemoryForRsdp ( + TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); if (MemRover) @@ -297,7 +300,8 @@ AcpiTbScanMemoryForRsdp ( { /* The RSDP signature and checksum must both be correct */ - Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover)); + Status = AcpiTbValidateRsdp ( + ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover)); if (ACPI_SUCCESS (Status)) { /* Sig and checksum valid, we have found a real RSDP */ diff --git a/sys/contrib/dev/acpica/components/utilities/utaddress.c b/sys/contrib/dev/acpica/components/utilities/utaddress.c index 5ed2b4d..166f552 100644 --- a/sys/contrib/dev/acpica/components/utilities/utaddress.c +++ b/sys/contrib/dev/acpica/components/utilities/utaddress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -263,7 +263,7 @@ AcpiUtCheckAddressRange ( OverlapCount++; if (Warn) /* Optional warning message */ { - Pathname = AcpiNsGetExternalPathname (RangeInfo->RegionNode); + Pathname = AcpiNsGetNormalizedPathname (RangeInfo->RegionNode, TRUE); ACPI_WARNING ((AE_INFO, "%s range 0x%8.8X%8.8X-0x%8.8X%8.8X conflicts with OpRegion 0x%8.8X%8.8X-0x%8.8X%8.8X (%s)", diff --git a/sys/contrib/dev/acpica/components/utilities/utalloc.c b/sys/contrib/dev/acpica/components/utilities/utalloc.c index 99fb15a1..b768f58 100644 --- a/sys/contrib/dev/acpica/components/utilities/utalloc.c +++ b/sys/contrib/dev/acpica/components/utilities/utalloc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -79,7 +79,7 @@ AcpiOsAllocateZeroed ( { /* Clear the memory block */ - ACPI_MEMSET (Allocation, 0, Size); + memset (Allocation, 0, Size); } return (Allocation); @@ -110,35 +110,35 @@ AcpiUtCreateCaches ( /* Object Caches, for frequently used objects */ Status = AcpiOsCreateCache ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), - ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache); + ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache); if (ACPI_FAILURE (Status)) { return (Status); } Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE), - ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache); + ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache); if (ACPI_FAILURE (Status)) { return (Status); } Status = AcpiOsCreateCache ("Acpi-Parse", sizeof (ACPI_PARSE_OBJ_COMMON), - ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache); + ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache); if (ACPI_FAILURE (Status)) { return (Status); } Status = AcpiOsCreateCache ("Acpi-ParseExt", sizeof (ACPI_PARSE_OBJ_NAMED), - ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache); + ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache); if (ACPI_FAILURE (Status)) { return (Status); } Status = AcpiOsCreateCache ("Acpi-Operand", sizeof (ACPI_OPERAND_OBJECT), - ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache); + ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache); if (ACPI_FAILURE (Status)) { return (Status); @@ -150,14 +150,14 @@ AcpiUtCreateCaches ( /* Memory allocation lists */ Status = AcpiUtCreateList ("Acpi-Global", 0, - &AcpiGbl_GlobalList); + &AcpiGbl_GlobalList); if (ACPI_FAILURE (Status)) { return (Status); } Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), - &AcpiGbl_NsNodeList); + &AcpiGbl_NsNodeList); if (ACPI_FAILURE (Status)) { return (Status); @@ -187,9 +187,10 @@ AcpiUtDeleteCaches ( #ifdef ACPI_DBG_TRACK_ALLOCATIONS char Buffer[7]; + if (AcpiGbl_DisplayFinalMemStats) { - ACPI_STRCPY (Buffer, "MEMORY"); + strcpy (Buffer, "MEMORY"); (void) AcpiDbDisplayStatistics (Buffer); } #endif @@ -359,6 +360,6 @@ AcpiUtInitializeBuffer ( /* Have a valid buffer, clear it */ - ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); + memset (Buffer->Pointer, 0, RequiredLength); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/utilities/utascii.c b/sys/contrib/dev/acpica/components/utilities/utascii.c new file mode 100644 index 0000000..9081c55 --- /dev/null +++ b/sys/contrib/dev/acpica/components/utilities/utascii.c @@ -0,0 +1,161 @@ +/****************************************************************************** + * + * Module Name: utascii - Utility ascii functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidNameseg + * + * PARAMETERS: Name - The name or table signature to be examined. + * Four characters, does not have to be a + * NULL terminated string. + * + * RETURN: TRUE if signature is has 4 valid ACPI characters + * + * DESCRIPTION: Validate an ACPI table signature. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidNameseg ( + char *Name) +{ + UINT32 i; + + + /* Validate each character in the signature */ + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!AcpiUtValidNameChar (Name[i], i)) + { + return (FALSE); + } + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidNameChar + * + * PARAMETERS: Char - The character to be examined + * Position - Byte position (0-3) + * + * RETURN: TRUE if the character is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI character. Must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + * We allow a '!' as the last character because of the ASF! table + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidNameChar ( + char Character, + UINT32 Position) +{ + + if (!((Character >= 'A' && Character <= 'Z') || + (Character >= '0' && Character <= '9') || + (Character == '_'))) + { + /* Allow a '!' in the last position */ + + if (Character == '!' && Position == 3) + { + return (TRUE); + } + + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCheckAndRepairAscii + * + * PARAMETERS: Name - Ascii string + * Count - Number of characters to check + * + * RETURN: None + * + * DESCRIPTION: Ensure that the requested number of characters are printable + * Ascii characters. Sets non-printable and null chars to <space>. + * + ******************************************************************************/ + +void +AcpiUtCheckAndRepairAscii ( + UINT8 *Name, + char *RepairedName, + UINT32 Count) +{ + UINT32 i; + + + for (i = 0; i < Count; i++) + { + RepairedName[i] = (char) Name[i]; + + if (!Name[i]) + { + return; + } + if (!isprint (Name[i])) + { + RepairedName[i] = ' '; + } + } +} diff --git a/sys/contrib/dev/acpica/components/utilities/utbuffer.c b/sys/contrib/dev/acpica/components/utilities/utbuffer.c index cc41419..dfe54d1 100644 --- a/sys/contrib/dev/acpica/components/utilities/utbuffer.c +++ b/sys/contrib/dev/acpica/components/utilities/utbuffer.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -168,7 +168,7 @@ AcpiUtDumpBuffer ( } BufChar = Buffer[(ACPI_SIZE) i + j]; - if (ACPI_IS_PRINT (BufChar)) + if (isprint (BufChar)) { AcpiOsPrintf ("%c", BufChar); } @@ -341,7 +341,7 @@ AcpiUtDumpBufferToFile ( } BufChar = Buffer[(ACPI_SIZE) i + j]; - if (ACPI_IS_PRINT (BufChar)) + if (isprint (BufChar)) { AcpiUtFilePrintf (File, "%c", BufChar); } diff --git a/sys/contrib/dev/acpica/components/utilities/utcache.c b/sys/contrib/dev/acpica/components/utilities/utcache.c index aa0161c..af6df92 100644 --- a/sys/contrib/dev/acpica/components/utilities/utcache.c +++ b/sys/contrib/dev/acpica/components/utilities/utcache.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -92,10 +92,10 @@ AcpiOsCreateCache ( /* Populate the cache object and return it */ - ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); - Cache->ListName = CacheName; + memset (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + Cache->ListName = CacheName; Cache->ObjectSize = ObjectSize; - Cache->MaxDepth = MaxDepth; + Cache->MaxDepth = MaxDepth; *ReturnCache = Cache; return (AE_OK); @@ -242,7 +242,7 @@ AcpiOsReleaseObject ( /* Mark the object as cached */ - ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize); + memset (Object, 0xCA, Cache->ObjectSize); ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED); /* Put the object at the head of the cache list */ @@ -279,7 +279,7 @@ AcpiOsAcquireObject ( void *Object; - ACPI_FUNCTION_NAME (OsAcquireObject); + ACPI_FUNCTION_TRACE (OsAcquireObject); if (!Cache) @@ -318,7 +318,7 @@ AcpiOsAcquireObject ( /* Clear (zero) the previously used Object */ - ACPI_MEMSET (Object, 0, Cache->ObjectSize); + memset (Object, 0, Cache->ObjectSize); } else { diff --git a/sys/contrib/dev/acpica/components/utilities/utcopy.c b/sys/contrib/dev/acpica/components/utilities/utcopy.c index 8a94ea6..c1be4cc 100644 --- a/sys/contrib/dev/acpica/components/utilities/utcopy.c +++ b/sys/contrib/dev/acpica/components/utilities/utcopy.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -146,7 +146,7 @@ AcpiUtCopyIsimpleToEsimple ( /* Always clear the external object */ - ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); + memset (ExternalObject, 0, sizeof (ACPI_OBJECT)); /* * In general, the external object will be the same type as @@ -163,9 +163,9 @@ AcpiUtCopyIsimpleToEsimple ( ExternalObject->String.Pointer = (char *) DataSpace; ExternalObject->String.Length = InternalObject->String.Length; *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( - (ACPI_SIZE) InternalObject->String.Length + 1); + (ACPI_SIZE) InternalObject->String.Length + 1); - ACPI_MEMCPY ((void *) DataSpace, + memcpy ((void *) DataSpace, (void *) InternalObject->String.Pointer, (ACPI_SIZE) InternalObject->String.Length + 1); break; @@ -175,9 +175,9 @@ AcpiUtCopyIsimpleToEsimple ( ExternalObject->Buffer.Pointer = DataSpace; ExternalObject->Buffer.Length = InternalObject->Buffer.Length; *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( - InternalObject->String.Length); + InternalObject->String.Length); - ACPI_MEMCPY ((void *) DataSpace, + memcpy ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer, InternalObject->Buffer.Length); break; @@ -275,9 +275,9 @@ AcpiUtCopyIelementToEelement ( ACPI_FUNCTION_ENTRY (); - ThisIndex = State->Pkg.Index; - TargetObject = (ACPI_OBJECT *) - &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; + ThisIndex = State->Pkg.Index; + TargetObject = (ACPI_OBJECT *) &((ACPI_OBJECT *) + (State->Pkg.DestObject))->Package.Elements[ThisIndex]; switch (ObjectType) { @@ -286,7 +286,7 @@ AcpiUtCopyIelementToEelement ( * This is a simple or null object */ Status = AcpiUtCopyIsimpleToEsimple (SourceObject, - TargetObject, Info->FreeSpace, &ObjectSpace); + TargetObject, Info->FreeSpace, &ObjectSpace); if (ACPI_FAILURE (Status)) { return (Status); @@ -297,9 +297,9 @@ AcpiUtCopyIelementToEelement ( /* * Build the package object */ - TargetObject->Type = ACPI_TYPE_PACKAGE; - TargetObject->Package.Count = SourceObject->Package.Count; - TargetObject->Package.Elements = + TargetObject->Type = ACPI_TYPE_PACKAGE; + TargetObject->Package.Count = SourceObject->Package.Count; + TargetObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); /* @@ -312,8 +312,8 @@ AcpiUtCopyIelementToEelement ( * update the buffer length counter */ ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( - (ACPI_SIZE) TargetObject->Package.Count * - sizeof (ACPI_OBJECT)); + (ACPI_SIZE) TargetObject->Package.Count * + sizeof (ACPI_OBJECT)); break; default: @@ -321,8 +321,8 @@ AcpiUtCopyIelementToEelement ( return (AE_BAD_PARAMETER); } - Info->FreeSpace += ObjectSpace; - Info->Length += ObjectSpace; + Info->FreeSpace += ObjectSpace; + Info->Length += ObjectSpace; return (Status); } @@ -368,28 +368,28 @@ AcpiUtCopyIpackageToEpackage ( /* * Free space begins right after the first package */ - Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( - sizeof (ACPI_OBJECT)); + Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace = Buffer + + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); Info.ObjectSpace = 0; Info.NumPackages = 1; - ExternalObject->Type = InternalObject->Common.Type; - ExternalObject->Package.Count = InternalObject->Package.Count; - ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, - Info.FreeSpace); + ExternalObject->Type = InternalObject->Common.Type; + ExternalObject->Package.Count = InternalObject->Package.Count; + ExternalObject->Package.Elements = + ACPI_CAST_PTR (ACPI_OBJECT, Info.FreeSpace); /* * Leave room for an array of ACPI_OBJECTS in the buffer * and move the free space past it */ - Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); Info.FreeSpace += ExternalObject->Package.Count * - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, - AcpiUtCopyIelementToEelement, &Info); + AcpiUtCopyIelementToEelement, &Info); *SpaceUsed = Info.Length; return_ACPI_STATUS (Status); @@ -428,7 +428,7 @@ AcpiUtCopyIobjectToEobject ( * nested packages) */ Status = AcpiUtCopyIpackageToEpackage (InternalObject, - RetBuffer->Pointer, &RetBuffer->Length); + RetBuffer->Pointer, &RetBuffer->Length); } else { @@ -436,10 +436,10 @@ AcpiUtCopyIobjectToEobject ( * Build a simple object (no nested objects) */ Status = AcpiUtCopyIsimpleToEsimple (InternalObject, - ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer), - ACPI_ADD_PTR (UINT8, RetBuffer->Pointer, - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), - &RetBuffer->Length); + ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer), + ACPI_ADD_PTR (UINT8, RetBuffer->Pointer, + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), + &RetBuffer->Length); /* * build simple does not include the object size in the length * so we add it in here @@ -489,7 +489,7 @@ AcpiUtCopyEsimpleToIsimple ( case ACPI_TYPE_LOCAL_REFERENCE: InternalObject = AcpiUtCreateInternalObject ( - (UINT8) ExternalObject->Type); + (UINT8) ExternalObject->Type); if (!InternalObject) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -528,11 +528,11 @@ AcpiUtCopyEsimpleToIsimple ( goto ErrorExit; } - ACPI_MEMCPY (InternalObject->String.Pointer, - ExternalObject->String.Pointer, - ExternalObject->String.Length); + memcpy (InternalObject->String.Pointer, + ExternalObject->String.Pointer, + ExternalObject->String.Length); - InternalObject->String.Length = ExternalObject->String.Length; + InternalObject->String.Length = ExternalObject->String.Length; break; case ACPI_TYPE_BUFFER: @@ -544,11 +544,11 @@ AcpiUtCopyEsimpleToIsimple ( goto ErrorExit; } - ACPI_MEMCPY (InternalObject->Buffer.Pointer, - ExternalObject->Buffer.Pointer, - ExternalObject->Buffer.Length); + memcpy (InternalObject->Buffer.Pointer, + ExternalObject->Buffer.Pointer, + ExternalObject->Buffer.Length); - InternalObject->Buffer.Length = ExternalObject->Buffer.Length; + InternalObject->Buffer.Length = ExternalObject->Buffer.Length; /* Mark buffer data valid */ @@ -557,7 +557,7 @@ AcpiUtCopyEsimpleToIsimple ( case ACPI_TYPE_INTEGER: - InternalObject->Integer.Value = ExternalObject->Integer.Value; + InternalObject->Integer.Value = ExternalObject->Integer.Value; break; case ACPI_TYPE_LOCAL_REFERENCE: @@ -615,7 +615,8 @@ AcpiUtCopyEpackageToIpackage ( /* Create the package object */ - PackageObject = AcpiUtCreatePackageObject (ExternalObject->Package.Count); + PackageObject = AcpiUtCreatePackageObject ( + ExternalObject->Package.Count); if (!PackageObject) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -624,14 +625,14 @@ AcpiUtCopyEpackageToIpackage ( PackageElements = PackageObject->Package.Elements; /* - * Recursive implementation. Probably ok, since nested external packages - * as parameters should be very rare. + * Recursive implementation. Probably ok, since nested external + * packages as parameters should be very rare. */ for (i = 0; i < ExternalObject->Package.Count; i++) { Status = AcpiUtCopyEobjectToIobject ( - &ExternalObject->Package.Elements[i], - &PackageElements[i]); + &ExternalObject->Package.Elements[i], + &PackageElements[i]); if (ACPI_FAILURE (Status)) { /* Truncate package and delete it */ @@ -678,14 +679,16 @@ AcpiUtCopyEobjectToIobject ( if (ExternalObject->Type == ACPI_TYPE_PACKAGE) { - Status = AcpiUtCopyEpackageToIpackage (ExternalObject, InternalObject); + Status = AcpiUtCopyEpackageToIpackage ( + ExternalObject, InternalObject); } else { /* * Build a simple object (no nested objects) */ - Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject); + Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, + InternalObject); } return_ACPI_STATUS (Status); @@ -732,7 +735,7 @@ AcpiUtCopySimpleObject ( CopySize = sizeof (ACPI_NAMESPACE_NODE); } - ACPI_MEMCPY (ACPI_CAST_PTR (char, DestDesc), + memcpy (ACPI_CAST_PTR (char, DestDesc), ACPI_CAST_PTR (char, SourceDesc), CopySize); /* Restore the saved fields */ @@ -766,7 +769,7 @@ AcpiUtCopySimpleObject ( /* Copy the actual buffer data */ - ACPI_MEMCPY (DestDesc->Buffer.Pointer, + memcpy (DestDesc->Buffer.Pointer, SourceDesc->Buffer.Pointer, SourceDesc->Buffer.Length); } break; @@ -788,7 +791,7 @@ AcpiUtCopySimpleObject ( /* Copy the actual string data */ - ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, + memcpy (DestDesc->String.Pointer, SourceDesc->String.Pointer, (ACPI_SIZE) SourceDesc->String.Length + 1); } break; @@ -836,7 +839,7 @@ AcpiUtCopySimpleObject ( case ACPI_TYPE_EVENT: Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &DestDesc->Event.OsSemaphore); + &DestDesc->Event.OsSemaphore); if (ACPI_FAILURE (Status)) { return (Status); @@ -882,9 +885,9 @@ AcpiUtCopyIelementToIelement ( ACPI_FUNCTION_ENTRY (); - ThisIndex = State->Pkg.Index; + ThisIndex = State->Pkg.Index; ThisTargetPtr = (ACPI_OPERAND_OBJECT **) - &State->Pkg.DestObject->Package.Elements[ThisIndex]; + &State->Pkg.DestObject->Package.Elements[ThisIndex]; switch (ObjectType) { @@ -898,7 +901,7 @@ AcpiUtCopyIelementToIelement ( * This is a simple object, just copy it */ TargetObject = AcpiUtCreateInternalObject ( - SourceObject->Common.Type); + SourceObject->Common.Type); if (!TargetObject) { return (AE_NO_MEMORY); @@ -925,7 +928,8 @@ AcpiUtCopyIelementToIelement ( * This object is a package - go down another nesting level * Create and build the package object */ - TargetObject = AcpiUtCreatePackageObject (SourceObject->Package.Count); + TargetObject = AcpiUtCreatePackageObject ( + SourceObject->Package.Count); if (!TargetObject) { return (AE_NO_MEMORY); @@ -982,16 +986,16 @@ AcpiUtCopyIpackageToIpackage ( ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); - DestObj->Common.Type = SourceObj->Common.Type; - DestObj->Common.Flags = SourceObj->Common.Flags; - DestObj->Package.Count = SourceObj->Package.Count; + DestObj->Common.Type = SourceObj->Common.Type; + DestObj->Common.Flags = SourceObj->Common.Flags; + DestObj->Package.Count = SourceObj->Package.Count; /* * Create the object array and walk the source package tree */ DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) SourceObj->Package.Count + 1) * - sizeof (void *)); + ((ACPI_SIZE) SourceObj->Package.Count + 1) * + sizeof (void *)); if (!DestObj->Package.Elements) { ACPI_ERROR ((AE_INFO, "Package allocation failure")); @@ -1003,7 +1007,7 @@ AcpiUtCopyIpackageToIpackage ( * This handles nested packages of arbitrary depth. */ Status = AcpiUtWalkPackageTree (SourceObj, DestObj, - AcpiUtCopyIelementToIelement, WalkState); + AcpiUtCopyIelementToIelement, WalkState); if (ACPI_FAILURE (Status)) { /* On failure, delete the destination package object */ @@ -1053,8 +1057,8 @@ AcpiUtCopyIobjectToIobject ( if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE) { - Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc, - WalkState); + Status = AcpiUtCopyIpackageToIpackage ( + SourceDesc, *DestDesc, WalkState); } else { @@ -1065,7 +1069,7 @@ AcpiUtCopyIobjectToIobject ( if (ACPI_FAILURE (Status)) { - AcpiUtRemoveReference(*DestDesc); + AcpiUtRemoveReference (*DestDesc); } return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/utilities/utdebug.c b/sys/contrib/dev/acpica/components/utilities/utdebug.c index 544450d..7e03b22 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdebug.c +++ b/sys/contrib/dev/acpica/components/utilities/utdebug.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ #include <contrib/dev/acpica/include/acpi.h> #include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acinterp.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdebug") @@ -52,15 +53,9 @@ #ifdef ACPI_DEBUG_OUTPUT -static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; -static char *AcpiGbl_FnEntryStr = "----Entry"; -static char *AcpiGbl_FnExitStr = "----Exit-"; - -/* Local prototypes */ - -static const char * -AcpiUtTrimFunctionName ( - const char *FunctionName); +static ACPI_THREAD_ID AcpiGbl_PreviousThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; +static const char *AcpiGbl_FunctionEntryPrefix = "----Entry"; +static const char *AcpiGbl_FunctionExitPrefix = "----Exit-"; /******************************************************************************* @@ -200,16 +195,16 @@ AcpiDebugPrint ( * Thread tracking and context switch notification */ ThreadId = AcpiOsGetThreadId (); - if (ThreadId != AcpiGbl_PrevThreadId) + if (ThreadId != AcpiGbl_PreviousThreadId) { if (ACPI_LV_THREADS & AcpiDbgLevel) { AcpiOsPrintf ( "\n**** Context Switch from TID %u to TID %u ****\n\n", - (UINT32) AcpiGbl_PrevThreadId, (UINT32) ThreadId); + (UINT32) AcpiGbl_PreviousThreadId, (UINT32) ThreadId); } - AcpiGbl_PrevThreadId = ThreadId; + AcpiGbl_PreviousThreadId = ThreadId; AcpiGbl_NestingLevel = 0; } @@ -324,7 +319,7 @@ AcpiUtTrace ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s\n", AcpiGbl_FnEntryStr); + "%s\n", AcpiGbl_FunctionEntryPrefix); } } @@ -354,7 +349,7 @@ AcpiUtTracePtr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - void *Pointer) + const void *Pointer) { AcpiGbl_NestingLevel++; @@ -366,7 +361,7 @@ AcpiUtTracePtr ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %p\n", AcpiGbl_FnEntryStr, Pointer); + "%s %p\n", AcpiGbl_FunctionEntryPrefix, Pointer); } } @@ -394,7 +389,7 @@ AcpiUtTraceStr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - char *String) + const char *String) { AcpiGbl_NestingLevel++; @@ -406,7 +401,7 @@ AcpiUtTraceStr ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %s\n", AcpiGbl_FnEntryStr, String); + "%s %s\n", AcpiGbl_FunctionEntryPrefix, String); } } @@ -446,7 +441,7 @@ AcpiUtTraceU32 ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %08X\n", AcpiGbl_FnEntryStr, Integer); + "%s %08X\n", AcpiGbl_FunctionEntryPrefix, Integer); } } @@ -481,7 +476,7 @@ AcpiUtExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s\n", AcpiGbl_FnExitStr); + "%s\n", AcpiGbl_FunctionExitPrefix); } if (AcpiGbl_NestingLevel) @@ -527,14 +522,14 @@ AcpiUtStatusExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %s\n", AcpiGbl_FnExitStr, + "%s %s\n", AcpiGbl_FunctionExitPrefix, AcpiFormatException (Status)); } else { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, + "%s ****Exception****: %s\n", AcpiGbl_FunctionExitPrefix, AcpiFormatException (Status)); } } @@ -580,7 +575,7 @@ AcpiUtValueExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, + "%s %8.8X%8.8X\n", AcpiGbl_FunctionExitPrefix, ACPI_FORMAT_UINT64 (Value)); } @@ -625,7 +620,49 @@ AcpiUtPtrExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %p\n", AcpiGbl_FnExitStr, Ptr); + "%s %p\n", AcpiGbl_FunctionExitPrefix, Ptr); + } + + if (AcpiGbl_NestingLevel) + { + AcpiGbl_NestingLevel--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * String - String to display + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit value also. + * + ******************************************************************************/ + +void +AcpiUtStrExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *String) +{ + + /* Check if enabled up-front for performance */ + + if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId)) + { + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FunctionExitPrefix, String); } if (AcpiGbl_NestingLevel) @@ -634,6 +671,42 @@ AcpiUtPtrExit ( } } + +/******************************************************************************* + * + * FUNCTION: AcpiTracePoint + * + * PARAMETERS: Type - Trace event type + * Begin - TRUE if before execution + * Aml - Executed AML address + * Pathname - Object path + * Pointer - Pointer to the related object + * + * RETURN: None + * + * DESCRIPTION: Interpreter execution trace. + * + ******************************************************************************/ + +void +AcpiTracePoint ( + ACPI_TRACE_EVENT_TYPE Type, + BOOLEAN Begin, + UINT8 *Aml, + char *Pathname) +{ + + ACPI_FUNCTION_ENTRY (); + + AcpiExTracePoint (Type, Begin, Aml, Pathname); + +#ifdef ACPI_USE_SYSTEM_TRACER + AcpiOsTracePoint (Type, Begin, Aml, Pathname); +#endif +} + +ACPI_EXPORT_SYMBOL (AcpiTracePoint) + #endif diff --git a/sys/contrib/dev/acpica/components/utilities/utdecode.c b/sys/contrib/dev/acpica/components/utilities/utdecode.c index c1887ee..8f8f06e 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdecode.c +++ b/sys/contrib/dev/acpica/components/utilities/utdecode.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -119,7 +119,7 @@ const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = }; -char * +const char * AcpiUtGetRegionName ( UINT8 SpaceId) { @@ -141,7 +141,7 @@ AcpiUtGetRegionName ( return ("InvalidSpaceId"); } - return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId])); + return (AcpiGbl_RegionTypes[SpaceId]); } @@ -169,7 +169,7 @@ static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = }; -char * +const char * AcpiUtGetEventName ( UINT32 EventId) { @@ -179,7 +179,7 @@ AcpiUtGetEventName ( return ("InvalidEventID"); } - return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId])); + return (AcpiGbl_EventTypes[EventId]); } @@ -201,7 +201,8 @@ AcpiUtGetEventName ( * * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; * when stored in a table it really means that we have thus far seen no - * evidence to indicate what type is actually going to be stored for this entry. + * evidence to indicate what type is actually going to be stored for this + & entry. */ static const char AcpiGbl_BadType[] = "UNDEFINED"; @@ -243,31 +244,47 @@ static const char *AcpiGbl_NsTypeNames[] = }; -char * +const char * AcpiUtGetTypeName ( ACPI_OBJECT_TYPE Type) { if (Type > ACPI_TYPE_INVALID) { - return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); + return (AcpiGbl_BadType); } - return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type])); + return (AcpiGbl_NsTypeNames[Type]); } -char * +const char * AcpiUtGetObjectTypeName ( ACPI_OPERAND_OBJECT *ObjDesc) { + ACPI_FUNCTION_TRACE (UtGetObjectTypeName); + if (!ObjDesc) { - return ("[NULL Object Descriptor]"); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); + return_PTR ("[NULL Object Descriptor]"); + } + + /* These descriptor types share a common area */ + + if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) && + (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_NAMED)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Invalid object descriptor type: 0x%2.2X [%s] (%p)\n", + ACPI_GET_DESCRIPTOR_TYPE (ObjDesc), + AcpiUtGetDescriptorName (ObjDesc), ObjDesc)); + + return_PTR ("Invalid object"); } - return (AcpiUtGetTypeName (ObjDesc->Common.Type)); + return_STR (AcpiUtGetTypeName (ObjDesc->Common.Type)); } @@ -283,7 +300,7 @@ AcpiUtGetObjectTypeName ( * ******************************************************************************/ -char * +const char * AcpiUtGetNodeName ( void *Object) { @@ -359,7 +376,7 @@ static const char *AcpiGbl_DescTypeNames[] = }; -char * +const char * AcpiUtGetDescriptorName ( void *Object) { @@ -374,9 +391,7 @@ AcpiUtGetDescriptorName ( return ("Not a Descriptor"); } - return (ACPI_CAST_PTR (char, - AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)])); - + return (AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]); } @@ -453,7 +468,7 @@ AcpiUtGetReferenceName ( /* Names for internal mutex objects, used for debug output */ -static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = +static const char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = { "ACPI_MTX_Interpreter", "ACPI_MTX_Namespace", @@ -461,11 +476,9 @@ static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = "ACPI_MTX_Events", "ACPI_MTX_Caches", "ACPI_MTX_Memory", - "ACPI_MTX_CommandComplete", - "ACPI_MTX_CommandReady" }; -char * +const char * AcpiUtGetMutexName ( UINT32 MutexId) { @@ -493,7 +506,7 @@ AcpiUtGetMutexName ( /* Names for Notify() values, used for debug output */ -static const char *AcpiGbl_GenericNotify[ACPI_NOTIFY_MAX + 1] = +static const char *AcpiGbl_GenericNotify[ACPI_GENERIC_NOTIFY_MAX + 1] = { /* 00 */ "Bus Check", /* 01 */ "Device Check", @@ -507,32 +520,35 @@ static const char *AcpiGbl_GenericNotify[ACPI_NOTIFY_MAX + 1] = /* 09 */ "Device PLD Check", /* 0A */ "Reserved", /* 0B */ "System Locality Update", - /* 0C */ "Shutdown Request", + /* 0C */ "Shutdown Request", /* Reserved in ACPI 6.0 */ /* 0D */ "System Resource Affinity Update" }; -static const char *AcpiGbl_DeviceNotify[4] = +static const char *AcpiGbl_DeviceNotify[5] = { /* 80 */ "Status Change", /* 81 */ "Information Change", /* 82 */ "Device-Specific Change", - /* 83 */ "Device-Specific Change" + /* 83 */ "Device-Specific Change", + /* 84 */ "Reserved" }; -static const char *AcpiGbl_ProcessorNotify[4] = +static const char *AcpiGbl_ProcessorNotify[5] = { /* 80 */ "Performance Capability Change", /* 81 */ "C-State Change", /* 82 */ "Throttling Capability Change", - /* 83 */ "Device-Specific Change" + /* 83 */ "Guaranteed Change", + /* 84 */ "Minimum Excursion" }; -static const char *AcpiGbl_ThermalNotify[4] = +static const char *AcpiGbl_ThermalNotify[5] = { /* 80 */ "Thermal Status Change", /* 81 */ "Thermal Trip Point Change", /* 82 */ "Thermal Device List Change", - /* 83 */ "Thermal Relationship Change" + /* 83 */ "Thermal Relationship Change", + /* 84 */ "Reserved" }; @@ -542,23 +558,23 @@ AcpiUtGetNotifyName ( ACPI_OBJECT_TYPE Type) { - /* 00 - 0D are common to all object types */ + /* 00 - 0D are "common to all object types" (from ACPI Spec) */ - if (NotifyValue <= ACPI_NOTIFY_MAX) + if (NotifyValue <= ACPI_GENERIC_NOTIFY_MAX) { return (AcpiGbl_GenericNotify[NotifyValue]); } - /* 0D - 7F are reserved */ + /* 0E - 7F are reserved */ if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) { return ("Reserved"); } - /* 80 - 83 are per-object-type */ + /* 80 - 84 are per-object-type */ - if (NotifyValue <= 0x83) + if (NotifyValue <= ACPI_SPECIFIC_NOTIFY_MAX) { switch (Type) { diff --git a/sys/contrib/dev/acpica/components/utilities/utdelete.c b/sys/contrib/dev/acpica/components/utilities/utdelete.c index bc9ab70..49d6cdd 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdelete.c +++ b/sys/contrib/dev/acpica/components/utilities/utdelete.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -220,6 +220,11 @@ AcpiUtDeleteInternalObj ( AcpiUtDeleteObjectDesc (Object->Method.Mutex); Object->Method.Mutex = NULL; } + + if (Object->Method.Node) + { + Object->Method.Node = NULL; + } break; case ACPI_TYPE_REGION: @@ -549,8 +554,8 @@ AcpiUtUpdateObjectReference ( } /* - * All sub-objects must have their reference count incremented also. - * Different object types have different subobjects. + * All sub-objects must have their reference count incremented + * also. Different object types have different subobjects. */ switch (Object->Common.Type) { @@ -610,7 +615,7 @@ AcpiUtUpdateObjectReference ( * for later processing (this eliminates recursion.) */ Status = AcpiUtCreateUpdateStateAndPush ( - NextObject, Action, &StateList); + NextObject, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -635,7 +640,7 @@ AcpiUtUpdateObjectReference ( NextObject = Object->BankField.BankObj; Status = AcpiUtCreateUpdateStateAndPush ( - Object->BankField.RegionObj, Action, &StateList); + Object->BankField.RegionObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -646,7 +651,7 @@ AcpiUtUpdateObjectReference ( NextObject = Object->IndexField.IndexObj; Status = AcpiUtCreateUpdateStateAndPush ( - Object->IndexField.DataObj, Action, &StateList); + Object->IndexField.DataObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; diff --git a/sys/contrib/dev/acpica/components/utilities/uterror.c b/sys/contrib/dev/acpica/components/utilities/uterror.c index 35e9ce6..bc4193f 100644 --- a/sys/contrib/dev/acpica/components/utilities/uterror.c +++ b/sys/contrib/dev/acpica/components/utilities/uterror.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -244,8 +244,8 @@ AcpiUtNamespaceError ( { /* Convert path to external format */ - Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, - InternalName, NULL, &Name); + Status = AcpiNsExternalizeName ( + ACPI_UINT32_MAX, InternalName, NULL, &Name); /* Print target name */ @@ -307,8 +307,8 @@ AcpiUtMethodError ( if (Path) { - Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH, - &Node); + Status = AcpiNsGetNode (PrefixNode, Path, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("[Could not get node by pathname]"); diff --git a/sys/contrib/dev/acpica/components/utilities/uteval.c b/sys/contrib/dev/acpica/components/utilities/uteval.c index b9d63b4..8fb6929 100644 --- a/sys/contrib/dev/acpica/components/utilities/uteval.c +++ b/sys/contrib/dev/acpica/components/utilities/uteval.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,7 +72,7 @@ ACPI_STATUS AcpiUtEvaluateObject ( ACPI_NAMESPACE_NODE *PrefixNode, - char *Path, + const char *Path, UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc) { @@ -219,7 +219,7 @@ Cleanup: ACPI_STATUS AcpiUtEvaluateNumericObject ( - char *ObjectName, + const char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, UINT64 *Value) { @@ -231,7 +231,7 @@ AcpiUtEvaluateNumericObject ( Status = AcpiUtEvaluateObject (DeviceNode, ObjectName, - ACPI_BTYPE_INTEGER, &ObjDesc); + ACPI_BTYPE_INTEGER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -278,7 +278,7 @@ AcpiUtExecute_STA ( Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA, - ACPI_BTYPE_INTEGER, &ObjDesc); + ACPI_BTYPE_INTEGER, &ObjDesc); if (ACPI_FAILURE (Status)) { if (AE_NOT_FOUND == Status) @@ -351,8 +351,8 @@ AcpiUtExecutePowerMethods ( * return type is an Integer. */ Status = AcpiUtEvaluateObject (DeviceNode, - ACPI_CAST_PTR (char, MethodNames[i]), - ACPI_BTYPE_INTEGER, &ObjDesc); + ACPI_CAST_PTR (char, MethodNames[i]), + ACPI_BTYPE_INTEGER, &ObjDesc); if (ACPI_SUCCESS (Status)) { OutValues[i] = (UINT8) ObjDesc->Integer.Value; diff --git a/sys/contrib/dev/acpica/components/utilities/utexcep.c b/sys/contrib/dev/acpica/components/utilities/utexcep.c index 2a38cff..d2ee5bb 100644 --- a/sys/contrib/dev/acpica/components/utilities/utexcep.c +++ b/sys/contrib/dev/acpica/components/utilities/utexcep.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/utilities/utfileio.c b/sys/contrib/dev/acpica/components/utilities/utfileio.c deleted file mode 100644 index 15cb3d0..0000000 --- a/sys/contrib/dev/acpica/components/utilities/utfileio.c +++ /dev/null @@ -1,358 +0,0 @@ -/******************************************************************************* - * - * Module Name: utfileio - simple file I/O routines - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2015, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include <contrib/dev/acpica/include/acpi.h> -#include <contrib/dev/acpica/include/accommon.h> -#include <contrib/dev/acpica/include/actables.h> -#include <contrib/dev/acpica/include/acapps.h> - -#ifdef ACPI_ASL_COMPILER -#include <contrib/dev/acpica/compiler/aslcompiler.h> -#endif - - -#define _COMPONENT ACPI_CA_DEBUGGER - ACPI_MODULE_NAME ("utfileio") - - -#ifdef ACPI_APPLICATION - -/* Local prototypes */ - -static ACPI_STATUS -AcpiUtCheckTextModeCorruption ( - UINT8 *Table, - UINT32 TableLength, - UINT32 FileLength); - -static ACPI_STATUS -AcpiUtReadTable ( - FILE *fp, - ACPI_TABLE_HEADER **Table, - UINT32 *TableLength); - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCheckTextModeCorruption - * - * PARAMETERS: Table - Table buffer - * TableLength - Length of table from the table header - * FileLength - Length of the file that contains the table - * - * RETURN: Status - * - * DESCRIPTION: Check table for text mode file corruption where all linefeed - * characters (LF) have been replaced by carriage return linefeed - * pairs (CR/LF). - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiUtCheckTextModeCorruption ( - UINT8 *Table, - UINT32 TableLength, - UINT32 FileLength) -{ - UINT32 i; - UINT32 Pairs = 0; - - - if (TableLength != FileLength) - { - ACPI_WARNING ((AE_INFO, - "File length (0x%X) is not the same as the table length (0x%X)", - FileLength, TableLength)); - } - - /* Scan entire table to determine if each LF has been prefixed with a CR */ - - for (i = 1; i < FileLength; i++) - { - if (Table[i] == 0x0A) - { - if (Table[i - 1] != 0x0D) - { - /* The LF does not have a preceding CR, table not corrupted */ - - return (AE_OK); - } - else - { - /* Found a CR/LF pair */ - - Pairs++; - } - i++; - } - } - - if (!Pairs) - { - return (AE_OK); - } - - /* - * Entire table scanned, each CR is part of a CR/LF pair -- - * meaning that the table was treated as a text file somewhere. - * - * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the - * original table are left untouched by the text conversion process -- - * meaning that we cannot simply replace CR/LF pairs with LFs. - */ - AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); - AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs); - AcpiOsPrintf ("Table cannot be repaired!\n"); - return (AE_BAD_VALUE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtReadTable - * - * PARAMETERS: fp - File that contains table - * Table - Return value, buffer with table - * TableLength - Return value, length of table - * - * RETURN: Status - * - * DESCRIPTION: Load the DSDT from the file pointer - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiUtReadTable ( - FILE *fp, - ACPI_TABLE_HEADER **Table, - UINT32 *TableLength) -{ - ACPI_TABLE_HEADER TableHeader; - UINT32 Actual; - ACPI_STATUS Status; - UINT32 FileSize; - BOOLEAN StandardHeader = TRUE; - INT32 Count; - - /* Get the file size */ - - FileSize = CmGetFileSize (fp); - if (FileSize == ACPI_UINT32_MAX) - { - return (AE_ERROR); - } - - if (FileSize < 4) - { - return (AE_BAD_HEADER); - } - - /* Read the signature */ - - fseek (fp, 0, SEEK_SET); - - Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), fp); - if (Count != sizeof (ACPI_TABLE_HEADER)) - { - AcpiOsPrintf ("Could not read the table header\n"); - return (AE_BAD_HEADER); - } - - /* The RSDP table does not have standard ACPI header */ - - if (ACPI_VALIDATE_RSDP_SIG (TableHeader.Signature)) - { - *TableLength = FileSize; - StandardHeader = FALSE; - } - else - { - -#if 0 - /* Validate the table header/length */ - - Status = AcpiTbValidateTableHeader (&TableHeader); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Table header is invalid!\n"); - return (Status); - } -#endif - - /* File size must be at least as long as the Header-specified length */ - - if (TableHeader.Length > FileSize) - { - AcpiOsPrintf ( - "TableHeader length [0x%X] greater than the input file size [0x%X]\n", - TableHeader.Length, FileSize); - -#ifdef ACPI_ASL_COMPILER - AcpiOsPrintf ("File is corrupt or is ASCII text -- " - "it must be a binary file\n"); -#endif - return (AE_BAD_HEADER); - } - -#ifdef ACPI_OBSOLETE_CODE - /* We only support a limited number of table types */ - - if (!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_DSDT) && - !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_PSDT) && - !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_SSDT)) - { - AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", - (char *) TableHeader.Signature); - ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); - return (AE_ERROR); - } -#endif - - *TableLength = TableHeader.Length; - } - - /* Allocate a buffer for the table */ - - *Table = AcpiOsAllocate ((size_t) FileSize); - if (!*Table) - { - AcpiOsPrintf ( - "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", - TableHeader.Signature, *TableLength); - return (AE_NO_MEMORY); - } - - /* Get the rest of the table */ - - fseek (fp, 0, SEEK_SET); - Actual = fread (*Table, 1, (size_t) FileSize, fp); - if (Actual == FileSize) - { - if (StandardHeader) - { - /* Now validate the checksum */ - - Status = AcpiTbVerifyChecksum ((void *) *Table, - ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length); - - if (Status == AE_BAD_CHECKSUM) - { - Status = AcpiUtCheckTextModeCorruption ((UINT8 *) *Table, - FileSize, (*Table)->Length); - return (Status); - } - } - return (AE_OK); - } - - if (Actual > 0) - { - AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", - FileSize, Actual); - return (AE_OK); - } - - AcpiOsPrintf ("Error - could not read the table file\n"); - AcpiOsFree (*Table); - *Table = NULL; - *TableLength = 0; - return (AE_ERROR); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtReadTableFromFile - * - * PARAMETERS: Filename - File where table is located - * Table - Where a pointer to the table is returned - * - * RETURN: Status - * - * DESCRIPTION: Get an ACPI table from a file - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtReadTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **Table) -{ - FILE *File; - UINT32 FileSize; - UINT32 TableLength; - ACPI_STATUS Status = AE_ERROR; - - - /* Open the file, get current size */ - - File = fopen (Filename, "rb"); - if (!File) - { - perror ("Could not open input file"); - return (Status); - } - - FileSize = CmGetFileSize (File); - if (FileSize == ACPI_UINT32_MAX) - { - goto Exit; - } - - /* Get the entire file */ - - fprintf (stderr, "Reading ACPI table from file %10s - Length %.8u (0x%06X)\n", - Filename, FileSize, FileSize); - - Status = AcpiUtReadTable (File, Table, &TableLength); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not get table from the file\n"); - } - -Exit: - fclose(File); - return (Status); -} - -#endif diff --git a/sys/contrib/dev/acpica/components/utilities/utglobal.c b/sys/contrib/dev/acpica/components/utilities/utglobal.c index e027aa1..759780a 100644 --- a/sys/contrib/dev/acpica/components/utilities/utglobal.c +++ b/sys/contrib/dev/acpica/components/utilities/utglobal.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,6 +87,12 @@ const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = }; +/* Hex-to-ascii */ + +const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; +const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; + + /******************************************************************************* * * Namespace globals @@ -179,6 +185,55 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = }; #endif /* !ACPI_REDUCED_HARDWARE */ + +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) + +/* ToPld macro: compile/disassemble strings */ + +const char *AcpiGbl_PldPanelList[] = +{ + "TOP", + "BOTTOM", + "LEFT", + "RIGHT", + "FRONT", + "BACK", + "UNKNOWN", + NULL +}; + +const char *AcpiGbl_PldVerticalPositionList[] = +{ + "UPPER", + "CENTER", + "LOWER", + NULL +}; + +const char *AcpiGbl_PldHorizontalPositionList[] = +{ + "LEFT", + "CENTER", + "RIGHT", + NULL +}; + +const char *AcpiGbl_PldShapeList[] = +{ + "ROUND", + "OVAL", + "SQUARE", + "VERTICALRECTANGLE", + "HORIZONTALRECTANGLE", + "VERTICALTRAPEZOID", + "HORIZONTALTRAPEZOID", + "UNKNOWN", + "CHAMFERED", + NULL +}; +#endif + + /* Public globals */ ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) diff --git a/sys/contrib/dev/acpica/components/utilities/uthex.c b/sys/contrib/dev/acpica/components/utilities/uthex.c index 7eede9d..2bae5c7 100644 --- a/sys/contrib/dev/acpica/components/utilities/uthex.c +++ b/sys/contrib/dev/acpica/components/utilities/uthex.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,7 +50,7 @@ /* Hex to ASCII conversion table */ -static char AcpiGbl_HexToAscii[] = +static const char AcpiGbl_HexToAscii[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' }; diff --git a/sys/contrib/dev/acpica/components/utilities/utids.c b/sys/contrib/dev/acpica/components/utilities/utids.c index 7d31429..4c8a8be 100644 --- a/sys/contrib/dev/acpica/components/utilities/utids.c +++ b/sys/contrib/dev/acpica/components/utilities/utids.c @@ -1,11 +1,11 @@ /****************************************************************************** * - * Module Name: utids - support for device IDs - HID, UID, CID + * Module Name: utids - support for device IDs - HID, UID, CID, SUB, CLS * *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -83,7 +83,7 @@ AcpiUtExecute_HID ( Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -102,7 +102,8 @@ AcpiUtExecute_HID ( /* Allocate a buffer for the HID */ - Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length); + Hid = ACPI_ALLOCATE_ZEROED ( + sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length); if (!Hid) { Status = AE_NO_MEMORY; @@ -121,7 +122,7 @@ AcpiUtExecute_HID ( } else { - ACPI_STRCPY (Hid->String, ObjDesc->String.Pointer); + strcpy (Hid->String, ObjDesc->String.Pointer); } Hid->Length = Length; @@ -139,77 +140,6 @@ Cleanup: /******************************************************************************* * - * FUNCTION: AcpiUtExecute_SUB - * - * PARAMETERS: DeviceNode - Node for the device - * ReturnId - Where the _SUB is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _SUB control method that returns the subsystem - * ID of the device. The _SUB value is always a string containing - * either a valid PNP or ACPI ID. - * - * NOTE: Internal function, no parameter validation - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtExecute_SUB ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID **ReturnId) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_PNP_DEVICE_ID *Sub; - UINT32 Length; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (UtExecute_SUB); - - - Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__SUB, - ACPI_BTYPE_STRING, &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the size of the String to be returned, includes null terminator */ - - Length = ObjDesc->String.Length + 1; - - /* Allocate a buffer for the SUB */ - - Sub = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length); - if (!Sub) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Area for the string starts after PNP_DEVICE_ID struct */ - - Sub->String = ACPI_ADD_PTR (char, Sub, sizeof (ACPI_PNP_DEVICE_ID)); - - /* Simply copy existing string */ - - ACPI_STRCPY (Sub->String, ObjDesc->String.Pointer); - Sub->Length = Length; - *ReturnId = Sub; - - -Cleanup: - - /* On exit, we must delete the return object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * * FUNCTION: AcpiUtExecute_UID * * PARAMETERS: DeviceNode - Node for the device @@ -241,7 +171,7 @@ AcpiUtExecute_UID ( Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -260,7 +190,8 @@ AcpiUtExecute_UID ( /* Allocate a buffer for the UID */ - Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length); + Uid = ACPI_ALLOCATE_ZEROED ( + sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length); if (!Uid) { Status = AE_NO_MEMORY; @@ -279,7 +210,7 @@ AcpiUtExecute_UID ( } else { - ACPI_STRCPY (Uid->String, ObjDesc->String.Pointer); + strcpy (Uid->String, ObjDesc->String.Pointer); } Uid->Length = Length; @@ -341,8 +272,8 @@ AcpiUtExecute_CID ( /* Evaluate the _CID method for this device */ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, - &ObjDesc); + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, + &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -419,14 +350,15 @@ AcpiUtExecute_CID ( { /* Convert the Integer (EISAID) CID to a string */ - AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value); + AcpiExEisaIdToString ( + NextIdString, CidObjects[i]->Integer.Value); Length = ACPI_EISAID_STRING_SIZE; } else /* ACPI_TYPE_STRING */ { /* Copy the String CID from the returned object */ - ACPI_STRCPY (NextIdString, CidObjects[i]->String.Pointer); + strcpy (NextIdString, CidObjects[i]->String.Pointer); Length = CidObjects[i]->String.Length + 1; } @@ -449,3 +381,98 @@ Cleanup: AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_CLS + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the _CLS is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _CLS control method that returns PCI-defined + * class code of the device. The _CLS value is always a package + * containing PCI class information as a list of integers. + * The returned string has format "BBSSPP", where: + * BB = Base-class code + * SS = Sub-class code + * PP = Programming Interface code + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_CLS ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_PNP_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **ClsObjects; + UINT32 Count; + ACPI_PNP_DEVICE_ID *Cls; + UINT32 Length; + ACPI_STATUS Status; + UINT8 ClassCode[3] = {0, 0, 0}; + + + ACPI_FUNCTION_TRACE (UtExecute_CLS); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CLS, + ACPI_BTYPE_PACKAGE, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + Length = ACPI_PCICLS_STRING_SIZE; + ClsObjects = ObjDesc->Package.Elements; + Count = ObjDesc->Package.Count; + + if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + if (Count > 0 && ClsObjects[0]->Common.Type == ACPI_TYPE_INTEGER) + { + ClassCode[0] = (UINT8) ClsObjects[0]->Integer.Value; + } + if (Count > 1 && ClsObjects[1]->Common.Type == ACPI_TYPE_INTEGER) + { + ClassCode[1] = (UINT8) ClsObjects[1]->Integer.Value; + } + if (Count > 2 && ClsObjects[2]->Common.Type == ACPI_TYPE_INTEGER) + { + ClassCode[2] = (UINT8) ClsObjects[2]->Integer.Value; + } + } + + /* Allocate a buffer for the CLS */ + + Cls = ACPI_ALLOCATE_ZEROED ( + sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Cls) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after PNP_DEVICE_ID struct */ + + Cls->String = ACPI_ADD_PTR (char, Cls, sizeof (ACPI_PNP_DEVICE_ID)); + + /* Simply copy existing string */ + + AcpiExPciClsToString (Cls->String, ClassCode); + Cls->Length = Length; + *ReturnId = Cls; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/components/utilities/utinit.c b/sys/contrib/dev/acpica/components/utilities/utinit.c index fd7fba2..a33c4bc 100644 --- a/sys/contrib/dev/acpica/components/utilities/utinit.c +++ b/sys/contrib/dev/acpica/components/utilities/utinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -224,11 +224,9 @@ AcpiUtInitGlobals ( AcpiGbl_AcpiHardwarePresent = TRUE; AcpiGbl_LastOwnerIdIndex = 0; AcpiGbl_NextOwnerIdOffset = 0; - AcpiGbl_TraceDbgLevel = 0; - AcpiGbl_TraceDbgLayer = 0; AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; AcpiGbl_OsiMutex = NULL; - AcpiGbl_RegMethodsExecuted = FALSE; + AcpiGbl_MaxLoopIterations = 0xFFFF; /* Hardware oriented */ @@ -263,8 +261,6 @@ AcpiUtInitGlobals ( AcpiGbl_DisableMemTracking = FALSE; #endif - ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = FALSE); - return_ACPI_STATUS (AE_OK); } @@ -313,6 +309,20 @@ AcpiUtSubsystemShutdown ( ACPI_FUNCTION_TRACE (UtSubsystemShutdown); + /* Just exit if subsystem is already shutdown */ + + if (AcpiGbl_Shutdown) + { + ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated")); + return_VOID; + } + + /* Subsystem appears active, go ahead and shut it down */ + + AcpiGbl_Shutdown = TRUE; + AcpiGbl_StartupFlags = 0; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); + #ifndef ACPI_ASL_COMPILER /* Close the AcpiEvent Handling */ diff --git a/sys/contrib/dev/acpica/components/utilities/utlock.c b/sys/contrib/dev/acpica/components/utilities/utlock.c index 3903e99..39d1808 100644 --- a/sys/contrib/dev/acpica/components/utilities/utlock.c +++ b/sys/contrib/dev/acpica/components/utilities/utlock.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/utilities/utmath.c b/sys/contrib/dev/acpica/components/utilities/utmath.c index ce11f39..788e330 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmath.c +++ b/sys/contrib/dev/acpica/components/utilities/utmath.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -122,9 +122,10 @@ AcpiUtShortDivide ( * and is generated by the second divide. */ ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor, - Quotient.Part.Hi, Remainder32); + Quotient.Part.Hi, Remainder32); + ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor, - Quotient.Part.Lo, Remainder32); + Quotient.Part.Lo, Remainder32); /* Return only what was requested */ @@ -200,9 +201,10 @@ AcpiUtDivide ( * and is generated by the second divide. */ ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor.Part.Lo, - Quotient.Part.Hi, Partial1); + Quotient.Part.Hi, Partial1); + ACPI_DIV_64_BY_32 (Partial1, Dividend.Part.Lo, Divisor.Part.Lo, - Quotient.Part.Lo, Remainder.Part.Lo); + Quotient.Part.Lo, Remainder.Part.Lo); } else @@ -219,25 +221,24 @@ AcpiUtDivide ( do { - ACPI_SHIFT_RIGHT_64 (NormalizedDivisor.Part.Hi, - NormalizedDivisor.Part.Lo); - ACPI_SHIFT_RIGHT_64 (NormalizedDividend.Part.Hi, - NormalizedDividend.Part.Lo); + ACPI_SHIFT_RIGHT_64 ( + NormalizedDivisor.Part.Hi, NormalizedDivisor.Part.Lo); + ACPI_SHIFT_RIGHT_64 ( + NormalizedDividend.Part.Hi, NormalizedDividend.Part.Lo); } while (NormalizedDivisor.Part.Hi != 0); /* Partial divide */ - ACPI_DIV_64_BY_32 (NormalizedDividend.Part.Hi, - NormalizedDividend.Part.Lo, - NormalizedDivisor.Part.Lo, - Quotient.Part.Lo, Partial1); + ACPI_DIV_64_BY_32 ( + NormalizedDividend.Part.Hi, NormalizedDividend.Part.Lo, + NormalizedDivisor.Part.Lo, Quotient.Part.Lo, Partial1); /* - * The quotient is always 32 bits, and simply requires adjustment. - * The 64-bit remainder must be generated. + * The quotient is always 32 bits, and simply requires + * adjustment. The 64-bit remainder must be generated. */ - Partial1 = Quotient.Part.Lo * Divisor.Part.Hi; + Partial1 = Quotient.Part.Lo * Divisor.Part.Hi; Partial2.Full = (UINT64) Quotient.Part.Lo * Divisor.Part.Lo; Partial3.Full = (UINT64) Partial2.Part.Hi + Partial1; @@ -263,7 +264,7 @@ AcpiUtDivide ( } } - Remainder.Full = Remainder.Full - Dividend.Full; + Remainder.Full = Remainder.Full - Dividend.Full; Remainder.Part.Hi = (UINT32) -((INT32) Remainder.Part.Hi); Remainder.Part.Lo = (UINT32) -((INT32) Remainder.Part.Lo); diff --git a/sys/contrib/dev/acpica/components/utilities/utmisc.c b/sys/contrib/dev/acpica/components/utilities/utmisc.c index f3d2222..13d920f 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmisc.c +++ b/sys/contrib/dev/acpica/components/utilities/utmisc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,11 +71,11 @@ AcpiUtIsPciRootBridge ( * Check if this is a PCI root bridge. * ACPI 3.0+: check for a PCI Express root also. */ - if (!(ACPI_STRCMP (Id, - PCI_ROOT_HID_STRING)) || + if (!(strcmp (Id, + PCI_ROOT_HID_STRING)) || - !(ACPI_STRCMP (Id, - PCI_EXPRESS_ROOT_HID_STRING))) + !(strcmp (Id, + PCI_EXPRESS_ROOT_HID_STRING))) { return (TRUE); } @@ -84,7 +84,7 @@ AcpiUtIsPciRootBridge ( } -#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP) +#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP) /******************************************************************************* * * FUNCTION: AcpiUtIsAmlTable @@ -108,7 +108,8 @@ AcpiUtIsAmlTable ( if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) || ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) || - ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT) || + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_OSDT)) { return (TRUE); } @@ -184,17 +185,17 @@ AcpiUtSetIntegerWidth ( { /* 32-bit case */ - AcpiGbl_IntegerBitWidth = 32; + AcpiGbl_IntegerBitWidth = 32; AcpiGbl_IntegerNybbleWidth = 8; - AcpiGbl_IntegerByteWidth = 4; + AcpiGbl_IntegerByteWidth = 4; } else { /* 64-bit case (ACPI 2.0+) */ - AcpiGbl_IntegerBitWidth = 64; + AcpiGbl_IntegerBitWidth = 64; AcpiGbl_IntegerNybbleWidth = 16; - AcpiGbl_IntegerByteWidth = 8; + AcpiGbl_IntegerByteWidth = 8; } } @@ -285,9 +286,9 @@ AcpiUtWalkPackageTree ( { /* Get one element of the package */ - ThisIndex = State->Pkg.Index; + ThisIndex = State->Pkg.Index; ThisSourceObj = (ACPI_OPERAND_OBJECT *) - State->Pkg.SourceObject->Package.Elements[ThisIndex]; + State->Pkg.SourceObject->Package.Elements[ThisIndex]; /* * Check for: @@ -298,7 +299,8 @@ AcpiUtWalkPackageTree ( * case below. */ if ((!ThisSourceObj) || - (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || + (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != + ACPI_DESC_TYPE_OPERAND) || (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE)) { Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, @@ -309,7 +311,8 @@ AcpiUtWalkPackageTree ( } State->Pkg.Index++; - while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) + while (State->Pkg.Index >= + State->Pkg.SourceObject->Package.Count) { /* * We've handled all of the objects at this level, This means @@ -344,8 +347,8 @@ AcpiUtWalkPackageTree ( { /* This is a subobject of type package */ - Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, - State, Context); + Status = WalkCallback ( + ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, State, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -356,8 +359,8 @@ AcpiUtWalkPackageTree ( * The callback above returned a new target package object. */ AcpiUtPushGenericState (&StateList, State); - State = AcpiUtCreatePkgState (ThisSourceObj, - State->Pkg.ThisTargetObj, 0); + State = AcpiUtCreatePkgState ( + ThisSourceObj, State->Pkg.ThisTargetObj, 0); if (!State) { /* Free any stacked Update State objects */ @@ -398,7 +401,7 @@ void AcpiUtDisplayInitPathname ( UINT8 Type, ACPI_NAMESPACE_NODE *ObjHandle, - char *Path) + const char *Path) { ACPI_STATUS Status; ACPI_BUFFER Buffer; @@ -417,7 +420,7 @@ AcpiUtDisplayInitPathname ( /* Get the full pathname to the node */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); if (ACPI_FAILURE (Status)) { return; diff --git a/sys/contrib/dev/acpica/components/utilities/utmutex.c b/sys/contrib/dev/acpica/components/utilities/utmutex.c index c7b162b..7f25642 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmutex.c +++ b/sys/contrib/dev/acpica/components/utilities/utmutex.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,6 +124,24 @@ AcpiUtMutexInitialize ( /* Create the reader/writer lock for namespace access */ Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + +#ifdef ACPI_DEBUGGER + + /* Debugger Support */ + + Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete); +#endif + return_ACPI_STATUS (Status); } @@ -169,6 +187,12 @@ AcpiUtMutexTerminate ( /* Delete the reader/writer lock */ AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock); + +#ifdef ACPI_DEBUGGER + AcpiOsDeleteMutex (AcpiGbl_DbCommandReady); + AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete); +#endif + return_VOID; } @@ -305,11 +329,12 @@ AcpiUtAcquireMutex ( "Thread %u attempting to acquire Mutex [%s]\n", (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId))); - Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex, - ACPI_WAIT_FOREVER); + Status = AcpiOsAcquireMutex ( + AcpiGbl_MutexInfo[MutexId].Mutex, ACPI_WAIT_FOREVER); if (ACPI_SUCCESS (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u acquired Mutex [%s]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %u acquired Mutex [%s]\n", (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId))); AcpiGbl_MutexInfo[MutexId].UseCount++; diff --git a/sys/contrib/dev/acpica/components/utilities/utnonansi.c b/sys/contrib/dev/acpica/components/utilities/utnonansi.c new file mode 100644 index 0000000..ca6bc7a --- /dev/null +++ b/sys/contrib/dev/acpica/components/utilities/utnonansi.c @@ -0,0 +1,667 @@ +/******************************************************************************* + * + * Module Name: utnonansi - Non-ansi C library functions + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utnonansi") + + +/* + * Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit + * version of strtoul. + */ + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrlwr (strlwr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert a string to lowercase + * + ******************************************************************************/ + +void +AcpiUtStrlwr ( + char *SrcString) +{ + char *String; + + + ACPI_FUNCTION_ENTRY (); + + + if (!SrcString) + { + return; + } + + /* Walk entire string, lowercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) tolower ((int) *String); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrupr (strupr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert a string to uppercase + * + ******************************************************************************/ + +void +AcpiUtStrupr ( + char *SrcString) +{ + char *String; + + + ACPI_FUNCTION_ENTRY (); + + + if (!SrcString) + { + return; + } + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) toupper ((int) *String); + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiUtStricmp (stricmp) + * + * PARAMETERS: String1 - first string to compare + * String2 - second string to compare + * + * RETURN: int that signifies string relationship. Zero means strings + * are equal. + * + * DESCRIPTION: Case-insensitive string compare. Implementation of the + * non-ANSI stricmp function. + * + ******************************************************************************/ + +int +AcpiUtStricmp ( + char *String1, + char *String2) +{ + int c1; + int c2; + + + do + { + c1 = tolower ((int) *String1); + c2 = tolower ((int) *String2); + + String1++; + String2++; + } + while ((c1 == c2) && (c1)); + + return (c1 - c2); +} + + +#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) +/******************************************************************************* + * + * FUNCTION: AcpiUtSafeStrcpy, AcpiUtSafeStrcat, AcpiUtSafeStrncat + * + * PARAMETERS: Adds a "DestSize" parameter to each of the standard string + * functions. This is the size of the Destination buffer. + * + * RETURN: TRUE if the operation would overflow the destination buffer. + * + * DESCRIPTION: Safe versions of standard Clib string functions. Ensure that + * the result of the operation will not overflow the output string + * buffer. + * + * NOTE: These functions are typically only helpful for processing + * user input and command lines. For most ACPICA code, the + * required buffer length is precisely calculated before buffer + * allocation, so the use of these functions is unnecessary. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtSafeStrcpy ( + char *Dest, + ACPI_SIZE DestSize, + char *Source) +{ + + if (strlen (Source) >= DestSize) + { + return (TRUE); + } + + strcpy (Dest, Source); + return (FALSE); +} + +BOOLEAN +AcpiUtSafeStrcat ( + char *Dest, + ACPI_SIZE DestSize, + char *Source) +{ + + if ((strlen (Dest) + strlen (Source)) >= DestSize) + { + return (TRUE); + } + + strcat (Dest, Source); + return (FALSE); +} + +BOOLEAN +AcpiUtSafeStrncat ( + char *Dest, + ACPI_SIZE DestSize, + char *Source, + ACPI_SIZE MaxTransferLength) +{ + ACPI_SIZE ActualTransferLength; + + + ActualTransferLength = ACPI_MIN (MaxTransferLength, strlen (Source)); + + if ((strlen (Dest) + ActualTransferLength) >= DestSize) + { + return (TRUE); + } + + strncat (Dest, Source, MaxTransferLength); + return (FALSE); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul64 + * + * PARAMETERS: String - Null terminated string + * Base - Radix of the string: 16 or 10 or + * ACPI_ANY_BASE + * MaxIntegerByteWidth - Maximum allowable integer,in bytes: + * 4 or 8 (32 or 64 bits) + * RetInteger - Where the converted integer is + * returned + * + * RETURN: Status and Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. Performs either a + * 32-bit or 64-bit conversion, depending on the input integer + * size (often the current mode of the interpreter). + * + * NOTES: Negative numbers are not supported, as they are not supported + * by ACPI. + * + * AcpiGbl_IntegerByteWidth should be set to the proper width. + * For the core ACPICA code, this width depends on the DSDT + * version. For iASL, the default byte width is always 8 for the + * parser, but error checking is performed later to flag cases + * where a 64-bit constant is defined in a 32-bit DSDT/SSDT. + * + * Does not support Octal strings, not needed at this time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Base, + UINT32 MaxIntegerByteWidth, + UINT64 *RetInteger) +{ + UINT32 ThisDigit = 0; + UINT64 ReturnValue = 0; + UINT64 Quotient; + UINT64 Dividend; + UINT8 ValidDigits = 0; + UINT8 SignOf0x = 0; + UINT8 Term = 0; + + + ACPI_FUNCTION_TRACE_STR (UtStrtoul64, String); + + + switch (Base) + { + case ACPI_ANY_BASE: + case 10: + case 16: + + break; + + default: + + /* Invalid Base */ + + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!String) + { + goto ErrorExit; + } + + /* Skip over any white space in the buffer */ + + while ((*String) && (isspace ((int) *String) || *String == '\t')) + { + String++; + } + + if (Base == ACPI_ANY_BASE) + { + /* + * Base equal to ACPI_ANY_BASE means 'Either decimal or hex'. + * We need to determine if it is decimal or hexadecimal. + */ + if ((*String == '0') && (tolower ((int) *(String + 1)) == 'x')) + { + SignOf0x = 1; + Base = 16; + + /* Skip over the leading '0x' */ + String += 2; + } + else + { + Base = 10; + } + } + + /* Any string left? Check that '0x' is not followed by white space. */ + + if (!(*String) || isspace ((int) *String) || *String == '\t') + { + if (Base == ACPI_ANY_BASE) + { + goto ErrorExit; + } + else + { + goto AllDone; + } + } + + /* + * Perform a 32-bit or 64-bit conversion, depending upon the input + * byte width + */ + Dividend = (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH) ? + ACPI_UINT32_MAX : ACPI_UINT64_MAX; + + /* Main loop: convert the string to a 32- or 64-bit integer */ + + while (*String) + { + if (isdigit ((int) *String)) + { + /* Convert ASCII 0-9 to Decimal value */ + + ThisDigit = ((UINT8) *String) - '0'; + } + else if (Base == 10) + { + /* Digit is out of range; possible in ToInteger case only */ + + Term = 1; + } + else + { + ThisDigit = (UINT8) toupper ((int) *String); + if (isxdigit ((int) ThisDigit)) + { + /* Convert ASCII Hex char to value */ + + ThisDigit = ThisDigit - 'A' + 10; + } + else + { + Term = 1; + } + } + + if (Term) + { + if (Base == ACPI_ANY_BASE) + { + goto ErrorExit; + } + else + { + break; + } + } + else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) + { + /* Skip zeros */ + String++; + continue; + } + + ValidDigits++; + + if (SignOf0x && ((ValidDigits > 16) || + ((ValidDigits > 8) && (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH)))) + { + /* + * This is ToInteger operation case. + * No restrictions for string-to-integer conversion, + * see ACPI spec. + */ + goto ErrorExit; + } + + /* Divide the digit into the correct position */ + + (void) AcpiUtShortDivide ( + (Dividend - (UINT64) ThisDigit), Base, &Quotient, NULL); + + if (ReturnValue > Quotient) + { + if (Base == ACPI_ANY_BASE) + { + goto ErrorExit; + } + else + { + break; + } + } + + ReturnValue *= Base; + ReturnValue += ThisDigit; + String++; + } + + /* All done, normal exit */ + +AllDone: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ReturnValue))); + + *RetInteger = ReturnValue; + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + + /* Base was set/validated above (10 or 16) */ + + if (Base == 10) + { + return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); + } + else + { + return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); + } +} + + +#ifdef _OBSOLETE_FUNCTIONS +/* Removed: 01/2016 */ + +/******************************************************************************* + * + * FUNCTION: strtoul64 + * + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte + * is returned + * Base - Radix of the string + * + * RETURN: Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. + * + ******************************************************************************/ + +ACPI_STATUS +strtoul64 ( + char *String, + UINT32 Base, + UINT64 *RetInteger) +{ + UINT32 Index; + UINT32 Sign; + UINT64 ReturnValue = 0; + ACPI_STATUS Status = AE_OK; + + + *RetInteger = 0; + + switch (Base) + { + case 0: + case 8: + case 10: + case 16: + + break; + + default: + /* + * The specified Base parameter is not in the domain of + * this function: + */ + return (AE_BAD_PARAMETER); + } + + /* Skip over any white space in the buffer: */ + + while (isspace ((int) *String) || *String == '\t') + { + ++String; + } + + /* + * The buffer may contain an optional plus or minus sign. + * If it does, then skip over it but remember what is was: + */ + if (*String == '-') + { + Sign = ACPI_SIGN_NEGATIVE; + ++String; + } + else if (*String == '+') + { + ++String; + Sign = ACPI_SIGN_POSITIVE; + } + else + { + Sign = ACPI_SIGN_POSITIVE; + } + + /* + * If the input parameter Base is zero, then we need to + * determine if it is octal, decimal, or hexadecimal: + */ + if (Base == 0) + { + if (*String == '0') + { + if (tolower ((int) *(++String)) == 'x') + { + Base = 16; + ++String; + } + else + { + Base = 8; + } + } + else + { + Base = 10; + } + } + + /* + * For octal and hexadecimal bases, skip over the leading + * 0 or 0x, if they are present. + */ + if (Base == 8 && *String == '0') + { + String++; + } + + if (Base == 16 && + *String == '0' && + tolower ((int) *(++String)) == 'x') + { + String++; + } + + /* Main loop: convert the string to an unsigned long */ + + while (*String) + { + if (isdigit ((int) *String)) + { + Index = ((UINT8) *String) - '0'; + } + else + { + Index = (UINT8) toupper ((int) *String); + if (isupper ((int) Index)) + { + Index = Index - 'A' + 10; + } + else + { + goto ErrorExit; + } + } + + if (Index >= Base) + { + goto ErrorExit; + } + + /* Check to see if value is out of range: */ + + if (ReturnValue > ((ACPI_UINT64_MAX - (UINT64) Index) / + (UINT64) Base)) + { + goto ErrorExit; + } + else + { + ReturnValue *= Base; + ReturnValue += Index; + } + + ++String; + } + + + /* If a minus sign was present, then "the conversion is negated": */ + + if (Sign == ACPI_SIGN_NEGATIVE) + { + ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + } + + *RetInteger = ReturnValue; + return (Status); + + +ErrorExit: + switch (Base) + { + case 8: + + Status = AE_BAD_OCTAL_CONSTANT; + break; + + case 10: + + Status = AE_BAD_DECIMAL_CONSTANT; + break; + + case 16: + + Status = AE_BAD_HEX_CONSTANT; + break; + + default: + + /* Base validated above */ + + break; + } + + return (Status); +} +#endif diff --git a/sys/contrib/dev/acpica/components/utilities/utobject.c b/sys/contrib/dev/acpica/components/utilities/utobject.c index 4c80c40..656568a 100644 --- a/sys/contrib/dev/acpica/components/utilities/utobject.c +++ b/sys/contrib/dev/acpica/components/utilities/utobject.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -107,7 +107,8 @@ AcpiUtCreateInternalObjectDbg ( /* Allocate the raw object descriptor */ - Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); + Object = AcpiUtAllocateObjectDescDbg ( + ModuleName, LineNumber, ComponentId); if (!Object) { return_PTR (NULL); @@ -121,8 +122,8 @@ AcpiUtCreateInternalObjectDbg ( /* These types require a secondary object */ - SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, - LineNumber, ComponentId); + SecondObject = AcpiUtAllocateObjectDescDbg ( + ModuleName, LineNumber, ComponentId); if (!SecondObject) { AcpiUtDeleteObjectDesc (Object); @@ -193,7 +194,7 @@ AcpiUtCreatePackageObject ( * terminated. */ PackageElements = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) Count + 1) * sizeof (void *)); + ((ACPI_SIZE) Count + 1) * sizeof (void *)); if (!PackageElements) { ACPI_FREE (PackageDesc); @@ -283,6 +284,7 @@ AcpiUtCreateBufferObject ( { ACPI_ERROR ((AE_INFO, "Could not allocate size %u", (UINT32) BufferSize)); + AcpiUtRemoveReference (BufferDesc); return_PTR (NULL); } @@ -342,6 +344,7 @@ AcpiUtCreateStringObject ( { ACPI_ERROR ((AE_INFO, "Could not allocate size %u", (UINT32) StringSize)); + AcpiUtRemoveReference (StringDesc); return_PTR (NULL); } @@ -398,8 +401,8 @@ AcpiUtValidInternalObject ( default: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%p is not an ACPI operand obj [%s]\n", - Object, AcpiUtGetDescriptorName (Object))); + "%p is not an ACPI operand obj [%s]\n", + Object, AcpiUtGetDescriptorName (Object))); break; } @@ -448,7 +451,7 @@ AcpiUtAllocateObjectDescDbg ( ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", - Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT))); + Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT))); return_PTR (Object); } @@ -711,12 +714,12 @@ AcpiUtGetPackageObjectSize ( ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject); - Info.Length = 0; + Info.Length = 0; Info.ObjectSpace = 0; Info.NumPackages = 1; - Status = AcpiUtWalkPackageTree (InternalObject, NULL, - AcpiUtGetElementLength, &Info); + Status = AcpiUtWalkPackageTree ( + InternalObject, NULL, AcpiUtGetElementLength, &Info); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -727,8 +730,8 @@ AcpiUtGetPackageObjectSize ( * just add the length of the package objects themselves. * Round up to the next machine word. */ - Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * - (ACPI_SIZE) Info.NumPackages; + Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD ( + sizeof (ACPI_OBJECT)) * (ACPI_SIZE) Info.NumPackages; /* Return the total package length */ @@ -762,7 +765,8 @@ AcpiUtGetObjectSize ( ACPI_FUNCTION_ENTRY (); - if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) && + if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == + ACPI_DESC_TYPE_OPERAND) && (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)) { Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength); diff --git a/sys/contrib/dev/acpica/components/utilities/utosi.c b/sys/contrib/dev/acpica/components/utilities/utosi.c index bf6ba86..2a9fa79 100644 --- a/sys/contrib/dev/acpica/components/utilities/utosi.c +++ b/sys/contrib/dev/acpica/components/utilities/utosi.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -156,7 +156,9 @@ AcpiUtInitializeInterfaces ( /* Link the static list of supported interfaces */ - for (i = 0; i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); i++) + for (i = 0; + i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); + i++) { AcpiDefaultSupportedInterfaces[i].Next = &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1]; @@ -256,7 +258,7 @@ AcpiUtInstallInterface ( return (AE_NO_MEMORY); } - InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1); + InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (strlen (InterfaceName) + 1); if (!InterfaceInfo->Name) { ACPI_FREE (InterfaceInfo); @@ -265,7 +267,7 @@ AcpiUtInstallInterface ( /* Initialize new info and insert at the head of the global list */ - ACPI_STRCPY (InterfaceInfo->Name, InterfaceName); + strcpy (InterfaceInfo->Name, InterfaceName); InterfaceInfo->Flags = ACPI_OSI_DYNAMIC; InterfaceInfo->Next = AcpiGbl_SupportedInterfaces; @@ -298,10 +300,12 @@ AcpiUtRemoveInterface ( PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces; while (NextInterface) { - if (!ACPI_STRCMP (InterfaceName, NextInterface->Name)) + if (!strcmp (InterfaceName, NextInterface->Name)) { - /* Found: name is in either the static list or was added at runtime */ - + /* + * Found: name is in either the static list + * or was added at runtime + */ if (NextInterface->Flags & ACPI_OSI_DYNAMIC) { /* Interface was added dynamically, remove and free it */ @@ -321,8 +325,8 @@ AcpiUtRemoveInterface ( else { /* - * Interface is in static list. If marked invalid, then it - * does not actually exist. Else, mark it invalid. + * Interface is in static list. If marked invalid, then + * it does not actually exist. Else, mark it invalid. */ if (NextInterface->Flags & ACPI_OSI_INVALID) { @@ -419,7 +423,7 @@ AcpiUtGetInterface ( NextInterface = AcpiGbl_SupportedInterfaces; while (NextInterface) { - if (!ACPI_STRCMP (InterfaceName, NextInterface->Name)) + if (!strcmp (InterfaceName, NextInterface->Name)) { return (NextInterface); } diff --git a/sys/contrib/dev/acpica/components/utilities/utownerid.c b/sys/contrib/dev/acpica/components/utilities/utownerid.c index 34c0024..0c57dba 100644 --- a/sys/contrib/dev/acpica/components/utilities/utownerid.c +++ b/sys/contrib/dev/acpica/components/utilities/utownerid.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,7 +81,8 @@ AcpiUtAllocateOwnerId ( if (*OwnerId) { - ACPI_ERROR ((AE_INFO, "Owner ID [0x%2.2X] already exists", *OwnerId)); + ACPI_ERROR ((AE_INFO, + "Owner ID [0x%2.2X] already exists", *OwnerId)); return_ACPI_STATUS (AE_ALREADY_EXISTS); } @@ -95,8 +96,8 @@ AcpiUtAllocateOwnerId ( /* * Find a free owner ID, cycle through all possible IDs on repeated - * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have - * to be scanned twice. + * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index + * may have to be scanned twice. */ for (i = 0, j = AcpiGbl_LastOwnerIdIndex; i < (ACPI_NUM_OWNERID_MASKS + 1); @@ -152,8 +153,8 @@ AcpiUtAllocateOwnerId ( * they are released when a table is unloaded or a method completes * execution. * - * If this error happens, there may be very deep nesting of invoked control - * methods, or there may be a bug where the IDs are not released. + * If this error happens, there may be very deep nesting of invoked + * control methods, or there may be a bug where the IDs are not released. */ Status = AE_OWNER_ID_LIMIT; ACPI_ERROR ((AE_INFO, diff --git a/sys/contrib/dev/acpica/components/utilities/utpredef.c b/sys/contrib/dev/acpica/components/utilities/utpredef.c index a445f85..496b900 100644 --- a/sys/contrib/dev/acpica/components/utilities/utpredef.c +++ b/sys/contrib/dev/acpica/components/utilities/utpredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -166,7 +166,7 @@ AcpiUtGetExpectedReturnTypes ( if (!ExpectedBtypes) { - ACPI_STRCPY (Buffer, "NONE"); + strcpy (Buffer, "NONE"); return; } @@ -180,7 +180,7 @@ AcpiUtGetExpectedReturnTypes ( if (ExpectedBtypes & ThisRtype) { - ACPI_STRCAT (Buffer, &UtRtypeNames[i][j]); + strcat (Buffer, &UtRtypeNames[i][j]); j = 0; /* Use name separator from now on */ } @@ -254,8 +254,10 @@ AcpiUtMatchResourceName ( const ACPI_PREDEFINED_INFO *ThisName; - /* Quick check for a predefined name, first character must be underscore */ - + /* + * Quick check for a predefined name, first character must + * be underscore + */ if (Name[0] != '_') { return (NULL); diff --git a/sys/contrib/dev/acpica/components/utilities/utprint.c b/sys/contrib/dev/acpica/components/utilities/utprint.c index 62aecf0..910a2b7 100644 --- a/sys/contrib/dev/acpica/components/utilities/utprint.c +++ b/sys/contrib/dev/acpica/components/utilities/utprint.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,12 +88,6 @@ AcpiUtPutNumber ( BOOLEAN Upper); -/* Module globals */ - -static const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; -static const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; - - /******************************************************************************* * * FUNCTION: AcpiUtBoundStringLength @@ -227,7 +221,7 @@ AcpiUtScanNumber ( UINT64 Number = 0; - while (ACPI_IS_DIGIT (*String)) + while (isdigit ((int) *String)) { Number *= 10; Number += *(String++) - '0'; @@ -390,8 +384,8 @@ AcpiUtFormatNumber ( String = AcpiUtBoundStringOutput (String, End, '0'); if (Base == 16) { - String = AcpiUtBoundStringOutput (String, End, - Upper ? 'X' : 'x'); + String = AcpiUtBoundStringOutput ( + String, End, Upper ? 'X' : 'x'); } } if (!(Type & ACPI_FORMAT_LEFT)) @@ -500,12 +494,13 @@ AcpiUtVsnprintf ( { break; } + } while (1); /* Process width */ Width = -1; - if (ACPI_IS_DIGIT (*Format)) + if (isdigit ((int) *Format)) { Format = AcpiUtScanNumber (Format, &Number); Width = (INT32) Number; @@ -527,7 +522,7 @@ AcpiUtVsnprintf ( if (*Format == '.') { ++Format; - if (ACPI_IS_DIGIT(*Format)) + if (isdigit ((int) *Format)) { Format = AcpiUtScanNumber (Format, &Number); Precision = (INT32) Number; @@ -537,6 +532,7 @@ AcpiUtVsnprintf ( ++Format; Precision = va_arg (Args, int); } + if (Precision < 0) { Precision = 0; @@ -599,11 +595,13 @@ AcpiUtVsnprintf ( Pos = AcpiUtBoundStringOutput (Pos, End, ' '); } } + for (i = 0; i < Length; ++i) { Pos = AcpiUtBoundStringOutput (Pos, End, *s); ++s; } + while (Length < Width--) { Pos = AcpiUtBoundStringOutput (Pos, End, ' '); @@ -642,8 +640,8 @@ AcpiUtVsnprintf ( } p = va_arg (Args, void *); - Pos = AcpiUtFormatNumber (Pos, End, - ACPI_TO_INTEGER (p), 16, Width, Precision, Type); + Pos = AcpiUtFormatNumber ( + Pos, End, ACPI_TO_INTEGER (p), 16, Width, Precision, Type); continue; default: @@ -694,7 +692,7 @@ AcpiUtVsnprintf ( } Pos = AcpiUtFormatNumber (Pos, End, Number, Base, - Width, Precision, Type); + Width, Precision, Type); } if (Size > 0) @@ -773,7 +771,7 @@ AcpiUtFileVprintf ( Flags = AcpiOsAcquireLock (AcpiGbl_PrintLock); Length = AcpiUtVsnprintf (AcpiGbl_PrintBuffer, - sizeof (AcpiGbl_PrintBuffer), Format, Args); + sizeof (AcpiGbl_PrintBuffer), Format, Args); (void) AcpiOsWriteFile (File, AcpiGbl_PrintBuffer, Length, 1); AcpiOsReleaseLock (AcpiGbl_PrintLock, Flags); diff --git a/sys/contrib/dev/acpica/components/utilities/utresrc.c b/sys/contrib/dev/acpica/components/utilities/utresrc.c index 65b23f1..72ebf65 100644 --- a/sys/contrib/dev/acpica/components/utilities/utresrc.c +++ b/sys/contrib/dev/acpica/components/utilities/utresrc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -489,8 +489,8 @@ AcpiUtWalkAmlResources ( if (ACPI_FAILURE (Status)) { /* - * Exit on failure. Cannot continue because the descriptor length - * may be bogus also. + * Exit on failure. Cannot continue because the descriptor + * length may be bogus also. */ return_ACPI_STATUS (Status); } @@ -503,7 +503,8 @@ AcpiUtWalkAmlResources ( if (UserFunction) { - Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context); + Status = UserFunction ( + Aml, Length, Offset, ResourceIndex, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -625,8 +626,8 @@ AcpiUtValidateResource ( } /* - * Check validity of the resource type, via AcpiGbl_ResourceTypes. Zero - * indicates an invalid resource. + * Check validity of the resource type, via AcpiGbl_ResourceTypes. + * Zero indicates an invalid resource. */ if (!AcpiGbl_ResourceTypes[ResourceIndex]) { @@ -813,7 +814,7 @@ AcpiUtGetResourceLength ( /* Small Resource type -- bits 2:0 of byte 0 contain the length */ ResourceLength = (UINT16) (ACPI_GET8 (Aml) & - ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); } return (ResourceLength); @@ -878,7 +879,7 @@ AcpiUtGetDescriptorLength ( * the header length (depends on if this is a small or large resource) */ return (AcpiUtGetResourceLength (Aml) + - AcpiUtGetResourceHeaderLength (Aml)); + AcpiUtGetResourceHeaderLength (Aml)); } @@ -918,7 +919,7 @@ AcpiUtGetResourceEndTag ( /* Validate the template and get a pointer to the EndTag */ Status = AcpiUtWalkAmlResources (NULL, ObjDesc->Buffer.Pointer, - ObjDesc->Buffer.Length, NULL, (void **) EndTag); + ObjDesc->Buffer.Length, NULL, (void **) EndTag); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/utilities/utstate.c b/sys/contrib/dev/acpica/components/utilities/utstate.c index 3396319..55778e0 100644 --- a/sys/contrib/dev/acpica/components/utilities/utstate.c +++ b/sys/contrib/dev/acpica/components/utilities/utstate.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -278,6 +278,7 @@ AcpiUtCreatePkgState ( State->Pkg.DestObject = ExternalObject; State->Pkg.Index= Index; State->Pkg.NumPackages = 1; + return (State); } @@ -317,6 +318,7 @@ AcpiUtCreateControlState ( State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_CONTROL; State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + return (State); } @@ -347,5 +349,6 @@ AcpiUtDeleteGenericState ( { (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); } + return; } diff --git a/sys/contrib/dev/acpica/components/utilities/utstring.c b/sys/contrib/dev/acpica/components/utilities/utstring.c index 4cbf435..3d02b6c 100644 --- a/sys/contrib/dev/acpica/components/utilities/utstring.c +++ b/sys/contrib/dev/acpica/components/utilities/utstring.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,343 +50,6 @@ ACPI_MODULE_NAME ("utstring") -/* - * Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit - * version of strtoul. - */ - -#ifdef ACPI_ASL_COMPILER -/******************************************************************************* - * - * FUNCTION: AcpiUtStrlwr (strlwr) - * - * PARAMETERS: SrcString - The source string to convert - * - * RETURN: None - * - * DESCRIPTION: Convert string to lowercase - * - * NOTE: This is not a POSIX function, so it appears here, not in utclib.c - * - ******************************************************************************/ - -void -AcpiUtStrlwr ( - char *SrcString) -{ - char *String; - - - ACPI_FUNCTION_ENTRY (); - - - if (!SrcString) - { - return; - } - - /* Walk entire string, lowercasing the letters */ - - for (String = SrcString; *String; String++) - { - *String = (char) ACPI_TOLOWER (*String); - } - - return; -} - - -/****************************************************************************** - * - * FUNCTION: AcpiUtStricmp (stricmp) - * - * PARAMETERS: String1 - first string to compare - * String2 - second string to compare - * - * RETURN: int that signifies string relationship. Zero means strings - * are equal. - * - * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare - * strings with no case sensitivity) - * - ******************************************************************************/ - -int -AcpiUtStricmp ( - char *String1, - char *String2) -{ - int c1; - int c2; - - - do - { - c1 = tolower ((int) *String1); - c2 = tolower ((int) *String2); - - String1++; - String2++; - } - while ((c1 == c2) && (c1)); - - return (c1 - c2); -} -#endif - - -/******************************************************************************* - * - * FUNCTION: AcpiUtStrupr (strupr) - * - * PARAMETERS: SrcString - The source string to convert - * - * RETURN: None - * - * DESCRIPTION: Convert string to uppercase - * - * NOTE: This is not a POSIX function, so it appears here, not in utclib.c - * - ******************************************************************************/ - -void -AcpiUtStrupr ( - char *SrcString) -{ - char *String; - - - ACPI_FUNCTION_ENTRY (); - - - if (!SrcString) - { - return; - } - - /* Walk entire string, uppercasing the letters */ - - for (String = SrcString; *String; String++) - { - *String = (char) ACPI_TOUPPER (*String); - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtStrtoul64 - * - * PARAMETERS: String - Null terminated string - * Base - Radix of the string: 16 or ACPI_ANY_BASE; - * ACPI_ANY_BASE means 'in behalf of ToInteger' - * RetInteger - Where the converted integer is returned - * - * RETURN: Status and Converted value - * - * DESCRIPTION: Convert a string into an unsigned value. Performs either a - * 32-bit or 64-bit conversion, depending on the current mode - * of the interpreter. - * NOTE: Does not support Octal strings, not needed. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtStrtoul64 ( - char *String, - UINT32 Base, - UINT64 *RetInteger) -{ - UINT32 ThisDigit = 0; - UINT64 ReturnValue = 0; - UINT64 Quotient; - UINT64 Dividend; - UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); - UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); - UINT8 ValidDigits = 0; - UINT8 SignOf0x = 0; - UINT8 Term = 0; - - - ACPI_FUNCTION_TRACE_STR (UtStroul64, String); - - - switch (Base) - { - case ACPI_ANY_BASE: - case 16: - - break; - - default: - - /* Invalid Base */ - - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!String) - { - goto ErrorExit; - } - - /* Skip over any white space in the buffer */ - - while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t')) - { - String++; - } - - if (ToIntegerOp) - { - /* - * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. - * We need to determine if it is decimal or hexadecimal. - */ - if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x')) - { - SignOf0x = 1; - Base = 16; - - /* Skip over the leading '0x' */ - String += 2; - } - else - { - Base = 10; - } - } - - /* Any string left? Check that '0x' is not followed by white space. */ - - if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t') - { - if (ToIntegerOp) - { - goto ErrorExit; - } - else - { - goto AllDone; - } - } - - /* - * Perform a 32-bit or 64-bit conversion, depending upon the current - * execution mode of the interpreter - */ - Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; - - /* Main loop: convert the string to a 32- or 64-bit integer */ - - while (*String) - { - if (ACPI_IS_DIGIT (*String)) - { - /* Convert ASCII 0-9 to Decimal value */ - - ThisDigit = ((UINT8) *String) - '0'; - } - else if (Base == 10) - { - /* Digit is out of range; possible in ToInteger case only */ - - Term = 1; - } - else - { - ThisDigit = (UINT8) ACPI_TOUPPER (*String); - if (ACPI_IS_XDIGIT ((char) ThisDigit)) - { - /* Convert ASCII Hex char to value */ - - ThisDigit = ThisDigit - 'A' + 10; - } - else - { - Term = 1; - } - } - - if (Term) - { - if (ToIntegerOp) - { - goto ErrorExit; - } - else - { - break; - } - } - else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) - { - /* Skip zeros */ - String++; - continue; - } - - ValidDigits++; - - if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) - { - /* - * This is ToInteger operation case. - * No any restrictions for string-to-integer conversion, - * see ACPI spec. - */ - goto ErrorExit; - } - - /* Divide the digit into the correct position */ - - (void) AcpiUtShortDivide ((Dividend - (UINT64) ThisDigit), - Base, &Quotient, NULL); - - if (ReturnValue > Quotient) - { - if (ToIntegerOp) - { - goto ErrorExit; - } - else - { - break; - } - } - - ReturnValue *= Base; - ReturnValue += ThisDigit; - String++; - } - - /* All done, normal exit */ - -AllDone: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ReturnValue))); - - *RetInteger = ReturnValue; - return_ACPI_STATUS (AE_OK); - - -ErrorExit: - /* Base was set/validated above */ - - if (Base == 10) - { - return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); - } - else - { - return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); - } -} - - /******************************************************************************* * * FUNCTION: AcpiUtPrintString @@ -469,7 +132,7 @@ AcpiUtPrintString ( /* Check for printable character or hex escape */ - if (ACPI_IS_PRINT (String[i])) + if (isprint ((int) String[i])) { /* This is a normal character */ @@ -484,6 +147,7 @@ AcpiUtPrintString ( break; } } + AcpiOsPrintf ("\""); if (i == MaxLength && String[i]) @@ -495,86 +159,6 @@ AcpiUtPrintString ( /******************************************************************************* * - * FUNCTION: AcpiUtValidAcpiChar - * - * PARAMETERS: Char - The character to be examined - * Position - Byte position (0-3) - * - * RETURN: TRUE if the character is valid, FALSE otherwise - * - * DESCRIPTION: Check for a valid ACPI character. Must be one of: - * 1) Upper case alpha - * 2) numeric - * 3) underscore - * - * We allow a '!' as the last character because of the ASF! table - * - ******************************************************************************/ - -BOOLEAN -AcpiUtValidAcpiChar ( - char Character, - UINT32 Position) -{ - - if (!((Character >= 'A' && Character <= 'Z') || - (Character >= '0' && Character <= '9') || - (Character == '_'))) - { - /* Allow a '!' in the last position */ - - if (Character == '!' && Position == 3) - { - return (TRUE); - } - - return (FALSE); - } - - return (TRUE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtValidAcpiName - * - * PARAMETERS: Name - The name to be examined. Does not have to - * be NULL terminated string. - * - * RETURN: TRUE if the name is valid, FALSE otherwise - * - * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: - * 1) Upper case alpha - * 2) numeric - * 3) underscore - * - ******************************************************************************/ - -BOOLEAN -AcpiUtValidAcpiName ( - char *Name) -{ - UINT32 i; - - - ACPI_FUNCTION_ENTRY (); - - - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (!AcpiUtValidAcpiChar (Name[i], i)) - { - return (FALSE); - } - } - - return (TRUE); -} - - -/******************************************************************************* - * * FUNCTION: AcpiUtRepairName * * PARAMETERS: Name - The ACPI name to be repaired @@ -607,13 +191,22 @@ AcpiUtRepairName ( ACPI_FUNCTION_NAME (UtRepairName); + /* + * Special case for the root node. This can happen if we get an + * error during the execution of module-level code. + */ + if (ACPI_COMPARE_NAME (Name, "\\___")) + { + return; + } + ACPI_MOVE_NAME (&OriginalName, Name); /* Check each character in the name */ for (i = 0; i < ACPI_NAME_SIZE; i++) { - if (AcpiUtValidAcpiChar (Name[i], i)) + if (AcpiUtValidNameChar (Name[i], i)) { continue; } @@ -682,81 +275,3 @@ UtConvertBackslashes ( } } #endif - -#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) -/******************************************************************************* - * - * FUNCTION: AcpiUtSafeStrcpy, AcpiUtSafeStrcat, AcpiUtSafeStrncat - * - * PARAMETERS: Adds a "DestSize" parameter to each of the standard string - * functions. This is the size of the Destination buffer. - * - * RETURN: TRUE if the operation would overflow the destination buffer. - * - * DESCRIPTION: Safe versions of standard Clib string functions. Ensure that - * the result of the operation will not overflow the output string - * buffer. - * - * NOTE: These functions are typically only helpful for processing - * user input and command lines. For most ACPICA code, the - * required buffer length is precisely calculated before buffer - * allocation, so the use of these functions is unnecessary. - * - ******************************************************************************/ - -BOOLEAN -AcpiUtSafeStrcpy ( - char *Dest, - ACPI_SIZE DestSize, - char *Source) -{ - - if (ACPI_STRLEN (Source) >= DestSize) - { - return (TRUE); - } - - ACPI_STRCPY (Dest, Source); - return (FALSE); -} - -BOOLEAN -AcpiUtSafeStrcat ( - char *Dest, - ACPI_SIZE DestSize, - char *Source) -{ - - if ((ACPI_STRLEN (Dest) + ACPI_STRLEN (Source)) >= DestSize) - { - return (TRUE); - } - - ACPI_STRCAT (Dest, Source); - return (FALSE); -} - -#ifndef _KERNEL -BOOLEAN -AcpiUtSafeStrncat ( - char *Dest, - ACPI_SIZE DestSize, - char *Source, - ACPI_SIZE MaxTransferLength) -{ - ACPI_SIZE ActualTransferLength; - - - ActualTransferLength = ACPI_MIN (MaxTransferLength, ACPI_STRLEN (Source)); - - if ((ACPI_STRLEN (Dest) + ActualTransferLength) >= DestSize) - { - return (TRUE); - } - - ACPI_STRNCAT (Dest, Source, MaxTransferLength); - return (FALSE); -} -#endif - -#endif diff --git a/sys/contrib/dev/acpica/components/utilities/uttrack.c b/sys/contrib/dev/acpica/components/utilities/uttrack.c index 5f208b5..76e915b 100644 --- a/sys/contrib/dev/acpica/components/utilities/uttrack.c +++ b/sys/contrib/dev/acpica/components/utilities/uttrack.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,7 +100,7 @@ AcpiUtRemoveAllocation ( ACPI_STATUS AcpiUtCreateList ( - char *ListName, + const char *ListName, UINT16 ObjectSize, ACPI_MEMORY_LIST **ReturnCache) { @@ -113,9 +113,9 @@ AcpiUtCreateList ( return (AE_NO_MEMORY); } - ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + memset (Cache, 0, sizeof (ACPI_MEMORY_LIST)); - Cache->ListName = ListName; + Cache->ListName = ListName; Cache->ObjectSize = ObjectSize; *ReturnCache = Cache; @@ -169,8 +169,8 @@ AcpiUtAllocateAndTrack ( return (NULL); } - Status = AcpiUtTrackAllocation (Allocation, Size, - ACPI_MEM_MALLOC, Component, Module, Line); + Status = AcpiUtTrackAllocation ( + Allocation, Size, ACPI_MEM_MALLOC, Component, Module, Line); if (ACPI_FAILURE (Status)) { AcpiOsFree (Allocation); @@ -180,9 +180,12 @@ AcpiUtAllocateAndTrack ( AcpiGbl_GlobalList->TotalAllocated++; AcpiGbl_GlobalList->TotalSize += (UINT32) Size; AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; - if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + + if (AcpiGbl_GlobalList->CurrentTotalSize > + AcpiGbl_GlobalList->MaxOccupied) { - AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + AcpiGbl_GlobalList->MaxOccupied = + AcpiGbl_GlobalList->CurrentTotalSize; } return ((void *) &Allocation->UserSpace); @@ -224,7 +227,8 @@ AcpiUtAllocateZeroedAndTrack ( Size = 1; } - Allocation = AcpiOsAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER)); + Allocation = AcpiOsAllocateZeroed ( + Size + sizeof (ACPI_DEBUG_MEM_HEADER)); if (!Allocation) { /* Report allocation error */ @@ -235,7 +239,7 @@ AcpiUtAllocateZeroedAndTrack ( } Status = AcpiUtTrackAllocation (Allocation, Size, - ACPI_MEM_CALLOC, Component, Module, Line); + ACPI_MEM_CALLOC, Component, Module, Line); if (ACPI_FAILURE (Status)) { AcpiOsFree (Allocation); @@ -245,9 +249,12 @@ AcpiUtAllocateZeroedAndTrack ( AcpiGbl_GlobalList->TotalAllocated++; AcpiGbl_GlobalList->TotalSize += (UINT32) Size; AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; - if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + + if (AcpiGbl_GlobalList->CurrentTotalSize > + AcpiGbl_GlobalList->MaxOccupied) { - AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + AcpiGbl_GlobalList->MaxOccupied = + AcpiGbl_GlobalList->CurrentTotalSize; } return ((void *) &Allocation->UserSpace); @@ -292,13 +299,12 @@ AcpiUtFreeAndTrack ( } DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, - (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); + (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); AcpiGbl_GlobalList->TotalFreed++; AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; - Status = AcpiUtRemoveAllocation (DebugBlock, - Component, Module, Line); + Status = AcpiUtRemoveAllocation (DebugBlock, Component, Module, Line); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory")); @@ -440,12 +446,12 @@ AcpiUtTrackAllocation ( /* Fill in the instance data */ - Allocation->Size = (UINT32) Size; + Allocation->Size = (UINT32) Size; Allocation->AllocType = AllocType; Allocation->Component = Component; - Allocation->Line = Line; + Allocation->Line = Line; - ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); + strncpy (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; if (!Element) @@ -454,7 +460,8 @@ AcpiUtTrackAllocation ( if (MemList->ListHead) { - ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; + ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = + Allocation; } Allocation->Next = MemList->ListHead; @@ -556,7 +563,7 @@ AcpiUtRemoveAllocation ( /* Mark the segment as deleted */ - ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); + memset (&Allocation->UserSpace, 0xEA, Allocation->Size); Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); return (Status); @@ -587,37 +594,37 @@ AcpiUtDumpAllocationInfo ( /* ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Current allocations", - MemList->CurrentCount, - ROUND_UP_TO_1K (MemList->CurrentSize))); + ("%30s: %4d (%3d Kb)\n", "Current allocations", + MemList->CurrentCount, + ROUND_UP_TO_1K (MemList->CurrentSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", - MemList->MaxConcurrentCount, - ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); + ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", + MemList->MaxConcurrentCount, + ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", - RunningObjectCount, - ROUND_UP_TO_1K (RunningObjectSize))); + ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", + RunningObjectCount, + ROUND_UP_TO_1K (RunningObjectSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", - RunningAllocCount, - ROUND_UP_TO_1K (RunningAllocSize))); + ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", + RunningAllocCount, + ROUND_UP_TO_1K (RunningAllocSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Current Nodes", - AcpiGbl_CurrentNodeCount, - ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); + ("%30s: %4d (%3d Kb)\n", "Current Nodes", + AcpiGbl_CurrentNodeCount, + ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Max Nodes", - AcpiGbl_MaxConcurrentNodeCount, - ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * - sizeof (ACPI_NAMESPACE_NODE))))); + ("%30s: %4d (%3d Kb)\n", "Max Nodes", + AcpiGbl_MaxConcurrentNodeCount, + ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * + sizeof (ACPI_NAMESPACE_NODE))))); */ return_VOID; } @@ -667,9 +674,10 @@ AcpiUtDumpAllocations ( while (Element) { if ((Element->Component & Component) && - ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) + ((Module == NULL) || (0 == strcmp (Module, Element->Module)))) { - Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); + Descriptor = ACPI_CAST_PTR ( + ACPI_DESCRIPTOR, &Element->UserSpace); if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR)) { @@ -682,7 +690,8 @@ AcpiUtDumpAllocations ( { /* Ignore allocated objects that are in a cache */ - if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) + if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != + ACPI_DESC_TYPE_CACHED) { AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ", Descriptor, Element->Size, Element->Module, @@ -766,7 +775,7 @@ AcpiUtDumpAllocations ( if (!NumOutstanding) { - ACPI_INFO ((AE_INFO, "No outstanding allocations")); + ACPI_INFO (("No outstanding allocations")); } else { diff --git a/sys/contrib/dev/acpica/components/utilities/utuuid.c b/sys/contrib/dev/acpica/components/utilities/utuuid.c index 435c6c3..281305a 100644 --- a/sys/contrib/dev/acpica/components/utilities/utuuid.c +++ b/sys/contrib/dev/acpica/components/utilities/utuuid.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -93,11 +93,11 @@ AcpiUtConvertStringToUuid ( for (i = 0; i < UUID_BUFFER_LENGTH; i++) { - UuidBuffer[i] = - (AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i]]) << 4); + UuidBuffer[i] = (AcpiUtAsciiCharToHex ( + InString[AcpiGbl_MapToUuidOffset[i]]) << 4); - UuidBuffer[i] |= - AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i] + 1]); + UuidBuffer[i] |= AcpiUtAsciiCharToHex ( + InString[AcpiGbl_MapToUuidOffset[i] + 1]); } } #endif diff --git a/sys/contrib/dev/acpica/components/utilities/utxface.c b/sys/contrib/dev/acpica/components/utilities/utxface.c index aab7473..02ca632 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxface.c +++ b/sys/contrib/dev/acpica/components/utilities/utxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,24 +73,6 @@ AcpiTerminate ( ACPI_FUNCTION_TRACE (AcpiTerminate); - /* Just exit if subsystem is already shutdown */ - - if (AcpiGbl_Shutdown) - { - ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated")); - return_ACPI_STATUS (AE_OK); - } - - /* Subsystem appears active, go ahead and shut it down */ - - AcpiGbl_Shutdown = TRUE; - AcpiGbl_StartupFlags = 0; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); - - /* Terminate the AML Debugger if present */ - - ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE); - /* Shutdown and free all resources */ AcpiUtSubsystemShutdown (); @@ -99,14 +81,6 @@ AcpiTerminate ( AcpiUtMutexTerminate (); - -#ifdef ACPI_DEBUGGER - - /* Shut down the debugger */ - - AcpiDbTerminate (); -#endif - /* Now we can shutdown the OS-dependent layer */ Status = AcpiOsTerminate (); @@ -198,7 +172,6 @@ AcpiGetSystemInfo ( * Populate the return buffer */ InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; - InfoPtr->AcpiCaVersion = ACPI_CA_VERSION; /* System flags (ACPI capabilities) */ @@ -263,14 +236,12 @@ AcpiGetStatistics ( Stats->SciCount = AcpiSciCount; Stats->GpeCount = AcpiGpeCount; - ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount, + memcpy (Stats->FixedEventCount, AcpiFixedEventCount, sizeof (AcpiFixedEventCount)); - /* Other counters */ Stats->MethodCount = AcpiMethodCount; - return_ACPI_STATUS (AE_OK); } @@ -367,7 +338,7 @@ AcpiInstallInterface ( /* Parameter validation */ - if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0)) + if (!InterfaceName || (strlen (InterfaceName) == 0)) { return (AE_BAD_PARAMETER); } @@ -432,7 +403,7 @@ AcpiRemoveInterface ( /* Parameter validation */ - if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0)) + if (!InterfaceName || (strlen (InterfaceName) == 0)) { return (AE_BAD_PARAMETER); } @@ -604,7 +575,7 @@ AcpiDecodePldBuffer ( /* Parameter validation */ - if (!InBuffer || !ReturnBuffer || (Length < 16)) + if (!InBuffer || !ReturnBuffer || (Length < ACPI_PLD_REV1_BUFFER_SIZE)) { return (AE_BAD_PARAMETER); } @@ -656,7 +627,7 @@ AcpiDecodePldBuffer ( PldInfo->Rotation = ACPI_PLD_GET_ROTATION (&Dword); PldInfo->Order = ACPI_PLD_GET_ORDER (&Dword); - if (Length >= ACPI_PLD_BUFFER_SIZE) + if (Length >= ACPI_PLD_REV2_BUFFER_SIZE) { /* Fifth 32-bit DWord (Revision 2 of _PLD) */ diff --git a/sys/contrib/dev/acpica/components/utilities/utxferror.c b/sys/contrib/dev/acpica/components/utilities/utxferror.c index d39682b..802da6d 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxferror.c +++ b/sys/contrib/dev/acpica/components/utilities/utxferror.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -133,8 +133,10 @@ AcpiException ( } else { - AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status)); + AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", + AcpiFormatException (Status)); } + va_start (ArgList, Format); AcpiOsVprintf (Format, ArgList); ACPI_MSG_SUFFIX; @@ -203,8 +205,6 @@ ACPI_EXPORT_SYMBOL (AcpiWarning) void ACPI_INTERNAL_VAR_XFACE AcpiInfo ( - const char *ModuleName, - UINT32 LineNumber, const char *Format, ...) { diff --git a/sys/contrib/dev/acpica/components/utilities/utxfinit.c b/sys/contrib/dev/acpica/components/utilities/utxfinit.c index 36107ca..f7085b4 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxfinit.c +++ b/sys/contrib/dev/acpica/components/utilities/utxfinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -132,17 +132,6 @@ AcpiInitializeSubsystem ( return_ACPI_STATUS (Status); } - /* If configured, initialize the AML debugger */ - -#ifdef ACPI_DEBUGGER - Status = AcpiDbInitialize (); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "During Debugger initialization")); - return_ACPI_STATUS (Status); - } -#endif - return_ACPI_STATUS (AE_OK); } @@ -172,6 +161,13 @@ AcpiEnableSubsystem ( ACPI_FUNCTION_TRACE (AcpiEnableSubsystem); + /* + * The early initialization phase is complete. The namespace is loaded, + * and we can now support address spaces other than Memory, I/O, and + * PCI_Config. + */ + AcpiGbl_EarlyInitialization = FALSE; + #if (!ACPI_REDUCED_HARDWARE) /* Enable ACPI mode */ @@ -194,33 +190,16 @@ AcpiEnableSubsystem ( * Obtain a permanent mapping for the FACS. This is required for the * Global Lock and the Firmware Waking Vector */ - Status = AcpiTbInitializeFacs (); - if (ACPI_FAILURE (Status)) - { - ACPI_WARNING ((AE_INFO, "Could not map the FACS table")); - return_ACPI_STATUS (Status); - } - -#endif /* !ACPI_REDUCED_HARDWARE */ - - /* - * Install the default OpRegion handlers. These are installed unless - * other handlers have already been installed via the - * InstallAddressSpaceHandler interface. - */ - if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + if (!(Flags & ACPI_NO_FACS_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Installing default address space handlers\n")); - - Status = AcpiEvInstallRegionHandlers (); + Status = AcpiTbInitializeFacs (); if (ACPI_FAILURE (Status)) { + ACPI_WARNING ((AE_INFO, "Could not map the FACS table")); return_ACPI_STATUS (Status); } } -#if (!ACPI_REDUCED_HARDWARE) /* * Initialize ACPI Event handling (Fixed and General Purpose) * @@ -294,25 +273,6 @@ AcpiInitializeObjects ( ACPI_FUNCTION_TRACE (AcpiInitializeObjects); - /* - * Run all _REG methods - * - * Note: Any objects accessed by the _REG methods will be automatically - * initialized, even if they contain executable AML (see the call to - * AcpiNsInitializeObjects below). - */ - if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Executing _REG OpRegion methods\n")); - - Status = AcpiEvInitializeOpRegions (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - #ifdef ACPI_EXEC_APP /* * This call implements the "initialization file" option for AcpiExec. @@ -328,36 +288,38 @@ AcpiInitializeObjects ( * outside of any control method is wrapped with a temporary control * method object and placed on a global list. The methods on this list * are executed below. + * + * This case executes the module-level code for all tables only after + * all of the tables have been loaded. It is a legacy option and is + * not compatible with other ACPI implementations. See AcpiNsLoadTable. */ - AcpiNsExecModuleCodeList (); - - /* - * Initialize the objects that remain uninitialized. This runs the - * executable AML that may be part of the declaration of these objects: - * OperationRegions, BufferFields, Buffers, and Packages. - */ - if (!(Flags & ACPI_NO_OBJECT_INIT)) + if (AcpiGbl_GroupModuleLevelCode) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Completing Initialization of ACPI Objects\n")); - - Status = AcpiNsInitializeObjects (); - if (ACPI_FAILURE (Status)) + AcpiNsExecModuleCodeList (); + + /* + * Initialize the objects that remain uninitialized. This + * runs the executable AML that may be part of the + * declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + if (!(Flags & ACPI_NO_OBJECT_INIT)) { - return_ACPI_STATUS (Status); + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } } /* - * Initialize all device objects in the namespace. This runs the device - * _STA and _INI methods. + * Initialize all device/region objects in the namespace. This runs + * the device _STA and _INI methods and region _REG methods. */ - if (!(Flags & ACPI_NO_DEVICE_INIT)) + if (!(Flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT))) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI Devices\n")); - - Status = AcpiNsInitializeDevices (); + Status = AcpiNsInitializeDevices (Flags); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/utilities/utxfmutex.c b/sys/contrib/dev/acpica/components/utilities/utxfmutex.c index 559f4b4..ef5a7bc 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxfmutex.c +++ b/sys/contrib/dev/acpica/components/utilities/utxfmutex.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,8 +98,8 @@ AcpiUtGetMutexObject ( MutexNode = Handle; if (Pathname != NULL) { - Status = AcpiGetHandle (Handle, Pathname, - ACPI_CAST_PTR (ACPI_HANDLE, &MutexNode)); + Status = AcpiGetHandle ( + Handle, Pathname, ACPI_CAST_PTR (ACPI_HANDLE, &MutexNode)); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/sys/contrib/dev/acpica/include/acapps.h b/sys/contrib/dev/acpica/include/acapps.h index 7c4880a..87284f2 100644 --- a/sys/contrib/dev/acpica/include/acapps.h +++ b/sys/contrib/dev/acpica/include/acapps.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,7 @@ #ifndef _ACAPPS #define _ACAPPS +#include <stdio.h> #ifdef _MSC_VER /* disable some level-4 warnings */ #pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ @@ -52,7 +53,7 @@ /* Common info for tool signons */ #define ACPICA_NAME "Intel ACPI Component Architecture" -#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2015 Intel Corporation" +#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2016 Intel Corporation" #if ACPI_MACHINE_WIDTH == 64 #define ACPI_WIDTH "-64" @@ -90,11 +91,49 @@ AcpiOsPrintf (Description); #define ACPI_OPTION(Name, Description) \ - AcpiOsPrintf (" %-18s%s\n", Name, Description); + AcpiOsPrintf (" %-20s%s\n", Name, Description); +/* Check for unexpected exceptions */ + +#define ACPI_CHECK_STATUS(Name, Status, Expected) \ + if (Status != Expected) \ + { \ + AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \ + AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \ + } + +/* Check for unexpected non-AE_OK errors */ + + +#define ACPI_CHECK_OK(Name, Status) ACPI_CHECK_STATUS (Name, Status, AE_OK); + #define FILE_SUFFIX_DISASSEMBLY "dsl" -#define ACPI_TABLE_FILE_SUFFIX ".dat" +#define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */ + + +/* acfileio */ + +ACPI_STATUS +AcGetAllTablesFromFile ( + char *Filename, + UINT8 GetOnlyAmlTables, + ACPI_NEW_TABLE_DESC **ReturnListHead); + +BOOLEAN +AcIsFileBinary ( + FILE *File); + +ACPI_STATUS +AcValidateTableHeader ( + FILE *File, + long TableOffset); + + +/* Values for GetOnlyAmlTables */ + +#define ACPI_GET_ONLY_AML_TABLES TRUE +#define ACPI_GET_ALL_TABLES FALSE /* @@ -125,51 +164,6 @@ CmGetFileSize ( ACPI_FILE File); -#ifndef ACPI_DUMP_APP -/* - * adisasm - */ -ACPI_STATUS -AdAmlDisassemble ( - BOOLEAN OutToFile, - char *Filename, - char *Prefix, - char **OutFilename); - -void -AdPrintStatistics ( - void); - -ACPI_STATUS -AdFindDsdt( - UINT8 **DsdtPtr, - UINT32 *DsdtLength); - -void -AdDumpTables ( - void); - -ACPI_STATUS -AdGetLocalTables ( - void); - -ACPI_STATUS -AdParseTable ( - ACPI_TABLE_HEADER *Table, - ACPI_OWNER_ID *OwnerId, - BOOLEAN LoadTable, - BOOLEAN External); - -ACPI_STATUS -AdDisplayTables ( - char *Filename, - ACPI_TABLE_HEADER *Table); - -ACPI_STATUS -AdDisplayStatistics ( - void); - - /* * adwalk */ @@ -228,6 +222,5 @@ AdWriteTable ( UINT32 Length, char *TableName, char *OemTableId); -#endif #endif /* _ACAPPS */ diff --git a/sys/contrib/dev/acpica/include/acbuffer.h b/sys/contrib/dev/acpica/include/acbuffer.h index 37f4170..78f6db4a 100644 --- a/sys/contrib/dev/acpica/include/acbuffer.h +++ b/sys/contrib/dev/acpica/include/acbuffer.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -157,6 +157,7 @@ typedef struct acpi_pld_info * (Intended for BIOS use only) */ #define ACPI_PLD_REV1_BUFFER_SIZE 16 /* For Revision 1 of the buffer (From ACPI spec) */ +#define ACPI_PLD_REV2_BUFFER_SIZE 20 /* For Revision 2 of the buffer (From ACPI spec) */ #define ACPI_PLD_BUFFER_SIZE 20 /* For Revision 2 of the buffer (From ACPI spec) */ /* First 32-bit dword, bits 0:32 */ diff --git a/sys/contrib/dev/acpica/include/acclib.h b/sys/contrib/dev/acpica/include/acclib.h new file mode 100644 index 0000000..56a3072 --- /dev/null +++ b/sys/contrib/dev/acpica/include/acclib.h @@ -0,0 +1,167 @@ +/****************************************************************************** + * + * Name: acclib.h -- C library support. Prototypes for the (optional) local + * implementations of required C library functions. + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef _ACCLIB_H +#define _ACCLIB_H + + +/* + * Prototypes and macros for local implementations of C library functions + */ + +/* is* functions. The AcpiGbl_Ctypes array is defined in utclib.c */ + +extern const UINT8 AcpiGbl_Ctypes[]; + +#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ +#define _ACPI_XS 0x40 /* extra space */ +#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ +#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ +#define _ACPI_DI 0x04 /* '0'-'9' */ +#define _ACPI_LO 0x02 /* 'a'-'z' */ +#define _ACPI_PU 0x10 /* punctuation */ +#define _ACPI_SP 0x08 /* space, tab, CR, LF, VT, FF */ +#define _ACPI_UP 0x01 /* 'A'-'Z' */ +#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ + +#define isdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_DI)) +#define isspace(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_SP)) +#define isxdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_XD)) +#define isupper(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_UP)) +#define islower(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO)) +#define isprint(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU)) +#define isalpha(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) + + +/* Strings */ + +char * +strcat ( + char *DstString, + const char *SrcString); + +char * +strchr ( + const char *String, + int ch); + +char * +strcpy ( + char *DstString, + const char *SrcString); + +int +strcmp ( + const char *String1, + const char *String2); + +ACPI_SIZE +strlen ( + const char *String); + +char * +strncat ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count); + +int +strncmp ( + const char *String1, + const char *String2, + ACPI_SIZE Count); + +char * +strncpy ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count); + +char * +strstr ( + char *String1, + char *String2); + + +/* Conversion */ + +UINT32 +strtoul ( + const char *String, + char **Terminator, + UINT32 Base); + + +/* Memory */ + +int +memcmp ( + void *Buffer1, + void *Buffer2, + ACPI_SIZE Count); + +void * +memcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count); + +void * +memset ( + void *Dest, + int Value, + ACPI_SIZE Count); + + +/* upper/lower case */ + +int +tolower ( + int c); + +int +toupper ( + int c); + +#endif /* _ACCLIB_H */ diff --git a/sys/contrib/dev/acpica/include/accommon.h b/sys/contrib/dev/acpica/include/accommon.h index e63943b..7851c54 100644 --- a/sys/contrib/dev/acpica/include/accommon.h +++ b/sys/contrib/dev/acpica/include/accommon.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,6 +59,9 @@ #include <contrib/dev/acpica/include/acglobal.h> /* All global variables */ #include <contrib/dev/acpica/include/achware.h> /* Hardware defines and interfaces */ #include <contrib/dev/acpica/include/acutils.h> /* Utility interfaces */ +#ifndef ACPI_USE_SYSTEM_CLIBRARY +#include <contrib/dev/acpica/include/acclib.h> /* C library interfaces */ +#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ #endif /* __ACCOMMON_H__ */ diff --git a/sys/contrib/dev/acpica/include/acconfig.h b/sys/contrib/dev/acpica/include/acconfig.h index 46dbc31..a626f87 100644 --- a/sys/contrib/dev/acpica/include/acconfig.h +++ b/sys/contrib/dev/acpica/include/acconfig.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -138,10 +138,6 @@ #define ACPI_ROOT_TABLE_SIZE_INCREMENT 4 -/* Maximum number of While() loop iterations before forced abort */ - -#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF - /* Maximum sleep allowed via Sleep() operator */ #define ACPI_MAX_SLEEP 2000 /* 2000 millisec == two seconds */ diff --git a/sys/contrib/dev/acpica/include/acdebug.h b/sys/contrib/dev/acpica/include/acdebug.h index 11cf02e..3e62565 100644 --- a/sys/contrib/dev/acpica/include/acdebug.h +++ b/sys/contrib/dev/acpica/include/acdebug.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,12 +44,18 @@ #ifndef __ACDEBUG_H__ #define __ACDEBUG_H__ +/* The debugger is used in conjunction with the disassembler most of time */ + +#ifdef ACPI_DISASSEMBLER +#include <contrib/dev/acpica/include/acdisasm.h> +#endif + #define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */ typedef struct acpi_db_command_info { - char *Name; /* Command Name */ + const char *Name; /* Command Name */ UINT8 MinArgs; /* Minimum arguments required */ } ACPI_DB_COMMAND_INFO; @@ -64,7 +70,7 @@ typedef struct acpi_db_command_help typedef struct acpi_db_argument_info { - char *Name; /* Argument Name */ + const char *Name; /* Argument Name */ } ACPI_DB_ARGUMENT_INFO; @@ -77,9 +83,6 @@ typedef struct acpi_db_execute_walk #define PARAM_LIST(pl) pl -#define DBTEST_OUTPUT_LEVEL(lvl) if (AcpiGbl_DbOpt_Verbose) -#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ - AcpiOsPrintf PARAM_LIST(fp);} #define EX_NO_SINGLE_STEP 1 #define EX_SINGLE_STEP 2 @@ -88,19 +91,17 @@ typedef struct acpi_db_execute_walk /* * dbxface - external debugger interfaces */ -ACPI_STATUS -AcpiDbInitialize ( - void); - -void -AcpiDbTerminate ( - void); - +ACPI_DBR_DEPENDENT_RETURN_OK ( ACPI_STATUS AcpiDbSingleStep ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, - UINT32 OpType); + UINT32 OpType)) + +ACPI_DBR_DEPENDENT_RETURN_VOID ( +void +AcpiDbSignalBreakPoint ( + ACPI_WALK_STATE *WalkState)) /* @@ -137,6 +138,12 @@ AcpiDbSleep ( char *ObjectArg); void +AcpiDbTrace ( + char *EnableArg, + char *MethodArg, + char *OnceArg); + +void AcpiDbDisplayLocks ( void); @@ -289,10 +296,11 @@ AcpiDbDecodeAndDisplayObject ( char *Target, char *OutputType); +ACPI_DBR_DEPENDENT_RETURN_VOID ( void AcpiDbDisplayResultObject ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_WALK_STATE *WalkState); + ACPI_WALK_STATE *WalkState)) ACPI_STATUS AcpiDbDisplayAllMethods ( @@ -318,10 +326,11 @@ void AcpiDbDisplayObjectType ( char *ObjectArg); +ACPI_DBR_DEPENDENT_RETURN_VOID ( void AcpiDbDisplayArgumentObject ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_WALK_STATE *WalkState); + ACPI_WALK_STATE *WalkState)) /* @@ -373,10 +382,8 @@ AcpiDbLoadAcpiTable ( char *Filename); ACPI_STATUS -AcpiDbGetTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **Table, - BOOLEAN MustBeAmlTable); +AcpiDbLoadTables ( + ACPI_NEW_TABLE_DESC *ListHead); /* @@ -425,6 +432,32 @@ AcpiDbGetNextToken ( /* + * dbobject + */ +void +AcpiDbDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiDbDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +void +AcpiDbDecodeArguments ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDbDecodeLocals ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDbDumpMethodInfo ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState); + + +/* * dbstats - Generation and display of ACPI table statistics */ void diff --git a/sys/contrib/dev/acpica/include/acdisasm.h b/sys/contrib/dev/acpica/include/acdisasm.h index bbd21b7..07be53f 100644 --- a/sys/contrib/dev/acpica/include/acdisasm.h +++ b/sys/contrib/dev/acpica/include/acdisasm.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -186,13 +186,16 @@ typedef struct acpi_dmtable_data typedef struct acpi_op_walk_info { + ACPI_WALK_STATE *WalkState; + ACPI_PARSE_OBJECT *MappingOp; + UINT8 *PreviousAml; + UINT8 *StartAml; UINT32 Level; UINT32 LastLevel; UINT32 Count; UINT32 BitOffset; UINT32 Flags; - ACPI_WALK_STATE *WalkState; - ACPI_PARSE_OBJECT *MappingOp; + UINT32 AmlOffset; } ACPI_OP_WALK_INFO; @@ -299,6 +302,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest6[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest7[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest8[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest10[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestBank[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[]; @@ -315,6 +319,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3a[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3b[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3c[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortAcc[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortMap[]; @@ -380,6 +385,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcctHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoS3pt[]; @@ -399,7 +405,9 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoStao[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoStaoStr[]; -extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaClient[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaServer[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoVrtc[]; @@ -595,6 +603,10 @@ AcpiDmDumpStao ( ACPI_TABLE_HEADER *Table); void +AcpiDmDumpTcpa ( + ACPI_TABLE_HEADER *Table); + +void AcpiDmDumpVrtc ( ACPI_TABLE_HEADER *Table); @@ -637,10 +649,6 @@ AcpiDmDisassembleOneOp ( ACPI_OP_WALK_INFO *Info, ACPI_PARSE_OBJECT *Op); -void -AcpiDmDecodeInternalObject ( - ACPI_OPERAND_OBJECT *ObjDesc); - UINT32 AcpiDmListType ( ACPI_PARSE_OBJECT *Op); @@ -700,29 +708,6 @@ AcpiDmNamestring ( /* - * dmobject - */ -void -AcpiDmDisplayInternalObject ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_WALK_STATE *WalkState); - -void -AcpiDmDisplayArguments ( - ACPI_WALK_STATE *WalkState); - -void -AcpiDmDisplayLocals ( - ACPI_WALK_STATE *WalkState); - -void -AcpiDmDumpMethodInfo ( - ACPI_STATUS Status, - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); - - -/* * dmbuffer */ void @@ -825,22 +810,22 @@ AcpiDmGetExternalsFromFile ( void AcpiDmDumpInteger8 ( UINT8 Value, - char *Name); + const char *Name); void AcpiDmDumpInteger16 ( UINT16 Value, - char *Name); + const char *Name); void AcpiDmDumpInteger32 ( UINT32 Value, - char *Name); + const char *Name); void AcpiDmDumpInteger64 ( UINT64 Value, - char *Name); + const char *Name); void AcpiDmResourceTemplate ( @@ -952,7 +937,7 @@ AcpiDmSerialBusDescriptor ( void AcpiDmVendorCommon ( - char *Name, + const char *Name, UINT8 *ByteData, UINT32 Length, UINT32 Level); @@ -1065,7 +1050,7 @@ AcpiDmCloseOperator ( /* - * acdisasm + * dmtables */ void AdDisassemblerHeader ( @@ -1075,4 +1060,35 @@ AdDisassemblerHeader ( #define ACPI_IS_AML_TABLE 0 #define ACPI_IS_DATA_TABLE 1 + +/* + * adisasm + */ +ACPI_STATUS +AdAmlDisassemble ( + BOOLEAN OutToFile, + char *Filename, + char *Prefix, + char **OutFilename); + +ACPI_STATUS +AdGetLocalTables ( + void); + +ACPI_STATUS +AdParseTable ( + ACPI_TABLE_HEADER *Table, + ACPI_OWNER_ID *OwnerId, + BOOLEAN LoadTable, + BOOLEAN External); + +ACPI_STATUS +AdDisplayTables ( + char *Filename, + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AdDisplayStatistics ( + void); + #endif /* __ACDISASM_H__ */ diff --git a/sys/contrib/dev/acpica/include/acdispat.h b/sys/contrib/dev/acpica/include/acdispat.h index 9364fe3..1a6f39e 100644 --- a/sys/contrib/dev/acpica/include/acdispat.h +++ b/sys/contrib/dev/acpica/include/acdispat.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -461,4 +461,14 @@ AcpiDsResultPush ( ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState); + +/* + * dsdebug - parser debugging routines + */ +void +AcpiDsDumpMethodStack ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + #endif /* _ACDISPAT_H_ */ diff --git a/sys/contrib/dev/acpica/include/acevents.h b/sys/contrib/dev/acpica/include/acevents.h index 2ae0aca..a14dbe5 100644 --- a/sys/contrib/dev/acpica/include/acevents.h +++ b/sys/contrib/dev/acpica/include/acevents.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -222,6 +222,11 @@ AcpiEvDeleteGpeHandlers ( /* * evhandler - Address space handling */ +ACPI_OPERAND_OBJECT * +AcpiEvFindRegionHandler ( + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_OPERAND_OBJECT *HandlerObj); + BOOLEAN AcpiEvHasDefaultHandler ( ACPI_NAMESPACE_NODE *Node, @@ -264,17 +269,18 @@ AcpiEvAttachRegion ( void AcpiEvDetachRegion ( - ACPI_OPERAND_OBJECT *RegionObj, + ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsIsLocked); -ACPI_STATUS +void AcpiEvExecuteRegMethods ( ACPI_NAMESPACE_NODE *Node, - ACPI_ADR_SPACE_TYPE SpaceId); + ACPI_ADR_SPACE_TYPE SpaceId, + UINT32 Function); ACPI_STATUS AcpiEvExecuteRegMethod ( - ACPI_OPERAND_OBJECT *RegionObj, + ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function); diff --git a/sys/contrib/dev/acpica/include/acexcep.h b/sys/contrib/dev/acpica/include/acexcep.h index 7a3fdcb..0f9a6aa 100644 --- a/sys/contrib/dev/acpica/include/acexcep.h +++ b/sys/contrib/dev/acpica/include/acexcep.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -128,8 +128,9 @@ typedef struct acpi_exception_info #define AE_OWNER_ID_LIMIT EXCEP_ENV (0x001B) #define AE_NOT_CONFIGURED EXCEP_ENV (0x001C) #define AE_ACCESS EXCEP_ENV (0x001D) +#define AE_IO_ERROR EXCEP_ENV (0x001E) -#define AE_CODE_ENV_MAX 0x001D +#define AE_CODE_ENV_MAX 0x001E /* @@ -197,8 +198,10 @@ typedef struct acpi_exception_info #define AE_AML_BAD_RESOURCE_LENGTH EXCEP_AML (0x001F) #define AE_AML_ILLEGAL_ADDRESS EXCEP_AML (0x0020) #define AE_AML_INFINITE_LOOP EXCEP_AML (0x0021) +#define AE_AML_UNINITIALIZED_NODE EXCEP_AML (0x0022) +#define AE_AML_TARGET_TYPE EXCEP_AML (0x0023) -#define AE_CODE_AML_MAX 0x0021 +#define AE_CODE_AML_MAX 0x0023 /* @@ -260,7 +263,8 @@ static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Env[] = EXCEP_TXT ("AE_NO_HANDLER", "A handler for the operation is not installed"), EXCEP_TXT ("AE_OWNER_ID_LIMIT", "There are no more Owner IDs available for ACPI tables or control methods"), EXCEP_TXT ("AE_NOT_CONFIGURED", "The interface is not part of the current subsystem configuration"), - EXCEP_TXT ("AE_ACCESS", "Permission denied for the requested operation") + EXCEP_TXT ("AE_ACCESS", "Permission denied for the requested operation"), + EXCEP_TXT ("AE_IO_ERROR", "An I/O error occurred") }; static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Pgm[] = @@ -322,7 +326,9 @@ static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Aml[] = EXCEP_TXT ("AE_AML_CIRCULAR_REFERENCE", "Two references refer to each other"), EXCEP_TXT ("AE_AML_BAD_RESOURCE_LENGTH", "The length of a Resource Descriptor in the AML is incorrect"), EXCEP_TXT ("AE_AML_ILLEGAL_ADDRESS", "A memory, I/O, or PCI configuration address is invalid"), - EXCEP_TXT ("AE_AML_INFINITE_LOOP", "An apparent infinite AML While loop, method was aborted") + EXCEP_TXT ("AE_AML_INFINITE_LOOP", "An apparent infinite AML While loop, method was aborted"), + EXCEP_TXT ("AE_AML_UNINITIALIZED_NODE", "A namespace node is uninitialized or unresolved"), + EXCEP_TXT ("AE_AML_TARGET_TYPE", "A target operand of an incorrect type was encountered") }; static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Ctrl[] = diff --git a/sys/contrib/dev/acpica/include/acglobal.h b/sys/contrib/dev/acpica/include/acglobal.h index ab2fc26..a883ac4 100644 --- a/sys/contrib/dev/acpica/include/acglobal.h +++ b/sys/contrib/dev/acpica/include/acglobal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,6 +59,10 @@ ACPI_GLOBAL (ACPI_TABLE_LIST, AcpiGbl_RootTableList); ACPI_GLOBAL (ACPI_TABLE_HEADER *, AcpiGbl_DSDT); ACPI_GLOBAL (ACPI_TABLE_HEADER, AcpiGbl_OriginalDsdtHeader); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_DsdtIndex, ACPI_INVALID_TABLE_INDEX); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_FacsIndex, ACPI_INVALID_TABLE_INDEX); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_XFacsIndex, ACPI_INVALID_TABLE_INDEX); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_FadtIndex, ACPI_INVALID_TABLE_INDEX); #if (!ACPI_REDUCED_HARDWARE) ACPI_GLOBAL (ACPI_TABLE_FACS *, AcpiGbl_FACS); @@ -144,6 +148,7 @@ ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_OperandCache); ACPI_INIT_GLOBAL (UINT32, AcpiGbl_StartupFlags, 0); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_Shutdown, TRUE); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_EarlyInitialization, TRUE); /* Global handlers */ @@ -163,7 +168,7 @@ ACPI_GLOBAL (UINT8, AcpiGbl_NextOwnerIdOffset); /* Initialization sequencing */ -ACPI_GLOBAL (BOOLEAN, AcpiGbl_RegMethodsExecuted); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_NamespaceInitialized, FALSE); /* Misc */ @@ -184,6 +189,8 @@ extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COU extern const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS]; extern const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS]; extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; +extern const char AcpiGbl_LowerHexDigits[]; +extern const char AcpiGbl_UpperHexDigits[]; extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; @@ -238,6 +245,10 @@ ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NestingLevel, 0); ACPI_GLOBAL (ACPI_THREAD_STATE *, AcpiGbl_CurrentWalkList); +/* Maximum number of While() loop iterations before forced abort */ + +ACPI_GLOBAL (UINT16, AcpiGbl_MaxLoopIterations); + /* Control method single step flag */ ACPI_GLOBAL (UINT8, AcpiGbl_CmSingleStep); @@ -291,8 +302,6 @@ ACPI_GLOBAL (UINT32, AcpiFixedEventCount[ACPI_NUM_FIXED_EVENT ACPI_GLOBAL (UINT32, AcpiGbl_OriginalDbgLevel); ACPI_GLOBAL (UINT32, AcpiGbl_OriginalDbgLayer); -ACPI_GLOBAL (UINT32, AcpiGbl_TraceDbgLevel); -ACPI_GLOBAL (UINT32, AcpiGbl_TraceDbgLayer); /***************************************************************************** @@ -311,9 +320,11 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_NoResourceDisassembly, FALSE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_IgnoreNoopOperator, FALSE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_CstyleDisassembly, TRUE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_ForceAmlDisassembly, FALSE); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Verbose, TRUE); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DmEmitExternalOpcodes, FALSE); -ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_Disasm); -ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_Verbose); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Disasm); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Listing); ACPI_GLOBAL (BOOLEAN, AcpiGbl_NumExternalMethods); ACPI_GLOBAL (UINT32, AcpiGbl_ResolvedExternalMethods); ACPI_GLOBAL (ACPI_EXTERNAL_LIST *, AcpiGbl_ExternalList); @@ -322,9 +333,9 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList); #ifdef ACPI_DEBUGGER -ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DbTerminateThreads, FALSE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_MethodExecuting, FALSE); +ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoRegionSupport); @@ -334,6 +345,8 @@ ACPI_GLOBAL (char *, AcpiGbl_DbFilename); ACPI_GLOBAL (UINT32, AcpiGbl_DbDebugLevel); ACPI_GLOBAL (UINT32, AcpiGbl_DbConsoleDebugLevel); ACPI_GLOBAL (ACPI_NAMESPACE_NODE *, AcpiGbl_DbScopeNode); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbTerminateLoop); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbThreadsTerminated); ACPI_GLOBAL (char *, AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]); ACPI_GLOBAL (ACPI_OBJECT_TYPE, AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARGS]); @@ -348,15 +361,26 @@ ACPI_GLOBAL (char, AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUF /* * Statistic globals */ -ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCount[ACPI_TYPE_NS_NODE_MAX+1]); -ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCount[ACPI_TYPE_NS_NODE_MAX+1]); +ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCount[ACPI_TOTAL_TYPES]); +ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCount[ACPI_TOTAL_TYPES]); ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCountMisc); ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCountMisc); ACPI_GLOBAL (UINT32, AcpiGbl_NumNodes); ACPI_GLOBAL (UINT32, AcpiGbl_NumObjects); +ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandReady); +ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandComplete); + #endif /* ACPI_DEBUGGER */ +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) + +ACPI_GLOBAL (const char, *AcpiGbl_PldPanelList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldVerticalPositionList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldHorizontalPositionList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldShapeList[]); + +#endif /***************************************************************************** * diff --git a/sys/contrib/dev/acpica/include/achware.h b/sys/contrib/dev/acpica/include/achware.h index 6ab28b6..b7a5f20 100644 --- a/sys/contrib/dev/acpica/include/achware.h +++ b/sys/contrib/dev/acpica/include/achware.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acinterp.h b/sys/contrib/dev/acpica/include/acinterp.h index 66463d6..148e8d0 100644 --- a/sys/contrib/dev/acpica/include/acinterp.h +++ b/sys/contrib/dev/acpica/include/acinterp.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,7 +69,7 @@ typedef const struct acpi_exdump_info { UINT8 Opcode; UINT8 Offset; - char *Name; + const char *Name; } ACPI_EXDUMP_INFO; @@ -143,6 +143,35 @@ AcpiExDoDebugObject ( UINT32 Level, UINT32 Index); +void +AcpiExStartTraceMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +void +AcpiExStopTraceMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +void +AcpiExStartTraceOpcode ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +void +AcpiExStopTraceOpcode ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +void +AcpiExTracePoint ( + ACPI_TRACE_EVENT_TYPE Type, + BOOLEAN Begin, + UINT8 *Aml, + char *Pathname); + /* * exfield - ACPI AML (p-code) execution - field manipulation @@ -638,6 +667,11 @@ AcpiExIntegerToString ( char *Dest, UINT64 Value); +void +AcpiExPciClsToString ( + char *Dest, + UINT8 ClassCode[3]); + BOOLEAN AcpiIsValidSpaceId ( UINT8 SpaceId); diff --git a/sys/contrib/dev/acpica/include/aclocal.h b/sys/contrib/dev/acpica/include/aclocal.h index 4c96303..e7a0d37 100644 --- a/sys/contrib/dev/acpica/include/aclocal.h +++ b/sys/contrib/dev/acpica/include/aclocal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,11 +87,9 @@ union acpi_parse_object; #define ACPI_MTX_EVENTS 3 /* Data for ACPI events */ #define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */ #define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */ -#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */ -#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */ -#define ACPI_MAX_MUTEX 7 -#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 +#define ACPI_MAX_MUTEX 5 +#define ACPI_NUM_MUTEX (ACPI_MAX_MUTEX+1) /* Lock structure for reader/writer interfaces */ @@ -113,12 +111,20 @@ typedef struct acpi_rw_lock #define ACPI_LOCK_HARDWARE 1 #define ACPI_MAX_LOCK 1 -#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 +#define ACPI_NUM_LOCK (ACPI_MAX_LOCK+1) /* This Thread ID means that the mutex is not in use (unlocked) */ -#define ACPI_MUTEX_NOT_ACQUIRED (ACPI_THREAD_ID) -1 +#define ACPI_MUTEX_NOT_ACQUIRED ((ACPI_THREAD_ID) -1) + +/* This Thread ID means an invalid thread ID */ + +#ifdef ACPI_OS_INVALID_THREAD_ID +#define ACPI_INVALID_THREAD_ID ACPI_OS_INVALID_THREAD_ID +#else +#define ACPI_INVALID_THREAD_ID ((ACPI_THREAD_ID) 0xFFFFFFFF) +#endif /* Table for the global mutexes */ @@ -193,8 +199,12 @@ typedef struct acpi_namespace_node */ #ifdef ACPI_LARGE_NAMESPACE_NODE union acpi_parse_object *Op; + void *MethodLocals; + void *MethodArgs; UINT32 Value; UINT32 Length; + UINT8 ArgCount; + #endif } ACPI_NAMESPACE_NODE; @@ -234,10 +244,19 @@ typedef struct acpi_table_list #define ACPI_ROOT_ALLOW_RESIZE (2) -/* Predefined (fixed) table indexes */ +/* List to manage incoming ACPI tables */ + +typedef struct acpi_new_table_desc +{ + ACPI_TABLE_HEADER *Table; + struct acpi_new_table_desc *Next; + +} ACPI_NEW_TABLE_DESC; + -#define ACPI_TABLE_INDEX_DSDT (0) -#define ACPI_TABLE_INDEX_FACS (1) +/* Predefined table indexes */ + +#define ACPI_INVALID_TABLE_INDEX (0xFFFFFFFF) typedef struct acpi_find_context @@ -325,13 +344,17 @@ ACPI_STATUS (*ACPI_INTERNAL_METHOD) ( #define ACPI_BTYPE_BUFFER_FIELD 0x00002000 #define ACPI_BTYPE_DDB_HANDLE 0x00004000 #define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 -#define ACPI_BTYPE_REFERENCE 0x00010000 +#define ACPI_BTYPE_REFERENCE_OBJECT 0x00010000 /* From Index(), RefOf(), etc (Type6Opcodes) */ #define ACPI_BTYPE_RESOURCE 0x00020000 +#define ACPI_BTYPE_NAMED_REFERENCE 0x00040000 /* Generic unresolved Name or Namepath */ #define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) -#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) + + /* Used by Copy, DeRefOf, Store, Printf, Fprintf */ + +#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE_OBJECT | ACPI_BTYPE_DDB_HANDLE) #define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF @@ -430,6 +453,7 @@ typedef union acpi_predefined_info /* Return object auto-repair info */ typedef ACPI_STATUS (*ACPI_OBJECT_CONVERTER) ( + struct acpi_namespace_node *Scope, union acpi_operand_object *OriginalObject, union acpi_operand_object **ConvertedObject); @@ -460,6 +484,17 @@ typedef struct acpi_simple_repair_info #define ACPI_NUM_RTYPES 5 /* Number of actual object types */ +/* Info for running the _REG methods */ + +typedef struct acpi_reg_walk_info +{ + ACPI_ADR_SPACE_TYPE SpaceId; + UINT32 Function; + UINT32 RegRunCount; + +} ACPI_REG_WALK_INFO; + + /***************************************************************************** * * Event typedefs and structs @@ -863,7 +898,7 @@ typedef union acpi_parse_value } ACPI_PARSE_VALUE; -#ifdef ACPI_DISASSEMBLER +#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) #define ACPI_DISASM_ONLY_MEMBERS(a) a; #else #define ACPI_DISASM_ONLY_MEMBERS(a) @@ -874,7 +909,7 @@ typedef union acpi_parse_value UINT8 DescriptorType; /* To differentiate various internal objs */\ UINT8 Flags; /* Type of Op */\ UINT16 AmlOpcode; /* AML opcode */\ - UINT32 AmlOffset; /* Offset of declaration in AML */\ + UINT8 *Aml; /* Address of declaration in AML */\ union acpi_parse_object *Next; /* Next op */\ ACPI_NAMESPACE_NODE *Node; /* For use by interpreter */\ ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ @@ -990,23 +1025,24 @@ typedef struct acpi_parse_state /* Parse object flags */ -#define ACPI_PARSEOP_GENERIC 0x01 -#define ACPI_PARSEOP_NAMED 0x02 -#define ACPI_PARSEOP_DEFERRED 0x04 -#define ACPI_PARSEOP_BYTELIST 0x08 -#define ACPI_PARSEOP_IN_STACK 0x10 -#define ACPI_PARSEOP_TARGET 0x20 -#define ACPI_PARSEOP_IN_CACHE 0x80 +#define ACPI_PARSEOP_GENERIC 0x01 +#define ACPI_PARSEOP_NAMED_OBJECT 0x02 +#define ACPI_PARSEOP_DEFERRED 0x04 +#define ACPI_PARSEOP_BYTELIST 0x08 +#define ACPI_PARSEOP_IN_STACK 0x10 +#define ACPI_PARSEOP_TARGET 0x20 +#define ACPI_PARSEOP_IN_CACHE 0x80 /* Parse object DisasmFlags */ -#define ACPI_PARSEOP_IGNORE 0x01 -#define ACPI_PARSEOP_PARAMLIST 0x02 -#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 -#define ACPI_PARSEOP_PREDEF_CHECKED 0x08 -#define ACPI_PARSEOP_SPECIAL 0x10 -#define ACPI_PARSEOP_COMPOUND 0x20 -#define ACPI_PARSEOP_ASSIGNMENT 0x40 +#define ACPI_PARSEOP_IGNORE 0x01 +#define ACPI_PARSEOP_PARAMETER_LIST 0x02 +#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 +#define ACPI_PARSEOP_PREDEFINED_CHECKED 0x08 +#define ACPI_PARSEOP_CLOSING_PAREN 0x10 +#define ACPI_PARSEOP_COMPOUND_ASSIGNMENT 0x20 +#define ACPI_PARSEOP_ASSIGNMENT 0x40 +#define ACPI_PARSEOP_ELSEIF 0x80 /***************************************************************************** @@ -1249,6 +1285,7 @@ typedef struct acpi_external_list #define ACPI_EXT_ORIGIN_FROM_FILE 0x02 /* External came from a file */ #define ACPI_EXT_INTERNAL_PATH_ALLOCATED 0x04 /* Deallocate internal path on completion */ #define ACPI_EXT_EXTERNAL_EMITTED 0x08 /* External() statement has been emitted */ +#define ACPI_EXT_ORIGIN_FROM_OPCODE 0x10 /* External came from a External() opcode */ typedef struct acpi_external_file @@ -1290,7 +1327,9 @@ typedef struct acpi_db_method_info * Index of current thread inside all them created. */ char InitArgs; +#ifdef ACPI_DEBUGGER ACPI_OBJECT_TYPE ArgTypes[4]; +#endif char *Arguments[4]; char NumThreadsStr[11]; char IdOfThreadStr[11]; @@ -1312,6 +1351,13 @@ typedef struct acpi_integrity_info #define ACPI_DB_DUPLICATE_OUTPUT 0x03 +typedef struct acpi_object_info +{ + UINT32 Types[ACPI_TOTAL_TYPES]; + +} ACPI_OBJECT_INFO; + + /***************************************************************************** * * Debug diff --git a/sys/contrib/dev/acpica/include/acmacros.h b/sys/contrib/dev/acpica/include/acmacros.h index 35d53f6..21256cb 100644 --- a/sys/contrib/dev/acpica/include/acmacros.h +++ b/sys/contrib/dev/acpica/include/acmacros.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -223,6 +223,16 @@ #define ACPI_MUL_32(a) _ACPI_MUL(a, 5) #define ACPI_MOD_32(a) _ACPI_MOD(a, 32) +/* Test for ASCII character */ + +#define ACPI_IS_ASCII(c) ((c) < 0x80) + +/* Signed integers */ + +#define ACPI_SIGN_POSITIVE 0 +#define ACPI_SIGN_NEGATIVE 1 + + /* * Rounding macros (Power of two boundaries only) */ @@ -277,10 +287,10 @@ /* Generic bitfield macros and masks */ #define ACPI_GET_BITS(SourcePtr, Position, Mask) \ - ((*SourcePtr >> Position) & Mask) + ((*(SourcePtr) >> (Position)) & (Mask)) #define ACPI_SET_BITS(TargetPtr, Position, Mask, Value) \ - (*TargetPtr |= ((Value & Mask) << Position)) + (*(TargetPtr) |= (((Value) & (Mask)) << (Position))) #define ACPI_1BIT_MASK 0x00000001 #define ACPI_2BIT_MASK 0x00000003 @@ -396,18 +406,6 @@ /* - * Some code only gets executed when the debugger is built in. - * Note that this is entirely independent of whether the - * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not. - */ -#ifdef ACPI_DEBUGGER -#define ACPI_DEBUGGER_EXEC(a) a -#else -#define ACPI_DEBUGGER_EXEC(a) -#endif - - -/* * Macros used for ACPICA utilities only */ diff --git a/sys/contrib/dev/acpica/include/acnames.h b/sys/contrib/dev/acpica/include/acnames.h index 6bb6bbf..4710323 100644 --- a/sys/contrib/dev/acpica/include/acnames.h +++ b/sys/contrib/dev/acpica/include/acnames.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,7 @@ #define METHOD_NAME__BBN "_BBN" #define METHOD_NAME__CBA "_CBA" #define METHOD_NAME__CID "_CID" +#define METHOD_NAME__CLS "_CLS" #define METHOD_NAME__CRS "_CRS" #define METHOD_NAME__DDN "_DDN" #define METHOD_NAME__HID "_HID" diff --git a/sys/contrib/dev/acpica/include/acnamesp.h b/sys/contrib/dev/acpica/include/acnamesp.h index 07e76b5..11ee70d 100644 --- a/sys/contrib/dev/acpica/include/acnamesp.h +++ b/sys/contrib/dev/acpica/include/acnamesp.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,6 +67,7 @@ #define ACPI_NS_PREFIX_IS_SCOPE 0x10 #define ACPI_NS_EXTERNAL 0x20 #define ACPI_NS_TEMPORARY 0x40 +#define ACPI_NS_OVERRIDE_IF_FOUND 0x80 /* Flags for AcpiNsWalkNamespace */ @@ -77,6 +78,7 @@ /* Object is not a package element */ #define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX +#define ACPI_ALL_PACKAGE_ELEMENTS (ACPI_UINT32_MAX-1) /* Always emit warning message, not dependent on node flags */ @@ -92,7 +94,7 @@ AcpiNsInitializeObjects ( ACPI_STATUS AcpiNsInitializeDevices ( - void); + UINT32 Flags); /* @@ -223,11 +225,19 @@ AcpiNsConvertToBuffer ( ACPI_STATUS AcpiNsConvertToUnicode ( + ACPI_NAMESPACE_NODE *Scope, ACPI_OPERAND_OBJECT *OriginalObject, ACPI_OPERAND_OBJECT **ReturnObject); ACPI_STATUS AcpiNsConvertToResource ( + ACPI_NAMESPACE_NODE *Scope, + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +ACPI_STATUS +AcpiNsConvertToReference ( + ACPI_NAMESPACE_NODE *Scope, ACPI_OPERAND_OBJECT *OriginalObject, ACPI_OPERAND_OBJECT **ReturnObject); @@ -248,14 +258,14 @@ AcpiNsDumpEntry ( void AcpiNsDumpPathname ( ACPI_HANDLE Handle, - char *Msg, + const char *Msg, UINT32 Level, UINT32 Component); void AcpiNsPrintPathname ( UINT32 NumSegments, - char *Pathname); + const char *Pathname); ACPI_STATUS AcpiNsDumpOneObject ( @@ -349,16 +359,22 @@ UINT32 AcpiNsOpensScope ( ACPI_OBJECT_TYPE Type); -ACPI_STATUS -AcpiNsBuildExternalPath ( - ACPI_NAMESPACE_NODE *Node, - ACPI_SIZE Size, - char *NameBuffer); - char * AcpiNsGetExternalPathname ( ACPI_NAMESPACE_NODE *Node); +UINT32 +AcpiNsBuildNormalizedPath ( + ACPI_NAMESPACE_NODE *Node, + char *FullPath, + UINT32 PathSize, + BOOLEAN NoTrailing); + +char * +AcpiNsGetNormalizedPathname ( + ACPI_NAMESPACE_NODE *Node, + BOOLEAN NoTrailing); + char * AcpiNsNameOfCurrentScope ( ACPI_WALK_STATE *WalkState); @@ -366,7 +382,8 @@ AcpiNsNameOfCurrentScope ( ACPI_STATUS AcpiNsHandleToPathname ( ACPI_HANDLE TargetHandle, - ACPI_BUFFER *Buffer); + ACPI_BUFFER *Buffer, + BOOLEAN NoTrailing); BOOLEAN AcpiNsPatternMatch ( diff --git a/sys/contrib/dev/acpica/include/acobject.h b/sys/contrib/dev/acpica/include/acobject.h index b7b624b..83f29ec 100644 --- a/sys/contrib/dev/acpica/include/acobject.h +++ b/sys/contrib/dev/acpica/include/acobject.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -94,9 +94,10 @@ #define AOPOBJ_AML_CONSTANT 0x01 /* Integer is an AML constant */ #define AOPOBJ_STATIC_POINTER 0x02 /* Data is part of an ACPI table, don't delete */ #define AOPOBJ_DATA_VALID 0x04 /* Object is initialized and data is valid */ -#define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized, _REG was run */ -#define AOPOBJ_SETUP_COMPLETE 0x10 /* Region setup is complete */ -#define AOPOBJ_INVALID 0x20 /* Host OS won't allow a Region address */ +#define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized */ +#define AOPOBJ_REG_CONNECTED 0x10 /* _REG was run */ +#define AOPOBJ_SETUP_COMPLETE 0x20 /* Region setup is complete */ +#define AOPOBJ_INVALID 0x40 /* Host OS won't allow a Region address */ /****************************************************************************** @@ -213,6 +214,7 @@ typedef struct acpi_object_method UINT8 ParamCount; UINT8 SyncLevel; union acpi_operand_object *Mutex; + union acpi_operand_object *Node; UINT8 *AmlStart; union { @@ -430,13 +432,14 @@ typedef struct acpi_object_addr_handler typedef struct acpi_object_reference { ACPI_OBJECT_COMMON_HEADER - UINT8 Class; /* Reference Class */ - UINT8 TargetType; /* Used for Index Op */ - UINT8 Reserved; - void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ - ACPI_NAMESPACE_NODE *Node; /* RefOf or Namepath */ - union acpi_operand_object **Where; /* Target of Index */ - UINT32 Value; /* Used for Local/Arg/Index/DdbHandle */ + UINT8 Class; /* Reference Class */ + UINT8 TargetType; /* Used for Index Op */ + UINT8 Reserved; + void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ + ACPI_NAMESPACE_NODE *Node; /* RefOf or Namepath */ + union acpi_operand_object **Where; /* Target of Index */ + UINT8 *IndexPointer; /* Used for Buffers and Strings */ + UINT32 Value; /* Used for Local/Arg/Index/DdbHandle */ } ACPI_OBJECT_REFERENCE; diff --git a/sys/contrib/dev/acpica/include/acopcode.h b/sys/contrib/dev/acpica/include/acopcode.h index 9432d61..a278d4a 100644 --- a/sys/contrib/dev/acpica/include/acopcode.h +++ b/sys/contrib/dev/acpica/include/acopcode.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -93,7 +93,7 @@ #define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) #define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_NAME_OR_REF,ARGP_TARGET) #define ARGP_CONNECTFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_CONTINUE_OP ARG_NONE #define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME) @@ -153,13 +153,14 @@ #define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_NOOP_OP ARG_NONE #define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_OBJECT_TYPE_OP ARGP_LIST1 (ARGP_NAME_OR_REF) #define ARGP_ONE_OP ARG_NONE #define ARGP_ONES_OP ARG_NONE #define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) #define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) #define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) #define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) -#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_NAME_OR_REF) #define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) #define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) @@ -186,7 +187,6 @@ #define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) #define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) #define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST) #define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) @@ -213,7 +213,7 @@ #define ARGI_ARG4 ARG_NONE #define ARGI_ARG5 ARG_NONE #define ARGI_ARG6 ARG_NONE -#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_BANK_FIELD_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) @@ -225,7 +225,7 @@ #define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_BYTE_OP ARGI_INVALID_OPCODE #define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE -#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) +#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_ANYTYPE, ARGI_ANYTYPE, ARGI_TARGETREF) #define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) #define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) #define ARGI_CONNECTFIELD_OP ARGI_INVALID_OPCODE @@ -287,6 +287,7 @@ #define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE #define ARGI_NOOP_OP ARG_NONE #define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER) +#define ARGI_OBJECT_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) #define ARGI_ONE_OP ARG_NONE #define ARGI_ONES_OP ARG_NONE #define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) @@ -309,7 +310,7 @@ #define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE -#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF) +#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_STORE_TARGET) #define ARGI_STRING_OP ARGI_INVALID_OPCODE #define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE @@ -320,7 +321,6 @@ #define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) #define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) #define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) -#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) #define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) #define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) diff --git a/sys/contrib/dev/acpica/include/acoutput.h b/sys/contrib/dev/acpica/include/acoutput.h index ab07809..4fb7182 100644 --- a/sys/contrib/dev/acpica/include/acoutput.h +++ b/sys/contrib/dev/acpica/include/acoutput.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -89,7 +89,8 @@ #define ACPI_LV_DEBUG_OBJECT 0x00000002 #define ACPI_LV_INFO 0x00000004 #define ACPI_LV_REPAIR 0x00000008 -#define ACPI_LV_ALL_EXCEPTIONS 0x0000000F +#define ACPI_LV_TRACE_POINT 0x00000010 +#define ACPI_LV_ALL_EXCEPTIONS 0x0000001F /* Trace verbosity level 1 [Standard Trace Level] */ @@ -149,6 +150,7 @@ #define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT) #define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) #define ACPI_DB_REPAIR ACPI_DEBUG_LEVEL (ACPI_LV_REPAIR) +#define ACPI_DB_TRACE_POINT ACPI_DEBUG_LEVEL (ACPI_LV_TRACE_POINT) #define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) /* Trace level -- also used in the global "DebugLevel" */ @@ -185,6 +187,21 @@ #define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) +/* + * Global trace flags + */ +#define ACPI_TRACE_ENABLED ((UINT32) 4) +#define ACPI_TRACE_ONESHOT ((UINT32) 2) +#define ACPI_TRACE_OPCODE ((UINT32) 1) + +/* Defaults for trace debugging level/layer */ + +#define ACPI_TRACE_LEVEL_ALL ACPI_LV_ALL +#define ACPI_TRACE_LAYER_ALL 0x000001FF +#define ACPI_TRACE_LEVEL_DEFAULT ACPI_LV_TRACE_POINT +#define ACPI_TRACE_LAYER_DEFAULT ACPI_EXECUTER + + #if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) /* * The module name is used primarily for error and debug messages. @@ -250,7 +267,7 @@ #define ACPI_GET_FUNCTION_NAME _AcpiFunctionName /* - * The Name parameter should be the procedure name as a quoted string. + * The Name parameter should be the procedure name as a non-quoted string. * The function name is also used by the function exit macros below. * Note: (const char) is used to be compatible with the debug interfaces * and macros such as __FUNCTION__. @@ -298,8 +315,12 @@ /* DEBUG_PRINT functions */ -#define ACPI_DEBUG_PRINT(plist) ACPI_ACTUAL_DEBUG plist -#define ACPI_DEBUG_PRINT_RAW(plist) ACPI_ACTUAL_DEBUG_RAW plist +#ifndef COMPILER_VA_MACRO + +#define ACPI_DEBUG_PRINT(plist) AcpiDebugPrint plist +#define ACPI_DEBUG_PRINT_RAW(plist) AcpiDebugPrintRaw plist + +#else /* Helper macros for DEBUG_PRINT */ @@ -319,6 +340,11 @@ ACPI_DO_DEBUG_PRINT (AcpiDebugPrintRaw, Level, Line, \ Filename, Modulename, Component, __VA_ARGS__) +#define ACPI_DEBUG_PRINT(plist) ACPI_ACTUAL_DEBUG plist +#define ACPI_DEBUG_PRINT_RAW(plist) ACPI_ACTUAL_DEBUG_RAW plist + +#endif + /* * Function entry tracing @@ -346,7 +372,7 @@ ACPI_TRACE_ENTRY (Name, AcpiUtTraceU32, UINT32, Value) #define ACPI_FUNCTION_TRACE_STR(Name, String) \ - ACPI_TRACE_ENTRY (Name, AcpiUtTraceStr, char *, String) + ACPI_TRACE_ENTRY (Name, AcpiUtTraceStr, const char *, String) #define ACPI_FUNCTION_ENTRY() \ AcpiUtTrackStackPtr() @@ -406,6 +432,9 @@ #define return_PTR(Pointer) \ ACPI_TRACE_EXIT (AcpiUtPtrExit, void *, Pointer) +#define return_STR(String) \ + ACPI_TRACE_EXIT (AcpiUtStrExit, const char *, String) + #define return_VALUE(Value) \ ACPI_TRACE_EXIT (AcpiUtValueExit, UINT64, Value) @@ -430,6 +459,8 @@ #define ACPI_DUMP_PATHNAME(a, b, c, d) AcpiNsDumpPathname(a, b, c, d) #define ACPI_DUMP_BUFFER(a, b) AcpiUtDebugDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) +#define ACPI_TRACE_POINT(a, b, c, d) AcpiTracePoint (a, b, c, d) + #else /* ACPI_DEBUG_OUTPUT */ /* * This is the non-debug case -- make everything go away, @@ -451,12 +482,14 @@ #define ACPI_DUMP_PATHNAME(a, b, c, d) #define ACPI_DUMP_BUFFER(a, b) #define ACPI_IS_DEBUG_ENABLED(Level, Component) 0 +#define ACPI_TRACE_POINT(a, b, c, d) /* Return macros must have a return statement at the minimum */ #define return_VOID return #define return_ACPI_STATUS(s) return(s) #define return_PTR(s) return(s) +#define return_STR(s) return(s) #define return_VALUE(s) return(s) #define return_UINT8(s) return(s) #define return_UINT32(s) return(s) diff --git a/sys/contrib/dev/acpica/include/acparser.h b/sys/contrib/dev/acpica/include/acparser.h index a3c7666..dd27821 100644 --- a/sys/contrib/dev/acpica/include/acparser.h +++ b/sys/contrib/dev/acpica/include/acparser.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -106,7 +106,12 @@ AcpiPsGetNextNamepath ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Arg, - BOOLEAN MethodCall); + BOOLEAN PossibleMethodCall); + +/* Values for BOOLEAN above */ + +#define ACPI_NOT_METHOD_CALL FALSE +#define ACPI_POSSIBLE_METHOD_CALL TRUE ACPI_STATUS AcpiPsGetNextArg ( @@ -166,7 +171,7 @@ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode); -char * +const char * AcpiPsGetOpcodeName ( UINT16 Opcode); @@ -306,7 +311,7 @@ AcpiPsDeleteParseTree ( */ ACPI_PARSE_OBJECT * AcpiPsCreateScopeOp ( - void); + UINT8 *Aml); void AcpiPsInitOp ( @@ -315,7 +320,8 @@ AcpiPsInitOp ( ACPI_PARSE_OBJECT * AcpiPsAllocOp ( - UINT16 opcode); + UINT16 Opcode, + UINT8 *Aml); void AcpiPsFreeOp ( diff --git a/sys/contrib/dev/acpica/include/acpi.h b/sys/contrib/dev/acpica/include/acpi.h index c57d4e3..6c422de 100644 --- a/sys/contrib/dev/acpica/include/acpi.h +++ b/sys/contrib/dev/acpica/include/acpi.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acpiosxf.h b/sys/contrib/dev/acpica/include/acpiosxf.h index 21cac7a..b6d0f80 100644 --- a/sys/contrib/dev/acpica/include/acpiosxf.h +++ b/sys/contrib/dev/acpica/include/acpiosxf.h @@ -7,7 +7,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,7 +57,8 @@ typedef enum OSL_GLOBAL_LOCK_HANDLER, OSL_NOTIFY_HANDLER, OSL_GPE_HANDLER, - OSL_DEBUGGER_THREAD, + OSL_DEBUGGER_MAIN_THREAD, + OSL_DEBUGGER_EXEC_THREAD, OSL_EC_POLL_HANDLER, OSL_EC_BURST_HANDLER @@ -599,5 +600,14 @@ AcpiOsSetFileOffset ( UINT8 From); #endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint +void +AcpiOsTracePoint ( + ACPI_TRACE_EVENT_TYPE Type, + BOOLEAN Begin, + UINT8 *Aml, + char *Pathname); +#endif + #endif /* __ACPIOSXF_H__ */ diff --git a/sys/contrib/dev/acpica/include/acpixf.h b/sys/contrib/dev/acpica/include/acpixf.h index 8d972eb..725317c 100644 --- a/sys/contrib/dev/acpica/include/acpixf.h +++ b/sys/contrib/dev/acpica/include/acpixf.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20150515 +#define ACPI_CA_VERSION 0x20160527 #include <contrib/dev/acpica/include/acconfig.h> #include <contrib/dev/acpica/include/actypes.h> @@ -192,6 +192,11 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_CopyDsdtLocally, FALSE); ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DoNotUseXsdt, FALSE); /* + * Optionally support group module level code. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_GroupModuleLevelCode, FALSE); + +/* * Optionally use 32-bit FADT addresses if and when there is a conflict * (address mismatch) between the 32-bit and 64-bit versions of the * address. Although ACPICA adheres to the ACPI specification which @@ -202,6 +207,15 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DoNotUseXsdt, FALSE); ACPI_INIT_GLOBAL (UINT8, AcpiGbl_Use32BitFadtAddresses, FALSE); /* + * Optionally use 32-bit FACS table addresses. + * It is reported that some platforms fail to resume from system suspending + * if 64-bit FACS table address is selected: + * https://bugzilla.kernel.org/show_bug.cgi?id=74021 + * Default is TRUE, favor the 32-bit addresses. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_Use32BitFacsAddresses, TRUE); + +/* * Optionally truncate I/O addresses to 16 bits. Provides compatibility * with other ACPI implementations. NOTE: During ACPICA initialization, * this value is set to TRUE if any Windows OSI strings have been @@ -222,6 +236,11 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableAutoRepair, FALSE); ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableSsdtTableInstall, FALSE); /* + * Optionally enable runtime namespace override. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_RuntimeNamespaceOverride, TRUE); + +/* * We keep track of the latest version of Windows that has been requested by * the BIOS. ACPI 5.0. */ @@ -239,7 +258,9 @@ ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_ReducedHardware, FALSE); * traced each time it is executed. */ ACPI_INIT_GLOBAL (UINT32, AcpiGbl_TraceFlags, 0); -ACPI_INIT_GLOBAL (ACPI_NAME, AcpiGbl_TraceMethodName, 0); +ACPI_INIT_GLOBAL (const char *, AcpiGbl_TraceMethodName, NULL); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_TraceDbgLevel, ACPI_TRACE_LEVEL_DEFAULT); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_TraceDbgLayer, ACPI_TRACE_LAYER_DEFAULT); /* * Runtime configuration of debug output control masks. We want the debug @@ -253,6 +274,10 @@ ACPI_INIT_GLOBAL (UINT32, AcpiDbgLevel, ACPI_NORMAL_DEFAULT); #endif ACPI_INIT_GLOBAL (UINT32, AcpiDbgLayer, ACPI_COMPONENT_DEFAULT); +/* Optionally enable timer output with Debug Object output */ + +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisplayDebugTimer, FALSE); + /* * Other miscellaneous globals */ @@ -361,6 +386,30 @@ ACPI_GLOBAL (BOOLEAN, AcpiGbl_SystemAwakeAndRunning); #endif /* ACPI_APPLICATION */ +/* + * Debugger prototypes + * + * All interfaces used by debugger will be configured + * out of the ACPICA build unless the ACPI_DEBUGGER + * flag is defined. + */ +#ifdef ACPI_DEBUGGER +#define ACPI_DBR_DEPENDENT_RETURN_OK(Prototype) \ + ACPI_EXTERNAL_RETURN_OK(Prototype) + +#define ACPI_DBR_DEPENDENT_RETURN_VOID(Prototype) \ + ACPI_EXTERNAL_RETURN_VOID(Prototype) + +#else +#define ACPI_DBR_DEPENDENT_RETURN_OK(Prototype) \ + static ACPI_INLINE Prototype {return(AE_OK);} + +#define ACPI_DBR_DEPENDENT_RETURN_VOID(Prototype) \ + static ACPI_INLINE Prototype {return;} + +#endif /* ACPI_DEBUGGER */ + + /***************************************************************************** * * ACPICA public interface prototypes @@ -596,7 +645,7 @@ AcpiGetData ( ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiDebugTrace ( - char *Name, + const char *Name, UINT32 DebugLevel, UINT32 DebugLayer, UINT32 Flags)) @@ -1066,14 +1115,8 @@ AcpiLeaveSleepState ( ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS AcpiSetFirmwareWakingVector ( - UINT32 PhysicalAddress)) - -#if ACPI_MACHINE_WIDTH == 64 -ACPI_HW_DEPENDENT_RETURN_STATUS ( -ACPI_STATUS -AcpiSetFirmwareWakingVector64 ( - UINT64 PhysicalAddress)) -#endif + ACPI_PHYSICAL_ADDRESS PhysicalAddress, + ACPI_PHYSICAL_ADDRESS PhysicalAddress64)) /* @@ -1129,11 +1172,9 @@ AcpiWarning ( ...)) ACPI_MSG_DEPENDENT_RETURN_VOID ( -ACPI_PRINTF_LIKE(3) +ACPI_PRINTF_LIKE(1) void ACPI_INTERNAL_VAR_XFACE AcpiInfo ( - const char *ModuleName, - UINT32 LineNumber, const char *Format, ...)) @@ -1183,6 +1224,14 @@ AcpiDebugPrintRaw ( const char *Format, ...)) +ACPI_DBG_DEPENDENT_RETURN_VOID ( +void +AcpiTracePoint ( + ACPI_TRACE_EVENT_TYPE Type, + BOOLEAN Begin, + UINT8 *Aml, + char *Pathname)) + ACPI_APP_DEPENDENT_RETURN_VOID ( ACPI_PRINTF_LIKE(1) void ACPI_INTERNAL_VAR_XFACE @@ -1190,4 +1239,16 @@ AcpiLogError ( const char *Format, ...)) +ACPI_STATUS +AcpiInitializeDebugger ( + void); + +void +AcpiTerminateDebugger ( + void); + +void +AcpiSetDebuggerThreadId ( + ACPI_THREAD_ID ThreadId); + #endif /* __ACXFACE_H__ */ diff --git a/sys/contrib/dev/acpica/include/acpredef.h b/sys/contrib/dev/acpica/include/acpredef.h index 5dae6aa..ab61c53 100644 --- a/sys/contrib/dev/acpica/include/acpredef.h +++ b/sys/contrib/dev/acpica/include/acpredef.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -131,7 +131,8 @@ enum AcpiReturnPackageTypes ACPI_PTYPE2_REV_FIXED = 9, ACPI_PTYPE2_FIX_VAR = 10, ACPI_PTYPE2_VAR_VAR = 11, - ACPI_PTYPE2_UUID_PAIR = 12 + ACPI_PTYPE2_UUID_PAIR = 12, + ACPI_PTYPE_CUSTOM = 13 }; @@ -344,7 +345,7 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_BIX", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (16 Int),(4 Str) */ - PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING, 4,0), + PACKAGE_INFO (ACPI_PTYPE_CUSTOM, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING, 4,0), {{"_BLT", METHOD_3ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER), METHOD_NO_RETURN_VALUE}}, @@ -516,6 +517,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */ PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0,0,0), + {{"_FIT", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, /* ACPI 6.0 */ + {{"_FIX", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints) */ PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0,0,0), @@ -1030,6 +1034,12 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_WED", METHOD_1ARGS (ACPI_TYPE_INTEGER), METHOD_RETURNS (ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER)}}, + {{"_WPC", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* ACPI 6.1 */ + + {{"_WPP", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* ACPI 6.1 */ + PACKAGE_INFO (0,0,0,0,0,0) /* Table terminator */ }; #else @@ -1104,7 +1114,7 @@ const ACPI_PREDEFINED_INFO AcpiGbl_ResourceNames[] = PACKAGE_INFO (0,0,0,0,0,0) /* Table terminator */ }; -static const ACPI_PREDEFINED_INFO AcpiGbl_ScopeNames[] = { +const ACPI_PREDEFINED_INFO AcpiGbl_ScopeNames[] = { {{"_GPE", 0, 0}}, {{"_PR_", 0, 0}}, {{"_SB_", 0, 0}}, @@ -1113,7 +1123,7 @@ static const ACPI_PREDEFINED_INFO AcpiGbl_ScopeNames[] = { PACKAGE_INFO (0,0,0,0,0,0) /* Table terminator */ }; #else -extern const ACPI_PREDEFINED_INFO AcpiGbl_ResourceNames[]; +extern const ACPI_PREDEFINED_INFO AcpiGbl_ResourceNames[]; #endif #endif diff --git a/sys/contrib/dev/acpica/include/acresrc.h b/sys/contrib/dev/acpica/include/acresrc.h index ef3265876..001e6d2 100644 --- a/sys/contrib/dev/acpica/include/acresrc.h +++ b/sys/contrib/dev/acpica/include/acresrc.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -130,7 +130,7 @@ typedef const struct acpi_rsdump_info { UINT8 Opcode; UINT8 Offset; - char *Name; + const char *Name; const char **Pointer; } ACPI_RSDUMP_INFO; @@ -227,7 +227,7 @@ AcpiRsGetPrsMethodData ( ACPI_STATUS AcpiRsGetMethodData ( ACPI_HANDLE Handle, - char *Path, + const char *Path, ACPI_BUFFER *RetBuffer); ACPI_STATUS diff --git a/sys/contrib/dev/acpica/include/acrestyp.h b/sys/contrib/dev/acpica/include/acrestyp.h index d695451..72f0d16 100644 --- a/sys/contrib/dev/acpica/include/acrestyp.h +++ b/sys/contrib/dev/acpica/include/acrestyp.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -485,6 +485,7 @@ typedef struct acpi_resource_gpio UINT8 Type; \ UINT8 ProducerConsumer; /* For values, see Producer/Consumer above */\ UINT8 SlaveMode; \ + UINT8 ConnectionSharing; \ UINT8 TypeRevisionId; \ UINT16 TypeDataLength; \ UINT16 VendorLength; \ diff --git a/sys/contrib/dev/acpica/include/acstruct.h b/sys/contrib/dev/acpica/include/acstruct.h index 547921b..f7538ad 100644 --- a/sys/contrib/dev/acpica/include/acstruct.h +++ b/sys/contrib/dev/acpica/include/acstruct.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,9 +85,10 @@ typedef struct acpi_walk_state UINT8 ReturnUsed; UINT8 ScopeDepth; UINT8 PassNumber; /* Parse pass during table load */ + BOOLEAN NamespaceOverride; /* Override existing objects */ UINT8 ResultSize; /* Total elements for the result stack */ UINT8 ResultCount; /* Current number of occupied elements of result stack */ - UINT32 AmlOffset; + UINT8 *Aml; UINT32 ArgTypes; UINT32 MethodBreakpoint; /* For single stepping */ UINT32 UserBreakpoint; /* User AML breakpoint */ @@ -201,7 +202,7 @@ typedef struct acpi_evaluate_info /* The first 3 elements are passed by the caller to AcpiNsEvaluate */ ACPI_NAMESPACE_NODE *PrefixNode; /* Input: starting node */ - char *RelativePathname; /* Input: path relative to PrefixNode */ + const char *RelativePathname; /* Input: path relative to PrefixNode */ ACPI_OPERAND_OBJECT **Parameters; /* Input: argument list */ ACPI_NAMESPACE_NODE *Node; /* Resolved node (PrefixNode:RelativePathname) */ diff --git a/sys/contrib/dev/acpica/include/actables.h b/sys/contrib/dev/acpica/include/actables.h index 3eb02d3..e1a4a6e 100644 --- a/sys/contrib/dev/acpica/include/actables.h +++ b/sys/contrib/dev/acpica/include/actables.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -115,7 +115,7 @@ AcpiTbSetTableLoadedFlag ( */ void AcpiTbParseFadt ( - UINT32 TableIndex); + void); void AcpiTbCreateLocalFadt ( @@ -207,10 +207,6 @@ ACPI_STATUS AcpiTbInitializeFacs ( void); -BOOLEAN -AcpiTbTablesLoaded ( - void); - void AcpiTbPrintTableHeader( ACPI_PHYSICAL_ADDRESS Address, @@ -236,18 +232,26 @@ AcpiTbCopyDsdt ( void AcpiTbInstallTableWithOverride ( - UINT32 TableIndex, ACPI_TABLE_DESC *NewTableDesc, - BOOLEAN Override); + BOOLEAN Override, + UINT32 *TableIndex); ACPI_STATUS AcpiTbInstallFixedTable ( ACPI_PHYSICAL_ADDRESS Address, char *Signature, - UINT32 TableIndex); + UINT32 *TableIndex); ACPI_STATUS AcpiTbParseRootTable ( ACPI_PHYSICAL_ADDRESS RsdpAddress); + +/* + * tbxfload + */ +ACPI_STATUS +AcpiTbLoadNamespace ( + void); + #endif /* __ACTABLES_H__ */ diff --git a/sys/contrib/dev/acpica/include/actbl.h b/sys/contrib/dev/acpica/include/actbl.h index ceef763..0ef82cd 100644 --- a/sys/contrib/dev/acpica/include/actbl.h +++ b/sys/contrib/dev/acpica/include/actbl.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,6 +67,7 @@ #define ACPI_SIG_DSDT "DSDT" /* Differentiated System Description Table */ #define ACPI_SIG_FADT "FACP" /* Fixed ACPI Description Table */ #define ACPI_SIG_FACS "FACS" /* Firmware ACPI Control Structure */ +#define ACPI_SIG_OSDT "OSDT" /* Override System Description Table */ #define ACPI_SIG_PSDT "PSDT" /* Persistent System Description Table */ #define ACPI_SIG_RSDP "RSD PTR " /* Root System Description Pointer */ #define ACPI_SIG_RSDT "RSDT" /* Root System Description Table */ @@ -247,7 +248,7 @@ typedef struct acpi_table_facs /******************************************************************************* * * FADT - Fixed ACPI Description Table (Signature "FACP") - * Version 4 + * Version 6 * ******************************************************************************/ @@ -448,4 +449,6 @@ typedef struct acpi_table_desc #define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId)) #define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) +#define ACPI_FADT_CONFORMANCE "ACPI 6.1 (FADT version 6)" + #endif /* __ACTBL_H__ */ diff --git a/sys/contrib/dev/acpica/include/actbl1.h b/sys/contrib/dev/acpica/include/actbl1.h index 962324a..0fe925a 100644 --- a/sys/contrib/dev/acpica/include/actbl1.h +++ b/sys/contrib/dev/acpica/include/actbl1.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -268,7 +268,8 @@ enum AcpiEinjActions ACPI_EINJ_CHECK_BUSY_STATUS = 6, ACPI_EINJ_GET_COMMAND_STATUS = 7, ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS = 8, - ACPI_EINJ_ACTION_RESERVED = 9, /* 9 and greater are reserved */ + ACPI_EINJ_GET_EXECUTE_TIMINGS = 9, + ACPI_EINJ_ACTION_RESERVED = 10, /* 10 and greater are reserved */ ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */ }; @@ -397,7 +398,8 @@ enum AcpiErstActions ACPI_ERST_GET_ERROR_RANGE = 13, ACPI_ERST_GET_ERROR_LENGTH = 14, ACPI_ERST_GET_ERROR_ATTRIBUTES = 15, - ACPI_ERST_ACTION_RESERVED = 16 /* 16 and greater are reserved */ + ACPI_ERST_EXECUTE_TIMINGS = 16, + ACPI_ERST_ACTION_RESERVED = 17 /* 17 and greater are reserved */ }; /* Values for Instruction field above */ @@ -489,7 +491,8 @@ enum AcpiHestTypes ACPI_HEST_TYPE_AER_ENDPOINT = 7, ACPI_HEST_TYPE_AER_BRIDGE = 8, ACPI_HEST_TYPE_GENERIC_ERROR = 9, - ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */ + ACPI_HEST_TYPE_GENERIC_ERROR_V2 = 10, + ACPI_HEST_TYPE_RESERVED = 11 /* 11 and greater are reserved */ }; @@ -578,7 +581,11 @@ enum AcpiHestNotifyTypes ACPI_HEST_NOTIFY_NMI = 4, ACPI_HEST_NOTIFY_CMCI = 5, /* ACPI 5.0 */ ACPI_HEST_NOTIFY_MCE = 6, /* ACPI 5.0 */ - ACPI_HEST_NOTIFY_RESERVED = 7 /* 7 and greater are reserved */ + ACPI_HEST_NOTIFY_GPIO = 7, /* ACPI 6.0 */ + ACPI_HEST_NOTIFY_SEA = 8, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_SEI = 9, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_GSIV = 10, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_RESERVED = 11 /* 11 and greater are reserved */ }; /* Values for ConfigWriteEnable bitfield above */ @@ -697,6 +704,27 @@ typedef struct acpi_hest_generic } ACPI_HEST_GENERIC; +/* 10: Generic Hardware Error Source, version 2 */ + +typedef struct acpi_hest_generic_v2 +{ + ACPI_HEST_HEADER Header; + UINT16 RelatedSourceId; + UINT8 Reserved; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 MaxRawDataLength; + ACPI_GENERIC_ADDRESS ErrorStatusAddress; + ACPI_HEST_NOTIFY Notify; + UINT32 ErrorBlockLength; + ACPI_GENERIC_ADDRESS ReadAckRegister; + UINT64 ReadAckPreserve; + UINT64 ReadAckWrite; + +} ACPI_HEST_GENERIC_V2; + + /* Generic Error Status block */ typedef struct acpi_hest_generic_status @@ -733,6 +761,35 @@ typedef struct acpi_hest_generic_data } ACPI_HEST_GENERIC_DATA; +/* Extension for revision 0x0300 */ + +typedef struct acpi_hest_generic_data_v300 +{ + UINT8 SectionType[16]; + UINT32 ErrorSeverity; + UINT16 Revision; + UINT8 ValidationBits; + UINT8 Flags; + UINT32 ErrorDataLength; + UINT8 FruId[16]; + UINT8 FruText[20]; + UINT64 TimeStamp; + +} ACPI_HEST_GENERIC_DATA_V300; + +/* Values for ErrorSeverity above */ + +#define ACPI_HEST_GEN_ERROR_RECOVERABLE 0 +#define ACPI_HEST_GEN_ERROR_FATAL 1 +#define ACPI_HEST_GEN_ERROR_CORRECTED 2 +#define ACPI_HEST_GEN_ERROR_NONE 3 + +/* Flags for ValidationBits above */ + +#define ACPI_HEST_GEN_VALID_FRU_ID (1) +#define ACPI_HEST_GEN_VALID_FRU_STRING (1<<1) +#define ACPI_HEST_GEN_VALID_TIMESTAMP (1<<2) + /******************************************************************************* * @@ -974,10 +1031,22 @@ typedef struct acpi_madt_generic_distributor UINT64 BaseAddress; UINT32 GlobalIrqBase; UINT8 Version; - UINT8 Reserved2[3]; /* Reserved - must be zero */ + UINT8 Reserved2[3]; /* Reserved - must be zero */ } ACPI_MADT_GENERIC_DISTRIBUTOR; +/* Values for Version field above */ + +enum AcpiMadtGicVersion +{ + ACPI_MADT_GIC_VERSION_NONE = 0, + ACPI_MADT_GIC_VERSION_V1 = 1, + ACPI_MADT_GIC_VERSION_V2 = 2, + ACPI_MADT_GIC_VERSION_V3 = 3, + ACPI_MADT_GIC_VERSION_V4 = 4, + ACPI_MADT_GIC_VERSION_RESERVED = 5 /* 5 and greater are reserved */ +}; + /* 13: Generic MSI Frame (ACPI 5.1) */ @@ -1083,7 +1152,7 @@ typedef struct acpi_msct_proximity /******************************************************************************* * - * NFIT - NVDIMM Interface Table (ACPI 6.0) + * NFIT - NVDIMM Interface Table (ACPI 6.0+) * Version 1 * ******************************************************************************/ @@ -1172,9 +1241,10 @@ typedef struct acpi_nfit_memory_map #define ACPI_NFIT_MEM_SAVE_FAILED (1) /* 00: Last SAVE to Memory Device failed */ #define ACPI_NFIT_MEM_RESTORE_FAILED (1<<1) /* 01: Last RESTORE from Memory Device failed */ #define ACPI_NFIT_MEM_FLUSH_FAILED (1<<2) /* 02: Platform flush failed */ -#define ACPI_NFIT_MEM_ARMED (1<<3) /* 03: Memory Device observed to be not armed */ +#define ACPI_NFIT_MEM_NOT_ARMED (1<<3) /* 03: Memory Device is not armed */ #define ACPI_NFIT_MEM_HEALTH_OBSERVED (1<<4) /* 04: Memory Device observed SMART/health events */ #define ACPI_NFIT_MEM_HEALTH_ENABLED (1<<5) /* 05: SMART/health events enabled */ +#define ACPI_NFIT_MEM_MAP_FAILED (1<<6) /* 06: Mapping to SPA failed */ /* 2: Interleave Structure */ @@ -1214,7 +1284,10 @@ typedef struct acpi_nfit_control_region UINT16 SubsystemVendorId; UINT16 SubsystemDeviceId; UINT16 SubsystemRevisionId; - UINT8 Reserved[6]; /* Reserved, must be zero */ + UINT8 ValidFields; + UINT8 ManufacturingLocation; + UINT16 ManufacturingDate; + UINT8 Reserved[2]; /* Reserved, must be zero */ UINT32 SerialNumber; UINT16 Code; UINT16 Windows; @@ -1230,7 +1303,11 @@ typedef struct acpi_nfit_control_region /* Flags */ -#define ACPI_NFIT_CONTROL_BUFFERED (1) /* Block Data Windows implementation is buffered */ +#define ACPI_NFIT_CONTROL_BUFFERED (1) /* Block Data Windows implementation is buffered */ + +/* ValidFields bits */ + +#define ACPI_NFIT_CONTROL_MFG_INFO_VALID (1) /* Manufacturing fields are valid */ /* 5: NVDIMM Block Data Window Region Structure */ diff --git a/sys/contrib/dev/acpica/include/actbl2.h b/sys/contrib/dev/acpica/include/actbl2.h index 6f0c62e..625d33f 100644 --- a/sys/contrib/dev/acpica/include/actbl2.h +++ b/sys/contrib/dev/acpica/include/actbl2.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,8 +52,8 @@ * These tables are not consumed directly by the ACPICA subsystem, but are * included here to support device drivers and the AML disassembler. * - * The tables in this file are defined by third-party specifications, and are - * not defined directly by the ACPI specification itself. + * Generally, the tables in this file are defined by third-party specifications, + * and are not defined directly by the ACPI specification itself. * ******************************************************************************/ @@ -82,6 +82,7 @@ #define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ #define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ #define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ +#define ACPI_SIG_TPM2 "TPM2" /* Trusted Platform Module 2.0 H/W interface table */ #define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ #define ACPI_SIG_VRTC "VRTC" /* Virtual Real Time Clock Table */ #define ACPI_SIG_WAET "WAET" /* Windows ACPI Emulated devices Table */ @@ -363,7 +364,7 @@ typedef struct acpi_csrt_descriptor * DBG2 - Debug Port Table 2 * Version 0 (Both main table and subtables) * - * Conforms to "Microsoft Debug Port Table 2 (DBG2)", May 22 2012. + * Conforms to "Microsoft Debug Port Table 2 (DBG2)", December 10, 2015 * ******************************************************************************/ @@ -420,6 +421,11 @@ typedef struct acpi_dbg2_device #define ACPI_DBG2_16550_COMPATIBLE 0x0000 #define ACPI_DBG2_16550_SUBSET 0x0001 +#define ACPI_DBG2_ARM_PL011 0x0003 +#define ACPI_DBG2_ARM_SBSA_32BIT 0x000D +#define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E +#define ACPI_DBG2_ARM_DCC 0x000F +#define ACPI_DBG2_BCM2835 0x0010 #define ACPI_DBG2_1394_STANDARD 0x0000 @@ -452,7 +458,7 @@ typedef struct acpi_table_dbgp * Version 1 * * Conforms to "Intel Virtualization Technology for Directed I/O", - * Version 2.2, Sept. 2013 + * Version 2.3, October 2014 * ******************************************************************************/ @@ -468,6 +474,8 @@ typedef struct acpi_table_dmar /* Masks for Flags field above */ #define ACPI_DMAR_INTR_REMAP (1) +#define ACPI_DMAR_X2APIC_OPT_OUT (1<<1) +#define ACPI_DMAR_X2APIC_MODE (1<<2) /* DMAR subtable header */ @@ -756,7 +764,7 @@ typedef struct acpi_ibft_target * IORT - IO Remapping Table * * Conforms to "IO Remapping Table System Software on ARM Platforms", - * Document number: ARM DEN 0049A, 2015 + * Document number: ARM DEN 0049B, October 2015 * ******************************************************************************/ @@ -792,7 +800,8 @@ enum AcpiIortNodeType ACPI_IORT_NODE_ITS_GROUP = 0x00, ACPI_IORT_NODE_NAMED_COMPONENT = 0x01, ACPI_IORT_NODE_PCI_ROOT_COMPLEX = 0x02, - ACPI_IORT_NODE_SMMU = 0x03 + ACPI_IORT_NODE_SMMU = 0x03, + ACPI_IORT_NODE_SMMU_V3 = 0x04 }; @@ -901,6 +910,26 @@ typedef struct acpi_iort_smmu #define ACPI_IORT_SMMU_COHERENT_WALK (1<<1) +typedef struct acpi_iort_smmu_v3 +{ + UINT64 BaseAddress; /* SMMUv3 base address */ + UINT32 Flags; + UINT32 Reserved; + UINT64 VatosAddress; + UINT32 Model; /* O: generic SMMUv3 */ + UINT32 EventGsiv; + UINT32 PriGsiv; + UINT32 GerrGsiv; + UINT32 SyncGsiv; + +} ACPI_IORT_SMMU_V3; + +/* Masks for Flags field above */ + +#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE (1) +#define ACPI_IORT_SMMU_V3_HTTU_OVERRIDE (1<<1) + + /******************************************************************************* * * IVRS - I/O Virtualization Reporting Structure @@ -1283,10 +1312,10 @@ typedef struct acpi_table_slic /******************************************************************************* * * SPCR - Serial Port Console Redirection table - * Version 1 + * Version 2 * * Conforms to "Serial Port Console Redirection Table", - * Version 1.00, January 11, 2002 + * Version 1.03, August 10, 2015 * ******************************************************************************/ @@ -1320,6 +1349,8 @@ typedef struct acpi_table_spcr #define ACPI_SPCR_DO_NOT_DISABLE (1) +/* Values for Interface Type: See the definition of the DBG2 table */ + /******************************************************************************* * @@ -1368,21 +1399,103 @@ enum AcpiSpmiInterfaceTypes /******************************************************************************* * * TCPA - Trusted Computing Platform Alliance table - * Version 1 + * Version 2 * - * Conforms to "TCG PC Specific Implementation Specification", - * Version 1.1, August 18, 2003 + * Conforms to "TCG ACPI Specification, Family 1.2 and 2.0", + * December 19, 2014 + * + * NOTE: There are two versions of the table with the same signature -- + * the client version and the server version. The common PlatformClass + * field is used to differentiate the two types of tables. * ******************************************************************************/ -typedef struct acpi_table_tcpa +typedef struct acpi_table_tcpa_hdr { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 PlatformClass; + +} ACPI_TABLE_TCPA_HDR; + +/* + * Values for PlatformClass above. + * This is how the client and server subtables are differentiated + */ +#define ACPI_TCPA_CLIENT_TABLE 0 +#define ACPI_TCPA_SERVER_TABLE 1 + + +typedef struct acpi_table_tcpa_client +{ + UINT32 MinimumLogLength; /* Minimum length for the event log area */ + UINT64 LogAddress; /* Address of the event log area */ + +} ACPI_TABLE_TCPA_CLIENT; + +typedef struct acpi_table_tcpa_server +{ UINT16 Reserved; - UINT32 MaxLogLength; /* Maximum length for the event log area */ + UINT64 MinimumLogLength; /* Minimum length for the event log area */ UINT64 LogAddress; /* Address of the event log area */ + UINT16 SpecRevision; + UINT8 DeviceFlags; + UINT8 InterruptFlags; + UINT8 GpeNumber; + UINT8 Reserved2[3]; + UINT32 GlobalInterrupt; + ACPI_GENERIC_ADDRESS Address; + UINT32 Reserved3; + ACPI_GENERIC_ADDRESS ConfigAddress; + UINT8 Group; + UINT8 Bus; /* PCI Bus/Segment/Function numbers */ + UINT8 Device; + UINT8 Function; + +} ACPI_TABLE_TCPA_SERVER; + +/* Values for DeviceFlags above */ + +#define ACPI_TCPA_PCI_DEVICE (1) +#define ACPI_TCPA_BUS_PNP (1<<1) +#define ACPI_TCPA_ADDRESS_VALID (1<<2) + +/* Values for InterruptFlags above */ + +#define ACPI_TCPA_INTERRUPT_MODE (1) +#define ACPI_TCPA_INTERRUPT_POLARITY (1<<1) +#define ACPI_TCPA_SCI_VIA_GPE (1<<2) +#define ACPI_TCPA_GLOBAL_INTERRUPT (1<<3) + + +/******************************************************************************* + * + * TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table + * Version 4 + * + * Conforms to "TCG ACPI Specification, Family 1.2 and 2.0", + * December 19, 2014 + * + ******************************************************************************/ + +typedef struct acpi_table_tpm2 +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 PlatformClass; + UINT16 Reserved; + UINT64 ControlAddress; + UINT32 StartMethod; + + /* Platform-specific data follows */ + +} ACPI_TABLE_TPM2; + +/* Values for StartMethod above */ -} ACPI_TABLE_TCPA; +#define ACPI_TPM2_NOT_ALLOWED 0 +#define ACPI_TPM2_START_METHOD 2 +#define ACPI_TPM2_MEMORY_MAPPED 6 +#define ACPI_TPM2_COMMAND_BUFFER 7 +#define ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD 8 /******************************************************************************* diff --git a/sys/contrib/dev/acpica/include/actbl3.h b/sys/contrib/dev/acpica/include/actbl3.h index f575d08..ef40f19 100644 --- a/sys/contrib/dev/acpica/include/actbl3.h +++ b/sys/contrib/dev/acpica/include/actbl3.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,8 @@ * These tables are not consumed directly by the ACPICA subsystem, but are * included here to support device drivers and the AML disassembler. * - * The tables in this file are fully defined within the ACPI specification. + * In general, the tables in this file are fully defined within the ACPI + * specification. * ******************************************************************************/ @@ -71,7 +72,6 @@ #define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */ #define ACPI_SIG_RASF "RASF" /* RAS Feature table */ #define ACPI_SIG_STAO "STAO" /* Status Override table */ -#define ACPI_SIG_TPM2 "TPM2" /* Trusted Platform Module 2.0 H/W interface table */ #define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */ #define ACPI_SIG_XENV "XENV" /* Xen Environment table */ @@ -205,7 +205,7 @@ typedef struct acpi_table_fpdt } ACPI_TABLE_FPDT; -/* FPDT subtable header */ +/* FPDT subtable header (Performance Record Structure) */ typedef struct acpi_fpdt_header { @@ -230,33 +230,29 @@ enum AcpiFpdtType /* 0: Firmware Basic Boot Performance Record */ -typedef struct acpi_fpdt_boot +typedef struct acpi_fpdt_boot_pointer { ACPI_FPDT_HEADER Header; UINT8 Reserved[4]; - UINT64 ResetEnd; - UINT64 LoadStart; - UINT64 StartupStart; - UINT64 ExitServicesEntry; - UINT64 ExitServicesExit; + UINT64 Address; -} ACPI_FPDT_BOOT; +} ACPI_FPDT_BOOT_POINTER; /* 1: S3 Performance Table Pointer Record */ -typedef struct acpi_fpdt_s3pt_ptr +typedef struct acpi_fpdt_s3pt_pointer { ACPI_FPDT_HEADER Header; UINT8 Reserved[4]; UINT64 Address; -} ACPI_FPDT_S3PT_PTR; +} ACPI_FPDT_S3PT_POINTER; /* * S3PT - S3 Performance Table. This table is pointed to by the - * FPDT S3 Pointer Record above. + * S3 Pointer Record above. */ typedef struct acpi_table_s3pt { @@ -267,27 +263,21 @@ typedef struct acpi_table_s3pt /* - * S3PT Subtables + * S3PT Subtables (Not part of the actual FPDT) */ -typedef struct acpi_s3pt_header -{ - UINT16 Type; - UINT8 Length; - UINT8 Revision; - -} ACPI_S3PT_HEADER; -/* Values for Type field above */ +/* Values for Type field in S3PT header */ enum AcpiS3ptType { ACPI_S3PT_TYPE_RESUME = 0, - ACPI_S3PT_TYPE_SUSPEND = 1 + ACPI_S3PT_TYPE_SUSPEND = 1, + ACPI_FPDT_BOOT_PERFORMANCE = 2 }; typedef struct acpi_s3pt_resume { - ACPI_S3PT_HEADER Header; + ACPI_FPDT_HEADER Header; UINT32 ResumeCount; UINT64 FullResume; UINT64 AverageResume; @@ -296,13 +286,29 @@ typedef struct acpi_s3pt_resume typedef struct acpi_s3pt_suspend { - ACPI_S3PT_HEADER Header; + ACPI_FPDT_HEADER Header; UINT64 SuspendStart; UINT64 SuspendEnd; } ACPI_S3PT_SUSPEND; +/* + * FPDT Boot Performance Record (Not part of the actual FPDT) + */ +typedef struct acpi_fpdt_boot +{ + ACPI_FPDT_HEADER Header; + UINT8 Reserved[4]; + UINT64 ResetEnd; + UINT64 LoadStart; + UINT64 StartupStart; + UINT64 ExitServicesEntry; + UINT64 ExitServicesExit; + +} ACPI_FPDT_BOOT; + + /******************************************************************************* * * GTDT - Generic Timer Description Table (ACPI 5.1) @@ -557,9 +563,10 @@ typedef struct acpi_table_pcct enum AcpiPcctType { - ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0, - ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE = 1, - ACPI_PCCT_TYPE_RESERVED = 2 /* 2 and greater are reserved */ + ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0, + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE = 1, + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2 = 2, /* ACPI 6.1 */ + ACPI_PCCT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ }; /* @@ -603,6 +610,30 @@ typedef struct acpi_pcct_hw_reduced } ACPI_PCCT_HW_REDUCED; + +/* 2: HW-reduced Communications Subspace Type 2 (ACPI 6.1) */ + +typedef struct acpi_pcct_hw_reduced_type2 +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 DoorbellInterrupt; + UINT8 Flags; + UINT8 Reserved; + UINT64 BaseAddress; + UINT64 Length; + ACPI_GENERIC_ADDRESS DoorbellRegister; + UINT64 PreserveMask; + UINT64 WriteMask; + UINT32 Latency; + UINT32 MaxAccessRate; + UINT16 MinTurnaroundTime; + ACPI_GENERIC_ADDRESS DoorbellAckRegister; + UINT64 AckPreserveMask; + UINT64 AckWriteMask; + +} ACPI_PCCT_HW_REDUCED_TYPE2; + + /* Values for doorbell flags above */ #define ACPI_PCCT_INTERRUPT_POLARITY (1) @@ -848,41 +879,6 @@ typedef struct acpi_table_stao /******************************************************************************* * - * TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table - * Version 3 - * - * Conforms to "TPM 2.0 Hardware Interface Table (TPM2)" 29 November 2011 - * - ******************************************************************************/ - -typedef struct acpi_table_tpm2 -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT32 Flags; - UINT64 ControlAddress; - UINT32 StartMethod; - -} ACPI_TABLE_TPM2; - -/* Control area structure (not part of table, pointed to by ControlAddress) */ - -typedef struct acpi_tpm2_control -{ - UINT32 Reserved; - UINT32 Error; - UINT32 Cancel; - UINT32 Start; - UINT64 InterruptControl; - UINT32 CommandSize; - UINT64 CommandAddress; - UINT32 ResponseSize; - UINT64 ResponseAddress; - -} ACPI_TPM2_CONTROL; - - -/******************************************************************************* - * * WPBT - Windows Platform Environment Table (ACPI 6.0) * Version 1 * diff --git a/sys/contrib/dev/acpica/include/actypes.h b/sys/contrib/dev/acpica/include/actypes.h index 0bee2a7..395b915 100644 --- a/sys/contrib/dev/acpica/include/actypes.h +++ b/sys/contrib/dev/acpica/include/actypes.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -555,14 +555,14 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b))) #define ACPI_MOVE_NAME(dest,src) (*ACPI_CAST_PTR (UINT32, (dest)) = *ACPI_CAST_PTR (UINT32, (src))) #else -#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE)) -#define ACPI_MOVE_NAME(dest,src) (ACPI_STRNCPY (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAME_SIZE)) +#define ACPI_COMPARE_NAME(a,b) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE)) +#define ACPI_MOVE_NAME(dest,src) (strncpy (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAME_SIZE)) #endif /* Support for the special RSDP signature (8 characters) */ -#define ACPI_VALIDATE_RSDP_SIG(a) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8)) -#define ACPI_MAKE_RSDP_SIG(dest) (ACPI_MEMCPY (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8)) +#define ACPI_VALIDATE_RSDP_SIG(a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8)) +#define ACPI_MAKE_RSDP_SIG(dest) (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8)) /******************************************************************************* @@ -582,6 +582,7 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NO_ACPI_ENABLE 0x10 #define ACPI_NO_DEVICE_INIT 0x20 #define ACPI_NO_OBJECT_INIT 0x40 +#define ACPI_NO_FACS_INIT 0x80 /* * Initialization state @@ -641,7 +642,8 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NOTIFY_SHUTDOWN_REQUEST (UINT8) 0x0C #define ACPI_NOTIFY_AFFINITY_UPDATE (UINT8) 0x0D -#define ACPI_NOTIFY_MAX 0x0D +#define ACPI_GENERIC_NOTIFY_MAX 0x0D +#define ACPI_SPECIFIC_NOTIFY_MAX 0x84 /* * Types associated with ACPI names and objects. The first group of @@ -673,6 +675,7 @@ typedef UINT32 ACPI_OBJECT_TYPE; #define ACPI_TYPE_DEBUG_OBJECT 0x10 #define ACPI_TYPE_EXTERNAL_MAX 0x10 +#define ACPI_NUM_TYPES (ACPI_TYPE_EXTERNAL_MAX + 1) /* * These are object types that do not map directly to the ACPI @@ -694,6 +697,7 @@ typedef UINT32 ACPI_OBJECT_TYPE; #define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple ObjectList Nodes */ #define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ +#define ACPI_TOTAL_TYPES (ACPI_TYPE_NS_NODE_MAX + 1) /* * These are special object types that never appear in @@ -767,10 +771,6 @@ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_GPE_ENABLE 0 #define ACPI_GPE_DISABLE 1 #define ACPI_GPE_CONDITIONAL_ENABLE 2 -#define ACPI_GPE_SAVE_MASK 4 - -#define ACPI_GPE_ENABLE_SAVE (ACPI_GPE_ENABLE | ACPI_GPE_SAVE_MASK) -#define ACPI_GPE_DISABLE_SAVE (ACPI_GPE_DISABLE | ACPI_GPE_SAVE_MASK) /* * GPE info flags - Per GPE @@ -1025,7 +1025,8 @@ typedef struct acpi_buffer */ #define ACPI_FULL_PATHNAME 0 #define ACPI_SINGLE_NAME 1 -#define ACPI_NAME_TYPE_MAX 1 +#define ACPI_FULL_PATHNAME_NO_TRAILING 2 +#define ACPI_NAME_TYPE_MAX 2 /* @@ -1033,7 +1034,7 @@ typedef struct acpi_buffer */ typedef struct acpi_predefined_names { - char *Name; + const char *Name; UINT8 Type; char *Val; @@ -1227,8 +1228,12 @@ UINT32 (*ACPI_INTERFACE_HANDLER) ( #define ACPI_UUID_LENGTH 16 +/* Length of 3-byte PCI class code values when converted back to a string */ + +#define ACPI_PCICLS_STRING_SIZE 7 /* Includes null terminator */ -/* Structures used for device/processor HID, UID, CID, and SUB */ + +/* Structures used for device/processor HID, UID, CID */ typedef struct acpi_pnp_device_id { @@ -1255,7 +1260,7 @@ typedef struct acpi_device_info UINT32 Name; /* ACPI object Name */ ACPI_OBJECT_TYPE Type; /* ACPI object Type */ UINT8 ParamCount; /* If a method, required parameter count */ - UINT8 Valid; /* Indicates which optional fields are valid */ + UINT16 Valid; /* Indicates which optional fields are valid */ UINT8 Flags; /* Miscellaneous info */ UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ UINT8 LowestDstates[5]; /* _SxW values: 0xFF indicates not valid */ @@ -1263,7 +1268,7 @@ typedef struct acpi_device_info UINT64 Address; /* _ADR value */ ACPI_PNP_DEVICE_ID HardwareId; /* _HID value */ ACPI_PNP_DEVICE_ID UniqueId; /* _UID value */ - ACPI_PNP_DEVICE_ID SubsystemId; /* _SUB value */ + ACPI_PNP_DEVICE_ID ClassCode; /* _CLS value */ ACPI_PNP_DEVICE_ID_LIST CompatibleIdList; /* _CID list <must be last> */ } ACPI_DEVICE_INFO; @@ -1274,16 +1279,16 @@ typedef struct acpi_device_info /* Flags for Valid field above (AcpiGetObjectInfo) */ -#define ACPI_VALID_STA 0x01 -#define ACPI_VALID_ADR 0x02 -#define ACPI_VALID_HID 0x04 -#define ACPI_VALID_UID 0x08 -#define ACPI_VALID_SUB 0x10 -#define ACPI_VALID_CID 0x20 -#define ACPI_VALID_SXDS 0x40 -#define ACPI_VALID_SXWS 0x80 +#define ACPI_VALID_STA 0x0001 +#define ACPI_VALID_ADR 0x0002 +#define ACPI_VALID_HID 0x0004 +#define ACPI_VALID_UID 0x0008 +#define ACPI_VALID_CID 0x0020 +#define ACPI_VALID_CLS 0x0040 +#define ACPI_VALID_SXDS 0x0100 +#define ACPI_VALID_SXWS 0x0200 -/* Flags for _STA return value (CurrentStatus above) */ +/* Flags for _STA method */ #define ACPI_STA_DEVICE_PRESENT 0x01 #define ACPI_STA_DEVICE_ENABLED 0x02 @@ -1320,7 +1325,7 @@ typedef struct acpi_mem_space_context */ typedef struct acpi_memory_list { - char *ListName; + const char *ListName; void *ListHead; UINT16 ObjectSize; UINT16 MaxDepth; @@ -1342,6 +1347,17 @@ typedef struct acpi_memory_list } ACPI_MEMORY_LIST; +/* Definitions of trace event types */ + +typedef enum +{ + ACPI_TRACE_AML_METHOD, + ACPI_TRACE_AML_OPCODE, + ACPI_TRACE_AML_REGION + +} ACPI_TRACE_EVENT_TYPE; + + /* Definitions of _OSI support */ #define ACPI_VENDOR_STRINGS 0x01 diff --git a/sys/contrib/dev/acpica/include/acutils.h b/sys/contrib/dev/acpica/include/acutils.h index fe6c057..b92a39b 100644 --- a/sys/contrib/dev/acpica/include/acutils.h +++ b/sys/contrib/dev/acpica/include/acutils.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -115,13 +115,25 @@ extern const char *AcpiGbl_PtDecode[]; /* * Common error message prefixes */ +#ifndef ACPI_MSG_ERROR #define ACPI_MSG_ERROR "ACPI Error: " +#endif +#ifndef ACPI_MSG_EXCEPTION #define ACPI_MSG_EXCEPTION "ACPI Exception: " +#endif +#ifndef ACPI_MSG_WARNING #define ACPI_MSG_WARNING "ACPI Warning: " +#endif +#ifndef ACPI_MSG_INFO #define ACPI_MSG_INFO "ACPI: " +#endif +#ifndef ACPI_MSG_BIOS_ERROR #define ACPI_MSG_BIOS_ERROR "ACPI BIOS Error (bug): " +#endif +#ifndef ACPI_MSG_BIOS_WARNING #define ACPI_MSG_BIOS_WARNING "ACPI BIOS Warning (bug): " +#endif /* * Common message suffix @@ -173,6 +185,55 @@ typedef struct acpi_pkg_info #define DB_DWORD_DISPLAY 4 #define DB_QWORD_DISPLAY 8 + +/* + * utascii - ASCII utilities + */ +BOOLEAN +AcpiUtValidNameseg ( + char *Signature); + +BOOLEAN +AcpiUtValidNameChar ( + char Character, + UINT32 Position); + +void +AcpiUtCheckAndRepairAscii ( + UINT8 *Name, + char *RepairedName, + UINT32 Count); + + +/* + * utnonansi - Non-ANSI C library functions + */ +void +AcpiUtStrupr ( + char *SrcString); + +void +AcpiUtStrlwr ( + char *SrcString); + +int +AcpiUtStricmp ( + char *String1, + char *String2); + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Base, + UINT32 MaxIntegerByteWidth, + UINT64 *RetInteger); + +/* Values for MaxIntegerByteWidth above */ + +#define ACPI_MAX32_BYTE_WIDTH 4 +#define ACPI_MAX64_BYTE_WIDTH 8 + + /* * utglobal - Global data structures and procedures */ @@ -182,7 +243,7 @@ AcpiUtInitGlobals ( #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -char * +const char * AcpiUtGetMutexName ( UINT32 MutexId); @@ -192,15 +253,15 @@ AcpiUtGetNotifyName ( ACPI_OBJECT_TYPE Type); #endif -char * +const char * AcpiUtGetTypeName ( ACPI_OBJECT_TYPE Type); -char * +const char * AcpiUtGetNodeName ( void *Object); -char * +const char * AcpiUtGetDescriptorName ( void *Object); @@ -208,15 +269,15 @@ const char * AcpiUtGetReferenceName ( ACPI_OPERAND_OBJECT *Object); -char * +const char * AcpiUtGetObjectTypeName ( ACPI_OPERAND_OBJECT *ObjDesc); -char * +const char * AcpiUtGetRegionName ( UINT8 SpaceId); -char * +const char * AcpiUtGetEventName ( UINT32 EventId); @@ -247,116 +308,6 @@ AcpiUtSubsystemShutdown ( /* - * utclib - Local implementations of C library functions - */ -#ifndef ACPI_USE_SYSTEM_CLIBRARY - -ACPI_SIZE -AcpiUtStrlen ( - const char *String); - -char * -AcpiUtStrchr ( - const char *String, - int ch); - -char * -AcpiUtStrcpy ( - char *DstString, - const char *SrcString); - -char * -AcpiUtStrncpy ( - char *DstString, - const char *SrcString, - ACPI_SIZE Count); - -int -AcpiUtMemcmp ( - const char *Buffer1, - const char *Buffer2, - ACPI_SIZE Count); - -int -AcpiUtStrncmp ( - const char *String1, - const char *String2, - ACPI_SIZE Count); - -int -AcpiUtStrcmp ( - const char *String1, - const char *String2); - -char * -AcpiUtStrcat ( - char *DstString, - const char *SrcString); - -char * -AcpiUtStrncat ( - char *DstString, - const char *SrcString, - ACPI_SIZE Count); - -UINT32 -AcpiUtStrtoul ( - const char *String, - char **Terminator, - UINT32 Base); - -char * -AcpiUtStrstr ( - char *String1, - char *String2); - -void * -AcpiUtMemcpy ( - void *Dest, - const void *Src, - ACPI_SIZE Count); - -void * -AcpiUtMemset ( - void *Dest, - UINT8 Value, - ACPI_SIZE Count); - -int -AcpiUtToUpper ( - int c); - -int -AcpiUtToLower ( - int c); - -extern const UINT8 _acpi_ctype[]; - -#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ -#define _ACPI_XS 0x40 /* extra space */ -#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ -#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ -#define _ACPI_DI 0x04 /* '0'-'9' */ -#define _ACPI_LO 0x02 /* 'a'-'z' */ -#define _ACPI_PU 0x10 /* punctuation */ -#define _ACPI_SP 0x08 /* space, tab, CR, LF, VT, FF */ -#define _ACPI_UP 0x01 /* 'A'-'Z' */ -#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ - -#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) -#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) -#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) -#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) -#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) -#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU)) -#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) - -#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ - -#define ACPI_IS_ASCII(c) ((c) < 0x80) - - -/* * utcopy - Object construction and conversion interfaces */ ACPI_STATUS @@ -427,7 +378,7 @@ AcpiUtTracePtr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - void *Pointer); + const void *Pointer); void AcpiUtTraceU32 ( @@ -443,7 +394,7 @@ AcpiUtTraceStr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - char *String); + const char *String); void AcpiUtExit ( @@ -477,6 +428,14 @@ AcpiUtPtrExit ( UINT8 *Ptr); void +AcpiUtStrExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *String); + +void AcpiUtDebugDumpBuffer ( UINT8 *Buffer, UINT32 Count, @@ -515,6 +474,7 @@ AcpiUtReportWarning ( char *ModuleName, UINT32 LineNumber); + /* * utdelete - Object deletion and reference counts */ @@ -545,13 +505,13 @@ AcpiUtDeleteInternalObjectList ( ACPI_STATUS AcpiUtEvaluateObject ( ACPI_NAMESPACE_NODE *PrefixNode, - char *Path, + const char *Path, UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc); ACPI_STATUS AcpiUtEvaluateNumericObject ( - char *ObjectName, + const char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, UINT64 *Value); @@ -569,17 +529,6 @@ AcpiUtExecutePowerMethods ( /* - * utfileio - file operations - */ -#ifdef ACPI_APPLICATION -ACPI_STATUS -AcpiUtReadTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **Table); -#endif - - -/* * utids - device ID support */ ACPI_STATUS @@ -593,14 +542,14 @@ AcpiUtExecute_UID ( ACPI_PNP_DEVICE_ID **ReturnId); ACPI_STATUS -AcpiUtExecute_SUB ( +AcpiUtExecute_CID ( ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID **ReturnId); + ACPI_PNP_DEVICE_ID_LIST **ReturnCidList); ACPI_STATUS -AcpiUtExecute_CID ( +AcpiUtExecute_CLS ( ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID_LIST **ReturnCidList); + ACPI_PNP_DEVICE_ID **ReturnId); /* @@ -822,7 +771,7 @@ BOOLEAN AcpiUtIsPciRootBridge ( char *Id); -#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP) +#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP) BOOLEAN AcpiUtIsAmlTable ( ACPI_TABLE_HEADER *Table); @@ -835,11 +784,11 @@ AcpiUtWalkPackageTree ( ACPI_PKG_CALLBACK WalkCallback, void *Context); - /* Values for Base above (16=Hex, 10=Decimal) */ #define ACPI_ANY_BASE 0 + UINT32 AcpiUtDwordByteSwap ( UINT32 Value); @@ -853,7 +802,7 @@ void AcpiUtDisplayInitPathname ( UINT8 Type, ACPI_NAMESPACE_NODE *ObjHandle, - char *Path); + const char *Path); #endif @@ -912,27 +861,6 @@ AcpiUtGetResourceEndTag ( * utstring - String and character utilities */ void -AcpiUtStrupr ( - char *SrcString); - -#ifdef ACPI_ASL_COMPILER -void -AcpiUtStrlwr ( - char *SrcString); - -int -AcpiUtStricmp ( - char *String1, - char *String2); -#endif - -ACPI_STATUS -AcpiUtStrtoul64 ( - char *String, - UINT32 Base, - UINT64 *RetInteger); - -void AcpiUtPrintString ( char *String, UINT16 MaxLength); @@ -943,15 +871,6 @@ UtConvertBackslashes ( char *Pathname); #endif -BOOLEAN -AcpiUtValidAcpiName ( - char *Name); - -BOOLEAN -AcpiUtValidAcpiChar ( - char Character, - UINT32 Position); - void AcpiUtRepairName ( char *Name); @@ -969,7 +888,6 @@ AcpiUtSafeStrcat ( ACPI_SIZE DestSize, char *Source); -#ifndef _KERNEL BOOLEAN AcpiUtSafeStrncat ( char *Dest, @@ -977,7 +895,6 @@ AcpiUtSafeStrncat ( char *Source, ACPI_SIZE MaxTransferLength); #endif -#endif /* @@ -1053,12 +970,13 @@ AcpiUtDumpAllocations ( ACPI_STATUS AcpiUtCreateList ( - char *ListName, + const char *ListName, UINT16 ObjectSize, ACPI_MEMORY_LIST **ReturnCache); #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + /* * utaddress - address range check */ @@ -1085,6 +1003,7 @@ void AcpiUtDeleteAddressLists ( void); + /* * utxferror - various error/warning output functions */ @@ -1131,6 +1050,7 @@ AcpiUtMethodError ( const char *Path, ACPI_STATUS LookupStatus); + /* * Utility functions for ACPI names and IDs */ @@ -1146,6 +1066,7 @@ const char * AcpiAhMatchUuid ( UINT8 *Data); + /* * utprint - printf/vprintf output functions */ @@ -1187,6 +1108,7 @@ AcpiUtFilePrintf ( ...); #endif + /* * utuuid -- UUID support functions */ diff --git a/sys/contrib/dev/acpica/include/acuuid.h b/sys/contrib/dev/acpica/include/acuuid.h index 59c1768..5c42990 100644 --- a/sys/contrib/dev/acpica/include/acuuid.h +++ b/sys/contrib/dev/acpica/include/acuuid.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/amlcode.h b/sys/contrib/dev/acpica/include/amlcode.h index d56f6d9..a432c2b 100644 --- a/sys/contrib/dev/acpica/include/amlcode.h +++ b/sys/contrib/dev/acpica/include/amlcode.h @@ -7,7 +7,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -120,7 +120,7 @@ #define AML_CREATE_WORD_FIELD_OP (UINT16) 0x8b #define AML_CREATE_BYTE_FIELD_OP (UINT16) 0x8c #define AML_CREATE_BIT_FIELD_OP (UINT16) 0x8d -#define AML_TYPE_OP (UINT16) 0x8e +#define AML_OBJECT_TYPE_OP (UINT16) 0x8e #define AML_CREATE_QWORD_FIELD_OP (UINT16) 0x8f /* ACPI 2.0 */ #define AML_LAND_OP (UINT16) 0x90 #define AML_LOR_OP (UINT16) 0x91 @@ -241,7 +241,8 @@ #define ARGP_TERMLIST 0x0F #define ARGP_WORDDATA 0x10 #define ARGP_QWORDDATA 0x11 -#define ARGP_SIMPLENAME 0x12 +#define ARGP_SIMPLENAME 0x12 /* NameString | LocalTerm | ArgTerm */ +#define ARGP_NAME_OR_REF 0x13 /* For ObjectType only */ /* * Resolved argument types for the AML Interpreter @@ -280,14 +281,15 @@ #define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ #define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ #define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ +#define ARGI_STORE_TARGET 0x12 /* Target for store is TARGETREF + package objects */ /* Multiple/complex types */ -#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/ -#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ -#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ -#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */ -#define ARGI_DATAREFOBJ 0x16 +#define ARGI_DATAOBJECT 0x13 /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/ +#define ARGI_COMPLEXOBJ 0x14 /* Buffer, String, or package (Used by INDEX op only) */ +#define ARGI_REF_OR_STRING 0x15 /* Reference or String (Used by DEREFOF op only) */ +#define ARGI_REGION_OR_BUFFER 0x16 /* Used by LOAD op only */ +#define ARGI_DATAREFOBJ 0x17 /* Note: types above can expand to 0x1F maximum */ diff --git a/sys/contrib/dev/acpica/include/amlresrc.h b/sys/contrib/dev/acpica/include/amlresrc.h index b38028e..960da1b 100644 --- a/sys/contrib/dev/acpica/include/amlresrc.h +++ b/sys/contrib/dev/acpica/include/amlresrc.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/platform/acenv.h b/sys/contrib/dev/acpica/include/platform/acenv.h index 88b1ffc..591af13 100644 --- a/sys/contrib/dev/acpica/include/platform/acenv.h +++ b/sys/contrib/dev/acpica/include/platform/acenv.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,17 +67,29 @@ * *****************************************************************************/ +/* Common application configuration. All single threaded except for AcpiExec. */ + +#if (defined ACPI_ASL_COMPILER) || \ + (defined ACPI_BIN_APP) || \ + (defined ACPI_DUMP_APP) || \ + (defined ACPI_HELP_APP) || \ + (defined ACPI_NAMES_APP) || \ + (defined ACPI_SRC_APP) || \ + (defined ACPI_XTRACT_APP) || \ + (defined ACPI_EXAMPLE_APP) +#define ACPI_APPLICATION +#define ACPI_SINGLE_THREADED +#endif + /* iASL configuration */ #ifdef ACPI_ASL_COMPILER -#define ACPI_APPLICATION -#define ACPI_DISASSEMBLER #define ACPI_DEBUG_OUTPUT #define ACPI_CONSTANT_EVAL_ONLY #define ACPI_LARGE_NAMESPACE_NODE #define ACPI_DATA_TABLE_DISASSEMBLY -#define ACPI_SINGLE_THREADED #define ACPI_32BIT_PHYSICAL_ADDRESS +#define ACPI_DISASSEMBLER 1 #endif /* AcpiExec configuration. Multithreaded with full AML debugger */ @@ -89,21 +101,6 @@ #define ACPI_DBG_TRACK_ALLOCATIONS #endif -/* - * AcpiBin/AcpiDump/AcpiHelp/AcpiNames/AcpiSrc/AcpiXtract/Example configuration. - * All single threaded. - */ -#if (defined ACPI_BIN_APP) || \ - (defined ACPI_DUMP_APP) || \ - (defined ACPI_HELP_APP) || \ - (defined ACPI_NAMES_APP) || \ - (defined ACPI_SRC_APP) || \ - (defined ACPI_XTRACT_APP) || \ - (defined ACPI_EXAMPLE_APP) -#define ACPI_APPLICATION -#define ACPI_SINGLE_THREADED -#endif - /* AcpiHelp configuration. Error messages disabled. */ #ifdef ACPI_HELP_APP @@ -124,7 +121,7 @@ #define ACPI_USE_NATIVE_RSDP_POINTER #endif -/* AcpiDump configuration. Native mapping used if provied by OSPMs */ +/* AcpiDump configuration. Native mapping used if provided by the host */ #ifdef ACPI_DUMP_APP #define ACPI_USE_NATIVE_MEMORY_MAPPING @@ -138,10 +135,16 @@ #define ACPI_REDUCED_HARDWARE 1 #endif -/* Linkable ACPICA library */ +/* Linkable ACPICA library. Two versions, one with full debug. */ #ifdef ACPI_LIBRARY #define ACPI_USE_LOCAL_CACHE +#define ACPI_DEBUGGER 1 +#define ACPI_DISASSEMBLER 1 + +#ifdef _DEBUG +#define ACPI_DEBUG_OUTPUT +#endif #endif /* Common for all ACPICA applications */ @@ -151,15 +154,14 @@ #define ACPI_USE_LOCAL_CACHE #endif -/* Common debug support */ +/* Common debug/disassembler support */ #ifdef ACPI_FULL_DEBUG -#define ACPI_DEBUGGER #define ACPI_DEBUG_OUTPUT -#define ACPI_DISASSEMBLER +#define ACPI_DEBUGGER 1 +#define ACPI_DISASSEMBLER 1 #endif - /*! [Begin] no source code translation */ /****************************************************************************** @@ -217,6 +219,9 @@ #elif defined(__HAIKU__) #include "achaiku.h" +#elif defined(__QNX__) +#include "acqnx.h" + #else /* Unknown environment */ @@ -296,6 +301,7 @@ #define ACPI_INTERNAL_VAR_XFACE #endif + /* * Debugger threading model * Use single threaded if the entire subsystem is contained in an application @@ -305,11 +311,11 @@ * multi-threaded if ACPI_APPLICATION is not set. */ #ifndef DEBUGGER_THREADING -#ifdef ACPI_APPLICATION -#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED +#if !defined (ACPI_APPLICATION) || defined (ACPI_EXEC_APP) +#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED #else -#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED #endif #endif /* !DEBUGGER_THREADING */ @@ -326,8 +332,8 @@ * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and * the standard header files may be used. * - * The ACPICA subsystem only uses low level C library functions that do not call - * operating system services and may therefore be inlined in the code. + * The ACPICA subsystem only uses low level C library functions that do not + * call operating system services and may therefore be inlined in the code. * * It may be necessary to tailor these include files to the target * generation environment. @@ -349,28 +355,6 @@ /* We will be linking to the standard Clib functions */ -#define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) -#define ACPI_STRCHR(s1,c) strchr((s1), (c)) -#define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s)) -#define ACPI_STRCPY(d,s) (void) strcpy((d), (s)) -#define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (ACPI_SIZE)(n)) -#define ACPI_STRNCMP(d,s,n) strncmp((d), (s), (ACPI_SIZE)(n)) -#define ACPI_STRCMP(d,s) strcmp((d), (s)) -#define ACPI_STRCAT(d,s) (void) strcat((d), (s)) -#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (ACPI_SIZE)(n)) -#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (ACPI_SIZE)(n)) -#define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) -#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n)) -#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n)) -#define ACPI_TOUPPER(i) toupper((int) (i)) -#define ACPI_TOLOWER(i) tolower((int) (i)) -#define ACPI_IS_XDIGIT(i) isxdigit((int) (i)) -#define ACPI_IS_DIGIT(i) isdigit((int) (i)) -#define ACPI_IS_SPACE(i) isspace((int) (i)) -#define ACPI_IS_UPPER(i) isupper((int) (i)) -#define ACPI_IS_PRINT(i) isprint((int) (i)) -#define ACPI_IS_ALPHA(i) isalpha((int) (i)) - #else /****************************************************************************** @@ -408,22 +392,6 @@ typedef char *va_list; /* Use the local (ACPICA) definitions of the clib functions */ -#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) -#define ACPI_STRCHR(s1,c) AcpiUtStrchr ((s1), (c)) -#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s)) -#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s)) -#define ACPI_STRNCPY(d,s,n) (void) AcpiUtStrncpy ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_STRNCMP(d,s,n) AcpiUtStrncmp ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s)) -#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s)) -#define ACPI_STRNCAT(d,s,n) AcpiUtStrncat ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_STRTOUL(d,s,n) AcpiUtStrtoul ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_MEMCMP(s1,s2,n) AcpiUtMemcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) -#define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n)) -#define ACPI_TOUPPER(c) AcpiUtToUpper ((int) (c)) -#define ACPI_TOLOWER(c) AcpiUtToLower ((int) (c)) - #endif /* ACPI_USE_SYSTEM_CLIBRARY */ #ifndef ACPI_FILE diff --git a/sys/contrib/dev/acpica/include/platform/acenvex.h b/sys/contrib/dev/acpica/include/platform/acenvex.h index 6e1130e..02a46f1 100644 --- a/sys/contrib/dev/acpica/include/platform/acenvex.h +++ b/sys/contrib/dev/acpica/include/platform/acenvex.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,15 @@ #if defined(_LINUX) || defined(__linux__) #include "aclinuxex.h" +#elif defined(WIN32) +#include "acwinex.h" + +#elif defined(_AED_EFI) +#include "acefiex.h" + +#elif defined(_GNU_EFI) +#include "acefiex.h" + #elif defined(__DragonFly__) #include "acdragonflyex.h" diff --git a/sys/contrib/dev/acpica/include/platform/acfreebsd.h b/sys/contrib/dev/acpica/include/platform/acfreebsd.h index f4ba48c..e2f5556 100644 --- a/sys/contrib/dev/acpica/include/platform/acfreebsd.h +++ b/sys/contrib/dev/acpica/include/platform/acfreebsd.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/platform/acgcc.h b/sys/contrib/dev/acpica/include/platform/acgcc.h index 2a27445..7d703da 100644 --- a/sys/contrib/dev/acpica/include/platform/acgcc.h +++ b/sys/contrib/dev/acpica/include/platform/acgcc.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,4 +75,8 @@ #undef strchr #endif +/* GCC supports __VA_ARGS__ in macros */ + +#define COMPILER_VA_MACRO 1 + #endif /* __ACGCC_H__ */ diff --git a/sys/contrib/dev/acpica/os_specific/service_layers/oslibcfs.c b/sys/contrib/dev/acpica/os_specific/service_layers/oslibcfs.c index c24cca4..44a0ff9 100644 --- a/sys/contrib/dev/acpica/os_specific/service_layers/oslibcfs.c +++ b/sys/contrib/dev/acpica/os_specific/service_layers/oslibcfs.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,6 +81,7 @@ AcpiOsOpenFile ( { ModesStr[i++] = 'w'; } + if (Modes & ACPI_FILE_BINARY) { ModesStr[i++] = 'b'; @@ -114,6 +115,7 @@ void AcpiOsCloseFile ( ACPI_FILE File) { + fclose (File); } @@ -239,6 +241,7 @@ AcpiOsSetFileOffset ( { Ret = fseek (File, Offset, SEEK_SET); } + if (From == ACPI_FILE_END) { Ret = fseek (File, Offset, SEEK_END); diff --git a/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c b/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c index fcd5fbc..f169f83 100644 --- a/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c +++ b/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/acpica/Osd/OsdDebug.c b/sys/dev/acpica/Osd/OsdDebug.c index 0547f75..5664719 100644 --- a/sys/dev/acpica/Osd/OsdDebug.c +++ b/sys/dev/acpica/Osd/OsdDebug.c @@ -104,7 +104,7 @@ acpi_EnterDebugger(void) if (!initted) { printf("Initialising ACPICA debugger...\n"); - AcpiDbInitialize(); + AcpiInitializeDebugger(); initted = 1; } diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c index e5d3d51..cf76974 100644 --- a/sys/dev/acpica/Osd/OsdSchedule.c +++ b/sys/dev/acpica/Osd/OsdSchedule.c @@ -209,7 +209,8 @@ AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function, case OSL_EC_BURST_HANDLER: pri = 5; break; - case OSL_DEBUGGER_THREAD: + case OSL_DEBUGGER_MAIN_THREAD: + case OSL_DEBUGGER_EXEC_THREAD: pri = 0; break; default: diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index c671ef9..dfd82d2 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -3682,7 +3682,7 @@ acpi_UserNotify(const char *subsystem, ACPI_HANDLE h, uint8_t notify) handle_buf.Pointer = NULL; handle_buf.Length = ACPI_ALLOCATE_BUFFER; - status = AcpiNsHandleToPathname(h, &handle_buf); + status = AcpiNsHandleToPathname(h, &handle_buf, FALSE); if (ACPI_FAILURE(status)) return; snprintf(notify_buf, sizeof(notify_buf), "notify=0x%02x", notify); diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index d70aaad..bb90375c 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -5339,3 +5339,165 @@ pci_find_pcie_root_port(device_t dev) dev = pcib; } } + +/* + * Wait for pending transactions to complete on a PCI-express function. + * + * The maximum delay is specified in milliseconds in max_delay. Note + * that this function may sleep. + * + * Returns true if the function is idle and false if the timeout is + * exceeded. If dev is not a PCI-express function, this returns true. + */ +bool +pcie_wait_for_pending_transactions(device_t dev, u_int max_delay) +{ + struct pci_devinfo *dinfo = device_get_ivars(dev); + uint16_t sta; + int cap; + + cap = dinfo->cfg.pcie.pcie_location; + if (cap == 0) + return (true); + + sta = pci_read_config(dev, cap + PCIER_DEVICE_STA, 2); + while (sta & PCIEM_STA_TRANSACTION_PND) { + if (max_delay == 0) + return (false); + + /* Poll once every 100 milliseconds up to the timeout. */ + if (max_delay > 100) { + pause_sbt("pcietp", 100 * SBT_1MS, 0, C_HARDCLOCK); + max_delay -= 100; + } else { + pause_sbt("pcietp", max_delay * SBT_1MS, 0, + C_HARDCLOCK); + max_delay = 0; + } + sta = pci_read_config(dev, cap + PCIER_DEVICE_STA, 2); + } + + return (true); +} + +/* + * Determine the maximum Completion Timeout in microseconds. + * + * For non-PCI-express functions this returns 0. + */ +int +pcie_get_max_completion_timeout(device_t dev) +{ + struct pci_devinfo *dinfo = device_get_ivars(dev); + int cap; + + cap = dinfo->cfg.pcie.pcie_location; + if (cap == 0) + return (0); + + /* + * Functions using the 1.x spec use the default timeout range of + * 50 microseconds to 50 milliseconds. Functions that do not + * support programmable timeouts also use this range. + */ + if ((dinfo->cfg.pcie.pcie_flags & PCIEM_FLAGS_VERSION) < 2 || + (pci_read_config(dev, cap + PCIER_DEVICE_CAP2, 4) & + PCIEM_CAP2_COMP_TIMO_RANGES) == 0) + return (50 * 1000); + + switch (pci_read_config(dev, cap + PCIER_DEVICE_CTL2, 2) & + PCIEM_CTL2_COMP_TIMO_VAL) { + case PCIEM_CTL2_COMP_TIMO_100US: + return (100); + case PCIEM_CTL2_COMP_TIMO_10MS: + return (10 * 1000); + case PCIEM_CTL2_COMP_TIMO_55MS: + return (55 * 1000); + case PCIEM_CTL2_COMP_TIMO_210MS: + return (210 * 1000); + case PCIEM_CTL2_COMP_TIMO_900MS: + return (900 * 1000); + case PCIEM_CTL2_COMP_TIMO_3500MS: + return (3500 * 1000); + case PCIEM_CTL2_COMP_TIMO_13S: + return (13 * 1000 * 1000); + case PCIEM_CTL2_COMP_TIMO_64S: + return (64 * 1000 * 1000); + default: + return (50 * 1000); + } +} + +/* + * Perform a Function Level Reset (FLR) on a device. + * + * This function first waits for any pending transactions to complete + * within the timeout specified by max_delay. If transactions are + * still pending, the function will return false without attempting a + * reset. + * + * If dev is not a PCI-express function or does not support FLR, this + * function returns false. + * + * Note that no registers are saved or restored. The caller is + * responsible for saving and restoring any registers including + * PCI-standard registers via pci_save_state() and + * pci_restore_state(). + */ +bool +pcie_flr(device_t dev, u_int max_delay, bool force) +{ + struct pci_devinfo *dinfo = device_get_ivars(dev); + uint16_t cmd, ctl; + int compl_delay; + int cap; + + cap = dinfo->cfg.pcie.pcie_location; + if (cap == 0) + return (false); + + if (!(pci_read_config(dev, cap + PCIER_DEVICE_CAP, 4) & PCIEM_CAP_FLR)) + return (false); + + /* + * Disable busmastering to prevent generation of new + * transactions while waiting for the device to go idle. If + * the idle timeout fails, the command register is restored + * which will re-enable busmastering. + */ + cmd = pci_read_config(dev, PCIR_COMMAND, 2); + pci_write_config(dev, PCIR_COMMAND, cmd & ~(PCIM_CMD_BUSMASTEREN), 2); + if (!pcie_wait_for_pending_transactions(dev, max_delay)) { + if (!force) { + pci_write_config(dev, PCIR_COMMAND, cmd, 2); + return (false); + } + pci_printf(&dinfo->cfg, + "Resetting with transactions pending after %d ms\n", + max_delay); + + /* + * Extend the post-FLR delay to cover the maximum + * Completion Timeout delay of anything in flight + * during the FLR delay. Enforce a minimum delay of + * at least 10ms. + */ + compl_delay = pcie_get_max_completion_timeout(dev) / 1000; + if (compl_delay < 10) + compl_delay = 10; + } else + compl_delay = 0; + + /* Initiate the reset. */ + ctl = pci_read_config(dev, cap + PCIER_DEVICE_CTL, 2); + pci_write_config(dev, cap + PCIER_DEVICE_CTL, ctl | + PCIEM_CTL_INITIATE_FLR, 2); + + /* Wait for 100ms. */ + pause_sbt("pcieflr", (100 + compl_delay) * SBT_1MS, 0, C_HARDCLOCK); + + if (pci_read_config(dev, cap + PCIER_DEVICE_STA, 2) & + PCIEM_STA_TRANSACTION_PND) + pci_printf(&dinfo->cfg, "Transactions pending after FLR!\n"); + return (true); +} diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index 38290c1..c540126 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -708,10 +708,9 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t * Go through the list of devices and copy out the devices * that match the user's criteria. */ - for (cio->num_matches = 0, error = 0, i = 0, - dinfo = STAILQ_FIRST(devlist_head); - (dinfo != NULL) && (cio->num_matches < ionum) - && (error == 0) && (i < pci_numdevs) && (dinfo != NULL); + for (cio->num_matches = 0, i = 0, + dinfo = STAILQ_FIRST(devlist_head); + dinfo != NULL; dinfo = STAILQ_NEXT(dinfo, pci_links), i++) { if (i < cio->offset) @@ -833,11 +832,12 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t } else #endif /* PRE7_COMPAT */ confdata = &dinfo->conf; - /* Only if we can copy it out do we count it. */ - if (!(error = copyout(confdata, + error = copyout(confdata, (caddr_t)cio->matches + - confsz * cio->num_matches, confsz))) - cio->num_matches++; + confsz * cio->num_matches, confsz); + if (error) + break; + cio->num_matches++; } } diff --git a/sys/dev/pci/pcireg.h b/sys/dev/pci/pcireg.h index 5453a53..cb13524 100644 --- a/sys/dev/pci/pcireg.h +++ b/sys/dev/pci/pcireg.h @@ -822,10 +822,25 @@ #define PCIEM_ROOT_STA_PME_STATUS 0x00010000 #define PCIEM_ROOT_STA_PME_PEND 0x00020000 #define PCIER_DEVICE_CAP2 0x24 -#define PCIEM_CAP2_ARI 0x20 +#define PCIEM_CAP2_COMP_TIMO_RANGES 0x0000000f +#define PCIEM_CAP2_COMP_TIMO_RANGE_A 0x00000001 +#define PCIEM_CAP2_COMP_TIMO_RANGE_B 0x00000002 +#define PCIEM_CAP2_COMP_TIMO_RANGE_C 0x00000004 +#define PCIEM_CAP2_COMP_TIMO_RANGE_D 0x00000008 +#define PCIEM_CAP2_COMP_TIMO_DISABLE 0x00000010 +#define PCIEM_CAP2_ARI 0x00000020 #define PCIER_DEVICE_CTL2 0x28 -#define PCIEM_CTL2_COMP_TIMEOUT_VAL 0x000f -#define PCIEM_CTL2_COMP_TIMEOUT_DIS 0x0010 +#define PCIEM_CTL2_COMP_TIMO_VAL 0x000f +#define PCIEM_CTL2_COMP_TIMO_50MS 0x0000 +#define PCIEM_CTL2_COMP_TIMO_100US 0x0001 +#define PCIEM_CTL2_COMP_TIMO_10MS 0x0002 +#define PCIEM_CTL2_COMP_TIMO_55MS 0x0005 +#define PCIEM_CTL2_COMP_TIMO_210MS 0x0006 +#define PCIEM_CTL2_COMP_TIMO_900MS 0x0009 +#define PCIEM_CTL2_COMP_TIMO_3500MS 0x000a +#define PCIEM_CTL2_COMP_TIMO_13S 0x000d +#define PCIEM_CTL2_COMP_TIMO_64S 0x000e +#define PCIEM_CTL2_COMP_TIMO_DISABLE 0x0010 #define PCIEM_CTL2_ARI 0x0020 #define PCIEM_CTL2_ATOMIC_REQ_ENABLE 0x0040 #define PCIEM_CTL2_ATOMIC_EGR_BLOCK 0x0080 diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 5c589ac..bdadf3a 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -543,7 +543,9 @@ uint32_t pcie_read_config(device_t dev, int reg, int width); void pcie_write_config(device_t dev, int reg, uint32_t value, int width); uint32_t pcie_adjust_config(device_t dev, int reg, uint32_t mask, uint32_t value, int width); - +bool pcie_flr(device_t dev, u_int max_delay, bool force); +int pcie_get_max_completion_timeout(device_t dev); +bool pcie_wait_for_pending_transactions(device_t dev, u_int max_delay); #ifdef BUS_SPACE_MAXADDR #if (BUS_SPACE_MAXADDR > 0xFFFFFFFF) diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c index 9e55cb1..633e4a4 100644 --- a/sys/dev/usb/serial/u3g.c +++ b/sys/dev/usb/serial/u3g.c @@ -317,6 +317,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = { U3G_DEV(HUAWEI, E220BIS, U3GINIT_HUAWEI), U3G_DEV(HUAWEI, E392, U3GINIT_HUAWEISCSI), U3G_DEV(HUAWEI, ME909U, U3GINIT_HUAWEISCSI2), + U3G_DEV(HUAWEI, ME909S, U3GINIT_HUAWEISCSI2), U3G_DEV(HUAWEI, MOBILE, U3GINIT_HUAWEI), U3G_DEV(HUAWEI, E1752, U3GINIT_HUAWEISCSI), U3G_DEV(HUAWEI, E1820, U3GINIT_HUAWEISCSI), diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index 84db769..1f01a9e 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -2417,6 +2417,7 @@ product HUAWEI E3272_INIT 0x155b LTE modem initial product HUAWEI ME909U 0x1573 LTE modem product HUAWEI R215_INIT 0x1582 LTE modem initial product HUAWEI R215 0x1588 LTE modem +product HUAWEI ME909S 0x15c1 LTE modem product HUAWEI ETS2055 0x1803 CDMA modem product HUAWEI E173 0x1c05 3G modem product HUAWEI E173_INIT 0x1c0b 3G modem initial diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index 747d1f5..77bec57 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -2669,8 +2669,12 @@ again: int error; error = g_mirror_clear_metadata(disk); - if (error != 0) - return (error); + if (error != 0) { + G_MIRROR_DEBUG(0, + "Device %s: failed to clear metadata on %s: %d.", + sc->sc_name, g_mirror_get_diskname(disk), error); + break; + } DISK_STATE_CHANGED(); G_MIRROR_DEBUG(0, "Device %s: provider %s destroyed.", sc->sc_name, g_mirror_get_diskname(disk)); diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index aba4364..6ccda55 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -5069,6 +5069,7 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, case DEV_ENABLE: case DEV_DISABLE: case DEV_SET_DRIVER: + case DEV_CLEAR_DRIVER: error = priv_check(td, PRIV_DRIVER); if (error == 0) error = find_device(req, &dev); @@ -5210,6 +5211,25 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, error = device_probe_and_attach(dev); break; } + case DEV_CLEAR_DRIVER: + if (!(dev->flags & DF_FIXEDCLASS)) { + error = 0; + break; + } + if (device_is_attached(dev)) { + if (req->dr_flags & DEVF_CLEAR_DRIVER_DETACH) + error = device_detach(dev); + else + error = EBUSY; + if (error) + break; + } + + dev->flags &= ~DF_FIXEDCLASS; + dev->flags |= DF_WILDCARD; + devclass_delete_device(dev->devclass, dev); + error = device_probe_and_attach(dev); + break; } mtx_unlock(&Giant); return (error); diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index ed2befc..5d4167d 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -84,7 +84,7 @@ clock_register(device_t dev, long res) /* res has units of microseconds */ { if (clock_dev != NULL) { - if (clock_res > res) { + if (clock_res <= res) { if (bootverbose) device_printf(dev, "not installed as " "time-of-day clock: clock %s has higher " diff --git a/sys/libkern/strncat.c b/sys/libkern/strncat.c new file mode 100644 index 0000000..95d0ef9 --- /dev/null +++ b/sys/libkern/strncat.c @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strncat.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/libkern.h> + +/* + * Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes + * are written at dst (at most n+1 bytes being appended). Return dst. + */ +char * +strncat(char *dst, const char *src, size_t n) +{ + + if (n != 0) { + char *d = dst; + const char *s = src; + + while (*d != 0) + d++; + do { + if ((*d = *s++) == 0) + break; + d++; + } while (--n != 0); + *d = 0; + } + return (dst); +} diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 57aadc0..b22e324 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -332,7 +332,7 @@ static int bridge_ip_checkbasic(struct mbuf **mp); #ifdef INET6 static int bridge_ip6_checkbasic(struct mbuf **mp); #endif /* INET6 */ -static int bridge_fragment(struct ifnet *, struct mbuf *, +static int bridge_fragment(struct ifnet *, struct mbuf **mp, struct ether_header *, int, struct llc *); static void bridge_linkstate(struct ifnet *ifp); static void bridge_linkcheck(struct bridge_softc *sc); @@ -1870,6 +1870,7 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m) m->m_flags &= ~M_VLANTAG; } + M_ASSERTPKTHDR(m); /* We shouldn't transmit mbuf without pkthdr */ if ((err = dst_ifp->if_transmit(dst_ifp, m))) { m_freem(m0); sc->sc_ifp->if_oerrors++; @@ -3226,10 +3227,12 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir) break; /* check if we need to fragment the packet */ + /* bridge_fragment generates a mbuf chain of packets */ + /* that already include eth headers */ if (pfil_member && ifp != NULL && dir == PFIL_OUT) { i = (*mp)->m_pkthdr.len; if (i > ifp->if_mtu) { - error = bridge_fragment(ifp, *mp, &eh2, snap, + error = bridge_fragment(ifp, mp, &eh2, snap, &llc1); return (error); } @@ -3468,56 +3471,77 @@ bad: /* * bridge_fragment: * - * Return a fragmented mbuf chain. + * Fragment mbuf chain in multiple packets and prepend ethernet header. */ static int -bridge_fragment(struct ifnet *ifp, struct mbuf *m, struct ether_header *eh, +bridge_fragment(struct ifnet *ifp, struct mbuf **mp, struct ether_header *eh, int snap, struct llc *llc) { - struct mbuf *m0; + struct mbuf *m = *mp, *nextpkt = NULL, *mprev = NULL, *mcur = NULL; struct ip *ip; int error = -1; if (m->m_len < sizeof(struct ip) && (m = m_pullup(m, sizeof(struct ip))) == NULL) - goto out; + goto dropit; ip = mtod(m, struct ip *); m->m_pkthdr.csum_flags |= CSUM_IP; error = ip_fragment(ip, &m, ifp->if_mtu, ifp->if_hwassist); if (error) - goto out; + goto dropit; - /* walk the chain and re-add the Ethernet header */ - for (m0 = m; m0; m0 = m0->m_nextpkt) { - if (error == 0) { - if (snap) { - M_PREPEND(m0, sizeof(struct llc), M_NOWAIT); - if (m0 == NULL) { - error = ENOBUFS; - continue; - } - bcopy(llc, mtod(m0, caddr_t), - sizeof(struct llc)); - } - M_PREPEND(m0, ETHER_HDR_LEN, M_NOWAIT); - if (m0 == NULL) { + /* + * Walk the chain and re-add the Ethernet header for + * each mbuf packet. + */ + for (mcur = m; mcur; mcur = mcur->m_nextpkt) { + nextpkt = mcur->m_nextpkt; + mcur->m_nextpkt = NULL; + if (snap) { + M_PREPEND(mcur, sizeof(struct llc), M_NOWAIT); + if (mcur == NULL) { error = ENOBUFS; - continue; + if (mprev != NULL) + mprev->m_nextpkt = nextpkt; + goto dropit; } - bcopy(eh, mtod(m0, caddr_t), ETHER_HDR_LEN); - } else - m_freem(m); - } + bcopy(llc, mtod(mcur, caddr_t),sizeof(struct llc)); + } - if (error == 0) - KMOD_IPSTAT_INC(ips_fragmented); + M_PREPEND(mcur, ETHER_HDR_LEN, M_NOWAIT); + if (mcur == NULL) { + error = ENOBUFS; + if (mprev != NULL) + mprev->m_nextpkt = nextpkt; + goto dropit; + } + bcopy(eh, mtod(mcur, caddr_t), ETHER_HDR_LEN); + /* + * The previous two M_PREPEND could have inserted one or two + * mbufs in front so we have to update the previous packet's + * m_nextpkt. + */ + mcur->m_nextpkt = nextpkt; + if (mprev != NULL) + mprev->m_nextpkt = mcur; + else { + /* The first mbuf in the original chain needs to be + * updated. */ + *mp = mcur; + } + mprev = mcur; + } + + KMOD_IPSTAT_INC(ips_fragmented); return (error); -out: - if (m != NULL) - m_freem(m); +dropit: + for (mcur = *mp; mcur; mcur = m) { /* droping the full packet chain */ + m = mcur->m_nextpkt; + m_freem(mcur); + } return (error); } diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 4ab8249..6c65449 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -103,6 +103,7 @@ struct devreq { #define DEV_ENABLE _IOW('D', 3, struct devreq) #define DEV_DISABLE _IOW('D', 4, struct devreq) #define DEV_SET_DRIVER _IOW('D', 7, struct devreq) +#define DEV_CLEAR_DRIVER _IOW('D', 8, struct devreq) /* Flags for DEV_DETACH and DEV_DISABLE. */ #define DEVF_FORCE_DETACH 0x0000001 @@ -110,6 +111,9 @@ struct devreq { /* Flags for DEV_SET_DRIVER. */ #define DEVF_SET_DRIVER_DETACH 0x0000001 /* Detach existing driver. */ +/* Flags for DEV_CLEAR_DRIVER. */ +#define DEVF_CLEAR_DRIVER_DETACH 0x0000001 /* Detach existing driver. */ + #ifdef _KERNEL #include <sys/eventhandler.h> diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 5faebb1..19b2124 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -123,6 +123,7 @@ int strcmp(const char *, const char *); char *strcpy(char * __restrict, const char * __restrict); size_t strcspn(const char * __restrict, const char * __restrict) __pure; char *strdup(const char *__restrict, struct malloc_type *); +char *strncat(char *, const char *, size_t); char *strndup(const char *__restrict, size_t, struct malloc_type *); size_t strlcat(char *, const char *, size_t); size_t strlcpy(char *, const char *, size_t); diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 8969af8..3ed5654 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -2156,12 +2156,13 @@ ffs_blkfree_cg(ump, fs, devvp, bno, size, inum, dephd) /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; cgblkno = fragstoblks(fs, cgtod(fs, cg)); - } else { + } else if (devvp->v_type == VCHR) { /* devvp is a normal disk device */ dev = devvp->v_rdev; cgblkno = fsbtodb(fs, cgtod(fs, cg)); ASSERT_VOP_LOCKED(devvp, "ffs_blkfree_cg"); - } + } else + return; #ifdef INVARIANTS if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0 || fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) { @@ -2255,7 +2256,7 @@ ffs_blkfree_cg(ump, fs, devvp, bno, size, inum, dephd) ACTIVECLEAR(fs, cg); UFS_UNLOCK(ump); mp = UFSTOVFS(ump); - if (MOUNTEDSOFTDEP(mp) && devvp->v_type != VREG) + if (MOUNTEDSOFTDEP(mp) && devvp->v_type == VCHR) softdep_setup_blkfree(UFSTOVFS(ump), bp, bno, numfrags(fs, size), dephd); bdwrite(bp); @@ -2320,7 +2321,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, inum, vtype, dephd) * it has a snapshot(s) associated with it, and one of the * snapshots wants to claim the block. */ - if (devvp->v_type != VREG && + if (devvp->v_type == VCHR && (devvp->v_vflag & VV_COPYONWRITE) && ffs_snapblkfree(fs, devvp, bno, size, inum, vtype, dephd)) { return; @@ -2463,10 +2464,13 @@ ffs_freefile(ump, fs, devvp, ino, mode, wkhd) /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; cgbno = fragstoblks(fs, cgtod(fs, cg)); - } else { + } else if (devvp->v_type == VCHR) { /* devvp is a normal disk device */ dev = devvp->v_rdev; cgbno = fsbtodb(fs, cgtod(fs, cg)); + } else { + bp = NULL; + return (0); } if (ino >= fs->fs_ipg * fs->fs_ncg) panic("ffs_freefile: range: dev = %s, ino = %ju, fs = %s", @@ -2505,7 +2509,7 @@ ffs_freefile(ump, fs, devvp, ino, mode, wkhd) fs->fs_fmod = 1; ACTIVECLEAR(fs, cg); UFS_UNLOCK(ump); - if (MOUNTEDSOFTDEP(UFSTOVFS(ump)) && devvp->v_type != VREG) + if (MOUNTEDSOFTDEP(UFSTOVFS(ump)) && devvp->v_type == VCHR) softdep_setup_inofree(UFSTOVFS(ump), bp, ino + cg * fs->fs_ipg, wkhd); bdwrite(bp); @@ -2532,9 +2536,11 @@ ffs_checkfreefile(fs, devvp, ino) if (devvp->v_type == VREG) { /* devvp is a snapshot */ cgbno = fragstoblks(fs, cgtod(fs, cg)); - } else { + } else if (devvp->v_type == VCHR) { /* devvp is a normal disk device */ cgbno = fsbtodb(fs, cgtod(fs, cg)); + } else { + return (1); } if (ino >= fs->fs_ipg * fs->fs_ncg) return (1); diff --git a/sys/ufs/ufs/ufs_gjournal.c b/sys/ufs/ufs/ufs_gjournal.c index 8e35c08..34677a7 100644 --- a/sys/ufs/ufs/ufs_gjournal.c +++ b/sys/ufs/ufs/ufs_gjournal.c @@ -70,14 +70,17 @@ ufs_gjournal_modref(struct vnode *vp, int count) ino = ip->i_number; cg = ino_to_cg(fs, ino); - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; cgbno = fragstoblks(fs, cgtod(fs, cg)); - } else { + } else if (devvp->v_type == VCHR) { /* devvp is a normal disk device */ dev = devvp->v_rdev; cgbno = fsbtodb(fs, cgtod(fs, cg)); + } else { + bp = NULL; + return (EIO); } if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg) panic("ufs_gjournal_modref: range: dev = %s, ino = %lu, fs = %s", diff --git a/sys/x86/acpica/acpi_wakeup.c b/sys/x86/acpica/acpi_wakeup.c index a839f7c..7c5286f 100644 --- a/sys/x86/acpica/acpi_wakeup.c +++ b/sys/x86/acpica/acpi_wakeup.c @@ -202,7 +202,7 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) if (acpi_resume_beep != 0) timer_spkr_acquire(); - AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc)); + AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc), 0); intr_suspend(); @@ -287,7 +287,7 @@ acpi_wakeup_machdep(struct acpi_softc *sc, int state, int sleep_result, #endif intr_resume(/*suspend_cancelled*/false); - AcpiSetFirmwareWakingVector(0); + AcpiSetFirmwareWakingVector(0, 0); } else { /* Wakeup MD procedures in interrupt enabled context */ if (sleep_result == 1 && mem_range_softc.mr_op != NULL && diff --git a/sys/x86/iommu/intel_reg.h b/sys/x86/iommu/intel_reg.h index 33e37ac..b9a70b6 100644 --- a/sys/x86/iommu/intel_reg.h +++ b/sys/x86/iommu/intel_reg.h @@ -67,7 +67,9 @@ typedef struct dmar_ctx_entry { #define DMAR_CTX2_AW_4LVL 2 /* 4-level page tables */ #define DMAR_CTX2_AW_5LVL 3 /* 5-level page tables */ #define DMAR_CTX2_AW_6LVL 4 /* 6-level page tables */ +#define DMAR_CTX2_DID_MASK 0xffff0 #define DMAR_CTX2_DID(x) ((x) << 8) /* Domain Identifier */ +#define DMAR_CTX2_GET_DID(ctx2) (((ctx2) & DMAR_CTX2_DID_MASK) >> 8) typedef struct dmar_pte { uint64_t pte; @@ -214,6 +216,8 @@ typedef struct dmar_irte { /* Root-Entry Table Address register */ #define DMAR_RTADDR_REG 0x20 +#define DMAR_RTADDR_RTT (1 << 11) /* Root Table Type */ +#define DMAR_RTADDR_RTA_MASK 0xfffffffffffff000 /* Context Command register */ #define DMAR_CCMD_REG 0x28 diff --git a/tools/tools/dmardump/Makefile b/tools/tools/dmardump/Makefile new file mode 100644 index 0000000..67b3243 --- /dev/null +++ b/tools/tools/dmardump/Makefile @@ -0,0 +1,15 @@ +# $FreeBSD$ + +PROG= dmardump +SRCS= dmardump.c +MAN= + +# Pull in bits from acpidump +ACPIDUMP=${.CURDIR}/../../../usr.sbin/acpi/acpidump +.PATH: ${ACPIDUMP} +SRCS+= acpi_user.c acpi.c +CFLAGS+= -I${ACPIDUMP} + +CFLAGS+= -I${.CURDIR}/../../../sys + +.include <bsd.prog.mk> diff --git a/tools/tools/dmardump/dmardump.c b/tools/tools/dmardump/dmardump.c new file mode 100644 index 0000000..43a2779 --- /dev/null +++ b/tools/tools/dmardump/dmardump.c @@ -0,0 +1,292 @@ +/*- + * Copyright (c) 2016 Chelsio Communications, Inc. + * All rights reserved. + * Written by: John Baldwin <jhb@FreeBSD.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/endian.h> +#include <sys/pciio.h> +#include <sys/queue.h> +#include <err.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> + +#include <x86/iommu/intel_reg.h> + +#include "acpidump.h" + +int tflag; +int vflag; + +static uint32_t +read_4(char *regs, size_t offset) +{ + return *(uint32_t *)(regs + offset); +} + +static uint64_t +read_8(char *regs, size_t offset) +{ + return *(uint64_t *)(regs + offset); +} + +static struct pci_conf * +pci_find_conf(int segment, int bus, int slot, int func) +{ + static int pcifd = -1; + static struct pci_conf conf; + struct pci_conf_io pc; + struct pci_match_conf patterns[1]; + + if (pcifd == -1) { + pcifd = open("/dev/pci", O_RDONLY); + if (pcifd < 0) + err(1, "Failed to open /dev/pci"); + } + + bzero(&pc, sizeof(pc)); + pc.match_buf_len = sizeof(conf); + pc.matches = &conf; + bzero(&patterns, sizeof(patterns)); + patterns[0].pc_sel.pc_domain = segment; + patterns[0].pc_sel.pc_bus = bus; + patterns[0].pc_sel.pc_dev = slot; + patterns[0].pc_sel.pc_func = func; + patterns[0].flags = PCI_GETCONF_MATCH_DOMAIN | + PCI_GETCONF_MATCH_BUS | PCI_GETCONF_MATCH_DEV | + PCI_GETCONF_MATCH_FUNC; + pc.num_patterns = 1; + pc.pat_buf_len = sizeof(patterns); + pc.patterns = patterns; + if (ioctl(pcifd, PCIOCGETCONF, &pc) == -1) + err(1, "ioctl(PCIOCGETCONF)"); + + if (pc.status != PCI_GETCONF_LAST_DEVICE || + pc.num_matches == 0) + return (NULL); + + return (&conf); +} + +static void +dump_context_table(int segment, int bus, uint64_t base_addr) +{ + struct dmar_ctx_entry *ctx; + struct pci_conf *conf; + bool printed; + int idx; + + printed = false; + ctx = acpi_map_physical(base_addr, DMAR_PAGE_SIZE); + for (idx = 0; idx < DMAR_CTX_CNT; idx++) { + if (!(ctx[idx].ctx1 & DMAR_CTX1_P)) + continue; + if (!printed) { + printf("\tPCI bus %d:\n", bus); + printed = true; + } + + /* Check for ARI device first. */ + conf = pci_find_conf(segment, bus, 0, idx); + if (conf == NULL) + conf = pci_find_conf(segment, bus, idx >> 3, idx & 7); + if (conf != NULL) { + printf("\t { %d,%d }", conf->pc_sel.pc_dev, + conf->pc_sel.pc_func); + if (conf->pd_name[0] != '\0') + printf(" (%s%lu)", conf->pd_name, + conf->pd_unit); + } else + printf("\t { %d,%d } (absent)", idx >> 3, + idx & 7); + if (ctx[idx].ctx1 & DMAR_CTX1_FPD) + printf(" FPD"); + switch (ctx[idx].ctx1 & 0xc) { + case DMAR_CTX1_T_UNTR: + printf(" UNTR"); + break; + case DMAR_CTX1_T_TR: + printf(" TR"); + break; + case DMAR_CTX1_T_PASS: + printf(" PASS"); + break; + default: + printf(" TT3?"); + break; + } + printf(" SLPT %#jx", (uintmax_t)(ctx[idx].ctx1 & + DMAR_CTX1_ASR_MASK)); + printf(" domain %d", (int)DMAR_CTX2_GET_DID(ctx[idx].ctx2)); + printf("\n"); + } +} + +static void +handle_drhd(int segment, uint64_t base_addr) +{ + struct dmar_root_entry *root_table; + char *regs; + uint64_t rtaddr; + uint32_t gsts, ver; + bool extended; + int bus; + + regs = acpi_map_physical(base_addr, 4096); + + ver = read_4(regs, DMAR_VER_REG); + gsts = read_4(regs, DMAR_GSTS_REG); + printf("drhd @ %#jx (version %d.%d) PCI segment %d%s:\n", + (uintmax_t)base_addr, DMAR_MAJOR_VER(ver), DMAR_MINOR_VER(ver), + segment, gsts & DMAR_GSTS_TES ? "" : " (disabled)"); + if ((gsts & (DMAR_GSTS_TES | DMAR_GSTS_RTPS)) != + (DMAR_GSTS_TES | DMAR_GSTS_RTPS)) + return; + rtaddr = read_8(regs, DMAR_RTADDR_REG); + extended = (rtaddr & DMAR_RTADDR_RTT) != 0; + printf(" %sroot table @ 0x%#jx\n", extended ? "extended " : "", + rtaddr & DMAR_RTADDR_RTA_MASK); + root_table = acpi_map_physical(rtaddr & DMAR_RTADDR_RTA_MASK, 4096); + for (bus = 0; bus < 255; bus++) { + if (extended) { +#ifdef notyet + if (root_table[bus].r1 & DMAR_ROOT_R1_P) + dump_ext_context_table(segment, bus, + root_table[bus].r1 & DMAR_ROOT_R1_CTP_MASK, + false); + if (root_table[bus].r2 & DMAR_ROOT_R1_P) + dump_ext_context_table(segment, bus, + root_table[bus].r2 & DMAR_ROOT_R1_CTP_MASK, + true); +#endif + } else if (root_table[bus].r1 & DMAR_ROOT_R1_P) + dump_context_table(segment, bus, root_table[bus].r1 & + DMAR_ROOT_R1_CTP_MASK); + } +} + +/* Borrowed from acpi.c in acpidump: */ + +static void +acpi_handle_dmar_drhd(ACPI_DMAR_HARDWARE_UNIT *drhd) +{ + + handle_drhd(drhd->Segment, drhd->Address); +} + +static int +acpi_handle_dmar_remapping_structure(void *addr, int remaining) +{ + ACPI_DMAR_HEADER *hdr = addr; + + if (remaining < (int)sizeof(ACPI_DMAR_HEADER)) + return (-1); + + if (remaining < hdr->Length) + return (-1); + + switch (hdr->Type) { + case ACPI_DMAR_TYPE_HARDWARE_UNIT: + acpi_handle_dmar_drhd(addr); + break; + } + return (hdr->Length); +} + +static void +acpi_handle_dmar(ACPI_TABLE_HEADER *sdp) +{ + char *cp; + int remaining, consumed; + ACPI_TABLE_DMAR *dmar; + + dmar = (ACPI_TABLE_DMAR *)sdp; + remaining = sdp->Length - sizeof(ACPI_TABLE_DMAR); + while (remaining > 0) { + cp = (char *)sdp + sdp->Length - remaining; + consumed = acpi_handle_dmar_remapping_structure(cp, remaining); + if (consumed <= 0) + break; + else + remaining -= consumed; + } +} + +static ACPI_TABLE_HEADER * +acpi_map_sdt(vm_offset_t pa) +{ + ACPI_TABLE_HEADER *sp; + + sp = acpi_map_physical(pa, sizeof(ACPI_TABLE_HEADER)); + sp = acpi_map_physical(pa, sp->Length); + return (sp); +} + +static void +walk_rsdt(ACPI_TABLE_HEADER *rsdp) +{ + ACPI_TABLE_HEADER *sdp; + ACPI_TABLE_RSDT *rsdt; + ACPI_TABLE_XSDT *xsdt; + vm_offset_t addr; + int addr_size, entries, i; + + if (memcmp(rsdp->Signature, "RSDT", 4) != 0) + addr_size = sizeof(uint32_t); + else + addr_size = sizeof(uint64_t); + rsdt = (ACPI_TABLE_RSDT *)rsdp; + xsdt = (ACPI_TABLE_XSDT *)rsdp; + entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size; + for (i = 0; i < entries; i++) { + if (addr_size == 4) + addr = le32toh(rsdt->TableOffsetEntry[i]); + else + addr = le64toh(xsdt->TableOffsetEntry[i]); + if (addr == 0) + continue; + sdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(addr); + if (acpi_checksum(sdp, sdp->Length)) { + continue; + } + if (!memcmp(sdp->Signature, ACPI_SIG_DMAR, 4)) + acpi_handle_dmar(sdp); + } +} + +int +main(int argc __unused, char *argv[] __unused) +{ + ACPI_TABLE_HEADER *rsdt; + + rsdt = sdt_load_devmem(); + walk_rsdt(rsdt); + return 0; +} diff --git a/usr.bin/dpv/dpv.1 b/usr.bin/dpv/dpv.1 index 0cf835d..df37b36 100644 --- a/usr.bin/dpv/dpv.1 +++ b/usr.bin/dpv/dpv.1 @@ -104,7 +104,7 @@ Do not use the default interface of .Xr dialog 3 , but instead spawn an instance of .Xr dialog 1 . -The path to +The path to .Xr dialog 1 is taken from the .Ev DIALOG @@ -313,7 +313,6 @@ is required. .It Pa $HOME/.dialogrc .El .Sh EXAMPLES -.Pp Simple example to show how fast .Xr yes 1 produces lines @@ -363,7 +362,18 @@ Zeroing a disk: .Bd -literal -offset indent dpv -o /dev/md42 < /dev/zero .Ed -.Pp +.Sh SEE ALSO +.Xr dialog 1 , +.Xr dialog 3 , +.Xr sh 1 , +.Xr Xdialog 1 +.Sh HISTORY +A +.Nm +utility first appeared in +.Fx 10.2 . +.Sh AUTHORS +.An Devin Teske Aq dteske@FreeBSD.org .Sh BUGS .Xr Xdialog 1 , when given both @@ -415,21 +425,9 @@ This does not effect .Xr Xdialog 1 , which renders the color escape sequences as plain text. See -.Do Li +.Do embedded "\\Z" sequences .Dc in .Xr dialog 1 for additional information. -.Sh SEE ALSO -.Xr dialog 1 , -.Xr dialog 3 , -.Xr sh 1 , -.Xr Xdialog 1 -.Sh HISTORY -A -.Nm -utility first appeared in -.Fx 10.2 . -.Sh AUTHORS -.An Devin Teske Aq dteske@FreeBSD.org diff --git a/usr.bin/mkimg/mkimg.1 b/usr.bin/mkimg/mkimg.1 index 246a397..856818a 100644 --- a/usr.bin/mkimg/mkimg.1 +++ b/usr.bin/mkimg/mkimg.1 @@ -328,4 +328,4 @@ utility first appeared in The .Nm utility and manpage were written by -.An Marcel Moolenaar Aq Mt marcelm@juniper.net . +.An Marcel Moolenaar Aq Mt marcel@FreeBSD.org . diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile index cf79bae..3669e3b 100644 --- a/usr.sbin/acpi/acpidb/Makefile +++ b/usr.sbin/acpi/acpidb/Makefile @@ -4,22 +4,22 @@ PROG= acpidb SRCS= acpidb.c # common -SRCS+= acgetline.c ahids.c ahuuids.c cmfsize.c +SRCS+= acfileio.c acgetline.c ahids.c ahuuids.c cmfsize.c # components/debugger SRCS+= dbcmds.c dbconvert.c dbdisply.c dbexec.c dbfileio.c \ - dbhistry.c dbinput.c dbmethod.c dbnames.c dbstats.c \ - dbtest.c dbutils.c dbxface.c + dbhistry.c dbinput.c dbmethod.c dbnames.c dbobject.c \ + dbstats.c dbtest.c dbutils.c dbxface.c # components/disassembler -SRCS+= dmbuffer.c dmcstyle.c dmdeferred.c dmnames.c dmobject.c \ - dmopcode.c dmresrc.c dmresrcl.c dmresrcl2.c dmresrcs.c \ - dmutils.c dmwalk.c +SRCS+= dmbuffer.c dmcstyle.c dmdeferred.c dmnames.c dmopcode.c \ + dmresrc.c dmresrcl.c dmresrcl2.c dmresrcs.c dmutils.c \ + dmwalk.c # components/dispatcher -SRCS+= dsargs.c dscontrol.c dsfield.c dsinit.c dsmethod.c \ - dsmthdat.c dsobject.c dsopcode.c dsutils.c dswexec.c \ - dswload.c dswload2.c dswscope.c dswstate.c +SRCS+= dsargs.c dscontrol.c dsdebug.c dsfield.c dsinit.c \ + dsmethod.c dsmthdat.c dsobject.c dsopcode.c dsutils.c \ + dswexec.c dswload.c dswload2.c dswscope.c dswstate.c # components/events SRCS+= evevent.c evglock.c evgpe.c evgpeblk.c evgpeinit.c \ @@ -27,11 +27,12 @@ SRCS+= evevent.c evglock.c evgpe.c evgpeblk.c evgpeinit.c \ evsci.c evxface.c evxfevnt.c evxfregn.c # components/executer -SRCS+= exconfig.c exconvrt.c excreate.c exdebug.c exdump.c \ - exfield.c exfldio.c exmisc.c exmutex.c exnames.c \ - exoparg1.c exoparg2.c exoparg3.c exoparg6.c exprep.c \ - exregion.c exresnte.c exresolv.c exresop.c exstore.c \ - exstoren.c exstorob.c exsystem.c exutils.c +SRCS+= exconcat.c exconfig.c exconvrt.c excreate.c exdebug.c \ + exdump.c exfield.c exfldio.c exmisc.c exmutex.c \ + exnames.c exoparg1.c exoparg2.c exoparg3.c exoparg6.c \ + exprep.c exregion.c exresnte.c exresolv.c exresop.c \ + exstore.c exstoren.c exstorob.c exsystem.c extrace.c \ + exutils.c # components/hardware SRCS+= hwacpi.c hwesleep.c hwgpe.c hwpci.c hwregs.c hwsleep.c \ @@ -59,10 +60,10 @@ SRCS+= tbdata.c tbfadt.c tbfind.c tbinstal.c tbprint.c \ tbutils.c tbxface.c tbxfload.c # components/utilities -SRCS+= utaddress.c utalloc.c utbuffer.c utcache.c utcopy.c \ - utdebug.c utdecode.c utdelete.c uterror.c uteval.c \ - utexcep.c utfileio.c utglobal.c uthex.c utids.c \ - utinit.c utlock.c utmath.c utmisc.c utmutex.c \ +SRCS+= utaddress.c utalloc.c utascii.c utbuffer.c utcache.c \ + utcopy.c utdebug.c utdecode.c utdelete.c uterror.c \ + uteval.c utexcep.c utglobal.c uthex.c utids.c utinit.c \ + utlock.c utmath.c utmisc.c utmutex.c utnonansi.c \ utobject.c utosi.c utownerid.c utpredef.c utprint.c \ utresrc.c utstate.c utstring.c uttrack.c utuuid.c \ utxface.c utxferror.c utxfinit.c diff --git a/usr.sbin/acpi/acpidb/acpidb.c b/usr.sbin/acpi/acpidb/acpidb.c index 7f4e49f..fefe6da 100644 --- a/usr.sbin/acpi/acpidb/acpidb.c +++ b/usr.sbin/acpi/acpidb/acpidb.c @@ -44,6 +44,7 @@ #include <contrib/dev/acpica/include/acpi.h> #include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acapps.h> #include <contrib/dev/acpica/include/acdebug.h> #include <contrib/dev/acpica/include/amlresrc.h> @@ -381,6 +382,7 @@ static int load_dsdt(const char *dsdtfile) { char filetmp[PATH_MAX]; + ACPI_NEW_TABLE_DESC *list; u_int8_t *code; struct stat sb; int dounlink, error, fd; @@ -488,9 +490,10 @@ load_dsdt(const char *dsdtfile) return (-1); } - AcpiDbGetTableFromFile(filetmp, NULL, TRUE); + list = NULL; + AcGetAllTablesFromFile(filetmp, TRUE, &list); - AcpiDbInitialize(); + AcpiInitializeDebugger(); AcpiGbl_DebuggerConfiguration = 0; AcpiDbUserCommands(':', NULL); diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile index e9faad2..87c7294 100644 --- a/usr.sbin/acpi/iasl/Makefile +++ b/usr.sbin/acpi/iasl/Makefile @@ -3,29 +3,31 @@ PROG= iasl # common -SRCS= adfile.c adisasm.c adwalk.c ahids.c ahpredef.c \ - ahtable.c ahuuids.c cmfsize.c dmextern.c dmrestag.c \ - dmtable.c dmtbdump.c dmtbinfo.c getopt.c +SRCS= acfileio.c adfile.c adisasm.c adwalk.c ahids.c \ + ahpredef.c ahtable.c ahuuids.c cmfsize.c dmextern.c \ + dmrestag.c dmtable.c dmtables.c dmtbdump.c dmtbinfo.c \ + getopt.c # compiler SRCS+= aslanalyze.c aslascii.c aslbtypes.c aslcodegen.c \ aslcompile.c aslcompiler.y.h aslcompilerlex.c \ - aslcompilerparse.c aslerror.c aslfileio.c aslfiles.c \ - aslfold.c aslhex.c asllength.c asllisting.c \ - asllistsup.c aslload.c asllookup.c aslmain.c aslmap.c \ - aslmapenter.c aslmapoutput.c aslmaputils.c \ - aslmessages.c aslmethod.c aslnamesp.c asloffset.c \ - aslopcodes.c asloperands.c aslopt.c asloptions.c \ - aslpredef.c aslprepkg.c aslprintf.c aslprune.c \ - aslresource.c aslrestype1.c aslrestype1i.c \ - aslrestype2.c aslrestype2d.c aslrestype2e.c \ - aslrestype2q.c aslrestype2s.c aslrestype2w.c \ - aslstartup.c aslstubs.c asltransform.c asltree.c \ - aslutils.c asluuid.c aslwalks.c aslxref.c dtcompile.c \ - dtexpress.c dtfield.c dtio.c dtparser.y.h dtparserlex.c \ - dtparserparse.c dtsubtable.c dttable.c dttemplate.c \ - dtutils.c prexpress.c prmacros.c prparser.y.h \ - prparserlex.c prparserparse.c prscan.c prutils.c + aslcompilerparse.c asldebug.c aslerror.c aslexternal.c \ + aslfileio.c aslfiles.c aslfold.c aslhex.c asllength.c \ + asllisting.c asllistsup.c aslload.c asllookup.c \ + aslmain.c aslmap.c aslmapenter.c aslmapoutput.c \ + aslmaputils.c aslmessages.c aslmethod.c aslnamesp.c \ + asloffset.c aslopcodes.c asloperands.c aslopt.c \ + asloptions.c aslpld.c aslpredef.c aslprepkg.c \ + aslprintf.c aslprune.c aslresource.c aslrestype1.c \ + aslrestype1i.c aslrestype2.c aslrestype2d.c \ + aslrestype2e.c aslrestype2q.c aslrestype2s.c \ + aslrestype2w.c aslstartup.c aslstubs.c asltransform.c \ + asltree.c aslutils.c asluuid.c aslwalks.c aslxref.c \ + aslxrefout.c dtcompile.c dtexpress.c dtfield.c dtio.c \ + dtparser.y.h dtparserlex.c dtparserparse.c dtsubtable.c \ + dttable.c dttable1.c dttable2.c dttemplate.c dtutils.c \ + prexpress.c prmacros.c prparser.y.h prparserlex.c \ + prparserparse.c prscan.c prutils.c # components/debugger SRCS+= dbfileio.c @@ -41,10 +43,10 @@ SRCS+= dsargs.c dscontrol.c dsfield.c dsobject.c dsopcode.c \ dswstate.c # components/executer -SRCS+= exconvrt.c excreate.c exdump.c exmisc.c exmutex.c \ - exnames.c exoparg1.c exoparg2.c exoparg3.c exoparg6.c \ - exprep.c exresnte.c exresolv.c exresop.c exstore.c \ - exstoren.c exstorob.c exsystem.c exutils.c +SRCS+= exconcat.c exconvrt.c excreate.c exdump.c exmisc.c \ + exmutex.c exnames.c exoparg1.c exoparg2.c exoparg3.c \ + exoparg6.c exprep.c exresnte.c exresolv.c exresop.c \ + exstore.c exstoren.c exstorob.c exsystem.c exutils.c # components/parser SRCS+= psargs.c psloop.c psobject.c psopcode.c psopinfo.c \ @@ -56,13 +58,13 @@ SRCS+= nsaccess.c nsalloc.c nsdump.c nsnames.c nsobject.c \ # components/tables SRCS+= tbdata.c tbfadt.c tbinstal.c tbprint.c tbutils.c \ - tbxface.c + tbxface.c tbxfload.c # components/utilities -SRCS+= utaddress.c utalloc.c utbuffer.c utcache.c utcopy.c \ - utdebug.c utdecode.c utdelete.c uterror.c utexcep.c \ - utfileio.c utglobal.c uthex.c utinit.c utlock.c \ - utmath.c utmisc.c utmutex.c utobject.c utownerid.c \ +SRCS+= utaddress.c utalloc.c utascii.c utbuffer.c utcache.c \ + utcopy.c utdebug.c utdecode.c utdelete.c uterror.c \ + utexcep.c utglobal.c uthex.c utinit.c utlock.c utmath.c \ + utmisc.c utmutex.c utnonansi.c utobject.c utownerid.c \ utpredef.c utprint.c utresrc.c utstate.c utstring.c \ utuuid.c utxface.c utxferror.c @@ -83,11 +85,14 @@ CLEANFILES= aslcompiler.y aslcompiler.y.h aslcompilerlex.c \ prparser.y.h prparserlex.c prparserparse.c \ prparserparse.h +PARSER= aslcstyle.y aslparser.y aslresources.y aslrules.y \ + aslsupport.y asltokens.y asltypes.y + aslcompilerlex.c: aslcompiler.l aslsupport.l ${LEX} ${LFLAGS} -PAslCompiler -o${.TARGET} \ ${ACPICA_DIR}/compiler/aslcompiler.l -aslcompiler.y: aslparser.y aslrules.y aslsupport.y asltokens.y asltypes.y +aslcompiler.y: ${PARSER} m4 -P -I${ACPICA_DIR}/compiler \ ${ACPICA_DIR}/compiler/aslparser.y > ${.TARGET} diff --git a/usr.sbin/devctl/devctl.8 b/usr.sbin/devctl/devctl.8 index 598bea1..67daec5 100644 --- a/usr.sbin/devctl/devctl.8 +++ b/usr.sbin/devctl/devctl.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 2, 2016 +.Dd August 29, 2016 .Dt DEVCTL 8 .Os .Sh NAME @@ -36,6 +36,10 @@ .Cm attach .Ar device .Nm +.Cm clear driver +.Op Fl f +.Ar device +.Nm .Cm detach .Op Fl f .Ar device @@ -115,6 +119,21 @@ If the device is already attached to a device driver and the .Fl f flag is not specified, the device will not be changed. +.It Xo Cm clear driver +.Op Fl f +.Ar device +.Xc +Clear a previously-forced driver name so that the device is able to use any +valid device driver. +After the previous name has been cleared, +the device is reprobed so that other device drivers may attach to it. +This can be used to undo an earlier +.Cm set driver +command. +If the device is currently attached to a device driver and the +.Fl f +flag is not specified, +the device will not be changed. .El .Sh SEE ALSO .Xr devctl 3 , diff --git a/usr.sbin/devctl/devctl.c b/usr.sbin/devctl/devctl.c index fdabd4f..dcdd2d8 100644 --- a/usr.sbin/devctl/devctl.c +++ b/usr.sbin/devctl/devctl.c @@ -65,17 +65,19 @@ static int devctl_table_handler(struct devctl_command **start, SET_DECLARE(DEVCTL_DATASET(top), struct devctl_command); +DEVCTL_TABLE(top, clear); DEVCTL_TABLE(top, set); static void usage(void) { - fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", + fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n", "usage: devctl attach device", " devctl detach [-f] device", " devctl disable [-f] device", " devctl enable device", - " devctl set driver [-f] device driver"); + " devctl set driver [-f] device driver", + " devctl clear driver [-f] device"); exit(1); } @@ -233,6 +235,40 @@ set_driver(int ac, char **av) } DEVCTL_COMMAND(set, driver, set_driver); +static void +clear_driver_usage(void) +{ + + fprintf(stderr, "usage: devctl clear driver [-f] device\n"); + exit(1); +} + +static int +clear_driver(int ac, char **av) +{ + bool force; + int ch; + + force = false; + while ((ch = getopt(ac, av, "f")) != -1) + switch (ch) { + case 'f': + force = true; + break; + default: + clear_driver_usage(); + } + ac -= optind; + av += optind; + + if (ac != 1) + clear_driver_usage(); + if (devctl_clear_driver(av[0], force) < 0) + err(1, "Failed to clear %s driver", av[0]); + return (0); +} +DEVCTL_COMMAND(clear, driver, clear_driver); + int main(int ac, char *av[]) { diff --git a/usr.sbin/portsnap/phttpget/phttpget.8 b/usr.sbin/portsnap/phttpget/phttpget.8 index f0c8210..34e1119 100644 --- a/usr.sbin/portsnap/phttpget/phttpget.8 +++ b/usr.sbin/portsnap/phttpget/phttpget.8 @@ -53,7 +53,7 @@ small files need to be downloaded. The .Xr freebsd-update 8 and -.Xr portnap 8 +.Xr portsnap 8 tools use .Nm to download binary patch files. diff --git a/usr.sbin/portsnap/phttpget/phttpget.c b/usr.sbin/portsnap/phttpget/phttpget.c index 1bf6d9d..33e969a 100644 --- a/usr.sbin/portsnap/phttpget/phttpget.c +++ b/usr.sbin/portsnap/phttpget/phttpget.c @@ -598,7 +598,7 @@ main(int argc, char *argv[]) fd = open(fname, O_CREAT | O_TRUNC | O_WRONLY, 0644); if (fd == -1) errx(1, "open(%s)", fname); - }; + } /* Read the message and send data to fd if appropriate */ if (chunked) { diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh index 37cb781..176dc13 100644 --- a/usr.sbin/portsnap/portsnap/portsnap.sh +++ b/usr.sbin/portsnap/portsnap/portsnap.sh @@ -686,6 +686,13 @@ fetch_snapshot() { fetch_index_sanity || return 1 # Verify the snapshot contents cut -f 2 -d '|' INDEX.new | fetch_snapshot_verify || return 1 + cut -f 2 -d '|' tINDEX.new INDEX.new | sort -u > files.expected + find snap -mindepth 1 | sed -E 's^snap/(.*)\.gz^\1^' | sort > files.snap + if ! cmp -s files.expected files.snap; then + echo "unexpected files in snapshot." + return 1 + fi + rm files.expected files.snap echo "done." # Move files into their proper locations |