mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-12-24 19:36:25 +02:00
libubb/swuart.c: use mlockall to prevent page faults with interrupts off
This commit is contained in:
parent
5487578ee7
commit
e4f8b97e36
@ -12,7 +12,9 @@
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <ubb/ubb.h>
|
||||
#include <ubb/regs4740.h>
|
||||
@ -232,6 +234,15 @@ void swuart_clear_errors(void)
|
||||
|
||||
int swuart_open(uint32_t tx, uint32_t rx, int bps)
|
||||
{
|
||||
/*
|
||||
* Make sure code and rx/tx buffers are locked into memory before we
|
||||
* disable interrupts in swuart_trx.
|
||||
*/
|
||||
if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
|
||||
perror("mlockall");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ticks = TCLK/bps-1;
|
||||
tx_mask = tx;
|
||||
rx_mask = rx;
|
||||
@ -247,4 +258,6 @@ int swuart_open(uint32_t tx, uint32_t rx, int bps)
|
||||
|
||||
void swuart_close(void)
|
||||
{
|
||||
if (munlockall())
|
||||
perror("munlockall");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user