Exemplo n.º 1
0
static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR LIBBASE)
{
D(bug("[SiS900] Init()\n"));

    UBYTE tmpbuff[100];
    sprintf((char *)tmpbuff, SiS900_TASK_NAME, "sis900.0");

    if (FindTask(tmpbuff) != NULL)
    {
        D(bug("[SiS900] device already up and running.\n"));
        return FALSE;
    }

    NEWLIST(&LIBBASE->sis900b_Units);

    LIBBASE->sis900b_PCIDeviceAttrBase = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);

    if (LIBBASE->sis900b_PCIDeviceAttrBase != 0)
    {
        D(bug("[SiS900] HiddPCIDeviceAttrBase @ %p\n", LIBBASE->sis900b_PCIDeviceAttrBase));

        LIBBASE->sis900b_PCI = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);

        if (LIBBASE->sis900b_PCI)
        {
            D(bug("[SiS900] PCI Subsystem HIDD object @ %p\n", LIBBASE->sis900b_PCI));

            struct Hook FindHook = {
                h_Entry:    (IPTR (*)())PCI_Enumerator,
                h_Data:     LIBBASE,
            };
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
static int KBD_InitClass(struct kbdbase *LIBBASE)
{
    struct Library *OOPBase = LIBBASE->csd.cs_OOPBase;

    D(bug("[KBD] base class initialization\n"));
    
    LIBBASE->csd.cs_UtilityBase = OpenLibrary("utility.library", 0);
    if (!LIBBASE->csd.cs_UtilityBase)
        return FALSE;

    LIBBASE->csd.hiddKbdAB = OOP_ObtainAttrBase(IID_Hidd_Kbd);
    LIBBASE->csd.hwAB = OOP_ObtainAttrBase(IID_HW);
    LIBBASE->csd.hwMB = OOP_GetMethodID(IID_HW, 0);

    if (LIBBASE->csd.hiddKbdAB && LIBBASE->csd.hwAB)
    {
        OOP_Object *root = OOP_NewObject(NULL, CLID_HW_Root, NULL);

        NewList((struct List *)&LIBBASE->csd.callbacks);

        if (HW_AddDriver(root, LIBBASE->csd.hwClass, NULL))
        {
            D(bug("[KBD] Everything OK\n"));
            return TRUE;
        }
    }

    return FALSE;
}
Exemplo n.º 4
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.º 5
0
static int System_Init(LIBBASETYPEPTR LIBBASE)
{
    struct class_static_data *csd = &LIBBASE->hsi_csd;
    struct Library *OOPBase = csd->cs_OOPBase;

    D(bug("[HiddSystem] %s()\n", __PRETTY_FUNCTION__));

    OOP_Object *hwroot = OOP_NewObject(NULL, CLID_HW_Root, NULL);
    csd->hwAttrBase = OOP_ObtainAttrBase(IID_HW);

    if (HW_AddDriver(hwroot, csd->oopclass, NULL))
    {
        D(bug("[HiddSystem] %s: initialised\n", __PRETTY_FUNCTION__));
        return TRUE;
    }
    D(bug("[HiddSystem] %s: failed\n", __PRETTY_FUNCTION__));
    
    return FALSE;
}
Exemplo n.º 6
0
static int ata_expunge(struct ataBase *ATABase)
{
    if (ATABase->ataObj)
    {
        /*
         * CLID_Hidd_Storage is a singletone, you can get it as many times as
         * you want. Here we save up some space in struct ataBase by
         * obtaining storageRoot object only when we need it. This happens
         * rarely, so small performance loss is OK here.
         */
        OOP_Object *storageRoot = OOP_NewObject(NULL, CLID_Hidd_Storage, NULL);

        if (storageRoot && HW_RemoveDriver(storageRoot, ATABase->ataObj))
        {
            /* Destroy our singletone */
            OOP_MethodID disp_msg = OOP_GetMethodID(IID_Root, moRoot_Dispose);

            D(bug("[ATA  ] ata_expunge: Stopping Daemon...\n"));
            ATABase->daemonParent = FindTask(NULL);
            SetSignal(0, SIGF_SINGLE);
            Signal(ATABase->ata_Daemon, SIGBREAKF_CTRL_C);
            Wait(SIGF_SINGLE);

            D(bug("[ATA  ] ata_expunge: Done, destroying subystem object\n"));
            OOP_DoSuperMethod(ATABase->ataClass, ATABase->ataObj, &disp_msg);
        }
        else
        {
            /* Our subsystem is in use, we have some bus driver(s) around. */
            D(bug("[ATA  ] ata_expunge: ATA subsystem is in use\n"));
            return FALSE;
        }
    }

    D(bug("[ATA  ] ata_expunge: Releasing attribute bases\n"));
    OOP_ReleaseAttrBasesArray(&ATABase->hwAttrBase, attrBaseIDs);

    if (ATABase->ata_UtilityBase)
        CloseLibrary(ATABase->ata_UtilityBase);

    D(bug("[ATA  ] ata_expunge: Exiting\n"));
    return TRUE;
}
Exemplo n.º 7
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.º 8
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.º 9
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.º 10
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.º 11
0
OOP_Class *init_serialunitclass (struct class_static_data *csd)
{
	OOP_Class *cl = NULL;
    
	struct OOP_MethodDescr serialunithiddroot_descr[NUM_ROOT_METHODS + 1] = 
	{
		{(IPTR (*)())serialunit_new,		moRoot_New},
		{(IPTR (*)())serialunit_dispose,	moRoot_Dispose},
/*
		{(IPTR (*)())serialunit_set,		moRoot_Set},
		{(IPTR (*)())serialunit_get,		moRoot_Get},
*/
		{NULL, 0UL}
	};
    
	struct OOP_MethodDescr serialunithidd_descr[NUM_SERIALUNIT_METHODS + 1] =
	{
		{(IPTR (*)())serialunit_init,		moHidd_SerialUnit_Init},
		{(IPTR (*)())serialunit_write,		moHidd_SerialUnit_Write},
		{(IPTR (*)())serialunit_setbaudrate,	moHidd_SerialUnit_SetBaudrate},
		{(IPTR (*)())serialunit_setparameters,	moHidd_SerialUnit_SetParameters},
		{(IPTR (*)())serialunit_sendbreak,	moHidd_SerialUnit_SendBreak},
		{(IPTR (*)())serialunit_start,		moHidd_SerialUnit_Start},
		{(IPTR (*)())serialunit_stop,		moHidd_SerialUnit_Stop},
		{(IPTR (*)())serialunit_getcapabilities,moHidd_SerialUnit_GetCapabilities},
		{(IPTR (*)())serialunit_getstatus      ,moHidd_SerialUnit_GetStatus},
		{NULL, 0UL}
	};
    
	struct OOP_InterfaceDescr ifdescr[] =
	{
		{serialunithiddroot_descr	, IID_Root		, NUM_ROOT_METHODS},
		{serialunithidd_descr		, IID_Hidd_SerialUnit	, NUM_SERIALUNIT_METHODS},
		{NULL, NULL, 0}
	};

	OOP_AttrBase MetaAttrBase = OOP_GetAttrBase(IID_Meta);
    	
	struct TagItem tags[] =
	{
		{ aMeta_SuperID,                (IPTR)CLID_Root},
		{ aMeta_InterfaceDescr,         (IPTR)ifdescr},
		{ aMeta_ID,                     (IPTR)CLID_Hidd_SerialUnit},
		{ aMeta_InstSize,               (IPTR)sizeof (struct HIDDSerialUnitData) },
		{TAG_DONE, 0UL}
	};


	EnterFunc(bug("    init_serialunitclass(csd=%p)\n", csd));

	cl = OOP_NewObject(NULL, CLID_HiddMeta, tags);
	D(bug("Class=%p\n", cl));
	if (cl) {
		__IHidd_SerialUnitAB = OOP_ObtainAttrBase(IID_Hidd_SerialUnit);
		if (NULL != __IHidd_SerialUnitAB) {
			D(bug("SerialUnit Class ok\n"));
			cl->UserData = (APTR)csd;

			OOP_AddClass(cl);
		} else {
			free_serialunitclass(csd);
			cl = NULL;
		}
	}

	ReturnPtr("init_serialunitclass", OOP_Class *, cl);
}
Exemplo n.º 12
0
/*
    Here shall we start. Make function static as it shouldn't be visible from
    outside.
*/
static int ata_init(struct ataBase *ATABase)
{
    OOP_Object *storageRoot;
    struct BootLoaderBase	*BootLoaderBase;

    D(bug("[ATA--] ata_init: ata.device Initialization\n"));

    ATABase->ata_UtilityBase = OpenLibrary("utility.library", 36);
    if (!ATABase->ata_UtilityBase)
        return FALSE;

    /*
     * I've decided to use memory pools again. Alloc everything needed from 
     * a pool, so that we avoid memory fragmentation.
     */
    ATABase->ata_MemPool = CreatePool(MEMF_CLEAR | MEMF_PUBLIC | MEMF_SEM_PROTECTED , 8192, 4096);
    if (ATABase->ata_MemPool == NULL)
        return FALSE;

    D(bug("[ATA--] ata_init: MemPool @ %p\n", ATABase->ata_MemPool));

    if (OOP_ObtainAttrBasesArray(&ATABase->unitAttrBase, attrBaseIDs))
        return FALSE;

    /* This is our own method base, so no check needed */
    if (OOP_ObtainMethodBasesArray(&ATABase->hwMethodBase, &attrBaseIDs[ATA_METHOD_ID_START]))
        return FALSE;

    storageRoot = OOP_NewObject(NULL, CLID_Hidd_Storage, NULL);
    if (!storageRoot)
        storageRoot = OOP_NewObject(NULL, CLID_HW_Root, NULL);
    if (!storageRoot)
        return FALSE;

    if (!HW_AddDriver(storageRoot, ATABase->ataClass, NULL))
        return FALSE;

    /* Set default ata.device config options */
    ATABase->ata_32bit   = FALSE;
    ATABase->ata_NoMulti = FALSE;
    ATABase->ata_NoDMA   = FALSE;
    ATABase->ata_Poll    = FALSE;

    /*
     * start initialization: 
     * obtain kernel parameters
     */
    BootLoaderBase = OpenResource("bootloader.resource");
    D(bug("[ATA--] ata_init: BootloaderBase = %p\n", BootLoaderBase));
    if (BootLoaderBase != NULL)
    {
        struct List *list;
        struct Node *node;

        list = (struct List *)GetBootInfo(BL_Args);
        if (list)
        {
            ForeachNode(list, node)
            {
                if (strncmp(node->ln_Name, "ATA=", 4) == 0)
                {
                    const char *CmdLine = &node->ln_Name[4];

                    if (strstr(CmdLine, "32bit"))
                    {
                        D(bug("[ATA  ] ata_init: Using 32-bit IO transfers\n"));
                        ATABase->ata_32bit = TRUE;
                    }
		    if (strstr(CmdLine, "nomulti"))
		    {
			D(bug("[ATA  ] ata_init: Disabled multisector transfers\n"));
			ATABase->ata_NoMulti = TRUE;
		    }
                    if (strstr(CmdLine, "nodma"))
                    {
                        D(bug("[ATA  ] ata_init: Disabled DMA transfers\n"));
                        ATABase->ata_NoDMA = TRUE;
                    }
                    if (strstr(CmdLine, "poll"))
                    {
                        D(bug("[ATA  ] ata_init: Using polling to detect end of busy state\n"));
                        ATABase->ata_Poll = TRUE;
                    }
                }
            }
        }
    }

    /* Try to setup daemon task looking for diskchanges */
    NEWLIST(&ATABase->Daemon_ios);
    InitSemaphore(&ATABase->DaemonSem);
    InitSemaphore(&ATABase->DetectionSem);
    ATABase->daemonParent = FindTask(NULL);
    SetSignal(0, SIGF_SINGLE);

    if (!NewCreateTask(TASKTAG_PC, DaemonCode,
                       TASKTAG_NAME       , "ATA.daemon",
                       TASKTAG_STACKSIZE  , STACK_SIZE,
                       TASKTAG_TASKMSGPORT, &ATABase->DaemonPort,
                       TASKTAG_PRI        , TASK_PRI - 1,	/* The daemon should have a little bit lower Pri than handler tasks */
                       TASKTAG_ARG1       , ATABase,
                       TAG_DONE))
    {
        D(bug("[ATA  ] Failed to start up daemon!\n"));
        return FALSE;
    }

    /* Wait for handshake */
    Wait(SIGF_SINGLE);
    D(bug("[ATA  ] Daemon task set to 0x%p\n", ATABase->ata_Daemon));

    return ATABase->ata_Daemon ? TRUE : FALSE;
}