Пример #1
0
void Init(void)
{  
  __disable_interrupt();

  ENABLE_LCD_LED();
  DISABLE_LCD_POWER();

  /* clear shipping mode, if set to allow configuration */
  PMMCTL0_H = PMMPW_H;
  PM5CTL0 &= ~LOCKLPM5;  
  PMMCTL0_H = 0x00;
  
  /* disable DMA during read-modify-write cycles */
  DMACTL4 = DMARMWDIS;

#ifdef BOOTLOADER
  /*
   * enable RAM alternate interrupt vectors
   * these are defined in AltVect.s43 and copied to RAM by cstartup
   */
  SYSCTL |= SYSRIVECT;
  ClearBootloaderSignature();
#else
  SaveResetSource();
#endif
  
  SetupClockAndPowerManagementModule();
  
  CheckResetCode();
  if (niReset != NORMAL_RESET_CODE)
  {
    InitProperty();
  }
  
  InitBufferPool(); // message queue

  InitBattery();
  CheckClip();

  PrintF("*** %s:%s", niReset == FLASH_RESET_CODE ? "FLASH" :
    (niReset == MASTER_RESET_CODE ? "MASTER" : "NORMAL"), niBuild);
  
  ShowWatchdogInfo();
  WhoAmI();

  /* timer for battery checking at a regular frequency. */
  StartTimer(BatteryTimer);

  InitVibration();
  InitRealTimeClock(); // enable rtc interrupt

  LcdPeripheralInit();
  DrawSplashScreen();
  SerialRamInit();

  /* turn the radio on; initialize the serial port profile or BLE/GATT */
  CreateAndSendMessage(TurnRadioOnMsg, MSG_OPT_NONE);

  DISABLE_LCD_LED();
}
Пример #2
0
void ProcessMessage(SMBData *smb)
{
  if (smb->state != SMB_STATE_WRITE_REQUESTED)
  {
    smb->state = SMB_STATE_IDLE;
    return;
  }

  switch (smb->rxBuffer[0]) // Command code.
  {
  case DRV_WHO_AM_I:
    WhoAmI(smb);
    break;
  case DRV_SET_DIRECTION:
    SetDirection(smb);
    break;
  case DRV_SET_SPEED:
    SetSpeed(smb);
    break;
  case DRV_DRV_ENABLE:
    EnableMotors(smb);
    break;
  case DRV_SET_ADDRESS:
    SetAddress(smb);
    break;
  case DRV_DRV_DISABLE:
    DisableMotors(smb);
    break;
  default:
    UndefinedCommand(smb);
  break;
  }
}
Пример #3
0
static void InitDisplay(void)
{  
  __disable_interrupt();

  ENABLE_LCD_LED();
  DISABLE_LCD_POWER();

  /* clear shipping mode, if set to allow configuration */
  PMMCTL0_H = PMMPW_H;
  PM5CTL0 &= ~LOCKLPM5;  
  PMMCTL0_H = 0x00;
  
  /* disable DMA during read-modify-write cycles */
  DMACTL4 = DMARMWDIS;

#if BOOTLOADER
  /*
   * enable RAM alternate interrupt vectors
   * these are defined in AltVect.s43 and copied to RAM by cstartup
   */
  SYSCTL |= SYSRIVECT;
  ClearBootloaderSignature();
#endif

  SetupClockAndPowerManagementModule();

  CheckClip(); // enable debuguart
  __enable_interrupt();
  PrintF("\r\n*** %s:%c%c%c ***", (niResetType == NORMAL_RESET ? "NORMAL" : "MASTER"),
    BUILD[0], BUILD[1], BUILD[2]);

  if (niResetType != NORMAL_RESET) InitStateLog();

  SaveStateLog();

  WhoAmI();
  ShowStateInfo();

  InitAdc();
  /* timer for battery checking at a regular frequency. */
  StartTimer(BatteryTimer);

  InitVibration();
  InitRealTimeClock(); // enable rtc interrupt

  LcdPeripheralInit();
  DrawSplashScreen();

  InitSerialRam();

  /* turn the radio on; initialize the serial port profile or BLE/GATT */
  SendMessage(TurnRadioOnMsg, MSG_OPT_NONE);

  DISABLE_LCD_LED();
}
/**
  Implementation of GetNumberOfProcessors() service of MP Services Protocol.

  This service retrieves the number of logical processor in the platform
  and the number of those logical processors that are enabled on this boot.
  This service may only be called from the BSP.

  @param  This                       A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
  @param  NumberOfProcessors         Pointer to the total number of logical processors in the system,
                                     including the BSP and disabled APs.
  @param  NumberOfEnabledProcessors  Pointer to the number of enabled logical processors that exist
                                     in system, including the BSP.

  @retval EFI_SUCCESS	             Number of logical processors and enabled logical processors retrieved..
  @retval EFI_DEVICE_ERROR           Caller processor is AP.
  @retval EFI_INVALID_PARAMETER      NumberOfProcessors is NULL
  @retval EFI_INVALID_PARAMETER      NumberOfEnabledProcessors is NULL

**/
EFI_STATUS
EFIAPI
GetNumberOfProcessors (
  IN  EFI_MP_SERVICES_PROTOCOL     *This,
  OUT UINTN                        *NumberOfProcessors,
  OUT UINTN                        *NumberOfEnabledProcessors
  )
{
  EFI_STATUS      Status;
  UINTN           CallerNumber;

  //
  // Check whether caller processor is BSP
  //
  WhoAmI (This, &CallerNumber);
  if (CallerNumber != GetBspNumber ()) {
    return EFI_DEVICE_ERROR;
  }

  //
  // Check parameter NumberOfProcessors
  //
  if (NumberOfProcessors == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  //
  // Check parameter NumberOfEnabledProcessors
  //
  if (NumberOfEnabledProcessors == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  Status = mFrameworkMpService->GetGeneralMPInfo (
                                  mFrameworkMpService,
                                  NumberOfProcessors,
                                  NULL,
                                  NumberOfEnabledProcessors,
                                  NULL,
                                  NULL
                                  );
  ASSERT_EFI_ERROR (Status);

  return EFI_SUCCESS;
}
Пример #5
0
void main(void)
{
    ENABLE_LCD_LED();

#if ENABLE_WATCHDOG
    RestartWatchdog();
#else
    WDTCTL = WDTPW + WDTHOLD;
#endif

    /* clear shipping mode, if set to allow configuration */
    PMMCTL0_H = PMMPW_H;
    PM5CTL0 &= ~LOCKLPM5;

    /* disable DMA during read-modify-write cycles */
    DMACTL4 = DMARMWDIS;

    DetermineErrata();

#ifdef BOOTLOADER

    /*
     * enable RAM alternate interrupt vectors
     * these are defined in AltVect.s43 and copied to RAM by cstartup
     */
    SYSCTL |= SYSRIVECT;

    ClearBootloaderSignature();

#endif

    /* calibration data is used for clock setup */
    InitializeCalibrationData();

#ifndef BOOTLOADER
    SaveResetSource();
#endif

    SetupClockAndPowerManagementModule();

    OsalNvInit(0);

    /* change the mux settings according to presense of the charging clip */
    InitializeMuxMode();
    ChangeMuxMode();

    InitDebugUart();
    TestModeControl();

    /* adc is required to get the board configuration */
    InitializeAdc();
    ConfigureDefaultIO(GetBoardConfiguration());

    InitializeDebugFlags();

//  InitButton();

    InitializeVibration();
    InitializeOneSecondTimers();

    InitializeBufferPool();
    InitializeWrapperTask();
    InitializeRealTimeClock();

    InitializeDisplayTask();

    DISABLE_LCD_LED();

#if CHECK_FOR_PMM15
    /* make sure error pmm15 does not exist */
    while ( PMM15Check() );
#endif

    /* Errata PMM17 - automatic prolongation mechanism
     * SVSLOW is disabled
     */
    *(unsigned int*)(0x0110) = 0x9602;
    *(unsigned int*)(0x0112) |= 0x0800;

    WhoAmI();
    PrintResetSource();

    /* if a watchdog occurred then print and save information about the source */
    WatchdogTimeoutHandler(GetResetSource());

    PrintString("Starting Task Scheduler\r\n");
    SetUartNormalMode();

    vTaskStartScheduler();

    /* if vTaskStartScheduler exits an error occured. */
    PrintString("Program Error\r\n");
    ForceWatchdogReset();
}
Пример #6
0
Файл: q.cpp Проект: ZachBeta/znc
	virtual void OnModCommand(const CString& sLine) {
		CString sCommand = sLine.Token(0).AsLower();

		if (sCommand == "help") {
			PutModule("The following commands are available:");
			CTable Table;
			Table.AddColumn("Command");
			Table.AddColumn("Description");
			Table.AddRow();
			Table.SetCell("Command", "Auth [<username> <password>]");
			Table.SetCell("Description", "Tries to authenticate you with Q. Both parameters are optional.");
			Table.AddRow();
			Table.SetCell("Command", "Cloak");
			Table.SetCell("Description", "Tries to set usermode +x to hide your real hostname.");
			Table.AddRow();
			Table.SetCell("Command", "Status");
			Table.SetCell("Description", "Prints the current status of the module.");
			Table.AddRow();
			Table.SetCell("Command", "Update");
			Table.SetCell("Description", "Re-requests the current user information from Q.");
			Table.AddRow();
			Table.SetCell("Command", "Set <setting> <value>");
			Table.SetCell("Description", "Changes the value of the given setting. See the list of settings below.");
			Table.AddRow();
			Table.SetCell("Command", "Get");
			Table.SetCell("Description", "Prints out the current configuration. See the list of settings below.");
			PutModule(Table);

			PutModule("The following settings are available:");
			CTable Table2;
			Table2.AddColumn("Setting");
			Table2.AddColumn("Type");
			Table2.AddColumn("Description");
			Table2.AddRow();
			Table2.SetCell("Setting", "Username");
			Table2.SetCell("Type", "String");
			Table2.SetCell("Description", "Your Q username.");
			Table2.AddRow();
			Table2.SetCell("Setting", "Password");
			Table2.SetCell("Type", "String");
			Table2.SetCell("Description", "Your Q password.");
			Table2.AddRow();
			Table2.SetCell("Setting", "UseCloakedHost");
			Table2.SetCell("Type", "Boolean");
			Table2.SetCell("Description", "Whether to cloak your hostname (+x) automatically on connect.");
			Table2.AddRow();
			Table2.SetCell("Setting", "UseChallenge");
			Table2.SetCell("Type", "Boolean");
			Table2.SetCell("Description", "Whether to use the CHALLENGEAUTH mechanism to avoid sending passwords in cleartext.");
			Table2.AddRow();
			Table2.SetCell("Setting", "RequestPerms");
			Table2.SetCell("Type", "Boolean");
			Table2.SetCell("Description", "Whether to request voice/op from Q on join/devoice/deop.");
			PutModule(Table2);

			PutModule("This module takes 2 optional parameters: <username> <password>");
			PutModule("Module settings are stored between restarts.");

		} else if (sCommand == "set") {
			CString sSetting = sLine.Token(1).AsLower();
			CString sValue   = sLine.Token(2);
			if (sSetting.empty() || sValue.empty()) {
				PutModule("Syntax: Set <setting> <value>");
			} else if (sSetting == "username") {
				SetUsername(sValue);
				PutModule("Username set");
			} else if (sSetting == "password") {
				SetPassword(sValue);
				PutModule("Password set");
			} else if (sSetting == "usecloakedhost") {
				SetUseCloakedHost(sValue.ToBool());
				PutModule("UseCloakedHost set");
				if (m_bUseCloakedHost && IsIRCConnected())
					Cloak();
			} else if (sSetting == "usechallenge") {
				SetUseChallenge(sValue.ToBool());
				PutModule("UseChallenge set");
			} else if (sSetting == "requestperms") {
				SetRequestPerms(sValue.ToBool());
				PutModule("RequestPerms set");
			} else
				PutModule("Unknown setting: " + sSetting);

		} else if (sCommand == "get" || sCommand == "list") {
			CTable Table;
			Table.AddColumn("Setting");
			Table.AddColumn("Value");
			Table.AddRow();
			Table.SetCell("Setting", "Username");
			Table.SetCell("Value", m_sUsername);
			Table.AddRow();
			Table.SetCell("Setting", "Password");
			Table.SetCell("Value", "*****"); // m_sPassword
			Table.AddRow();
			Table.SetCell("Setting", "UseCloakedHost");
			Table.SetCell("Value", CString(m_bUseCloakedHost));
			Table.AddRow();
			Table.SetCell("Setting", "UseChallenge");
			Table.SetCell("Value", CString(m_bUseChallenge));
			Table.AddRow();
			Table.SetCell("Setting", "RequestPerms");
			Table.SetCell("Value", CString(m_bRequestPerms));
			PutModule(Table);

		} else if (sCommand == "status") {
			PutModule("Connected: " + CString(IsIRCConnected() ? "yes" : "no"));
			PutModule("Cloaked: "   + CString(m_bCloaked       ? "yes" : "no"));
			PutModule("Authed: "    + CString(m_bAuthed        ? "yes" : "no"));

		} else {
			// The following commands require an IRC connection.
			if (!IsIRCConnected()) {
				PutModule("Error: You are not connected to IRC.");
				return;
			}

			if (sCommand == "cloak") {
				if (!m_bCloaked)
					Cloak();
				else
					PutModule("Error: You are already cloaked!");

			} else if (sCommand == "auth") {
				if (!m_bAuthed)
					Auth(sLine.Token(1), sLine.Token(2));
				else
					PutModule("Error: You are already authed!");

			} else if (sCommand == "update") {
				WhoAmI();
				PutModule("Update requested.");

			} else {
				PutModule("Unknown command. Try 'help'.");
			}
		}
	}
Пример #7
0
Файл: q.cpp Проект: ZachBeta/znc
	virtual void OnIRCConnected() {
		if (m_bUseCloakedHost)
			Cloak();
		WhoAmI();
	}
Пример #8
0
Файл: q.cpp Проект: ZachBeta/znc
	EModRet HandleMessage(const CNick& Nick, CString sMessage) {
		if (!Nick.GetNick().Equals("Q") || !Nick.GetHost().Equals("CServe.quakenet.org"))
			return CONTINUE;

		sMessage.Trim();

#if Q_DEBUG_COMMUNICATION
		PutModule("[ZNC <-- Q] " + sMessage);
#endif

		// WHOAMI
		if (sMessage.find("WHOAMI is only available to authed users") != CString::npos) {
			m_bAuthed = false;
			Auth();
			m_bCatchResponse = m_bRequestedWhoami;
		}
		else if (sMessage.find("Information for user") != CString::npos) {
			m_bAuthed = true;
			m_msChanModes.clear();
			m_bCatchResponse = m_bRequestedWhoami;
			m_bRequestedWhoami = true;
		}
		else if (m_bRequestedWhoami && sMessage.WildCmp("#*")) {
			CString sChannel = sMessage.Token(0);
			CString sFlags   = sMessage.Token(1, true).Trim_n().TrimLeft_n("+");
			m_msChanModes[sChannel] = sFlags;
		}
		else if (m_bRequestedWhoami && m_bCatchResponse
				&& (sMessage.Equals("End of list.")
				||  sMessage.Equals("account, or HELLO to create an account."))) {
			m_bRequestedWhoami = m_bCatchResponse = false;
			return HALT;
		}

		// AUTH
		else if (sMessage.Equals("Username or password incorrect.")) {
			m_bAuthed = false;
			PutModule("Auth failed: " + sMessage);
			return HALT;
		}
		else if (sMessage.WildCmp("You are now logged in as *.")) {
			m_bAuthed = true;
			PutModule("Auth successful: " + sMessage);
			WhoAmI();
			return HALT;
		}
		else if (m_bRequestedChallenge && sMessage.Token(0).Equals("CHALLENGE")) {
			m_bRequestedChallenge = false;
			if (sMessage.find("not available once you have authed") != CString::npos) {
				m_bAuthed = true;
			} else {
				if (sMessage.find("HMAC-MD5") != CString::npos) {
					ChallengeAuth(sMessage.Token(1));
				} else {
					PutModule("Auth failed: Q does not support HMAC-MD5 for CHALLENGEAUTH, falling back to standard AUTH.");
					SetUseChallenge(false);
					Auth();
				}
			}
			return HALT;
		}

		// prevent buffering of Q's responses
		return !m_bCatchResponse && GetUser()->IsUserAttached() ? CONTINUE : HALT;
	}
/**
  Implementation of GetNumberOfProcessors() service of MP Services Protocol.

  Gets detailed MP-related information on the requested processor at the
  instant this call is made. This service may only be called from the BSP.

  @param  This                  A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
  @param  ProcessorNumber       The handle number of processor.
  @param  ProcessorInfoBuffer   A pointer to the buffer where information for the requested processor is deposited.

  @retval EFI_SUCCESS           Processor information successfully returned.
  @retval EFI_DEVICE_ERROR      Caller processor is AP.
  @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL
  @retval EFI_NOT_FOUND         Processor with the handle specified by ProcessorNumber does not exist.

**/
EFI_STATUS
EFIAPI
GetProcessorInfo (
  IN       EFI_MP_SERVICES_PROTOCOL     *This,
  IN       UINTN                        ProcessorNumber,
  OUT      EFI_PROCESSOR_INFORMATION    *ProcessorInfoBuffer
  )
{
  EFI_STATUS                 Status;
  UINTN                      CallerNumber;
  UINTN                      BufferSize;
  EFI_MP_PROC_CONTEXT        ProcessorContextBuffer;

  //
  // Check whether caller processor is BSP
  //
  WhoAmI (This, &CallerNumber);
  if (CallerNumber != GetBspNumber ()) {
    return EFI_DEVICE_ERROR;
  }

  //
  // Check parameter ProcessorInfoBuffer
  //
  if (ProcessorInfoBuffer == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  //
  // Check whether processor with the handle specified by ProcessorNumber exists
  //
  if (ProcessorNumber >= mNumberOfProcessors) {
    return EFI_NOT_FOUND;
  }

  BufferSize = sizeof (EFI_MP_PROC_CONTEXT);
  Status = mFrameworkMpService->GetProcessorContext (
                                  mFrameworkMpService,
                                  ProcessorNumber,
                                  &BufferSize,
                                  &ProcessorContextBuffer
                                  );
  ASSERT_EFI_ERROR (Status);

  ProcessorInfoBuffer->ProcessorId = (UINT64) ProcessorContextBuffer.ApicID;

  //
  // Get Status Flag of specified processor
  //
  ProcessorInfoBuffer->StatusFlag = 0;

  if (ProcessorContextBuffer.Enabled) {
    ProcessorInfoBuffer->StatusFlag |= PROCESSOR_ENABLED_BIT;
  }

  if (ProcessorContextBuffer.Designation == EfiCpuBSP) {
    ProcessorInfoBuffer->StatusFlag |= PROCESSOR_AS_BSP_BIT;
  }

  if (ProcessorContextBuffer.Health.Flags.Uint32 == 0) {
    ProcessorInfoBuffer->StatusFlag |= PROCESSOR_HEALTH_STATUS_BIT;
  }

  ProcessorInfoBuffer->Location.Package = (UINT32) ProcessorContextBuffer.PackageNumber;
  ProcessorInfoBuffer->Location.Core    = (UINT32) ProcessorContextBuffer.NumberOfCores;
  ProcessorInfoBuffer->Location.Thread  = (UINT32) ProcessorContextBuffer.NumberOfThreads;

  return EFI_SUCCESS;
}