> From: Jordan Hargrave <[email protected]>
> Date: Sun, 1 Apr 2012 08:13:13 +0000
> 
> you will need to fix AMLOP_ONES as well. It does a (char)opcode typecast,
> which would be 0xff not 0xffff... if using uint64.

No, that one is fine, at least on machines where char is signed.  For
AMLOP_ONES, opcode will be 0xff.  The cast to (signed) char turns this
into -1.  The the implicit cast to either int64_t or uint64_t turns
this into a 64-bit all-ones bit pattern (0xffff...ffff).

> amlop_match, amlop_wait, amlop_acquire, amlop_condref all will need to return
> AML_ONES or AML_TRUE

Made me look at the aml_match() function.  It is a bit weird, since
all its arguments, even the ones representing AML integers, are int.
Using int as a return value here isn't a real problem.  The -1 will be
correctly converted into a 64-bit all-ones bit patter when converted
to uint64_t by the caller.  Might be worth making this explicit,
although widening the return type of functions to 64-bit might have a
performance penalty on 32-bit platforms.

Anyway, below is what I'm running now.  Doesn't seem to affect things
on my x220 running amd64.


Index: amltypes.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/amltypes.h,v
retrieving revision 1.39
diff -u -p -r1.39 amltypes.h
--- amltypes.h  15 Oct 2010 20:25:04 -0000      1.39
+++ amltypes.h  1 Apr 2012 09:42:15 -0000
@@ -263,7 +263,7 @@ struct aml_value {
        int     stack;
        struct aml_node *node;
        union {
-               int64_t         vinteger;
+               uint64_t        vinteger;
                char            *vstring;
                u_int8_t        *vbuffer;
                struct aml_value **vpackage;
Index: dsdt.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
retrieving revision 1.193
diff -u -p -r1.193 dsdt.c
--- dsdt.c      15 Mar 2012 18:36:53 -0000      1.193
+++ dsdt.c      1 Apr 2012 09:42:17 -0000
@@ -56,16 +56,16 @@ struct aml_scope    *aml_load(struct acpi_s
 void                   aml_copyvalue(struct aml_value *, struct aml_value *);
 
 void                   aml_setvalue(struct aml_scope *, struct aml_value *,
-                           struct aml_value *, int64_t);
+                           struct aml_value *, uint64_t);
 void                   aml_freevalue(struct aml_value *);
-struct aml_value       *aml_allocvalue(int, int64_t, const void *);
-struct aml_value       *_aml_setvalue(struct aml_value *, int, int64_t,
+struct aml_value       *aml_allocvalue(int, uint64_t, const void *);
+struct aml_value       *_aml_setvalue(struct aml_value *, int, uint64_t,
                            const void *);
 
-u_int64_t              aml_convradix(u_int64_t, int, int);
-u_int64_t              aml_evalexpr(u_int64_t, u_int64_t, int);
-int                    aml_lsb(u_int64_t);
-int                    aml_msb(u_int64_t);
+uint64_t               aml_convradix(uint64_t, int, int);
+uint64_t               aml_evalexpr(uint64_t, uint64_t, int);
+int                    aml_lsb(uint64_t);
+int                    aml_msb(uint64_t);
 
 int                    aml_tstbit(const u_int8_t *, int);
 void                   aml_setbit(u_int8_t *, int, int);
@@ -99,7 +99,7 @@ void                  acpi_stall(int);
 struct aml_value       *aml_callosi(struct aml_scope *, struct aml_value *);
 
 const char             *aml_getname(const char *);
-int64_t                        aml_hextoint(const char *);
+uint64_t               aml_hextoint(const char *);
 void                   aml_dump(int, u_int8_t *);
 void                   _aml_die(const char *fn, int line, const char *fmt, 
...);
 #define aml_die(x...)  _aml_die(__FUNCTION__, __LINE__, x)
@@ -869,10 +869,10 @@ aml_showvalue(struct aml_value *val, int
 }
 #endif /* SMALL_KERNEL */
 
-int64_t
+uint64_t
 aml_val2int(struct aml_value *rval)
 {
-       int64_t ival = 0;
+       uint64_t ival = 0;
 
        if (rval == NULL) {
                dnprintf(50, "null val2int\n");
@@ -895,7 +895,7 @@ aml_val2int(struct aml_value *rval)
 
 /* Sets value into LHS: lhs must already be cleared */
 struct aml_value *
-_aml_setvalue(struct aml_value *lhs, int type, int64_t ival, const void *bval)
+_aml_setvalue(struct aml_value *lhs, int type, uint64_t ival, const void *bval)
 {
        memset(&lhs->_, 0x0, sizeof(lhs->_));
 
@@ -923,7 +923,7 @@ _aml_setvalue(struct aml_value *lhs, int
                        memcpy(lhs->v_buffer, bval, ival);
                break;
        case AML_OBJTYPE_STRING:
-               if (ival == -1)
+               if (ival == (uint64_t)-1)
                        ival = strlen((const char *)bval);
                lhs->length = ival;
                lhs->v_string = (char *)acpi_os_malloc(ival+1);
@@ -1001,7 +1001,7 @@ aml_copyvalue(struct aml_value *lhs, str
  *   bval : Buffer value (action depends on type)
  */
 struct aml_value *
-aml_allocvalue(int type, int64_t ival, const void *bval)
+aml_allocvalue(int type, uint64_t ival, const void *bval)
 {
        struct aml_value *rv;
 
@@ -1053,10 +1053,10 @@ aml_freevalue(struct aml_value *val)
 
 /* Convert number from one radix to another
  * Used in BCD conversion routines */
-u_int64_t
-aml_convradix(u_int64_t val, int iradix, int oradix)
+uint64_t
+aml_convradix(uint64_t val, int iradix, int oradix)
 {
-       u_int64_t rv = 0, pwr;
+       uint64_t rv = 0, pwr;
 
        rv = 0;
        pwr = 1;
@@ -1070,7 +1070,7 @@ aml_convradix(u_int64_t val, int iradix,
 
 /* Calculate LSB */
 int
-aml_lsb(u_int64_t val)
+aml_lsb(uint64_t val)
 {
        int             lsb;
 
@@ -1085,7 +1085,7 @@ aml_lsb(u_int64_t val)
 
 /* Calculate MSB */
 int
-aml_msb(u_int64_t val)
+aml_msb(uint64_t val)
 {
        int             msb;
 
@@ -1099,10 +1099,10 @@ aml_msb(u_int64_t val)
 }
 
 /* Evaluate Math operands */
-u_int64_t
-aml_evalexpr(u_int64_t lhs, u_int64_t rhs, int opcode)
+uint64_t
+aml_evalexpr(uint64_t lhs, uint64_t rhs, int opcode)
 {
-       u_int64_t res = 0;
+       uint64_t res = 0;
 
        switch (opcode) {
                /* Math operations */
@@ -1451,7 +1451,7 @@ static char osstring[] = "Macrosift Wind
 struct aml_defval {
        const char              *name;
        int                     type;
-       int64_t                 ival;
+       uint64_t                ival;
        const void              *bval;
        struct aml_value        **gval;
 } aml_defobj[] = {
@@ -1731,8 +1731,8 @@ struct aml_scope *aml_popscope(struct am
 void           aml_showstack(struct aml_scope *);
 struct aml_value *aml_convert(struct aml_value *, int, int);
 
-int            aml_matchtest(int64_t, int64_t, int);
-int            aml_match(struct aml_value *, int, int, int, int, int);
+int            aml_matchtest(uint64_t, uint64_t, int);
+int            aml_match(struct aml_value *, int, int, uint64_t, int, 
uint64_t);
 
 int            aml_compare(struct aml_value *, struct aml_value *, int);
 struct aml_value *aml_concat(struct aml_value *, struct aml_value *);
@@ -1740,7 +1740,7 @@ struct aml_value *aml_concatres(struct a
 struct aml_value *aml_mid(struct aml_value *, int, int);
 int            aml_ccrlen(union acpi_resource *, void *);
 
-void           aml_store(struct aml_scope *, struct aml_value *, int64_t,
+void           aml_store(struct aml_scope *, struct aml_value *, uint64_t,
     struct aml_value *);
 
 /*
@@ -1928,7 +1928,7 @@ aml_popscope(struct aml_scope *scope)
 
 /* Test AMLOP_MATCH codes */
 int
-aml_matchtest(int64_t a, int64_t b, int op)
+aml_matchtest(uint64_t a, uint64_t b, int op)
 {
        switch (op) {
        case AML_MATCH_TR:
@@ -1950,8 +1950,7 @@ aml_matchtest(int64_t a, int64_t b, int 
 /* Search a package for a matching value */
 int
 aml_match(struct aml_value *pkg, int index,
-          int op1, int v1,
-          int op2, int v2)
+    int op1, uint64_t v1, int op2, uint64_t v2)
 {
        struct aml_value *tmp;
        int flag;
@@ -1976,10 +1975,10 @@ aml_match(struct aml_value *pkg, int ind
 /*
  * Conversion routines
  */
-int64_t
+uint64_t
 aml_hextoint(const char *str)
 {
-       int64_t v = 0;
+       uint64_t v = 0;
        char c;
 
        while (*str) {
@@ -2204,7 +2203,7 @@ void aml_rwgas(struct aml_value *, int, 
 int
 aml_rdpciaddr(struct aml_node *pcidev, union amlpci_t *addr)
 {
-       int64_t res;
+       uint64_t res;
 
        if (aml_evalinteger(acpi_softc, pcidev, "_ADR", 0, NULL, &res) == 0) {
                addr->fun = res & 0xFFFF;
@@ -2519,7 +2518,7 @@ acpi_event_reset(struct aml_scope *scope
 
 /* Store result value into an object */
 void
-aml_store(struct aml_scope *scope, struct aml_value *lhs , int64_t ival,
+aml_store(struct aml_scope *scope, struct aml_value *lhs , uint64_t ival,
     struct aml_value *rhs)
 {
        struct aml_value tmp;
@@ -3271,7 +3270,7 @@ aml_parse(struct aml_scope *scope, int r
        struct aml_scope *mscope, *iscope;
        uint8_t *start, *end;
        const char *ch;
-       int64_t ival;
+       uint64_t ival;
 
        my_ret = NULL;
        if (scope == NULL || scope->pos >= scope->end) {
@@ -4060,7 +4059,7 @@ aml_evalname(struct acpi_softc *sc, stru
  */
 int
 aml_evalinteger(struct acpi_softc *sc, struct aml_node *parent,
-    const char *name, int argc, struct aml_value *argv, int64_t *ival)
+    const char *name, int argc, struct aml_value *argv, uint64_t *ival)
 {
        struct aml_value res;
        int rc;
Index: dsdt.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.h,v
retrieving revision 1.59
diff -u -p -r1.59 dsdt.h
--- dsdt.h      3 Jun 2011 03:54:19 -0000       1.59
+++ dsdt.h      1 Apr 2012 09:42:17 -0000
@@ -41,12 +41,12 @@ struct aml_opcode {
 
 const char             *aml_eisaid(u_int32_t);
 const char             *aml_mnem(int, uint8_t *);
-int64_t                        aml_val2int(struct aml_value *);
+uint64_t               aml_val2int(struct aml_value *);
 struct aml_node                *aml_searchname(struct aml_node *, const void 
*);
 struct aml_node                *aml_searchrel(struct aml_node *, const void *);
 
 struct aml_value       *aml_getstack(struct aml_scope *, int);
-struct aml_value       *aml_allocvalue(int, int64_t, const void *);
+struct aml_value       *aml_allocvalue(int, uint64_t, const void *);
 void                   aml_freevalue(struct aml_value *);
 void                   aml_notify(struct aml_node *, int);
 void                   aml_showvalue(struct aml_value *, int);
@@ -67,7 +67,7 @@ int                   aml_evalname(struct acpi_softc *, 
                            const char *, int, struct aml_value *,
                            struct aml_value *);
 int                    aml_evalinteger(struct acpi_softc *, struct aml_node *,
-                            const char *, int, struct aml_value *, int64_t *);
+                            const char *, int, struct aml_value *, uint64_t *);
 
 void                   aml_create_defaultobjects(void);
 
@@ -247,7 +247,6 @@ const char          *aml_val_to_string(const str
 void                   aml_disasm(struct aml_scope *scope, int lvl,
                            void (*dbprintf)(void *, const char *, ...),
                            void *arg);
-int                    aml_getpci(struct aml_node *, int64_t *);
 int                    aml_evalhid(struct aml_node *, struct aml_value *);
 
 int                    acpi_walkmem(int, const char *);

Reply via email to