pc_serial: replace contiguous area by arrays as buffers
We don't need to DMA unlike usb_serial.
This commit is contained in:
parent
5925b1badc
commit
d78faaaf70
@ -27,13 +27,12 @@ SerialDevice::SerialDevice(const struct serial_support_descriptor *device,
|
|||||||
fIOBase(ioBase),
|
fIOBase(ioBase),
|
||||||
fIRQ(irq),
|
fIRQ(irq),
|
||||||
fMaster(master),
|
fMaster(master),
|
||||||
fBufferArea(-1),
|
fReadBufferAvail(0),
|
||||||
fReadBuffer(NULL),
|
fReadBufferIn(0),
|
||||||
fReadBufferSize(ROUNDUP(DEF_BUFFER_SIZE, 16)),
|
fReadBufferOut(0),
|
||||||
fWriteBuffer(NULL),
|
fWriteBufferAvail(0),
|
||||||
fWriteBufferSize(ROUNDUP(DEF_BUFFER_SIZE, 16)),
|
fWriteBufferIn(0),
|
||||||
fInterruptBuffer(NULL),
|
fWriteBufferOut(0),
|
||||||
fInterruptBufferSize(16),
|
|
||||||
fDoneRead(-1),
|
fDoneRead(-1),
|
||||||
fDoneWrite(-1),
|
fDoneWrite(-1),
|
||||||
fControlOut(0),
|
fControlOut(0),
|
||||||
@ -56,9 +55,6 @@ SerialDevice::~SerialDevice()
|
|||||||
delete_sem(fDoneRead);
|
delete_sem(fDoneRead);
|
||||||
if (fDoneWrite >= B_OK)
|
if (fDoneWrite >= B_OK)
|
||||||
delete_sem(fDoneWrite);
|
delete_sem(fDoneWrite);
|
||||||
|
|
||||||
if (fBufferArea >= B_OK)
|
|
||||||
delete_area(fBufferArea);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,14 +64,6 @@ SerialDevice::Init()
|
|||||||
fDoneRead = create_sem(0, "usb_serial:done_read");
|
fDoneRead = create_sem(0, "usb_serial:done_read");
|
||||||
fDoneWrite = create_sem(0, "usb_serial:done_write");
|
fDoneWrite = create_sem(0, "usb_serial:done_write");
|
||||||
|
|
||||||
size_t totalBuffers = fReadBufferSize + fWriteBufferSize + fInterruptBufferSize;
|
|
||||||
fBufferArea = create_area("usb_serial:buffers_area", (void **)&fReadBuffer,
|
|
||||||
B_ANY_KERNEL_ADDRESS, ROUNDUP(totalBuffers, B_PAGE_SIZE), B_CONTIGUOUS,
|
|
||||||
B_READ_AREA | B_WRITE_AREA);
|
|
||||||
|
|
||||||
fWriteBuffer = fReadBuffer + fReadBufferSize;
|
|
||||||
fInterruptBuffer = fWriteBuffer + fWriteBufferSize;
|
|
||||||
|
|
||||||
// disable DLAB
|
// disable DLAB
|
||||||
WriteReg8(LCR, 0);
|
WriteReg8(LCR, 0);
|
||||||
|
|
||||||
|
@ -38,10 +38,8 @@ static SerialDevice * MakeDevice(struct serial_config_descriptor
|
|||||||
const SerialDevice * Master() const { return fMaster ? fMaster : this; };
|
const SerialDevice * Master() const { return fMaster ? fMaster : this; };
|
||||||
|
|
||||||
char * ReadBuffer() { return fReadBuffer; };
|
char * ReadBuffer() { return fReadBuffer; };
|
||||||
size_t ReadBufferSize() { return fReadBufferSize; };
|
|
||||||
|
|
||||||
char * WriteBuffer() { return fWriteBuffer; };
|
char * WriteBuffer() { return fWriteBuffer; };
|
||||||
size_t WriteBufferSize() { return fWriteBufferSize; };
|
|
||||||
|
|
||||||
void SetModes(struct termios *tios);
|
void SetModes(struct termios *tios);
|
||||||
|
|
||||||
@ -80,10 +78,6 @@ virtual void OnClose();
|
|||||||
uint32 IOBase() const { return fIOBase; };
|
uint32 IOBase() const { return fIOBase; };
|
||||||
uint32 IRQ() const { return fIRQ; };
|
uint32 IRQ() const { return fIRQ; };
|
||||||
|
|
||||||
protected:
|
|
||||||
void SetReadBufferSize(size_t size) { fReadBufferSize = size; };
|
|
||||||
void SetWriteBufferSize(size_t size) { fWriteBufferSize = size; };
|
|
||||||
void SetInterruptBufferSize(size_t size) { fInterruptBufferSize = size; };
|
|
||||||
private:
|
private:
|
||||||
static int32 DeviceThread(void *data);
|
static int32 DeviceThread(void *data);
|
||||||
|
|
||||||
@ -118,13 +112,14 @@ static void InterruptCallbackFunction(void *cookie,
|
|||||||
//usb_serial_line_coding fLineCoding;
|
//usb_serial_line_coding fLineCoding;
|
||||||
|
|
||||||
/* data buffers */
|
/* data buffers */
|
||||||
area_id fBufferArea;
|
char fReadBuffer[DEF_BUFFER_SIZE];
|
||||||
char * fReadBuffer;
|
uint32 fReadBufferAvail;
|
||||||
size_t fReadBufferSize;
|
uint32 fReadBufferIn;
|
||||||
char * fWriteBuffer;
|
uint32 fReadBufferOut;
|
||||||
size_t fWriteBufferSize;
|
char fWriteBuffer[DEF_BUFFER_SIZE];
|
||||||
char * fInterruptBuffer;
|
uint32 fWriteBufferAvail;
|
||||||
size_t fInterruptBufferSize;
|
uint32 fWriteBufferIn;
|
||||||
|
uint32 fWriteBufferOut;
|
||||||
|
|
||||||
/* variables used in callback functionality */
|
/* variables used in callback functionality */
|
||||||
size_t fActualLengthRead;
|
size_t fActualLengthRead;
|
||||||
|
Loading…
Reference in New Issue
Block a user