Exemplo n.º 1
0
/******* TapUnit::Dispose() ***********************************/
OOP_Object *UXTapUnit__Root__Dispose(OOP_Class *cl, OOP_Object *obj, OOP_Msg msg)
{
	struct HIDDTapUnitData * data;
	EnterFunc(bug("TapUnit::Dispose()\n"));

	data = OOP_INST_DATA(cl, obj);
	D(bug("Freeing filedescriptor (%d)!\n",data->filedescriptor));

	if (-1 != data->filedescriptor) { 
		Hidd_UnixIO_AbortAsyncIO(data->unixio_read,
		                         data->filedescriptor,
		                         SysBase);

		close(data->filedescriptor);
	
		FreeMem(data->replyport_read,	sizeof(struct MsgPort));
		FreeMem(data->replyport_write, sizeof(struct MsgPort));

		FreeMem(data->softint_read , sizeof(struct Interrupt));
		FreeMem(data->softint_write, sizeof(struct Interrupt));

		OOP_DisposeObject(data->unixio_read);
		OOP_DisposeObject(data->unixio_write);
	}
	OOP_DoSuperMethod(cl, obj, (OOP_Msg)msg);
	ReturnPtr("TapUnit::Dispose()", OOP_Object *, obj);
}
Exemplo n.º 2
0
static int PCILx_Expunge(LIBBASETYPEPTR LIBBASE)
{
    BOOL ret = TRUE;
    
    D(bug("[PCILinux] expunge\n"));

    /* Try to open PCI subsystem */
    OOP_Object *pci = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
    if (pci)
    {
	/* If PCI successed to open, remove your driver from subsystem */
	struct pHidd_PCI_RemHardwareDriver msg;

	msg.driverClass = LIBBASE->psd.driverClass;
	msg.mID = OOP_GetMethodID(IID_Hidd_PCI, moHidd_PCI_RemHardwareDriver);

	D(bug("[PCILinux] Removing driver\n"));
	if (OOP_DoMethod(pci, (OOP_Msg)&msg) == FALSE)
	{
	    ret = FALSE;
	    D(bug("[PCILinux] PCI class refused to remove driver for some reason. Delaying expunge then\n"));
	}
	OOP_DisposeObject(pci);
    }

    return ret;
}
Exemplo n.º 3
0
BOOL DriverInit( struct DriverBase* AHIsubBase )
{
    struct ac97Base* ac97Base = (struct ac97Base*) AHIsubBase;

    ac97Base->dosbase = OpenLibrary( DOSNAME, 37 );
    ac97Base->sysbase = SysBase;

    D(bug("[ac97] Init\n"));

    if(DOSBase)
    {
	ac97Base->oopbase = OpenLibrary(AROSOOP_NAME, 0);
	if (ac97Base)
	{
	    __IHidd_PCIDev = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);

	    D(bug("[ac97] Libraries opened\n"));

	    if (__IHidd_PCIDev)
	    {
		OOP_Object *pci = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
		
		D(bug("[ac97] PCIDevice AttrBase = %x\n",__IHidd_PCIDev));
		
		if (pci)
		{
		    struct Hook FindHook = {
			h_Entry:    (IPTR(*)())Enumerator,
			h_Data:	    ac97Base,
		    };

		    struct TagItem Reqs[] = {
			{ tHidd_PCI_Class,	0x04 },
			{ tHidd_PCI_SubClass,	0x01 },
			{ TAG_DONE, 0UL },
		    };

		    struct pHidd_PCI_EnumDevices enummsg = {
			mID:		OOP_GetMethodID(CLID_Hidd_PCI, moHidd_PCI_EnumDevices),
			callback:	&FindHook,
			requirements:	(struct TagItem *)&Reqs,
		    }, *msg = &enummsg;
		    
		    D(bug("[ac97] Got PCI object\n"));
		    
		    ac97Base->cardfound = FALSE;
		    ac97Base->PCM_out = AllocMem(8*32, MEMF_PUBLIC | MEMF_CLEAR);

		    OOP_DoMethod(pci, (OOP_Msg)msg);
		    
		    OOP_DisposeObject(pci);

		    D(bug("[ac97] PCM out base %08x\n", ac97Base->PCM_out));

		    return ac97Base->cardfound;
		}
	    }
Exemplo n.º 4
0
void free_serialunitclass(struct class_static_data *csd)
{
	EnterFunc(bug("free_serialhiddclass(csd=%p)\n", csd));

	if(csd) {
		OOP_RemoveClass(csd->serialhiddclass);
	
		if(csd->serialhiddclass) OOP_DisposeObject((OOP_Object *) csd->serialhiddclass);
		csd->serialhiddclass = NULL;
	}

	ReturnVoid("free_serialhiddclass");
}
Exemplo n.º 5
0
static int PCPCI_Expunge(LIBBASETYPEPTR LIBBASE)
{
    int ok;
	
    OOP_Object *pci = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
    if (pci)
    {
	struct pHidd_PCI_RemHardwareDriver msg, *pmsg=&msg;
	
	msg.mID = OOP_GetMethodID(IID_Hidd_PCI, moHidd_PCI_RemHardwareDriver);
	msg.driverClass = LIBBASE->psd.driverClass;

	ok = OOP_DoMethod(pci, (OOP_Msg)pmsg);

	OOP_DisposeObject(pci);
    }
    else
	ok = FALSE;

    return ok;
}
Exemplo n.º 6
0
int main(int argc, char **argv)
{
    ULONG ret = RETURN_FAIL;

    OOP_AttrBase HiddGCAttrBase;
    OOP_AttrBase HiddGfxAttrBase;
    OOP_AttrBase HiddBitMapAttrBase;

    OOP_Object   *gfxHidd;
    OOP_Object   *bitMap;
    OOP_Object   *gc;

    STRPTR hiddName = "graphics.hidd";
    ULONG  width    = 320;
    ULONG  height   = 200;
    ULONG  depth    = 8;
    ULONG  format   = vHidd_BitMap_Format_Planar;

    WORD x;
    char wait;

    struct Args
    {
        STRPTR hiddName;
        IPTR   *width;
        IPTR   *height;
        IPTR   *depth;
        IPTR   *chunky;
        ULONG  displayable;
    };

    struct Args args = {hiddName, &width, &height, &depth, 0, 0};
    struct RDArgs *rda;


    if(ght_OpenLibs(LibsArray))
    {
        rda = ReadArgs("HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S", (IPTR *)&args, NULL);
        if (rda != NULL)
        {
            if(args.chunky      != 0) format           = vHidd_BitMap_Format_Chunky;
            if(args.displayable != 0) args.displayable = (ULONG) TRUE;

            HIDDGraphicsBase = OpenLibrary(args.hiddName, 0);
            if(HIDDGraphicsBase)
            {
                ret = RETURN_ERROR;

                HiddGfxAttrBase    = OOP_ObtainAttrBase(IID_Hidd_Gfx);
                HiddBitMapAttrBase = OOP_ObtainAttrBase(IID_Hidd_BitMap);
                HiddGCAttrBase     = OOP_ObtainAttrBase(IID_Hidd_GC);
        
                if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase)
                {
                    gfxHidd = OOP_NewObject(NULL, args.hiddName, NULL);
                    if(gfxHidd)
                    {
                        struct TagItem bm_tags[] =
                        {
                            {aHidd_BitMap_Width,       (IPTR) *args.width},
                            {aHidd_BitMap_Height,      (IPTR) *args.height},
                            {aHidd_BitMap_Depth,       (IPTR) *args.depth},
                            {aHidd_BitMap_Format,      (IPTR) format},
                            {aHidd_BitMap_Displayable, (IPTR) args.displayable},
                            {TAG_DONE, 0UL}
                        };
    
                        bitMap = HIDD_Gfx_NewBitMap(gfxHidd, bm_tags);
                        if(bitMap)
                        {
                            struct TagItem gc_tags[] =
                            {
                                {aHidd_GC_BitMap,     (IPTR) bitMap},
                                {TAG_DONE, 0UL}
                            };
        
                            gc = HIDD_Gfx_NewGC(gfxHidd, gc_tags);
                            if(gc)
                            {
                                OOP_SetAttrsTags(gc, aHidd_GC_Foreground, 15, TAG_END);

                                for(x = 10; x < 30; x++)
                                {
                                    OOP_SetAttrsTags(gc, aHidd_GC_ColorMask, ~0, TAG_END);
                                    HIDD_BM_DrawPixel(gc, x, 10);

                                    OOP_SetAttrsTags(gc, aHidd_GC_ColorMask, ~0 - 7, TAG_END);
                                    HIDD_BM_DrawPixel(gc, x, 12);

                                    OOP_SetAttrsTags(gc, aHidd_GC_ColorMask, 0, TAG_END);
                                    HIDD_BM_DrawPixel(gc, x, 14);
                                }

                                printf("Press enter to continue");
                                scanf("%c", &wait);

                                HIDD_Gfx_DisposeGC(gfxHidd, gc);
        
                                ret = RETURN_OK;
                            }
        
                            HIDD_Gfx_DisposeBitMap(gfxHidd, bitMap);
                        }
    
                        if(gfxHidd) OOP_DisposeObject(gfxHidd);
                    }
                }  /* if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase) */
    
                if(HiddGfxAttrBase)    OOP_ReleaseAttrBase(IID_Hidd_Gfx);
                if(HiddBitMapAttrBase) OOP_ReleaseAttrBase(IID_Hidd_BitMap);
                if(HiddGCAttrBase)     OOP_ReleaseAttrBase(IID_Hidd_GC);

                CloseLibrary(HIDDGraphicsBase);
            } /* if(HIDDGraphicsBase) */
            FreeArgs(rda);
        }
        else
        {
           PrintFault(IoErr(), "");
        }  /* if (rda != NULL) */
    } /* if OpenLibs() */

    ght_CloseLibs(LibsArray);

    return(ret);
}
Exemplo n.º 7
0
/******* TapUnit::New() ***********************************/
OOP_Object *UXTapUnit__Root__New(OOP_Class *cl, OOP_Object *obj, struct pRoot_New *msg)
{
	struct HIDDTapUnitData * data;
	static const struct TagItem tags[] = {{ TAG_END, 0}};
	struct TagItem *tag, *tstate;
	ULONG unitnum = 0;
	
	EnterFunc(bug("TapUnit::New()\n"));

	tstate = msg->attrList;
	while ((tag = NextTagItem((const struct TagItem **)&tstate))) {
		ULONG idx;

		if (IS_HIDDTAPUNIT_ATTR(tag->ti_Tag, idx)) {
			switch (idx) {
				case aoHidd_TapUnit_Unit:
					unitnum = (ULONG)tag->ti_Data;
				break;
			}
		}

	} /* while (tags to process) */
		
	D(bug("!!!!Request for unit number %d\n",unitnum));

	obj = (OOP_Object *)OOP_DoSuperMethod(cl, obj, (OOP_Msg)msg);

	if (obj) {
		data = OOP_INST_DATA(cl, obj);
		
		data->unitnum = unitnum;

		D(bug("Creating network device %s.\n",unitname[data->unitnum]));

		data->filedescriptor = unix_open_nonblock("/dev/net/tun");
		if (data->filedescriptor < 0)
			data->filedescriptor = unix_open_nonblock("/dev/tap");

		D(bug("Opened %s on handle %d\n",unitname[data->unitnum], data->filedescriptor));
		
		if (-1 != data->filedescriptor) {
			struct ifreq ifr;
			memset(&ifr, 0, sizeof(ifr));
			ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
			strncpy(ifr.ifr_name, unitname[data->unitnum], IFNAMSIZ);
			
			/*
			** Configure the tty driver ?!?!?!
			*/
			{
				data->replyport_read = AllocMem(sizeof(struct MsgPort), MEMF_PUBLIC|MEMF_CLEAR);
				data->replyport_write= AllocMem(sizeof(struct MsgPort), MEMF_PUBLIC|MEMF_CLEAR);

				if (data->replyport_read && data->replyport_write) {
					/*
					** Init the msg ports. They don't need a signal to be allocated
					*/
					NEWLIST(&data->replyport_read->mp_MsgList);
					data->replyport_read ->mp_Node.ln_Type = NT_MSGPORT;

					NEWLIST(&data->replyport_write->mp_MsgList);
					data->replyport_write->mp_Node.ln_Type = NT_MSGPORT;

					data->softint_read	= AllocMem(sizeof(struct Interrupt), MEMF_CLEAR);
					data->softint_write = AllocMem(sizeof(struct Interrupt), MEMF_CLEAR);

					if (data->softint_read && data->softint_write) {
						data->softint_read->is_Data = data;
						data->softint_read->is_Code = tapunit_receive_data;

						data->softint_write->is_Data = data;
						data->softint_write->is_Code = tapunit_write_more_data;

						data->replyport_read->mp_Flags = PA_SOFTINT;
						data->replyport_read->mp_SoftInt = data->softint_read;

						data->replyport_write->mp_Flags = PA_SOFTINT;
						data->replyport_write->mp_SoftInt = data->softint_write;

						data->unixio_read	= OOP_NewObject(NULL, CLID_Hidd_UnixIO, (struct TagItem *)tags);
						data->unixio_write = OOP_NewObject(NULL, CLID_Hidd_UnixIO, (struct TagItem *)tags);

						if (NULL != data->unixio_read && NULL != data->unixio_write)
						{
							Hidd_UnixIO_IOControlFile(data->unixio_read, 
							    data->filedescriptor,
							    TUNSETIFF,
							    &ifr,
							    NULL);
							    
							ULONG error;
							D(bug("Creating UnixIO AsyncIO command!\n"));

							error = Hidd_UnixIO_AsyncIO(data->unixio_read,
							                            data->filedescriptor,
							                            vHidd_UnixIO_Terminal,
							                            data->replyport_read,
							                            vHidd_UnixIO_Read | vHidd_UnixIO_Keep,
							                            SysBase);

							error = Hidd_UnixIO_AsyncIO(data->unixio_write,
							                            data->filedescriptor,
							                            vHidd_UnixIO_Terminal,
							                            data->replyport_write,
							                            vHidd_UnixIO_Write | vHidd_UnixIO_Keep,
							                            SysBase);
							goto exit;

						}

						if (NULL != data->unixio_read)
							OOP_DisposeObject(data->unixio_read);

						if (NULL != data->unixio_write)
							OOP_DisposeObject(data->unixio_write);
					}
					
					if (data->softint_read) 
						FreeMem(data->softint_read, sizeof(struct Interrupt));
					if (data->softint_write)
						FreeMem(data->softint_write, sizeof(struct Interrupt));
				}
				
				if (data->replyport_read)
					FreeMem(data->replyport_read , sizeof(struct MsgPort));
				if (data->replyport_write)
					FreeMem(data->replyport_write, sizeof(struct MsgPort));

			} 
			
			close(data->filedescriptor);	
		}

		OOP_DisposeObject(obj);
		obj = NULL;
	} /* if (obj) */

	D(bug("%s - an error occurred!\n",__FUNCTION__));

exit:
	ReturnPtr("TapUnit::New()", OOP_Object *, obj);
}
Exemplo n.º 8
0
int main(int argc, char **argv)
{
    ULONG ret = RETURN_FAIL;

    OOP_AttrBase HiddGfxAttrBase     = 0;
    OOP_AttrBase HiddGCAttrBase      = 0;
    OOP_AttrBase HiddBitMapAttrBase  = 0;

    OOP_Object   *gfxHidd;
    OOP_Object   *bitMap;
    OOP_Object   *gc;

    STRPTR hiddName = "graphics.hidd";
    ULONG  fg       = 1;
    ULONG  bg       = 2;

    /* ReadArgs() declarations                */
    /* each entry must have a size of 4 bytes */
    struct Args
    {
        STRPTR hiddName;
        IPTR   *fg;
        IPTR   *bg;
    };

    struct Args args = {hiddName, &fg, &bg};
    struct RDArgs *rda;


    if(ght_OpenLibs(LibsArray))
    {
        rda = ReadArgs("HIDD/K,FG/N/K,BG/N/K", (IPTR *)&args, NULL);
        if (rda != NULL)
        {
            HIDDGraphicsBase = OpenLibrary(args.hiddName, 0);
            if(HIDDGraphicsBase)
            {
                ret = RETURN_ERROR;

                HiddGfxAttrBase    = OOP_ObtainAttrBase(IID_Hidd_Gfx);
                HiddBitMapAttrBase = OOP_ObtainAttrBase(IID_Hidd_BitMap);
                HiddGCAttrBase     = OOP_ObtainAttrBase(IID_Hidd_GC);
                if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase)
                {
                    gfxHidd = OOP_NewObject(NULL, args.hiddName, NULL);
                    if(gfxHidd)
                    {
                        bitMap = HIDD_Gfx_NewBitMap(gfxHidd, NULL);
                        if(bitMap)
                        {
                            struct TagItem gc_tags[] =
                            {
                                {aHidd_GC_BitMap,     (IPTR) bitMap},
                                {aHidd_GC_Foreground, (IPTR) *args.fg},
                                {aHidd_GC_Background, (IPTR) *args.bg},
                                {TAG_DONE, 0UL}
                            };

                            gc = HIDD_Gfx_NewGC(gfxHidd, gc_tags);
                            if(gc)
                            {
                                printf("GC created:\n");
                                printf("  fg    : %li\n", ght_GetAttr(gc, aHidd_GC_Foreground));
                                printf("  bg    : %li\n", ght_GetAttr(gc, aHidd_GC_Background));
                                printf("  drMode: %li\n", ght_GetAttr(gc, aHidd_GC_DrawMode));
                                printf("  bitMap: %li\n", ght_GetAttr(gc, aHidd_GC_BitMap));
        
                                HIDD_Gfx_DisposeGC(gfxHidd, gc);
        
                                ret = RETURN_OK;
                            }
        
                            HIDD_Gfx_DisposeBitMap(gfxHidd, bitMap);
                        }

                        if(gfxHidd) OOP_DisposeObject(gfxHidd);
                    } /* if(gfxHidd) */
                }  /* if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase) */

                if(HiddGCAttrBase)     OOP_ReleaseAttrBase(IID_Hidd_GC);
                if(HiddBitMapAttrBase) OOP_ReleaseAttrBase(IID_Hidd_BitMap);
                if(HiddGfxAttrBase)    OOP_ReleaseAttrBase(IID_Hidd_Gfx);

                CloseLibrary(HIDDGraphicsBase);
            } /* if(HIDDGraphicsBase) */

            FreeArgs(rda);
        }
        else
        {
           PrintFault(IoErr(), "");
        }  /* if (rda != NULL) */

    } /* if OpenLibs() */

    ght_CloseLibs(LibsArray);

    return(ret);
}
Exemplo n.º 9
0
static VOID inputtask_entry(struct inputtask_params *inputparams)
{
    struct linux_staticdata *lsd;
    struct inputtask_params itp;
    UBYTE lastcode = 0xFF;
    
    struct MsgPort *kbd_port = NULL;
    struct MsgPort *mouse_port = NULL;
    
    struct mouse_state oldstate = { { 0, 0, 0 }, 0, 0 };
    struct pHidd_Mouse_Event mouse_event;
    
    HIDD *unixio = NULL;
    ULONG kbdsig, mousesig, sigs;
    /* We must copy the parameter struct because they are allocated
     on the parent's stack */
kprintf("INSIDE INPUT TASK\n");
    itp = *inputparams;
    lsd = itp.lsd;
kprintf("in inputtask: lsd = %p\n", lsd);

kprintf("CREATING UNIXIO,,, OOPBase=%p\n", OOPBase);
kprintf("now\n");
    unixio = (HIDD)New_UnixIO(OOPBase, SysBase);
kprintf("UNIXIO %p\n", unixio);
    if (NULL == unixio) {
    	goto failexit;
    }
    
    kbd_port   = CreateMsgPort();
    mouse_port = CreateMsgPort();
    
    if (NULL == kbd_port || NULL == mouse_port)
	goto failexit;
    
    Signal(itp.parent, itp.ok_signal);
    
    kbdsig	= 1L << kbd_port->mp_SigBit;
    mousesig	= 1L << mouse_port->mp_SigBit;
kprintf("SIGS: %p, %p\n", kbdsig, mousesig);
kprintf("FDS: %d, %d\n", lsd->kbdfd, lsd->mousefd);

    Hidd_UnixIO_AsyncIO(unixio, lsd->kbdfd,   vHidd_UnixIO_Terminal, kbd_port,	vHidd_UnixIO_Read, SysBase);
    Hidd_UnixIO_AsyncIO(unixio, lsd->mousefd, vHidd_UnixIO_Terminal, mouse_port,  vHidd_UnixIO_Read, SysBase);
    
    for (;;) {
	LONG err_kbd, err_mouse;
	
	//kprintf("GETTING INPUT FROM UNIXIO\n");
	/* Turn on kbd support */
//	init_kbd(lsd);
	
	
//    	ret = (int)Hidd_UnixIO_Wait( unixio, lsd->kbdfd, vHidd_UnixIO_Read, NULL, NULL);
//	cleanup_kbd(lsd);
//	kprintf("GOT INPUT FROM UNIXIO\n");
	
	sigs = Wait( kbdsig | mousesig );

	if (sigs & kbdsig) {
	
//kprintf("---------- GOT KBD INPUT --------------------\n");
 	    for (;;) {
		UBYTE code;
		size_t bytesread;
	    
	    
		bytesread = read(lsd->kbdfd, &code, 1);
		if (-1 == bytesread)  {
	    	    kprintf("!!! COULD NOT READ FROM LINUX KBD DEVICE: %s\n"
			, strerror(errno));
		    break;
		
		} else {
	    	    /* Let the kbd hidd handle it */
		    /* Key doewn ? */
		    
		    //kprintf("## code %d\n", code);
		    if (code == lastcode)
			break;
		    
	    	    // if (!(code & 0x80)) kprintf("GOT SCANCODE %d from kbd hidd\n", code);
		    if (code == 88) /* F12 */
		    {
			    kill(getpid(), SIGTERM);
		    }
		
		    /* Send code to the application */
    	    	    ObtainSemaphore(&lsd->sema);
		    if (lsd->kbdhidd) HIDD_LinuxKbd_HandleEvent(lsd->kbdhidd, code);
    	    	    ReleaseSemaphore(&lsd->sema);

		    lastcode = code;
		}
		break;

	    }	/* for (;;) */
	    free_unixio_message(kbd_port, lsd);

	    err_kbd = Hidd_UnixIO_AsyncIO(unixio, lsd->kbdfd,   vHidd_UnixIO_Terminal, kbd_port,	vHidd_UnixIO_Read, SysBase);

	} /* if (sigs & kbdsig) */
	
	if (sigs & mousesig)
	{
	    ULONG i;
	    LONG bytesread;
	    UBYTE buf[4];
	    BYTE dx = 0, dy = 0;
	    struct mouse_state newstate;
	    
	    /* Got mouse event */
	    //kprintf("------------- MOUSE EVENT ------------\n");
	    for (i = 0; i < 4; i ++) {
	    	bytesread = read(lsd->mousefd, &buf[i], 1);
		if (-1 == bytesread)
		{
		    if (errno == EAGAIN)
		    {
		    	i--;
			continue;
		    }
		    kprintf("!!! linux input task: Could not read from mouse device: %s\n", strerror(errno));
		    goto end_mouse_event;    
		}
		
		if ((buf[0] & 8) != 8) i--;
	    }
	    
	    //kprintf("%02x: %02x: %02x\n", buf[0], buf[1], buf[2]);
	    /* Get button states */
	    newstate.buts[0] = (buf[0] & 0x01) ? 1 : 0;
	    newstate.buts[1] = (buf[0] & 0x02) ? 1 : 0;
	    newstate.buts[2] = (buf[0] & 0x04) ? 1 : 0;
	    
	    if (buf[1] != 0) {
		dx = (buf[0] & 0x10) ? buf[1] - 256 : buf[1];
	    }
	    
	    if (buf[2] != 0) {
		dy = (buf[0] & 0x20) ? buf[2] - 256 : buf[2];
	    }
		
	    newstate.dx = dx;
	    newstate.dy = -dy;
	    
	    //kprintf("EVENT: STATE 1:%d, 2:%d, 3:%d, dx:%d, dy:%d\n"
	    //	, newstate.buts[0], newstate.buts[1], newstate.buts[2]
	    //	, newstate.dx, newstate.dy);
		
            ObtainSemaphore(&lsd->sema);    
    	    if (lsd->mousehidd)
	    {
    		mouse_event.x = newstate.dx;
		mouse_event.y = newstate.dy;

		if (newstate.dx || newstate.dy)
		{
	    	    mouse_event.button = vHidd_Mouse_NoButton;
		    mouse_event.type = vHidd_Mouse_Motion;

	    	    HIDD_LinuxMouse_HandleEvent(lsd->mousehidd, &mouse_event);
		}

		if (newstate.buts[0] != oldstate.buts[0])
		{
	    	    mouse_event.button = vHidd_Mouse_Button1;
		    mouse_event.type = newstate.buts[0] ? vHidd_Mouse_Press : vHidd_Mouse_Release;	

	    	    HIDD_LinuxMouse_HandleEvent(lsd->mousehidd, &mouse_event);
		}

		if (newstate.buts[1] != oldstate.buts[1])
		{
	    	    mouse_event.button = vHidd_Mouse_Button2;
		    mouse_event.type = newstate.buts[1] ? vHidd_Mouse_Press : vHidd_Mouse_Release;	

	    	    HIDD_LinuxMouse_HandleEvent(lsd->mousehidd, &mouse_event);
		}

		if (newstate.buts[2] != oldstate.buts[2])
		{
	    	    mouse_event.button = vHidd_Mouse_Button3;
		    mouse_event.type = newstate.buts[2] ? vHidd_Mouse_Press : vHidd_Mouse_Release;	

	    	    HIDD_LinuxMouse_HandleEvent(lsd->mousehidd, &mouse_event);
		}
	    }
    	    ReleaseSemaphore(&lsd->sema);
	    
    	    oldstate = newstate;
	    	    	    
end_mouse_event:
	    free_unixio_message(mouse_port, lsd);

	    err_mouse	= Hidd_UnixIO_AsyncIO(unixio, lsd->mousefd, vHidd_UnixIO_Terminal, mouse_port,  vHidd_UnixIO_Read, SysBase);

	}
    	
    } /* Forever */
    
failexit:

    if (NULL != kbd_port)
    	DeleteMsgPort(kbd_port);

    if (NULL != mouse_port)
	DeleteMsgPort(mouse_port);
	
    if (NULL != unixio)
    	OOP_DisposeObject((OOP_Object *)unixio);

    Signal(itp.parent, itp.fail_signal);
     
    return;
    
}