Example #1
0
//------------------------------------------------------------------------------
static BOOL
SetDeviceDriverFlags(
    LPCWSTR szKeyPath,
    DWORD flags
    )
{
    LONG code;
    HKEY hKey;
    DWORD value;

    // Open/create key
    code = NKRegCreateKeyEx(
            HKEY_LOCAL_MACHINE, szKeyPath, 0, NULL, 0, 0, NULL, &hKey, &value
            );          

    if (code != ERROR_SUCCESS) goto cleanUp;

    // Set value
    code = NKRegSetValueEx(
        hKey, L"Flags", 0, REG_DWORD, (UCHAR*)&flags, sizeof(DWORD)
        );

    // Close key
    NKRegCloseKey(hKey);

cleanUp:
    return (code == ERROR_SUCCESS);
}
Example #2
0
static BOOL
SetDeviceGroup(
    LPCWSTR szKeyPath,
    LPCWSTR groupName
    )
{
    LONG code;
    HKEY hKey;
    DWORD value;

    // Open/create key
    code = NKRegCreateKeyEx(
            HKEY_LOCAL_MACHINE, szKeyPath, 0, NULL, 0, 0, NULL, &hKey, &value
            );          

    if (code != ERROR_SUCCESS) goto cleanUp;

    // Set value
    code = NKRegSetValueEx(
        hKey, L"Group", 0, REG_SZ, (UCHAR*)groupName,  (wcslen(groupName) + 1) * sizeof(WCHAR)
        );

    // Close key
    NKRegCloseKey(hKey);

cleanUp:
    return (code == ERROR_SUCCESS);
}
Example #3
0
static BOOL ReserveKitlIRQ()
{
    // If we're using an interrupt for KITL, make sure nothing else can share its IRQ
    // by reserving it in the resource manager

    BOOL retVal = FALSE;
    UINT32 kitlFlags;

    if(!OALKitlGetFlags(&kitlFlags))
    {
        KITL_RETAILMSG(ZONE_WARNING,("WARN: Reserve KITL IRQ: Could not get KITL flags, bailing out\r\n"));
        return FALSE;
    }

    // Are we using active, interrupt-based KITL?
    if((g_pNKGlobal->pfnKITLIoctl) &&
      (kitlFlags & OAL_KITL_FLAGS_ENABLED) &&
      !(kitlFlags & OAL_KITL_FLAGS_PASSIVE) &&
      !(kitlFlags & OAL_KITL_FLAGS_POLL))
    {
        DWORD dwStatus, dwDisp, dwEnableKITLSharedIRQ;
        DWORD dwSize = sizeof(DWORD);
        HKEY hkResourcesReserved;
        HKEY hkNoReserve;
        DWORD kitlIRQ = g_pX86KitlInfo->pX86Info->ucKitlIrq;
        const WCHAR szReservedIRQPath[] = L"Drivers\\Resources\\IRQ\\Reserved";
        const WCHAR szNoReservePath[] = L"Platform";

        // Check the registry to see if we've added a platform-specific key telling us disable IRQ sharing with the KITL NIC
        if(!(dwStatus = NKRegOpenKeyEx(HKEY_LOCAL_MACHINE, szNoReservePath, 0, 0, &hkNoReserve)))
        {
            if(!(dwStatus = NKRegQueryValueEx(hkNoReserve, TEXT("DisableKITLSharedIRQ"), NULL, NULL, (BYTE*)(&dwEnableKITLSharedIRQ), &dwSize)))
            {
                if(dwEnableKITLSharedIRQ == 1)
                {
                    // Registry has requested that disable IRQ sharing for KITL (this can help verify debugger hangs
                    // that occur due to IRQ-sharing hangs)
 
                    // If we got here then go ahead and reserve the IRQ
                    if(!(dwStatus = NKRegCreateKeyEx(HKEY_LOCAL_MACHINE, szReservedIRQPath, 0, NULL, 0, 0, NULL, &hkResourcesReserved, &dwDisp)))
                    {
                        if(!(dwStatus = NKRegSetValueEx(hkResourcesReserved, TEXT("KitlIRQ"), 0, REG_DWORD, (BYTE*)(&kitlIRQ), sizeof(DWORD))))
                        {
                            KITL_RETAILMSG (ZONE_INIT,("Reserve KITL IRQ: Reserved IRQ %d.  Other device drivers will not load on this IRQ.\r\n",kitlIRQ));
                            retVal = TRUE;
                        }
                        else
                        {
                            KITL_RETAILMSG(ZONE_INIT, ("Reserve KITL IRQ: Error creating reserved value\r\n"));
                        }
                    }
                    else
                    {
                        KITL_RETAILMSG(ZONE_INIT, ("Reserve KITL IRQ: Error creating reserved key\r\n"));
                    }
                }
            }
        }
    }
    else
    {
        // Not using active interrupt-based KITL, don't need to reserve an IRQ
        retVal = TRUE;
    }

    if(!retVal)
    {        
        KITL_RETAILMSG(ZONE_INIT, ("Reserve KITL IRQ: No IRQ reserved, KITL NIC IRQ may be shared with other devices.\r\n"));
    }

    return retVal;
}
Example #4
0
VOID OALKitlInitRegistry()
{
    HKEY Key;
    DWORD Status;
    DWORD Disposition;
    DWORD Value;
    DWORD Flags;
    DEVICE_LOCATION devLoc;

    // Get KITL device location
    if (!OALKitlGetDevLoc(&devLoc))
        goto CleanUp;

    if (devLoc.LogicalLoc == S3C6410_BASE_REG_PA_USBOTG_LINK)
    {
        // Disable the UsbFn driver since it is used for KITL
        //

        Status = NKRegCreateKeyEx(HKEY_LOCAL_MACHINE, L"Drivers\\BuiltIn\\SC6410USBFN", 0, NULL, 0, 0, NULL, &Key, &Disposition);

        if (Status == ERROR_SUCCESS)
        {
            Disposition = DEVFLAGS_NOLOAD;
            // Set Flags value to indicate no loading of driver for this device
            Status = NKRegSetValueEx(Key, DEVLOAD_FLAGS_VALNAME, 0, DEVLOAD_FLAGS_VALTYPE, (PBYTE)&Disposition, sizeof(Disposition));
        }

        // Close the registry key.
        NKRegCloseKey(Key);

        if (Status != ERROR_SUCCESS)
        {
            KITL_RETAILMSG(ZONE_INIT, ("OALKitlInitRegistry: failed to set \"no load\" key for Usbfn driver.\r\n"));
            goto CleanUp;
        }

        KITL_RETAILMSG(ZONE_INIT, ("INFO: USB being used for KITL - disabling Usbfn driver...\r\n"));
    }

    if (devLoc.LogicalLoc == BSP_BASE_REG_PA_DM9000A_IOBASE)
    {
        // If KITL is over Ethernet and interrupt is enabled, let the 
        // PowerButton Driver know, so that it can disable the Reset Button 
        // (The Reset button interrupt clashes with the Ethernet KITL interrupt)

        // Get the KITL flags
        if (!OALKitlGetFlags(&Flags))
            goto CleanUp;

        if (!(Flags & OAL_KITL_FLAGS_POLL))
        {
            Status = NKRegCreateKeyEx(HKEY_LOCAL_MACHINE, L"Drivers\\BuiltIn\\PowerButton", 0, NULL, 0, 0, NULL, &Key, &Disposition);

            if (Status == ERROR_SUCCESS)
            {
                Value = 1;
                Status = NKRegSetValueEx(Key, L"EthernetKITLInterruptEnabled", 0, REG_DWORD, (PBYTE)&Value, sizeof(Value));
            }

            // Close the registry key.
            NKRegCloseKey(Key);

            if (Status != ERROR_SUCCESS)
            {
                KITL_RETAILMSG(ZONE_INIT, ("OALKitlInitRegistry: failed to set key to disable reset button.\r\n"));
                goto CleanUp;
            }

            KITL_RETAILMSG(ZONE_INIT, ("INFO: Ethernet KITL Interrupt enabled - disabling reset button in button driver.\r\n"));

        }
    }

CleanUp:
    return;
}