After the report from a few weeks ago I went ahead and fixed most (if
not all) of the signed integer usages in the AML parser.

Please have a look at this diff, test it thoroughly and comment/okay it.

Index: dev/acpi/amltypes.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/amltypes.h,v
retrieving revision 1.39
diff -u -p -r1.39 amltypes.h
--- dev/acpi/amltypes.h 15 Oct 2010 20:25:04 -0000      1.39
+++ dev/acpi/amltypes.h 30 Mar 2012 22:45:14 -0000
@@ -263,7 +263,7 @@ struct aml_value {
        int     stack;
        struct aml_node *node;
        union {
-               int64_t         vinteger;
+               u_int64_t       vinteger;
                char            *vstring;
                u_int8_t        *vbuffer;
                struct aml_value **vpackage;
Index: dev/acpi/dsdt.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
retrieving revision 1.193
diff -u -p -r1.193 dsdt.c
--- dev/acpi/dsdt.c     15 Mar 2012 18:36:53 -0000      1.193
+++ dev/acpi/dsdt.c     30 Mar 2012 22:45:15 -0000
@@ -54,12 +54,9 @@ struct aml_scope     *aml_load(struct acpi_s
                            struct aml_value *, struct aml_value *);
 
 void                   aml_copyvalue(struct aml_value *, struct aml_value *);
-
-void                   aml_setvalue(struct aml_scope *, struct aml_value *,
-                           struct aml_value *, int64_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, u_int64_t, const void *);
+struct aml_value       *_aml_setvalue(struct aml_value *, int, u_int64_t,
                            const void *);
 
 u_int64_t              aml_convradix(u_int64_t, int, int);
@@ -99,7 +96,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 *);
+u_int64_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 +866,10 @@ aml_showvalue(struct aml_value *val, int
 }
 #endif /* SMALL_KERNEL */
 
-int64_t
+u_int64_t
 aml_val2int(struct aml_value *rval)
 {
-       int64_t ival = 0;
+       u_int64_t ival = 0;
 
        if (rval == NULL) {
                dnprintf(50, "null val2int\n");
@@ -895,7 +892,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, u_int64_t ival, const void 
*bval)
 {
        memset(&lhs->_, 0x0, sizeof(lhs->_));
 
@@ -923,7 +920,7 @@ _aml_setvalue(struct aml_value *lhs, int
                        memcpy(lhs->v_buffer, bval, ival);
                break;
        case AML_OBJTYPE_STRING:
-               if (ival == -1)
+               if ((signed)ival == -1)
                        ival = strlen((const char *)bval);
                lhs->length = ival;
                lhs->v_string = (char *)acpi_os_malloc(ival+1);
@@ -1001,7 +998,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, u_int64_t ival, const void *bval)
 {
        struct aml_value *rv;
 
@@ -1451,11 +1448,11 @@ static char osstring[] = "Macrosift Wind
 struct aml_defval {
        const char              *name;
        int                     type;
-       int64_t                 ival;
+       u_int64_t               ival;
        const void              *bval;
        struct aml_value        **gval;
 } aml_defobj[] = {
-       { "_OS_", AML_OBJTYPE_STRING, -1, osstring },
+       { "_OS_", AML_OBJTYPE_STRING, (unsigned)-1, osstring },
        { "_REV", AML_OBJTYPE_INTEGER, 2, NULL },
        { "_GL", AML_OBJTYPE_MUTEX, 1, NULL, &aml_global_lock },
        { "_OSI", AML_OBJTYPE_METHOD, 1, aml_callosi },
@@ -1731,7 +1728,7 @@ 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_matchtest(u_int64_t, u_int64_t, int);
 int            aml_match(struct aml_value *, int, int, int, int, int);
 
 int            aml_compare(struct aml_value *, struct aml_value *, int);
@@ -1740,7 +1737,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 *, u_int64_t,
     struct aml_value *);
 
 /*
@@ -1928,7 +1925,7 @@ aml_popscope(struct aml_scope *scope)
 
 /* Test AMLOP_MATCH codes */
 int
-aml_matchtest(int64_t a, int64_t b, int op)
+aml_matchtest(u_int64_t a, u_int64_t b, int op)
 {
        switch (op) {
        case AML_MATCH_TR:
@@ -1976,10 +1973,10 @@ aml_match(struct aml_value *pkg, int ind
 /*
  * Conversion routines
  */
-int64_t
+u_int64_t
 aml_hextoint(const char *str)
 {
-       int64_t v = 0;
+       u_int64_t v = 0;
        char c;
 
        while (*str) {
@@ -2204,7 +2201,7 @@ void aml_rwgas(struct aml_value *, int, 
 int
 aml_rdpciaddr(struct aml_node *pcidev, union amlpci_t *addr)
 {
-       int64_t res;
+       u_int64_t res;
 
        if (aml_evalinteger(acpi_softc, pcidev, "_ADR", 0, NULL, &res) == 0) {
                addr->fun = res & 0xFFFF;
@@ -2213,7 +2210,8 @@ aml_rdpciaddr(struct aml_node *pcidev, u
        while (pcidev != NULL) {
                /* HID device (PCI or PCIE root): eval _BBN */
                if (__aml_search(pcidev, "_HID", 0)) {
-                       if (aml_evalinteger(acpi_softc, pcidev, "_BBN", 0, 
NULL, &res) == 0) {
+                       if (aml_evalinteger(acpi_softc, pcidev, "_BBN", 0, NULL,
+                           &res) == 0) {
                                addr->bus = res;
                                break;
                        }
@@ -2519,7 +2517,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 , u_int64_t ival,
     struct aml_value *rhs)
 {
        struct aml_value tmp;
@@ -2608,7 +2606,7 @@ aml_disasm(struct aml_scope *scope, int 
 {
        int pc, opcode;
        struct aml_opcode *htab;
-       uint64_t ival;
+       u_int64_t ival;
        struct aml_value *rv, tmp;
        uint8_t *end = NULL;
        struct aml_scope ms;
@@ -3271,7 +3269,7 @@ aml_parse(struct aml_scope *scope, int r
        struct aml_scope *mscope, *iscope;
        uint8_t *start, *end;
        const char *ch;
-       int64_t ival;
+       u_int64_t ival;
 
        my_ret = NULL;
        if (scope == NULL || scope->pos >= scope->end) {
@@ -4060,7 +4058,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, u_int64_t *ival)
 {
        struct aml_value res;
        int rc;
Index: dev/acpi/dsdt.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.h,v
retrieving revision 1.59
diff -u -p -r1.59 dsdt.h
--- dev/acpi/dsdt.h     3 Jun 2011 03:54:19 -0000       1.59
+++ dev/acpi/dsdt.h     30 Mar 2012 22:45:15 -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 *);
+u_int64_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, u_int64_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 *, u_int64_t 
*);
 
 void                   aml_create_defaultobjects(void);

Reply via email to