void NoSleepExtension::saveState() { #ifdef DEBUG IOLog("%s[%p]::%s()\n", getName(), this, __FUNCTION__); #endif UInt8 savedState; UInt8 stateToSave = packSleepState(batterySleepSuppressionState, acSleepSuppressionState); #ifdef DEBUG IOLog("%s: value to save: 0x%02x\n", getName(), stateToSave); #endif OSReturn readResult = readNVRAM(&savedState); if((readResult != kOSReturnSuccess) || (stateToSave != savedState)) { writeNVRAM(stateToSave); } #ifdef DEBUG else { IOLog("%s: skip writing, reason: readResult == %s, stateToSave %s savedState\n", getName(), (readResult == kOSReturnSuccess)?"kOSReturnSuccess":"kOSReturnError", stateToSave == savedState?"==":"!="); } #endif }
bool NoSleepExtension::start( IOService * provider ) { #ifdef DEBUG IOLog("%s[%p]::%s(%p)\n", getName(), this, __FUNCTION__, provider); #endif if( !super::start( provider )) return( false ); //task_t x = current_task(); //IOLog("task: %p, %p\n", x, bootstrap_port); delayTimer = thread_call_allocate(_switchOffUserSleepDisabled, (thread_call_param_t) this); isSleepStateInitialized = false; acSleepSuppressionState = kNoSleepStateDisabled; batterySleepSuppressionState = kNoSleepStateDisabled; forceClientMessage = false; isOnAC = true; pPowerSource = NULL; // This should be done ASAP, cause pRootDomain // is used later in other methods pRootDomain = getPMRootDomain(); UInt8 loadedState; OSReturn ret = readNVRAM(&loadedState); if(ret == kOSReturnSuccess) { unpackSleepState(loadedState, &batterySleepSuppressionState, &acSleepSuppressionState); } /// NoSleep will be activeted after matching with the IOPMPowerSource //updateSleepPowerState(); clamshellStateInterestNotifier = pRootDomain->registerInterest(gIOGeneralInterest, NoSleepExtension::_clamshellEventInterestHandler, this); registerService(); startPM(provider); IOLog("%s: successfully started\n", getName()); return true; }
int main() { int ok; NetConfigCtxtRec ctx; netConfigCtxtInitialize(&ctx, stdout, 0); if ( !(ok=readNVRAM(&ctx)) ) { fprintf(stderr,"ERROR: couldn't read NVRAM\n"); } netConfigCtxtFinalize(&ctx); if ( !ok ) exit(1); #ifndef NVRAM_READONLY nvramConfig(); #endif nvramConfigShow(0); bootConfigShow(0); }
int main() { /* Perform processor initialization */ sysinit(); printf("\nRunning the SolderTermo_v2 project.\r\n"); initTime(); initNVRAM(); readNVRAM(); printf("Version %hd\tCRC %hd\r\n", nvram.Version, nvram.nvramCrc); initDisplay(); //initMAX31855(); initThermocoupleADC(); initPowerPWM(); initHMI(); initButtons(); initStateMachine(); int fastLog = 0; while(1) { if (fastLog) printf("%hd\t%hd\r\n", vram.ADCVal, vram.CurrTemp); else printf("%hd\t%hd\t%hd\t%hd\t%hd\t%hd\r\n", vram.CurrTemp / 10, nvram.Tsp, vram.PWM_Sp, nvram.Kp, nvram.Ki, nvram.Kd); if ( UART_CharPresent(UART2) ) { uint8_t c; uint8_t charNo = 0; memset(uartBuff, 0, UART_MAX_BUFF); printf("Finish your input by ENTER\r\n"); printf("\r\n"); do { c = uartBuff[charNo++] = UART_GetChar(UART2); // wait for char to come UART_PutChar(UART2, c); WAIT_Waitms(50); } while ( c != '\r' && charNo < UART_MAX_BUFF ); switch(uartBuff[0]) { case 'f': fastLog = 1; break; // fast logging case 's': fastLog = 0; break; // slow logging case 'p': nvram.Kp = atoi(uartBuff + 1); break; // fast logging case 'i': nvram.Ki = atoi(uartBuff + 1); break; // slow logging case 'd': nvram.Kd = atoi(uartBuff + 1); break; // slow logging } } WAIT_Waitms(fastLog ? 20 : 200); } return 0; // should never come here }
void nvramFixupBsdnetConfig(int readNvram, char *argline) { Parm p; struct rtems_bsdnet_ifconfig *ifc; /* now hack into the network configuration... */ /* extract_boot_params() modifies the commandline string (part of the fixup) */ if ( readNvram ) { NetConfigCtxtRec ctx; lock(); netConfigCtxtInitialize(&ctx,stdout,0); readNVRAM(&ctx); netConfigCtxtFinalize(&ctx); unlock(); } #ifndef HAVE_BSP_COMMANDLINE_STRING if ( !argline ) #ifdef HAVE_BSP_CMDLINE argline = bsp_cmdline(); #else argline = cmdlinebuf; #endif #endif if ( argline ) cmdlinePairExtract(argline, putparm, 1); if ( boot_my_if ) { if ( (boot_my_media = strchr(boot_my_if,':')) ) { *boot_my_media++ = 0; if ( 0 == *boot_my_if ) boot_my_if = 0; } else { boot_my_media = boot_my_if; boot_my_if = 0; } #ifndef BSP_HAS_MULTIPLE_NETIFS /* just drop the interface name */ boot_my_if = 0; #endif } ifc = find_first_real_if(); assert(ifc && "NO INTERFACE CONFIGURATION STRUCTURE FOUND"); if ( boot_my_if ) ifc->name = boot_my_if; if ( 'N' == do_bootp() ) { /* no bootp */ /* get pointers to the first interface's configuration */ ifc->ip_address = boot_my_ip; boot_my_ip=0; ifc->ip_netmask = boot_my_netmask; boot_my_netmask = 0; } else { the_apps_bootp=net_config.bootp; /* release the strings that will be set up by * bootp - bootpc relies on them being NULL */ for (p=parmList; p->name; p++) { if (!p->pval) continue; if (p->flags & FLAG_CLRBP) { free(*p->pval); *p->pval=0; } } } /* Always intercept; this gives us a chance do to things * after the interfaces are attached */ net_config.bootp=my_bootp_intercept; }