pc_serial: replace contiguous area by arrays as buffers

We don't need to DMA unlike usb_serial.
This commit is contained in:
François Revol 2014-08-20 02:40:09 +02:00
parent 5925b1badc
commit d78faaaf70
2 changed files with 14 additions and 31 deletions

View File

@ -27,13 +27,12 @@ SerialDevice::SerialDevice(const struct serial_support_descriptor *device,
fIOBase(ioBase),
fIRQ(irq),
fMaster(master),
fBufferArea(-1),
fReadBuffer(NULL),
fReadBufferSize(ROUNDUP(DEF_BUFFER_SIZE, 16)),
fWriteBuffer(NULL),
fWriteBufferSize(ROUNDUP(DEF_BUFFER_SIZE, 16)),
fInterruptBuffer(NULL),
fInterruptBufferSize(16),
fReadBufferAvail(0),
fReadBufferIn(0),
fReadBufferOut(0),
fWriteBufferAvail(0),
fWriteBufferIn(0),
fWriteBufferOut(0),
fDoneRead(-1),
fDoneWrite(-1),
fControlOut(0),
@ -56,9 +55,6 @@ SerialDevice::~SerialDevice()
delete_sem(fDoneRead);
if (fDoneWrite >= B_OK)
delete_sem(fDoneWrite);
if (fBufferArea >= B_OK)
delete_area(fBufferArea);
}
@ -68,14 +64,6 @@ SerialDevice::Init()
fDoneRead = create_sem(0, "usb_serial:done_read");
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
WriteReg8(LCR, 0);

View File

@ -38,10 +38,8 @@ static SerialDevice * MakeDevice(struct serial_config_descriptor
const SerialDevice * Master() const { return fMaster ? fMaster : this; };
char * ReadBuffer() { return fReadBuffer; };
size_t ReadBufferSize() { return fReadBufferSize; };
char * WriteBuffer() { return fWriteBuffer; };
size_t WriteBufferSize() { return fWriteBufferSize; };
void SetModes(struct termios *tios);
@ -80,10 +78,6 @@ virtual void OnClose();
uint32 IOBase() const { return fIOBase; };
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:
static int32 DeviceThread(void *data);
@ -118,13 +112,14 @@ static void InterruptCallbackFunction(void *cookie,
//usb_serial_line_coding fLineCoding;
/* data buffers */
area_id fBufferArea;
char * fReadBuffer;
size_t fReadBufferSize;
char * fWriteBuffer;
size_t fWriteBufferSize;
char * fInterruptBuffer;
size_t fInterruptBufferSize;
char fReadBuffer[DEF_BUFFER_SIZE];
uint32 fReadBufferAvail;
uint32 fReadBufferIn;
uint32 fReadBufferOut;
char fWriteBuffer[DEF_BUFFER_SIZE];
uint32 fWriteBufferAvail;
uint32 fWriteBufferIn;
uint32 fWriteBufferOut;
/* variables used in callback functionality */
size_t fActualLengthRead;