diff options
Diffstat (limited to 'os/hal/platforms')
| -rw-r--r-- | os/hal/platforms/Posix/hal_lld.c | 12 | ||||
| -rw-r--r-- | os/hal/platforms/Posix/serial_lld.c | 26 | ||||
| -rw-r--r-- | os/hal/platforms/STM32F1xx/hal_lld.c | 1 | ||||
| -rw-r--r-- | os/hal/platforms/STM32F2xx/hal_lld.c | 1 | ||||
| -rw-r--r-- | os/hal/platforms/STM32F4xx/hal_lld.c | 1 | ||||
| -rw-r--r-- | os/hal/platforms/STM32L1xx/hal_lld.c | 15 | ||||
| -rw-r--r-- | os/hal/platforms/Win32/hal_lld.c | 12 | ||||
| -rw-r--r-- | os/hal/platforms/Win32/serial_lld.c | 26 | 
8 files changed, 79 insertions, 15 deletions
| diff --git a/os/hal/platforms/Posix/hal_lld.c b/os/hal/platforms/Posix/hal_lld.c index 8b59d992b..8e1c34939 100644 --- a/os/hal/platforms/Posix/hal_lld.c +++ b/os/hal/platforms/Posix/hal_lld.c @@ -78,8 +78,10 @@ void ChkIntSources(void) {  #if HAL_USE_SERIAL
    if (sd_lld_interrupt_pending()) {
 +    dbg_check_lock();
      if (chSchIsPreemptionRequired())
        chSchDoReschedule();
 +    dbg_check_unlock();
      return;
    }
  #endif
 @@ -87,9 +89,19 @@ void ChkIntSources(void) {    gettimeofday(&tv, NULL);
    if (timercmp(&tv, &nextcnt, >=)) {
      timeradd(&nextcnt, &tick, &nextcnt);
 +
 +    CH_IRQ_PROLOGUE();
 +
 +    chSysLockFromIsr();
      chSysTimerHandlerI();
 +    chSysUnlockFromIsr();
 +
 +    CH_IRQ_EPILOGUE();
 +
 +    dbg_check_lock();
      if (chSchIsPreemptionRequired())
        chSchDoReschedule();
 +    dbg_check_unlock();
    }
  }
 diff --git a/os/hal/platforms/Posix/serial_lld.c b/os/hal/platforms/Posix/serial_lld.c index 31be73825..5bf22bc76 100644 --- a/os/hal/platforms/Posix/serial_lld.c +++ b/os/hal/platforms/Posix/serial_lld.c @@ -120,7 +120,9 @@ static bool_t connint(SerialDriver *sdp) {        printf("%s: Unable to setup non blocking mode on data socket\n", sdp->com_name);
        goto abort;
      }
 +    chSysLockFromIsr();
      chIOAddFlagsI(sdp, IO_CONNECTED);
 +    chSysUnlockFromIsr();
      return TRUE;
    }
    return FALSE;
 @@ -146,7 +148,9 @@ static bool_t inint(SerialDriver *sdp) {      case 0:
        close(sdp->com_data);
        sdp->com_data = INVALID_SOCKET;
 +      chSysLockFromIsr();
        chIOAddFlagsI(sdp, IO_DISCONNECTED);
 +      chSysUnlockFromIsr();
        return FALSE;
      case INVALID_SOCKET:
        if (errno == EWOULDBLOCK)
 @@ -155,8 +159,11 @@ static bool_t inint(SerialDriver *sdp) {        sdp->com_data = INVALID_SOCKET;
        return FALSE;
      }
 -    for (i = 0; i < n; i++)
 +    for (i = 0; i < n; i++) {
 +      chSysLockFromIsr();
        sdIncomingDataI(sdp, data[i]);
 +      chSysUnlockFromIsr();
 +    }
      return TRUE;
    }
    return FALSE;
 @@ -171,7 +178,9 @@ static bool_t outint(SerialDriver *sdp) {      /*
       * Input.
       */
 +    chSysLockFromIsr();
      n = sdRequestDataI(sdp);
 +    chSysUnlockFromIsr();
      if (n < 0)
        return FALSE;
      data[0] = (uint8_t)n;
 @@ -180,7 +189,9 @@ static bool_t outint(SerialDriver *sdp) {      case 0:
        close(sdp->com_data);
        sdp->com_data = INVALID_SOCKET;
 +      chSysLockFromIsr();
        chIOAddFlagsI(sdp, IO_DISCONNECTED);
 +      chSysUnlockFromIsr();
        return FALSE;
      case INVALID_SOCKET:
        if (errno == EWOULDBLOCK)
 @@ -256,10 +267,17 @@ void sd_lld_stop(SerialDriver *sdp) {  }
  bool_t sd_lld_interrupt_pending(void) {
 +  bool_t b;
 +
 +  CH_IRQ_PROLOGUE();
 +
 +  b =  connint(&SD1) || connint(&SD2) ||
 +       inint(&SD1)   || inint(&SD2)   ||
 +       outint(&SD1)  || outint(&SD2);
 +
 +  CH_IRQ_EPILOGUE();
 -  return connint(&SD1) || connint(&SD2) ||
 -         inint(&SD1)   || inint(&SD2)   ||
 -         outint(&SD1)  || outint(&SD2);
 +  return b;
  }
  #endif /* HAL_USE_SERIAL */
 diff --git a/os/hal/platforms/STM32F1xx/hal_lld.c b/os/hal/platforms/STM32F1xx/hal_lld.c index f5efeed5d..0112d7eaa 100644 --- a/os/hal/platforms/STM32F1xx/hal_lld.c +++ b/os/hal/platforms/STM32F1xx/hal_lld.c @@ -54,6 +54,7 @@ static void hal_lld_backup_domain_init(void) {    if ((RCC->BDCR & RCC_BDCR_LSEON) == 0) {
      /* Backup domain reset.*/
      RCC->BDCR = RCC_BDCR_BDRST;
 +    RCC->BDCR = 0;
      RCC->BDCR = RCC_BDCR_LSEON;
      while ((RCC->BDCR & RCC_BDCR_LSERDY) == 0)
        ;                                     /* Waits until LSE is stable.   */
 diff --git a/os/hal/platforms/STM32F2xx/hal_lld.c b/os/hal/platforms/STM32F2xx/hal_lld.c index b9af01a92..7cc24f2a0 100644 --- a/os/hal/platforms/STM32F2xx/hal_lld.c +++ b/os/hal/platforms/STM32F2xx/hal_lld.c @@ -54,6 +54,7 @@ static void hal_lld_backup_domain_init(void) {    if ((RCC->BDCR & RCC_BDCR_LSEON) == 0) {
      /* Backup domain reset.*/
      RCC->BDCR = RCC_BDCR_BDRST;
 +    RCC->BDCR = 0;
      RCC->BDCR = RCC_BDCR_LSEON;
      while ((RCC->BDCR & RCC_BDCR_LSERDY) == 0)
        ;                                     /* Waits until LSE is stable.   */
 diff --git a/os/hal/platforms/STM32F4xx/hal_lld.c b/os/hal/platforms/STM32F4xx/hal_lld.c index d26059d70..00c560f08 100644 --- a/os/hal/platforms/STM32F4xx/hal_lld.c +++ b/os/hal/platforms/STM32F4xx/hal_lld.c @@ -54,6 +54,7 @@ static void hal_lld_backup_domain_init(void) {    if ((RCC->BDCR & RCC_BDCR_LSEON) == 0) {
      /* Backup domain reset.*/
      RCC->BDCR = RCC_BDCR_BDRST;
 +    RCC->BDCR = 0;
      RCC->BDCR = RCC_BDCR_LSEON;
      while ((RCC->BDCR & RCC_BDCR_LSERDY) == 0)
        ;                                     /* Waits until LSE is stable.   */
 diff --git a/os/hal/platforms/STM32L1xx/hal_lld.c b/os/hal/platforms/STM32L1xx/hal_lld.c index 01d61fbc2..4e1b385a3 100644 --- a/os/hal/platforms/STM32L1xx/hal_lld.c +++ b/os/hal/platforms/STM32L1xx/hal_lld.c @@ -51,11 +51,12 @@ static void hal_lld_backup_domain_init(void) {    /* If enabled then the LSE is started.*/
  #if STM32_LSE_ENABLED
 -  if ((RCC->BDCR & RCC_BDCR_LSEON) == 0) {
 +  if ((RCC->CSR & RCC_CSR_LSEON) == 0) {
      /* Backup domain reset.*/
 -    RCC->BDCR = RCC_BDCR_BDRST;
 -    RCC->BDCR = RCC_BDCR_LSEON;
 -    while ((RCC->BDCR & RCC_BDCR_LSERDY) == 0)
 +    RCC->CSR |= RCC_CSR_RTCRST;
 +    RCC->CSR &= ~RCC_CSR_RTCRST;
 +    RCC->CSR |= RCC_CSR_LSEON;
 +    while ((RCC->CSR & RCC_CSR_LSERDY) == 0)
        ;                                     /* Waits until LSE is stable.   */
    }
  #endif
 @@ -63,12 +64,12 @@ static void hal_lld_backup_domain_init(void) {  #if STM32_RTCSEL != STM32_RTCSEL_NOCLOCK
    /* If the backup domain hasn't been initialized yet then proceed with
       initialization.*/
 -  if ((RCC->BDCR & RCC_BDCR_RTCEN) == 0) {
 +  if ((RCC->CSR & RCC_CSR_RTCEN) == 0) {
      /* Selects clock source.*/
 -    RCC->BDCR = (RCC->BDCR & ~RCC_BDCR_RTCSEL) | STM32_RTCSEL;
 +    RCC->CSR = (RCC->CSR & ~RCC_CSR_RTCSEL) | STM32_RTCSEL;
      /* RTC clock enabled.*/
 -    RCC->BDCR |= RCC_BDCR_RTCEN;
 +    RCC->CSR |= RCC_CSR_RTCEN;
    }
  #endif /* STM32_RTCSEL != STM32_RTCSEL_NOCLOCK */
 diff --git a/os/hal/platforms/Win32/hal_lld.c b/os/hal/platforms/Win32/hal_lld.c index 48d017f2f..183185c98 100644 --- a/os/hal/platforms/Win32/hal_lld.c +++ b/os/hal/platforms/Win32/hal_lld.c @@ -83,8 +83,10 @@ void ChkIntSources(void) {  #if HAL_USE_SERIAL
    if (sd_lld_interrupt_pending()) {
 +    dbg_check_lock();
      if (chSchIsPreemptionRequired())
        chSchDoReschedule();
 +    dbg_check_unlock();
      return;
    }
  #endif
 @@ -93,9 +95,19 @@ void ChkIntSources(void) {    QueryPerformanceCounter(&n);
    if (n.QuadPart > nextcnt.QuadPart) {
      nextcnt.QuadPart += slice.QuadPart;
 +
 +    CH_IRQ_PROLOGUE();
 +
 +    chSysLockFromIsr();
      chSysTimerHandlerI();
 +    chSysUnlockFromIsr();
 +
 +    CH_IRQ_EPILOGUE();
 +
 +    dbg_check_lock();
      if (chSchIsPreemptionRequired())
        chSchDoReschedule();
 +    dbg_check_unlock();
    }
  }
 diff --git a/os/hal/platforms/Win32/serial_lld.c b/os/hal/platforms/Win32/serial_lld.c index 6b76ebbc7..170067c4a 100644 --- a/os/hal/platforms/Win32/serial_lld.c +++ b/os/hal/platforms/Win32/serial_lld.c @@ -113,7 +113,9 @@ static bool_t connint(SerialDriver *sdp) {        printf("%s: Unable to setup non blocking mode on data socket\n", sdp->com_name);
        goto abort;
      }
 +    chSysLockFromIsr();
      chIOAddFlagsI(sdp, IO_CONNECTED);
 +    chSysUnlockFromIsr();
      return TRUE;
    }
    return FALSE;
 @@ -140,7 +142,9 @@ static bool_t inint(SerialDriver *sdp) {      case 0:
        closesocket(sdp->com_data);
        sdp->com_data = INVALID_SOCKET;
 +      chSysLockFromIsr();
        chIOAddFlagsI(sdp, IO_DISCONNECTED);
 +      chSysUnlockFromIsr();
        return FALSE;
      case SOCKET_ERROR:
        if (WSAGetLastError() == WSAEWOULDBLOCK)
 @@ -149,8 +153,11 @@ static bool_t inint(SerialDriver *sdp) {        sdp->com_data = INVALID_SOCKET;
        return FALSE;
      }
 -    for (i = 0; i < n; i++)
 +    for (i = 0; i < n; i++) {
 +      chSysLockFromIsr();
        sdIncomingDataI(sdp, data[i]);
 +      chSysUnlockFromIsr();
 +    }
      return TRUE;
    }
    return FALSE;
 @@ -165,7 +172,9 @@ static bool_t outint(SerialDriver *sdp) {      /*
       * Input.
       */
 +    chSysLockFromIsr();
      n = sdRequestDataI(sdp);
 +    chSysUnlockFromIsr();
      if (n < 0)
        return FALSE;
      data[0] = (uint8_t)n;
 @@ -174,7 +183,9 @@ static bool_t outint(SerialDriver *sdp) {      case 0:
        closesocket(sdp->com_data);
        sdp->com_data = INVALID_SOCKET;
 +      chSysLockFromIsr();
        chIOAddFlagsI(sdp, IO_DISCONNECTED);
 +      chSysUnlockFromIsr();
        return FALSE;
      case SOCKET_ERROR:
        if (WSAGetLastError() == WSAEWOULDBLOCK)
 @@ -253,10 +264,17 @@ void sd_lld_stop(SerialDriver *sdp) {  }
  bool_t sd_lld_interrupt_pending(void) {
 +  bool_t b;
 +
 +  CH_IRQ_PROLOGUE();
 +
 +  b =  connint(&SD1) || connint(&SD2) ||
 +       inint(&SD1)   || inint(&SD2)   ||
 +       outint(&SD1)  || outint(&SD2);
 +
 +  CH_IRQ_EPILOGUE();
 -  return connint(&SD1) || connint(&SD2) ||
 -         inint(&SD1)   || inint(&SD2)   ||
 -         outint(&SD1)  || outint(&SD2);
 +  return b;
  }
  #endif /* HAL_USE_SERIAL */
 | 
