From 9d614a366d5c1541986aab61e03ea3f3c7e19269 Mon Sep 17 00:00:00 2001 From: jmcmullan Date: Sat, 28 Jul 2012 02:38:34 +0000 Subject: [PATCH] exec/ports.h: struct MagicMessage is an AROS private message Signed-off-by: Jason S. McMullan git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@45343 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/include/exec/ports.h | 20 -------------------- compiler/include/intuition/intuition.h | 23 +++++++++++++++++++++++ workbench/devs/printer/driver.c | 34 +++++++++++++++++++++------------- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/compiler/include/exec/ports.h b/compiler/include/exec/ports.h index 666a9cc30f..6c02ec5539 100644 --- a/compiler/include/exec/ports.h +++ b/compiler/include/exec/ports.h @@ -56,24 +56,4 @@ struct Message structure in the length) */ }; -struct MagicMessage -{ - struct Node mn_Node; - struct MsgPort * mn_ReplyPort; /* message reply port */ - UWORD mn_Length; /* total message length, in bytes */ - /* (include the size of the Message - structure in the length) */ - ULONG mn_Magic; /* can be used to figure out the message sender */ - ULONG mn_Version; /* version can be used to extend a message in later versions */ -}; - -/* definition for entry Magic in Messages - Magic is introduced to prevent Multiple Ports, for example if you´r using - ScreenNotifications and DecorNotifications you must have two Ports as long - as you cannot figure out which Messsage ist posted. With Magic this is no - problem. */ - -#define MAGIC_DECORATOR 0x8000001 -#define MAGIC_SCREENNOTIFY 0x8000002 - #endif /* EXEC_PORTS_H */ diff --git a/compiler/include/intuition/intuition.h b/compiler/include/intuition/intuition.h index e3224b3f15..46fedd7c32 100644 --- a/compiler/include/intuition/intuition.h +++ b/compiler/include/intuition/intuition.h @@ -899,6 +899,29 @@ struct NewDecorator IPTR nd_ScreenWindowObjOffset; }; +/*** AROS Private Messages ***/ + +struct MagicMessage +{ + struct Node mn_Node; + struct MsgPort * mn_ReplyPort; /* message reply port */ + UWORD mn_Length; /* total message length, in bytes */ + /* (include the size of the Message + structure in the length) */ + ULONG mn_Magic; /* can be used to figure out the message sender */ + ULONG mn_Version; /* version can be used to extend a message in later versions */ +}; + +/* definition for entry Magic in Messages + Magic is introduced to prevent Multiple Ports, for example if you´r using + ScreenNotifications and DecorNotifications you must have two Ports as long + as you cannot figure out which Messsage ist posted. With Magic this is no + problem. */ + +#define MAGIC_DECORATOR 0x8000001 +#define MAGIC_SCREENNOTIFY 0x8000002 + + struct DecoratorMessage { struct MagicMessage dm_Message; diff --git a/workbench/devs/printer/driver.c b/workbench/devs/printer/driver.c index c61157db29..fbfa1a68c0 100644 --- a/workbench/devs/printer/driver.c +++ b/workbench/devs/printer/driver.c @@ -46,6 +46,14 @@ const struct EasyStruct driverMisuse = { \ .es_GadgetFormat = "Ok", }; +/* Internal, private message + */ +struct PrinterMessage { + struct Message mm_Message; + ULONG mm_Magic; + ULONG mm_Version; +}; + #define TASK_PRINTERDATA(pd) \ struct PrinterData *pd =(struct PrinterData *)FindTask(NULL)->tc_UserData; \ if (pd == NULL || \ @@ -512,7 +520,7 @@ static LONG pd_DriverTask(VOID) struct Process *me = (struct Process *)FindTask(NULL); struct PrinterExtendedData *ped = &pd->pd_SegmentData->ps_PED; - struct MagicMessage *msg = NULL; + struct PrinterMessage *msg = NULL; union printerIO *pio; UWORD cmd; BOOL stopped = FALSE; @@ -524,14 +532,14 @@ static LONG pd_DriverTask(VOID) */ D(bug("%s: Waiting for startup. pd=%p\n", __func__, pd)); WaitPort(&me->pr_MsgPort); - msg = (struct MagicMessage *)GetMsg(&me->pr_MsgPort); + msg = (struct PrinterMessage *)GetMsg(&me->pr_MsgPort); D(bug("%s: Initializing driver, Unit Port %p\n", __func__, &pd->pd_Unit)); ret = pd_Init(pd); D(bug("%s: Replying with %d\n", __func__, ret)); - msg->mn_Version = ret; - ReplyMsg((struct Message *)msg); + msg->mm_Version = ret; + ReplyMsg(&msg->mm_Message); if (0 != ret) return ret; @@ -787,24 +795,24 @@ struct PrinterUnit *Printer_Unit(struct PrinterBase *PrinterBase, LONG unitnum) if ((port = CreateMsgPort())) { - struct MagicMessage startup, *reply; + struct PrinterMessage startup, *reply; D(bug("%s: Driver unit port %p\n", __func__, port)); - startup.mn_ReplyPort=port; - startup.mn_Length = sizeof(startup); - startup.mn_Magic = AROS_MAKE_ID('p','r','u','n'); - startup.mn_Version = 0; + startup.mm_Message.mn_ReplyPort=port; + startup.mm_Message.mn_Length = sizeof(startup); + startup.mm_Magic = AROS_MAKE_ID('p','r','u','n'); + startup.mm_Version = 0; PutMsg(&proc->pr_MsgPort, (struct Message *)&startup); WaitPort(port); D(bug("%s: Driver replied\n", __func__)); - reply = (struct MagicMessage *)GetMsg(port); + reply = (struct PrinterMessage *)GetMsg(port); D(bug("%s: Driver reply = %p\n", __func__, reply)); DeleteMsgPort(port); D(bug("%s: Driver port %p gone\n", __func__, port)); if (reply == &startup && - reply->mn_Length == sizeof(*reply) && - reply->mn_Magic == AROS_MAKE_ID('p','r','u','n') && - reply->mn_Version == 0) { + reply->mm_Message.mn_Length == sizeof(*reply) && + reply->mm_Magic == AROS_MAKE_ID('p','r','u','n') && + reply->mm_Version == 0) { /* Success! */ D(bug("%s: Driver started\n", __func__)); return pu; -- 2.11.4.GIT