Changeset 16637

Show
Ignore:
Timestamp:
03/08/06 01:51:46 (3 years ago)
Author:
bvarner
Message:

* acpi bus_manager addition of get_object() functions.
* thermal driver uses get_object to obtain the passive device package.

Need changes to acpi_object_type to handle references... that'll have to come in the near future.

Location:
haiku/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/headers/os/drivers/ACPI.h

    r11891 r16637  
    3535        status_t                        (*get_device_hid) (const char *path, char *hid); 
    3636        uint32                          (*get_object_type) (const char *path); 
     37        status_t                        (*get_object) (const char *path, acpi_object_type **return_value); 
     38        status_t                        (*get_object_typed) (const char *path, acpi_object_type **return_value, uint32 object_type); 
    3739         
    3840        /* Control method execution and data acquisition */ 
  • haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c

    r12440 r16637  
    2424 
    2525status_t get_device_hid (const char *path, char *hid); 
     26status_t get_object(const char *path, acpi_object_type **return_value); 
     27status_t get_object_typed(const char *path, acpi_object_type **return_value, uint32 object_type); 
    2628uint32 get_object_type (const char *path); 
    2729 
     
    5153        get_device, 
    5254        get_device_hid, 
     55        get_object, 
     56        get_object_typed, 
    5357        get_object_type, 
    5458        evaluate_object, 
     
    252256} 
    253257 
     258status_t get_object (const char *path, acpi_object_type **return_value) { 
     259        ACPI_HANDLE handle; 
     260        ACPI_BUFFER buffer; 
     261        ACPI_STATUS status; 
     262         
     263        status = AcpiGetHandle(NULL, path, &handle); 
     264        if (status != AE_OK) { 
     265                return B_ENTRY_NOT_FOUND; 
     266        } 
     267        buffer.Pointer = NULL; 
     268        buffer.Length = ACPI_ALLOCATE_BUFFER; 
     269         
     270        status = AcpiEvaluateObject(handle, NULL, NULL, &buffer); 
     271         
     272        *return_value = buffer.Pointer; 
     273        return (status == AE_OK) ? B_OK : B_ERROR; 
     274} 
     275 
     276status_t get_object_typed (const char *path, acpi_object_type **return_value, uint32 object_type) { 
     277        ACPI_HANDLE handle; 
     278        ACPI_BUFFER buffer; 
     279        ACPI_STATUS status; 
     280         
     281        status = AcpiGetHandle(NULL, path, &handle); 
     282        if (status != AE_OK) { 
     283                return B_ENTRY_NOT_FOUND; 
     284        } 
     285        buffer.Pointer = NULL; 
     286        buffer.Length = ACPI_ALLOCATE_BUFFER; 
     287         
     288        status = AcpiEvaluateObjectTyped(handle, NULL, NULL, &buffer, object_type); 
     289         
     290        *return_value = buffer.Pointer; 
     291        return (status == AE_OK) ? B_OK : B_ERROR; 
     292} 
     293 
    254294status_t evaluate_object (const char *object, acpi_object_type *return_value, size_t buf_len) { 
    255295        ACPI_BUFFER buffer; 
  • haiku/trunk/src/add-ons/kernel/drivers/power/acpi_thermal/acpi_thermal.c

    r16562 r16637  
    3737                                td->open = 0; 
    3838                                td->num = device_count; 
     39                                 
    3940                                dprintf("acpi_thermal: Adding thermal device from: %s\n", result); 
    4041                                td->path = malloc(sizeof(char) * strlen(result) + 1); 
     
    140141acpi_thermal_read (void* cookie, off_t position, void *buf, size_t* num_bytes) 
    141142{ 
     143        int i; 
    142144        acpi_thermal_type therm_info; 
    143145        if (*num_bytes < 1) 
     
    150152                *num_bytes = strlen((char *)buf); 
    151153         
    152                 sprintf((char *)buf + *num_bytes, "  Critical Temperature: %lu.%lu K\n", (therm_info.critical_temp / 10), (therm_info.critical_temp % 10)); 
     154                sprintf((char *)buf + *num_bytes, "  Critical Temperature: %lu.%lu K\n",  
     155                                (therm_info.critical_temp / 10), (therm_info.critical_temp % 10)); 
    153156                *num_bytes = strlen((char *)buf); 
    154157                 
    155                 sprintf((char *)buf + *num_bytes, "  Current Temperature: %lu.%lu K\n", (therm_info.current_temp / 10), (therm_info.current_temp % 10)); 
     158                sprintf((char *)buf + *num_bytes, "  Current Temperature: %lu.%lu K\n",  
     159                                (therm_info.current_temp / 10), (therm_info.current_temp % 10)); 
    156160                *num_bytes = strlen((char *)buf); 
    157161         
    158162                if (therm_info.hot_temp > 0) { 
    159                         sprintf((char *)buf, "Hot Temperature: %lu.%lu K\n", (therm_info.hot_temp / 10), (therm_info.hot_temp % 10)); 
     163                        sprintf((char *)buf + *num_bytes, "  Hot Temperature: %lu.%lu K\n",  
     164                                        (therm_info.hot_temp / 10), (therm_info.hot_temp % 10)); 
    160165                        *num_bytes = strlen((char *)buf); 
     166                } 
     167 
     168                if (therm_info.passive_package) { 
     169/* Incomplete.  
     170     Needs to obtain acpi global lock. 
     171     acpi_object_type needs Reference entry (with Handle that can be resolved) 
     172     what you see here is _highly_ unreliable. 
     173*/ 
     174/*                      if (therm_info.passive_package->data.package.count > 0) { 
     175                                sprintf((char *)buf + *num_bytes, "  Passive Devices\n"); 
     176                                *num_bytes = strlen((char *)buf); 
     177                                for (i = 0; i < therm_info.passive_package->data.package.count; i++) { 
     178                                        sprintf((char *)buf + *num_bytes, "    Processor: %lu\n", therm_info.passive_package->data.package.objects[i].data.processor.cpu_id); 
     179                                        *num_bytes = strlen((char *)buf); 
     180                                } 
     181                        } 
     182*/ 
     183                        free(therm_info.passive_package); 
    161184                } 
    162185        } else { 
     
    179202         
    180203        thermal_dev *td = (thermal_dev *)cookie; 
     204        char objname[255]; 
    181205        acpi_thermal_type *att = NULL; 
    182206         
     207        size_t bufsize = sizeof(acpi_object_type); 
    183208        acpi_object_type buf; 
    184         size_t bufsize = sizeof(buf); 
    185  
     209         
    186210        switch (op) { 
    187211                case drvOpGetThermalType: { 
     
    189213                        att = (acpi_thermal_type *)arg; 
    190214                         
     215                        // Read basic temperature thresholds. 
    191216                        att->devnum = td->num; 
    192217                        err = acpi->evaluate_method(td->path, "_CRT", &buf, bufsize, NULL, 0); 
     
    202227                        dprintf("acpi_thermal: GotBasicTemperatures()\n"); 
    203228                         
    204                         // TODO: Fill this out 
    205                         att->passive_count = 0; 
     229                        // Read Passive Cooling devices 
    206230                        att->passive_package = NULL; 
     231                        sprintf(objname, "%s._PSL", td->path); 
     232                        err = acpi->get_object(objname, &(att->passive_package)); 
    207233                         
    208234                        att->active_count = 0; 
  • haiku/trunk/src/add-ons/kernel/drivers/power/acpi_thermal/acpi_thermal.h

    r16562 r16637  
    2727        uint32 hot_temp; 
    2828         
    29         /* List of acpi_objects_types assigned to the passive device list */ 
    30         uint32 passive_count; 
     29        /* acpi_objects_type evaluated from _PSL  
     30           if != NULL, client must free() 
     31        */ 
    3132        acpi_object_type *passive_package; 
    3233