mirror of
https://github.com/deadw00d/AROS.git
synced 2026-03-19 03:28:06 +00:00
only add the interrupt handlers when the units are created.
This commit is contained in:
@ -18,10 +18,6 @@
|
||||
|
||||
#include LC_LIBDEFS_FILE
|
||||
|
||||
#undef SDEBUG
|
||||
#undef DEBUG
|
||||
#define SDEBUG 0
|
||||
#define DEBUG 0
|
||||
#include <aros/debug.h>
|
||||
|
||||
/*** HIDDSerial::NewUnit() *********************************************************/
|
||||
@ -38,7 +34,7 @@ OOP_Object *PCSer__Hidd_Serial__NewUnit(OOP_Class *cl, OOP_Object *obj, struct p
|
||||
|
||||
#if (AROS_SERIAL_DEBUG > 0)
|
||||
if (msg->unitnum == (AROS_SERIAL_DEBUG-1))
|
||||
ReturnPtr("HIDDSerial::NewSerial", Object *, su);
|
||||
ReturnPtr("HIDDSerial::NewSerial", OOP_Object *, su);
|
||||
#endif
|
||||
|
||||
switch (msg->unitnum)
|
||||
@ -85,7 +81,7 @@ OOP_Object *PCSer__Hidd_Serial__NewUnit(OOP_Class *cl, OOP_Object *obj, struct p
|
||||
data->usedunits |= (1 << unitnum);
|
||||
}
|
||||
|
||||
ReturnPtr("HIDDSerial::NewSerial", Object *, su);
|
||||
ReturnPtr("HIDDSerial::NewSerial", OOP_Object *, su);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -32,10 +32,6 @@
|
||||
|
||||
#include "serial_intern.h"
|
||||
|
||||
#undef SDEBUG
|
||||
#undef DEBUG
|
||||
#define SDEBUG 0
|
||||
#define DEBUG 0
|
||||
#include <aros/debug.h>
|
||||
|
||||
#define DIRQ(x)
|
||||
@ -43,6 +39,9 @@
|
||||
/* The speed of the crystal */
|
||||
#define CRYSTAL_SPEED 1843200
|
||||
|
||||
AROS_INTP(serial_int_13);
|
||||
AROS_INTP(serial_int_24);
|
||||
|
||||
void serialunit_receive_data();
|
||||
ULONG serialunit_write_more_data();
|
||||
|
||||
@ -115,7 +114,57 @@ OOP_Object *PCSerUnit__Root__New(OOP_Class *cl, OOP_Object *obj, struct pRoot_Ne
|
||||
{
|
||||
struct IntuitionBase * IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
|
||||
data = OOP_INST_DATA(cl, obj);
|
||||
|
||||
|
||||
if (unitnum < 5 )
|
||||
{
|
||||
struct Interrupt *irq;
|
||||
if ((unitnum == 1) || (unitnum == 3))
|
||||
{
|
||||
/* Install COM2 and COM4 interrupt */
|
||||
irq = &CSD(cl->UserData)->intHandler[1];
|
||||
if (!irq->is_Node.ln_Name)
|
||||
{
|
||||
irq->is_Node.ln_Name = "COM2/COM4";
|
||||
irq->is_Code = (VOID_FUNC)serial_int_24;
|
||||
irq->is_Node.ln_Type = NT_INTERRUPT;
|
||||
irq->is_Node.ln_Pri = 127; /* Set the highest pri */
|
||||
irq->is_Data = (APTR)CSD(cl->UserData);
|
||||
AddIntServer(INTB_KERNEL + 3, irq);
|
||||
D(bug("[Serial:PC] %s: Interrupt handler installed\n", __func__));
|
||||
|
||||
/* Install reset callback */
|
||||
data->unitsdh.is_Node.ln_Pri = -61;
|
||||
data->unitsdh.is_Node.ln_Name = ((struct Node *)obj)->ln_Name;
|
||||
data->unitsdh.is_Code = (VOID_FUNC)PCSerUnit_ResetHandler;
|
||||
data->unitsdh.is_Data = data;
|
||||
AddResetCallback(&data->unitsdh);
|
||||
D(bug("[Serial:PC] %s: Shutdown handler installed\n", __func__));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Install COM1 and COM3 interrupt */
|
||||
irq = &CSD(cl->UserData)->intHandler[0];
|
||||
if (!irq->is_Node.ln_Name)
|
||||
{
|
||||
irq->is_Node.ln_Name = "COM1/COM3";
|
||||
irq->is_Code = (VOID_FUNC)serial_int_13;
|
||||
irq->is_Node.ln_Type = NT_INTERRUPT;
|
||||
irq->is_Node.ln_Pri = 127; /* Set the highest pri */
|
||||
irq->is_Data = (APTR)CSD(cl->UserData);
|
||||
AddIntServer(INTB_KERNEL + 4, irq);
|
||||
D(bug("[Serial:PC] %s: Interrupt handler installed\n", __func__));
|
||||
|
||||
/* Install reset callback */
|
||||
data->unitsdh.is_Node.ln_Pri = -61;
|
||||
data->unitsdh.is_Node.ln_Name = ((struct Node *)obj)->ln_Name;
|
||||
data->unitsdh.is_Code = (VOID_FUNC)PCSerUnit_ResetHandler;
|
||||
data->unitsdh.is_Data = data;
|
||||
AddResetCallback(&data->unitsdh);
|
||||
D(bug("[Serial:PC] %s: Shutdown handler installed\n", __func__));
|
||||
}
|
||||
}
|
||||
}
|
||||
data->baseaddr = bases[unitnum];
|
||||
|
||||
if (NULL != IntuitionBase) {
|
||||
@ -137,15 +186,6 @@ OOP_Object *PCSerUnit__Root__New(OOP_Class *cl, OOP_Object *obj, struct pRoot_Ne
|
||||
|
||||
D(bug("[Serial:PC] %s: Unit %d at 0x0%x\n", __func__, data->unitnum, data->baseaddr));
|
||||
|
||||
/* Install reset callback */
|
||||
data->unitsdh.is_Node.ln_Pri = -61;
|
||||
data->unitsdh.is_Node.ln_Name = ((struct Node *)obj)->ln_Name;
|
||||
data->unitsdh.is_Code = (VOID_FUNC)PCSerUnit_ResetHandler;
|
||||
data->unitsdh.is_Data = data;
|
||||
AddResetCallback(&data->unitsdh);
|
||||
|
||||
D(bug("[Serial:PC] %s: Shutdown handler installed\n", __func__));
|
||||
|
||||
/* Wake up UART */
|
||||
serial_outp(data, UART_LCR, 0xBF);
|
||||
serial_outp(data, UART_EFR, UART_EFR_ECB);
|
||||
@ -263,6 +303,8 @@ BOOL PCSerUnit__Hidd_SerialUnit__SetBaudrate(OOP_Class *cl, OOP_Object *o, struc
|
||||
struct HIDDSerialUnitData * data = OOP_INST_DATA(cl, o);
|
||||
BOOL valid = FALSE;
|
||||
|
||||
EnterFunc(bug("SerialUnit::SetBaudrate()\n"));
|
||||
|
||||
if (msg->baudrate != data->baudrate)
|
||||
{
|
||||
valid = set_baudrate(data, msg->baudrate);
|
||||
@ -286,7 +328,9 @@ BOOL PCSerUnit__Hidd_SerialUnit__SetParameters(OOP_Class *cl, OOP_Object *o, str
|
||||
BOOL valid = TRUE;
|
||||
int i = 0;
|
||||
struct TagItem * tags = msg->tags;
|
||||
|
||||
|
||||
EnterFunc(bug("SerialUnit::SetParameters()\n"));
|
||||
|
||||
while (TAG_END != tags[i].ti_Tag && TRUE == valid)
|
||||
{
|
||||
switch (tags[i].ti_Tag)
|
||||
@ -347,26 +391,30 @@ BOOL PCSerUnit__Hidd_SerialUnit__SetParameters(OOP_Class *cl, OOP_Object *o, str
|
||||
/******* SerialUnit::SendBreak() **********************************/
|
||||
BYTE PCSerUnit__Hidd_SerialUnit__SendBreak(OOP_Class *cl, OOP_Object *o, struct pHidd_SerialUnit_SendBreak *msg)
|
||||
{
|
||||
|
||||
EnterFunc(bug("SerialUnit::SendBreak()\n"));
|
||||
|
||||
return SerErr_LineErr;
|
||||
}
|
||||
|
||||
/******* SerialUnit::Start() **********************************/
|
||||
VOID PCSerUnit__Hidd_SerialUnit__Start(OOP_Class *cl, OOP_Object *o, struct pHidd_SerialUnit_Start *msg)
|
||||
{
|
||||
struct HIDDSerialUnitData * data = OOP_INST_DATA(cl, o);
|
||||
|
||||
/*
|
||||
* Allow or start feeding the UART with data. Get the data
|
||||
* from upper layer.
|
||||
*/
|
||||
if (TRUE == data->stopped) {
|
||||
if (NULL != data->DataWriteCallBack)
|
||||
data->DataWriteCallBack(data->unitnum, data->DataWriteUserData);
|
||||
/*
|
||||
* Also mark the stopped flag as FALSE.
|
||||
*/
|
||||
data->stopped = FALSE;
|
||||
}
|
||||
struct HIDDSerialUnitData * data = OOP_INST_DATA(cl, o);
|
||||
|
||||
EnterFunc(bug("SerialUnit::Start()\n"));
|
||||
/*
|
||||
* Allow or start feeding the UART with data. Get the data
|
||||
* from upper layer.
|
||||
*/
|
||||
if (TRUE == data->stopped) {
|
||||
if (NULL != data->DataWriteCallBack)
|
||||
data->DataWriteCallBack(data->unitnum, data->DataWriteUserData);
|
||||
/*
|
||||
* Also mark the stopped flag as FALSE.
|
||||
*/
|
||||
data->stopped = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/******* SerialUnit::Stop() **********************************/
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
##begin config
|
||||
basename PCSer
|
||||
libbasetype struct IntHIDDSerialBase
|
||||
version 1.1
|
||||
version 1.2
|
||||
residentpri 9
|
||||
classptr_field hdg_csd.serialhiddclass
|
||||
classid CLID_Hidd_Serial
|
||||
superclass CLID_Root
|
||||
superclass CLID_Hidd
|
||||
classdatatype struct HIDDSerialData
|
||||
options noexpunge
|
||||
##end config
|
||||
@ -27,7 +27,7 @@ basename PCSerUnit
|
||||
type hidd
|
||||
classid CLID_Hidd_SerialUnit
|
||||
classptr_field hdg_csd.serialunitclass
|
||||
superclass CLID_Root
|
||||
superclass CLID_Hidd
|
||||
classdatatype struct HIDDSerialUnitData
|
||||
##end config
|
||||
|
||||
|
||||
@ -18,42 +18,16 @@
|
||||
|
||||
#include LC_LIBDEFS_FILE
|
||||
|
||||
#undef SDEBUG
|
||||
#undef DEBUG
|
||||
#define DEBUG 0
|
||||
#include <aros/debug.h>
|
||||
|
||||
AROS_INTP(serial_int_13);
|
||||
AROS_INTP(serial_int_24);
|
||||
|
||||
static int PCSer_Init(LIBBASETYPEPTR LIBBASE)
|
||||
{
|
||||
struct class_static_data *csd = &LIBBASE->hdg_csd; /* SerialHidd static data */
|
||||
struct Interrupt *irq;
|
||||
|
||||
EnterFunc(bug("SerialHIDD_Init()\n"));
|
||||
|
||||
/* Install COM1 and COM3 interrupt */
|
||||
irq = &csd->intHandler[0];
|
||||
irq->is_Node.ln_Name = "COM1/COM3";
|
||||
irq->is_Node.ln_Type = NT_INTERRUPT;
|
||||
irq->is_Node.ln_Pri=127; /* Set the highest pri */
|
||||
irq->is_Code = (VOID_FUNC)serial_int_13;
|
||||
irq->is_Data = (APTR)csd;
|
||||
AddIntServer(INTB_KERNEL + 4, irq);
|
||||
// TODO: Probe for the Serial ports and register units.
|
||||
|
||||
/* Install COM2 and COM4 interrupt */
|
||||
irq = &csd->intHandler[1];
|
||||
irq->is_Node.ln_Name = "COM2/COM4";
|
||||
irq->is_Node.ln_Type = NT_INTERRUPT;
|
||||
irq->is_Node.ln_Pri=127; /* Set the highest pri */
|
||||
irq->is_Code = (VOID_FUNC)serial_int_24;
|
||||
irq->is_Data = (APTR)csd;
|
||||
AddIntServer(INTB_KERNEL + 3, irq);
|
||||
|
||||
D(bug("[Serial:PC] %s: Interrupt handlers installed\n", __func__));
|
||||
|
||||
ReturnInt("SerialHIDD_Init", ULONG, TRUE);
|
||||
ReturnInt("SerialHIDD_Init", int, TRUE);
|
||||
}
|
||||
|
||||
ADD2INITLIB(PCSer_Init, 0)
|
||||
|
||||
Reference in New Issue
Block a user