Merge branch 'master' of ssh://git.haiku-os.org/haiku

This commit is contained in:
Adrien Destugues - PulkoMandy
2012-07-15 17:30:48 +02:00
17 changed files with 175 additions and 97 deletions
@@ -3,8 +3,8 @@
* Copyright 2006, Jérôme Duval. All rights reserved. * Copyright 2006, Jérôme Duval. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef __ACPI_PRIV_H__ #ifndef _ACPI_PRIVATE_H
#define __ACPI_PRIV_H__ #define _ACPI_PRIVATE_H
#include <sys/cdefs.h> #include <sys/cdefs.h>
@@ -227,4 +227,4 @@ status_t get_table(const char* signature, uint32 instance, void** tableHeader);
__END_DECLS __END_DECLS
#endif /* __ACPI_PRIV_H__ */ #endif /* _ACPI_PRIVATE_H */
@@ -20,11 +20,13 @@
#include <safemode.h> #include <safemode.h>
extern "C" {
#include "acpi.h" #include "acpi.h"
#include "accommon.h" #include "accommon.h"
#include "acdisasm.h" #include "acdisasm.h"
#include "acnamesp.h" #include "acnamesp.h"
#include "acpi_priv.h" }
#include "ACPIPrivate.h"
//#define TRACE_ACPI_BUS //#define TRACE_ACPI_BUS
#ifdef TRACE_ACPI_BUS #ifdef TRACE_ACPI_BUS
@@ -384,7 +386,7 @@ status_t
install_fixed_event_handler(uint32 event, interrupt_handler* handler, install_fixed_event_handler(uint32 event, interrupt_handler* handler,
void *data) void *data)
{ {
return AcpiInstallFixedEventHandler(event, (void*)handler, data) == AE_OK return AcpiInstallFixedEventHandler(event, (ACPI_EVENT_HANDLER)handler, data) == AE_OK
? B_OK : B_ERROR; ? B_OK : B_ERROR;
} }
@@ -392,7 +394,7 @@ install_fixed_event_handler(uint32 event, interrupt_handler* handler,
status_t status_t
remove_fixed_event_handler(uint32 event, interrupt_handler* handler) remove_fixed_event_handler(uint32 event, interrupt_handler* handler)
{ {
return AcpiRemoveFixedEventHandler(event, (void*)handler) == AE_OK return AcpiRemoveFixedEventHandler(event, (ACPI_EVENT_HANDLER)handler) == AE_OK
? B_OK : B_ERROR; ? B_OK : B_ERROR;
} }
@@ -441,7 +443,7 @@ get_device(const char* hid, uint32 index, char* result, size_t resultLength)
char *buffer = NULL; char *buffer = NULL;
TRACE("get_device %s, index %ld\n", hid, index); TRACE("get_device %s, index %ld\n", hid, index);
status = AcpiGetDevices((ACPI_STRING)hid, (void*)&get_device_by_hid_callback, status = AcpiGetDevices((ACPI_STRING)hid, (ACPI_WALK_CALLBACK)&get_device_by_hid_callback,
counter, (void**)&buffer); counter, (void**)&buffer);
if (status != AE_OK || buffer == NULL) if (status != AE_OK || buffer == NULL)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
@@ -523,7 +525,7 @@ get_object(const char* path, acpi_object_type** _returnValue)
status = AcpiEvaluateObject(handle, NULL, NULL, &buffer); status = AcpiEvaluateObject(handle, NULL, NULL, &buffer);
*_returnValue = buffer.Pointer; *_returnValue = (acpi_object_type*)buffer.Pointer;
return status == AE_OK ? B_OK : B_ERROR; return status == AE_OK ? B_OK : B_ERROR;
} }
@@ -545,7 +547,7 @@ get_object_typed(const char* path, acpi_object_type** _returnValue,
status = AcpiEvaluateObjectTyped(handle, NULL, NULL, &buffer, objectType); status = AcpiEvaluateObjectTyped(handle, NULL, NULL, &buffer, objectType);
*_returnValue = buffer.Pointer; *_returnValue = (acpi_object_type*)buffer.Pointer;
return status == AE_OK ? B_OK : B_ERROR; return status == AE_OK ? B_OK : B_ERROR;
} }
@@ -642,7 +644,7 @@ prepare_sleep_state(uint8 state, void (*wakeFunc)(void), size_t size)
status_t status; status_t status;
// Note: The supplied code must already be locked into memory. // Note: The supplied code must already be locked into memory.
status = get_memory_map(wakeFunc, size, &wakeVector, 1); status = get_memory_map((const void*)wakeFunc, size, &wakeVector, 1);
if (status != B_OK) if (status != B_OK)
return status; return status;
@@ -676,7 +678,10 @@ enter_sleep_state(uint8 state, uint8 flags)
TRACE("enter_sleep_state %d with flags %d\n", state, flags); TRACE("enter_sleep_state %d with flags %d\n", state, flags);
cpu_status cpu = disable_interrupts();
status = AcpiEnterSleepState(state, flags); status = AcpiEnterSleepState(state, flags);
restore_interrupts(cpu);
panic("AcpiEnterSleepState should not return.");
if (status != AE_OK) if (status != AE_OK)
return B_ERROR; return B_ERROR;
@@ -9,8 +9,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "acpi_priv.h" #include "ACPIPrivate.h"
extern "C" {
#include "acpi.h" #include "acpi.h"
}
static status_t static status_t
@@ -77,8 +79,6 @@ acpi_device_init_driver(device_node *node, void **cookie)
{ {
ACPI_HANDLE handle; ACPI_HANDLE handle;
const char *path; const char *path;
acpi_device_cookie *device;
status_t status = B_OK;
uint32 type; uint32 type;
if (gDeviceManager->get_attr_uint32(node, ACPI_DEVICE_TYPE_ITEM, &type, false) != B_OK) if (gDeviceManager->get_attr_uint32(node, ACPI_DEVICE_TYPE_ITEM, &type, false) != B_OK)
@@ -86,7 +86,7 @@ acpi_device_init_driver(device_node *node, void **cookie)
if (gDeviceManager->get_attr_string(node, ACPI_DEVICE_PATH_ITEM, &path, false) != B_OK) if (gDeviceManager->get_attr_string(node, ACPI_DEVICE_PATH_ITEM, &path, false) != B_OK)
return B_ERROR; return B_ERROR;
device = malloc(sizeof(*device)); acpi_device_cookie *device = (acpi_device_cookie*)malloc(sizeof(*device));
if (device == NULL) if (device == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -102,19 +102,16 @@ acpi_device_init_driver(device_node *node, void **cookie)
device->type = type; device->type = type;
device->node = node; device->node = node;
snprintf(device->name, sizeof(device->name), "acpi_device %s", snprintf(device->name, sizeof(device->name), "acpi_device %s", path);
path);
*cookie = device; *cookie = device;
return B_OK;
return status;
} }
static void static void
acpi_device_uninit_driver(void *cookie) acpi_device_uninit_driver(void *cookie)
{ {
acpi_device_cookie *device = cookie; acpi_device_cookie *device = (acpi_device_cookie*)cookie;
free(device->path); free(device->path);
free(device); free(device);
@@ -28,7 +28,7 @@
*/ */
#include "acpi_embedded_controller.h" #include "EmbeddedController.h"
#include <kernel.h> #include <kernel.h>
#include <stdio.h> #include <stdio.h>
@@ -44,7 +44,7 @@ extern "C" {
# include "accommon.h" # include "accommon.h"
# include "acnamesp.h" # include "acnamesp.h"
# include "actypes.h" # include "actypes.h"
# include "acpi_priv.h" # include "ACPIPrivate.h"
} }
+6 -6
View File
@@ -200,12 +200,12 @@ SEARCH on [ FGristFiles $(tables_src) ] = [ FDirName $(HAIKU_TOP) src add-ons ke
SEARCH on [ FGristFiles $(utilities_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components utilities ] ; SEARCH on [ FGristFiles $(utilities_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components utilities ] ;
KernelAddon acpi : KernelAddon acpi :
oshaiku.cpp ACPICAHaiku.cpp
acpi_busman.c BusManager.cpp
acpi_module.c Module.cpp
acpi_device.c Device.cpp
acpi_ns_dump.cpp NamespaceDump.cpp
acpi_embedded_controller.cpp EmbeddedController.cpp
SmallResourceData.cpp SmallResourceData.cpp
: :
libacpi_ca.a libacpi_ca.a
@@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "acpi_priv.h" #include "ACPIPrivate.h"
#include <dpc.h> #include <dpc.h>
#include <PCI.h> #include <PCI.h>
@@ -126,7 +126,7 @@ acpi_enumerate_child_devices(device_node* node, const char* root)
static status_t static status_t
acpi_module_register_child_devices(void* cookie) acpi_module_register_child_devices(void* cookie)
{ {
device_node* node = cookie; device_node* node = (device_node*)cookie;
status_t status = gDeviceManager->publish_device(node, "acpi/namespace", status_t status = gDeviceManager->publish_device(node, "acpi/namespace",
ACPI_NS_DUMP_DEVICE_MODULE_NAME); ACPI_NS_DUMP_DEVICE_MODULE_NAME);
@@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "acpi_priv.h" #include "ACPIPrivate.h"
#include <util/kernel_cpp.h> #include <util/kernel_cpp.h>
#include <util/ring_buffer.h> #include <util/ring_buffer.h>
@@ -693,10 +693,12 @@ DwarfImageDebugInfo::GetStatement(FunctionDebugInfo* _function,
int32 statementLine = -1; int32 statementLine = -1;
int32 statementColumn = -1; int32 statementColumn = -1;
while (program.GetNextRow(state)) { while (program.GetNextRow(state)) {
bool isOurFile = state.file == fileIndex; // skip statements of other files
if (state.file != fileIndex)
continue;
if (statementAddress != 0 if (statementAddress != 0
&& (!isOurFile || state.isStatement || state.isSequenceEnd)) { && (state.isStatement || state.isSequenceEnd)) {
target_addr_t endAddress = state.address; target_addr_t endAddress = state.address;
if (address >= statementAddress && address < endAddress) { if (address >= statementAddress && address < endAddress) {
ContiguousStatement* statement = new(std::nothrow) ContiguousStatement* statement = new(std::nothrow)
@@ -714,10 +716,6 @@ DwarfImageDebugInfo::GetStatement(FunctionDebugInfo* _function,
statementAddress = 0; statementAddress = 0;
} }
// skip statements of other files
if (!isOurFile)
continue;
if (state.isStatement) { if (state.isStatement) {
statementAddress = state.address; statementAddress = state.address;
statementLine = state.line - 1; statementLine = state.line - 1;
@@ -2697,6 +2697,7 @@ DebugInfoEntryFactory::CreateDebugInfoEntry(uint16 tag, DebugInfoEntry*& _entry)
entry = new(std::nothrow) DIESharedType; entry = new(std::nothrow) DIESharedType;
break; break;
default: default:
return B_ENTRY_NOT_FOUND;
break; break;
} }
+5 -1
View File
@@ -825,8 +825,12 @@ DwarfFile::_ParseDebugInfoEntry(DataReader& dataReader,
DebugInfoEntry* entry; DebugInfoEntry* entry;
status_t error = fDebugInfoFactory.CreateDebugInfoEntry( status_t error = fDebugInfoFactory.CreateDebugInfoEntry(
abbreviationEntry.Tag(), entry); abbreviationEntry.Tag(), entry);
if (error != B_OK) if (error != B_OK) {
WARNING("Failed to generate entry for tag %lu, code %lu\n",
abbreviationEntry.Tag(), code);
return error; return error;
}
ObjectDeleter<DebugInfoEntry> entryDeleter(entry); ObjectDeleter<DebugInfoEntry> entryDeleter(entry);
TRACE_DIE("%*sentry %p at %lld: %lu, tag: %s (%lu), children: %d\n", TRACE_DIE("%*sentry %p at %lld: %lu, tag: %s (%lu), children: %d\n",
@@ -251,9 +251,6 @@ InspectorWindow::MessageReceived(BMessage* msg)
} }
break; break;
} }
{
break;
}
default: default:
{ {
BWindow::MessageReceived(msg); BWindow::MessageReceived(msg);
@@ -109,6 +109,7 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener)
fStepOverButton(NULL), fStepOverButton(NULL),
fStepIntoButton(NULL), fStepIntoButton(NULL),
fStepOutButton(NULL), fStepOutButton(NULL),
fInspectorWindow(NULL),
fSourceLocatePanel(NULL) fSourceLocatePanel(NULL)
{ {
fTeam->Lock(); fTeam->Lock();
@@ -237,6 +238,7 @@ TeamWindow::MessageReceived(BMessage* message)
{ {
_SaveInspectorSettings(CurrentMessage()); _SaveInspectorSettings(CurrentMessage());
fInspectorWindow = NULL; fInspectorWindow = NULL;
break;
} }
case B_REFS_RECEIVED: case B_REFS_RECEIVED:
+95 -25
View File
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2012, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -7,10 +8,88 @@
#include "IntegerFormatter.h" #include "IntegerFormatter.h"
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <TypeConstants.h> #include <TypeConstants.h>
static integer_format
GetFormatForTypeAndFormat(type_code type, integer_format format,
char* _formatString, int formatSize)
{
integer_format result = format;
_formatString[0] = '%';
++_formatString;
formatSize -= 1;
switch (type) {
case B_INT8_TYPE:
switch (format) {
case INTEGER_FORMAT_HEX_DEFAULT:
result = INTEGER_FORMAT_HEX_8;
break;
case INTEGER_FORMAT_SIGNED:
strlcpy(_formatString, B_PRId8, formatSize);
break;
case INTEGER_FORMAT_UNSIGNED:
strlcpy(_formatString, B_PRIu8, formatSize);
break;
default:
break;
}
break;
case B_INT16_TYPE:
switch (format) {
case INTEGER_FORMAT_HEX_DEFAULT:
result = INTEGER_FORMAT_HEX_16;
break;
case INTEGER_FORMAT_SIGNED:
strlcpy(_formatString, B_PRId16, formatSize);
break;
case INTEGER_FORMAT_UNSIGNED:
strlcpy(_formatString, B_PRIu16, formatSize);
break;
default:
break;
}
break;
case B_INT32_TYPE:
switch (format) {
case INTEGER_FORMAT_HEX_DEFAULT:
result = INTEGER_FORMAT_HEX_32;
break;
case INTEGER_FORMAT_SIGNED:
strlcpy(_formatString, B_PRId32, formatSize);
break;
case INTEGER_FORMAT_UNSIGNED:
strlcpy(_formatString, B_PRIu32, formatSize);
break;
default:
break;
}
break;
case B_INT64_TYPE:
default:
switch (format) {
case INTEGER_FORMAT_HEX_DEFAULT:
result = INTEGER_FORMAT_HEX_64;
break;
case INTEGER_FORMAT_SIGNED:
strlcpy(_formatString, B_PRId64, formatSize);
break;
case INTEGER_FORMAT_UNSIGNED:
strlcpy(_formatString, B_PRIu64, formatSize);
break;
default:
break;
}
break;
}
return result;
}
/*static*/ bool /*static*/ bool
IntegerFormatter::FormatValue(const BVariant& value, integer_format format, IntegerFormatter::FormatValue(const BVariant& value, integer_format format,
char* buffer, size_t bufferSize) char* buffer, size_t bufferSize)
@@ -19,38 +98,30 @@ IntegerFormatter::FormatValue(const BVariant& value, integer_format format,
if (!value.IsInteger(&isSigned)) if (!value.IsInteger(&isSigned))
return false; return false;
if (format == INTEGER_FORMAT_DEFAULT) char formatString[10];
format = isSigned ? INTEGER_FORMAT_SIGNED : INTEGER_FORMAT_UNSIGNED;
if (format == INTEGER_FORMAT_HEX_DEFAULT) { if (format == INTEGER_FORMAT_DEFAULT) {
switch (value.Type()) { format = isSigned ? INTEGER_FORMAT_SIGNED : INTEGER_FORMAT_UNSIGNED;
case B_INT8_TYPE:
case B_UINT8_TYPE:
format = INTEGER_FORMAT_HEX_8;
break;
case B_INT16_TYPE:
case B_UINT16_TYPE:
format = INTEGER_FORMAT_HEX_16;
break;
case B_INT32_TYPE:
case B_UINT32_TYPE:
format = INTEGER_FORMAT_HEX_32;
break;
case B_INT64_TYPE:
case B_UINT64_TYPE:
default:
format = INTEGER_FORMAT_HEX_64;
break;
}
} }
format = GetFormatForTypeAndFormat(value.Type(), format, formatString,
sizeof(formatString));
// format the value // format the value
switch (format) { switch (format) {
case INTEGER_FORMAT_SIGNED: case INTEGER_FORMAT_SIGNED:
snprintf(buffer, bufferSize, "%lld", value.ToInt64()); snprintf(buffer, bufferSize, formatString,
value.Type() == B_INT8_TYPE ? value.ToInt8() :
value.Type() == B_INT16_TYPE ? value.ToInt16() :
value.Type() == B_INT32_TYPE ? value.ToInt32() :
value.ToInt64());
break; break;
case INTEGER_FORMAT_UNSIGNED: case INTEGER_FORMAT_UNSIGNED:
snprintf(buffer, bufferSize, "%llu", value.ToUInt64()); snprintf(buffer, bufferSize, formatString,
value.Type() == B_INT8_TYPE ? value.ToUInt8() :
value.Type() == B_INT16_TYPE ? value.ToUInt16() :
value.Type() == B_INT32_TYPE ? value.ToUInt32() :
value.ToUInt64());
break; break;
case INTEGER_FORMAT_HEX_8: case INTEGER_FORMAT_HEX_8:
snprintf(buffer, bufferSize, "%#x", (uint8)value.ToUInt64()); snprintf(buffer, bufferSize, "%#x", (uint8)value.ToUInt64());
@@ -62,7 +133,6 @@ IntegerFormatter::FormatValue(const BVariant& value, integer_format format,
snprintf(buffer, bufferSize, "%#lx", (uint32)value.ToUInt64()); snprintf(buffer, bufferSize, "%#lx", (uint32)value.ToUInt64());
break; break;
case INTEGER_FORMAT_HEX_64: case INTEGER_FORMAT_HEX_64:
case INTEGER_FORMAT_HEX_DEFAULT:
default: default:
snprintf(buffer, bufferSize, "%#llx", value.ToUInt64()); snprintf(buffer, bufferSize, "%#llx", value.ToUInt64());
break; break;
@@ -281,6 +281,9 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
uint8* messageBuffer = new(std::nothrow) uint8[totalSize]; uint8* messageBuffer = new(std::nothrow) uint8[totalSize];
if (messageBuffer == NULL) if (messageBuffer == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
ArrayDeleter<uint8> deleter(messageBuffer);
memset(messageBuffer, 0, totalSize); memset(messageBuffer, 0, totalSize);
memcpy(messageBuffer, fHeader, sizeof(BMessage::message_header)); memcpy(messageBuffer, fHeader, sizeof(BMessage::message_header));
uint8* tempBuffer = messageBuffer + sizeof(BMessage::message_header); uint8* tempBuffer = messageBuffer + sizeof(BMessage::message_header);
@@ -313,7 +316,6 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
} }
error = fMessage.Unflatten((const char*)messageBuffer); error = fMessage.Unflatten((const char*)messageBuffer);
delete[] messageBuffer;
if (error != B_OK) if (error != B_OK)
return error; return error;
+4 -2
View File
@@ -184,15 +184,17 @@ BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
{ {
float width = rect.Width() - (2 * kTEXT_MARGIN); float width = rect.Width() - (2 * kTEXT_MARGIN);
BStringField* field = static_cast<BStringField*>(_field); BStringField* field = static_cast<BStringField*>(_field);
bool clipNeeded = width < field->Width();
if (width != field->Width()) { if (clipNeeded) {
BString out_string(field->String()); BString out_string(field->String());
parent->TruncateString(&out_string, fTruncate, width + 2); parent->TruncateString(&out_string, fTruncate, width + 2);
field->SetClippedString(out_string.String()); field->SetClippedString(out_string.String());
field->SetWidth(width); field->SetWidth(width);
} }
DrawString(field->ClippedString(), parent, rect);
DrawString(clipNeeded ? field->ClippedString() : field->String(), parent, rect);
} }