Index: branches/meklort/i386/libsaio/device_inject.c =================================================================== --- branches/meklort/i386/libsaio/device_inject.c (revision 547) +++ branches/meklort/i386/libsaio/device_inject.c (revision 548) @@ -31,7 +31,8 @@ char *efi_inject_get_devprop_string(uint32_t *len) { - if(string) { + if(string) + { *len = string->length; return devprop_generate_string(string); } @@ -41,31 +42,31 @@ void setupDeviceProperties(Node *node) { - const char *val; - uint8_t *binStr; - int cnt, cnt2; - - static char DEVICE_PROPERTIES_PROP[] = "device-properties"; - - /* Generate devprop string. - */ - uint32_t strlength; - char *string = efi_inject_get_devprop_string(&strlength); - - /* Use the static "device-properties" boot config key contents if available, - * otheriwse use the generated one. - */ - if (!getValueForKey(kDeviceProperties, &val, &cnt, &bootInfo->bootConfig) && string) - { - val = (const char*)string; - cnt = strlength * 2; - } + const char *val; + uint8_t *binStr; + int cnt, cnt2; + + static char DEVICE_PROPERTIES_PROP[] = "device-properties"; + + /* Generate devprop string. + */ + uint32_t strlength; + char *string = efi_inject_get_devprop_string(&strlength); + + /* Use the static "device-properties" boot config key contents if available, + * otheriwse use the generated one. + */ + if (!getValueForKey(kDeviceProperties, &val, &cnt, &bootInfo->bootConfig) && string) + { + val = (const char*)string; + cnt = strlength * 2; + } - if (cnt > 1) - { - binStr = convertHexStr2Binary(val, &cnt2); - if (cnt2 > 0) DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, binStr); - } + if (cnt > 1) + { + binStr = convertHexStr2Binary(val, &cnt2); + if (cnt2 > 0) DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, binStr); + } } struct DevPropString *devprop_create_string(void) @@ -73,46 +74,54 @@ string = (struct DevPropString*)malloc(sizeof(struct DevPropString)); if(string == NULL) + { return NULL; + } memset(string, 0, sizeof(struct DevPropString)); string->length = 12; string->WHAT2 = 0x01000000; return string; } - + struct DevPropDevice *devprop_add_device(struct DevPropString *string, char *path) { struct DevPropDevice *device; const char pciroot_string[] = "PciRoot(0x"; const char pci_device_string[] = "Pci(0x"; - + if (string == NULL || path == NULL) { return NULL; } device = malloc(sizeof(struct DevPropDevice)); - + if (strncmp(path, pciroot_string, strlen(pciroot_string))) { printf("ERROR parsing device path\n"); return NULL; } - + memset(device, 0, sizeof(struct DevPropDevice)); device->acpi_dev_path._UID = getPciRootUID(); - + int numpaths = 0; int x, curr = 0; char buff[] = "00"; - - for (x = 0; x < strlen(path); x++) { - if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string))) { + + for (x = 0; x < strlen(path); x++) + { + if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string))) + { x+=strlen(pci_device_string); curr=x; while(path[++x] != ','); if(x-curr == 2) + { sprintf(buff, "%c%c", path[curr], path[curr+1]); + } else if(x-curr == 1) + { sprintf(buff, "%c", path[curr]); + } else { printf("ERROR parsing device path\n"); @@ -125,9 +134,13 @@ curr = x; while(path[++x] != ')'); if(x-curr == 2) + { sprintf(buff, "%c%c", path[curr], path[curr+1]); + } else if(x-curr == 1) + { sprintf(buff, "%c", path[curr]); + } else { printf("ERROR parsing device path\n"); @@ -141,7 +154,9 @@ } if(!numpaths) + { return NULL; + } device->numentries = 0x00; @@ -171,8 +186,12 @@ string->length += device->length; if(!string->entries) + { if((string->entries = (struct DevPropDevice**)malloc(sizeof(device)))== NULL) + { return 0; + } + } string->entries[string->numentries++] = (struct DevPropDevice*)malloc(sizeof(device)); string->entries[string->numentries-1] = device; @@ -184,13 +203,17 @@ { if(!nm || !vl || !len) + { return 0; + } uint32_t length = ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2); uint8_t *data = (uint8_t*)malloc(length); { if(!data) + { return 0; + } memset(data, 0, length); uint32_t off= 0; @@ -219,11 +242,17 @@ uint8_t *newdata = (uint8_t*)malloc((length + offset)); if(!newdata) + { return 0; + } if(device->data) + { if(offset > 1) + { memcpy(newdata, device->data, offset); - + } + } + memcpy(newdata + offset, data, length); device->length += length; @@ -231,9 +260,13 @@ device->numentries++; if(!device->data) + { device->data = (uint8_t*)malloc(sizeof(uint8_t)); + } else + { free(device->data); + } free(data); device->data = newdata; @@ -247,8 +280,10 @@ char *ptr = buffer; if(!buffer) + { return NULL; - + } + sprintf(buffer, "%08x%08x%04x%04x", dp_swap32(string->length), string->WHAT2, dp_swap16(string->numentries), string->WHAT3); buffer += 24; @@ -265,7 +300,7 @@ dp_swap16(string->entries[i]->acpi_dev_path.length), string->entries[i]->acpi_dev_path._HID, dp_swap32(string->entries[i]->acpi_dev_path._UID)); - + buffer += 24; for(x=0;x < string->entries[i]->num_pci_devpaths; x++) { @@ -296,7 +331,9 @@ void devprop_free_string(struct DevPropString *string) { if(!string) + { return; + } int i; for(i = 0; i < string->numentries; i++) Index: branches/meklort/i386/libsaio/pci.c =================================================================== --- branches/meklort/i386/libsaio/pci.c (revision 547) +++ branches/meklort/i386/libsaio/pci.c (revision 548) @@ -179,7 +179,7 @@ return dev_path; } -#if DEBUG_PCI +#ifndef OPTION_ROM void dump_pci_dt(pci_dt_t *pci_dt) { pci_dt_t *current; Index: branches/meklort/i386/boot2/boot.c =================================================================== --- branches/meklort/i386/boot2/boot.c (revision 547) +++ branches/meklort/i386/boot2/boot.c (revision 548) @@ -57,6 +57,8 @@ #include "libsa.h" #include "ramdisk.h" #include "platform.h" +#include "graphics.h" + #include "modules.h" long gBootMode; /* defaults to 0 == kBootModeNormal */ @@ -185,19 +187,14 @@ getc(); } - // If we were in text mode, switch to graphics mode. - // This will draw the boot graphics unless we are in - // verbose mode. - - if(gVerboseMode) + if (bootArgs->Video.v_display == VGA_TEXT_MODE) { - if (bootArgs->Video.v_display == VGA_TEXT_MODE) - { - setVideoMode( GRAPHICS_MODE, 0 ); - } - + setVideoMode( GRAPHICS_MODE, 0 ); } + // Draw gray screen. NOTE: no boot image, that's in the gui module + if(!gVerboseMode) drawColorRectangle(0, 0, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 0x01); + setupBooterLog(); finalizeBootStruct(); Index: branches/meklort/i386/boot2/boot.h =================================================================== --- branches/meklort/i386/boot2/boot.h (revision 547) +++ branches/meklort/i386/boot2/boot.h (revision 548) @@ -67,7 +67,6 @@ #define karch "arch" /* boot.c */ #define kDSDT "DSDT" /* acpi_patcher.c */ #define kDropSSDT "DropSSDT" /* acpi_patcher.c */ -#define kRestartFix "RestartFix" /* acpi_patcher.c */ #define kRestartFix "RestartFix" /* acpi_patcher.c */ #define kGeneratePStates "GeneratePStates" /* acpi_patcher.c */ #define kGenerateCStates "GenerateCStates" /* acpi_patcher.c */ Index: branches/meklort/i386/boot2/modules.c =================================================================== --- branches/meklort/i386/boot2/modules.c (revision 547) +++ branches/meklort/i386/boot2/modules.c (revision 548) @@ -45,7 +45,7 @@ /* * Initialize the module system by loading the Symbols.dylib module. - * Once laoded, locate the _lookup_symbol function so that internal + * Once loaded, locate the _lookup_symbol function so that internal * symbols can be resolved. */ int init_module_system() @@ -85,8 +85,9 @@ { if(strcmp(&name[strlen(name) - sizeof("dylib")], ".dylib") == 0) { - char* tmp = malloc(strlen(name) + 1); // TODO: look into this + char* tmp = malloc(strlen(name) + 1); strcpy(tmp, name); + DBG("Attempting to load %s\n", tmp); load_module(tmp); } @@ -105,6 +106,9 @@ */ int load_module(char* module) { + void (*module_start)(void) = NULL; + + // Check to see if the module has already been loaded if(is_module_loaded(module)) { @@ -127,9 +131,8 @@ unsigned int moduleSize = file_size(fh); char* module_base = (char*) malloc(moduleSize); - if (read(fh, module_base, moduleSize) == moduleSize) + if (moduleSize && read(fh, module_base, moduleSize) == moduleSize) { - void (*module_start)(void) = NULL; //printf("Module %s read in.\n", modString); @@ -144,13 +147,14 @@ DBG("Module %s Loaded.\n", module); } else { + // The module does not have a valid start function printf("Unable to start %s\n", module); getc(); } } else { - printf("Unable to read in module %s\n.", module); + DBG("Unable to read in module %s\n.", module); getc(); } close(fh); @@ -349,7 +353,7 @@ return NULL; // Module is in the incorrect format }*/ - while(cmd < ((struct mach_header*)binary)->ncmds) // TODO: for loop instead + while(cmd < ((struct mach_header*)binary)->ncmds) { cmd++; @@ -1037,17 +1041,7 @@ void module_loaded(const char* name/*, UInt32 version, UInt32 compat*/) { moduleList_t* entry; - /* - DBG("\%s.dylib Version %d.%d.%d loaded\n" - "\tCompatibility Version: %d.%d.%d\n", - name, - (version >> 16) & 0xFFFF, - (version >> 8) & 0x00FF, - (version >> 0) & 0x00FF, - (compat >> 16) & 0xFFFF, - (compat >> 8) & 0x00FF, - (compat >> 0) & 0x00FF); - */ + if(loadedModules == NULL) { loadedModules = entry = malloc(sizeof(moduleList_t)); @@ -1123,11 +1117,13 @@ } } +#if DEBUG_MODULES if(strcmp(name, SYMBOL_DYLD_STUB_BINDER) != 0) { - printf("Unable to locate symbol %s\n", name); - getc(); + verbose("Unable to locate symbol %s\n", name); + //getc(); } +#endif return 0xFFFFFFFF; } @@ -1225,7 +1221,7 @@ } -/* Nedded to devide 64bit numbers correctly. TODO: look into why modules need this +/* Nedded to divide 64bit numbers correctly. TODO: look into why modules need this * And why it isn't needed when compiled into boot2 */ Index: branches/meklort/i386/modules/HPET/HPET.c =================================================================== --- branches/meklort/i386/modules/HPET/HPET.c (revision 547) +++ branches/meklort/i386/modules/HPET/HPET.c (revision 548) @@ -63,7 +63,9 @@ { 0x8086, 0x27b8, "ICH7" }, { 0x8086, 0x27b9, "ICH7M" }, { 0x8086, 0x27bd, "ICH7M DH" }, - + + { 0x8086, 0x27bc, "NM10" }, + { 0x8086, 0x2810, "ICH8R" }, { 0x8086, 0x2811, "ICH8M-E" }, { 0x8086, 0x2812, "ICH8DH" }, @@ -116,7 +118,6 @@ uint32_t val, hpet_address = 0xFED00000; int i; - /* LPC on Intel ICH is always (?) at 00:1f.0 */ for(i = 1; i < sizeof(lpc_controllers_via) / sizeof(lpc_controllers_via[0]); i++) { if ( (lpc_controllers_via[i].vendor == lpc_dev->vendor_id) @@ -125,7 +126,7 @@ val = pci_config_read32(lpc_dev->dev.addr, 0x68); DBG("VIA %s LPC Interface [%04x:%04x], MMIO\n", - lpc_controllers[i].name, lpc_dev->vendor_id, lpc_dev->device_id); + lpc_controllers_via[i].name, lpc_dev->vendor_id, lpc_dev->device_id); if (val & 0x80) { hpet_address = (val & ~0x3ff); @@ -166,7 +167,7 @@ rcba = (void *)(pci_config_read32(lpc_dev->dev.addr, 0xF0) & 0xFFFFC000); DBG("Intel(R) %s LPC Interface [%04x:%04x], MMIO @ 0x%lx\n", - lpc_controllers[i].name, lpc_dev->vendor_id, lpc_dev->device_id, rcba); + lpc_controllers_intel[i].name, lpc_dev->vendor_id, lpc_dev->device_id, rcba); if (rcba == 0) printf(" RCBA disabled; cannot force enable HPET\n"); Index: branches/meklort/i386/modules/KernelPatcher/kernel_patcher.c =================================================================== --- branches/meklort/i386/modules/KernelPatcher/kernel_patcher.c (revision 547) +++ branches/meklort/i386/modules/KernelPatcher/kernel_patcher.c (revision 548) @@ -220,16 +220,11 @@ // Locate the symbol in the list, if it exists, update it's address kernSymbols_t *symbol = lookup_kernel_symbol(symbolName); - - if(symbol) { - - //printf("Located %sbit symbol %s at 0x%lX\n", is64 ? "64" : "32", symbolName, addr); - //getc(); - symbol->addr = addr; } + return 0xFFFFFFFF; // fixme }