From 32e0876c86f8e1ae1b7155b6d861f525826d3cc5 Mon Sep 17 00:00:00 2001 From: DizzyOfCRN Date: Wed, 17 Sep 2014 10:44:41 +0000 Subject: [PATCH] Start of felsunxi.class, binds with Allwinner SoC when SoC is in FEL mode - Idea with this is to make it a Aros installer for Allwinner SoCs - Porting Aros to Allwinner SoC has a problem that we would need UBoot (or equivalent bootloader) that is specially build for one platform and one platform only (eg. pcDuino to setup the hardware) - We are trying to bypass the problem by not using UBoot at all, instead we will install generic Allwinner Aros port directly to NAND and the installer gives user the opportunity to inform bootstrap about the hardware with Zune GUI that pops up (debug serial port, dram size, dram speed, NAND size, power IC etc.) - Information is then written on a structure to some NAND location where the bootstrap code finds it... - All platform dependand code will be removed from arm-aros-sunxi, instead a generic build is setup and all needed modules will be installed with the said installer to NAND git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49641 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/usb/classes/felsunxi/class_DeviceBinding.c | 72 +++++++++++++++++++ rom/usb/classes/felsunxi/class_DoMethodA.c | 95 ++++++++++++++++++++++++++ rom/usb/classes/felsunxi/class_GetAttrsA.c | 86 +++++++++++++++++++++++ rom/usb/classes/felsunxi/class_Library.c | 39 +++++++++++ rom/usb/classes/felsunxi/class_SetAttrsA.c | 55 +++++++++++++++ rom/usb/classes/felsunxi/felsunxi.conf | 16 +++++ rom/usb/classes/felsunxi/felsunxi_intern.h | 42 ++++++++++++ rom/usb/classes/felsunxi/mmakefile.src | 12 ++++ rom/usb/classes/mmakefile.src | 6 +- 9 files changed, 421 insertions(+), 2 deletions(-) create mode 100644 rom/usb/classes/felsunxi/class_DeviceBinding.c create mode 100644 rom/usb/classes/felsunxi/class_DoMethodA.c create mode 100644 rom/usb/classes/felsunxi/class_GetAttrsA.c create mode 100644 rom/usb/classes/felsunxi/class_Library.c create mode 100644 rom/usb/classes/felsunxi/class_SetAttrsA.c create mode 100644 rom/usb/classes/felsunxi/felsunxi.conf create mode 100644 rom/usb/classes/felsunxi/felsunxi_intern.h create mode 100644 rom/usb/classes/felsunxi/mmakefile.src diff --git a/rom/usb/classes/felsunxi/class_DeviceBinding.c b/rom/usb/classes/felsunxi/class_DeviceBinding.c new file mode 100644 index 0000000000..e3cc351bb8 --- /dev/null +++ b/rom/usb/classes/felsunxi/class_DeviceBinding.c @@ -0,0 +1,72 @@ +/* + Copyright © 2014, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ + +#ifdef DEBUG +#undef DEBUG +#endif +#define DEBUG 1 + +#include "felsunxi_intern.h" + +struct FELSunxiDevice * AttemptDeviceBinding(LIBBASETYPEPTR LIBBASE, struct PsdDevice *pd) { + mybug(-1,("FELSunxi AttemptDeviceBinding\n")); + + struct Library *ps; + + IPTR prodid; + IPTR vendid; + + if((ps = OpenLibrary("poseidon.library", 4))) { + psdGetAttrs(PGA_DEVICE, pd, DA_VendorID, &vendid, DA_ProductID, &prodid, TAG_END); + CloseLibrary(ps); + if((vendid == 0x1f3a) && (prodid == 0xefe8)) { + return(ForceDeviceBinding(LIBBASE, pd)); + } + } + + return NULL; +} + +struct FELSunxiDevice * ForceDeviceBinding(LIBBASETYPEPTR LIBBASE, struct PsdDevice *pd) { + mybug(-1,("FELSunxi ForceDeviceBinding\n")); + + struct FELSunxiDevice *FELSunxiDevice; + struct Library *ps; + + if((ps = OpenLibrary("poseidon.library", 4))) { + if((FELSunxiDevice = psdAllocVec(sizeof(struct FELSunxiDevice)))) { + + ObtainSemaphore(&LIBBASE->device_listlock); + AddTail(&LIBBASE->device_list, &FELSunxiDevice->node); + ReleaseSemaphore(&LIBBASE->device_listlock); + + CloseLibrary(ps); + return FELSunxiDevice; + } + CloseLibrary(ps); + } + + return NULL; +} + +void ReleaseDeviceBinding(LIBBASETYPEPTR LIBBASE, struct FELSunxiDevice *FELSunxiDevice) { + mybug(-1,("FELSunxi ReleaseDeviceBinding\n")); + + struct Library *ps; + + if((ps = OpenLibrary("poseidon.library", 4))) { + + ObtainSemaphore(&LIBBASE->device_listlock); + Remove(&FELSunxiDevice->node); + ReleaseSemaphore(&LIBBASE->device_listlock); + + psdFreeVec(FELSunxiDevice); + CloseLibrary(ps); + } +} + diff --git a/rom/usb/classes/felsunxi/class_DoMethodA.c b/rom/usb/classes/felsunxi/class_DoMethodA.c new file mode 100644 index 0000000000..c51338387d --- /dev/null +++ b/rom/usb/classes/felsunxi/class_DoMethodA.c @@ -0,0 +1,95 @@ +/* + Copyright © 2014, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ + +#ifdef DEBUG +#undef DEBUG +#endif +#define DEBUG 1 + +#include "felsunxi_intern.h" + +/***************************************************************************** + + NAME */ + + AROS_LH2(IPTR, DoMethodA, + +/* SYNOPSIS */ + AROS_LHA(ULONG, methodid, D0), + AROS_LHA(IPTR *, methoddata, A1), + +/* LOCATION */ + LIBBASETYPEPTR, LIBBASE, 7, FELSunxi) + +/* FUNCTION + + INPUTS + + RESULT + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + + HISTORY + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + switch(methodid) { + + case UCM_AttemptDeviceBinding: + mybug(-1,("FELSunxi DoMethodA AttemptDeviceBinding\n")); + return((IPTR) AttemptDeviceBinding(LIBBASE, (struct PsdDevice *) methoddata[0])); + break; + case UCM_ForceDeviceBinding: + mybug(-1,("FELSunxi DoMethodA ForceDeviceBinding\n")); + return((IPTR) ForceDeviceBinding(LIBBASE, (struct PsdDevice *) methoddata[0])); + break; + case UCM_ReleaseDeviceBinding: + mybug(-1,("FELSunxi DoMethodA ReleaseDeviceBinding\n")); + ReleaseDeviceBinding(LIBBASE, (struct FELSunxiDevice *) methoddata[0]); + return(TRUE); + break; + + case UCM_AttemptInterfaceBinding: + mybug(-1,("FELSunxi DoMethodA AttemptInterfaceBinding\n")); + break; + case UCM_ForceInterfaceBinding: + mybug(-1,("FELSunxi DoMethodA ForceInterfaceBinding\n")); + break; + case UCM_ReleaseInterfaceBinding: + mybug(-1,("FELSunxi DoMethodA ReleaseInterfaceBinding\n")); + break; + + case UCM_OpenCfgWindow: + mybug(-1,("FELSunxi DoMethodA OpenCfgWindow\n")); + break; + case UCM_OpenBindingCfgWindow: + mybug(-1,("FELSunxi DoMethodA OpenBindingCfgWindow\n")); + break; + case UCM_ConfigChangedEvent: + mybug(-1,("FELSunxi DoMethodA ConfigChangedEvent\n")); + break; + + default: + mybug(-1,("FELSunxi DoMethodA default\n")); + break; + } + + return(0); + AROS_LIBFUNC_EXIT + +} /* DoMethodA */ diff --git a/rom/usb/classes/felsunxi/class_GetAttrsA.c b/rom/usb/classes/felsunxi/class_GetAttrsA.c new file mode 100644 index 0000000000..31caaa63a5 --- /dev/null +++ b/rom/usb/classes/felsunxi/class_GetAttrsA.c @@ -0,0 +1,86 @@ +/* + Copyright © 2014, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ + +#ifdef DEBUG +#undef DEBUG +#endif +#define DEBUG 1 + +#include "felsunxi_intern.h" + +/***************************************************************************** + + NAME */ + + AROS_LH3(ULONG, GetAttrsA, + +/* SYNOPSIS */ + AROS_LHA(ULONG, type, D0), + AROS_LHA(APTR, usbstruct, A0), + AROS_LHA(struct TagItem *, taglist, D0), + +/* LOCATION */ + LIBBASETYPEPTR, FELSunxiBase, 5, FELSunxi) + +/* FUNCTION + + INPUTS + + RESULT + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + + HISTORY + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + struct TagItem *tag; + ULONG count = 0; + + switch(type) { + case UGA_CLASS: { + while((tag = LibNextTagItem(&taglist)) != NULL) { + switch (tag->ti_Tag) { + case UCCA_Description: + *((STRPTR *) tag->ti_Data) = "Support for Allwinner FEL mode"; + count++; + break; + } + } + break; + } + + case UGA_BINDING: { + while((tag = LibNextTagItem(&taglist)) != NULL) { + switch (tag->ti_Tag) { + case UCBA_UsingDefaultCfg: + //*((IPTR *) tag->ti_Data) = ((struct NepClassHid *) usbstruct)->nch_UsingDefaultCfg; + //*((IPTR *) tag->ti_Data) = 0; + //count++; + break; + } + } + break; + } + + } + + return count; + AROS_LIBFUNC_EXIT + +} /* GetAttrsA */ diff --git a/rom/usb/classes/felsunxi/class_Library.c b/rom/usb/classes/felsunxi/class_Library.c new file mode 100644 index 0000000000..1a493ca5b3 --- /dev/null +++ b/rom/usb/classes/felsunxi/class_Library.c @@ -0,0 +1,39 @@ +/* + Copyright © 2014, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ + +#ifdef DEBUG +#undef DEBUG +#endif +#define DEBUG 1 + +#include "felsunxi_intern.h" + +static const STRPTR libname = MOD_NAME_STRING; + +static int libInit(LIBBASETYPEPTR LIBBASE) { + mybug(0,("FELSunxi libInit\n")); + + NEWLIST(&LIBBASE->device_list); + InitSemaphore(&LIBBASE->device_listlock); + + return(TRUE); +} + +static int libOpen(LIBBASETYPEPTR LIBBASE) { + mybug(0,("FELSunxi libOpen\n")); + return(TRUE); +} + +static int libExpunge(LIBBASETYPEPTR LIBBASE) { + mybug(0,("FELSunxi libExpunge\n")); + return(TRUE); +} + +ADD2INITLIB(libInit, 0) +ADD2OPENLIB(libOpen, 0) +ADD2EXPUNGELIB(libExpunge, 0) diff --git a/rom/usb/classes/felsunxi/class_SetAttrsA.c b/rom/usb/classes/felsunxi/class_SetAttrsA.c new file mode 100644 index 0000000000..d5e842a38b --- /dev/null +++ b/rom/usb/classes/felsunxi/class_SetAttrsA.c @@ -0,0 +1,55 @@ +/* + Copyright © 2014, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ + +#ifdef DEBUG +#undef DEBUG +#endif +#define DEBUG 1 + +#include "felsunxi_intern.h" + +/***************************************************************************** + + NAME */ + + AROS_LH3(ULONG, SetAttrsA, + +/* SYNOPSIS */ + AROS_LHA(ULONG, type, D0), + AROS_LHA(APTR, usbstruct, A0), + AROS_LHA(struct TagItem *, taglist, D0), + +/* LOCATION */ + LIBBASETYPEPTR, FELSunxiBase, 6, FELSunxi) + +/* FUNCTION + + INPUTS + + RESULT + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + + HISTORY + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + return(0); + AROS_LIBFUNC_EXIT + +} /* SetAttrsA */ diff --git a/rom/usb/classes/felsunxi/felsunxi.conf b/rom/usb/classes/felsunxi/felsunxi.conf new file mode 100644 index 0000000000..1d91b33d45 --- /dev/null +++ b/rom/usb/classes/felsunxi/felsunxi.conf @@ -0,0 +1,16 @@ +##begin config +basename FELSunxi +libbase FELSunxiBase +libbasetype struct FELSunxiBase +version 0.1 +##end config + +##begin cdefprivate +#include "felsunxi_intern.h" +##end cdefprivate + +##begin functionlist +LONG GetAttrsA(ULONG type, APTR usbstruct, struct TagItem *taglist) (D0,A0,A1) +LONG SetAttrsA(ULONG type, APTR usbstruct, struct TagItem *taglist) (D0,A0,A1) +IPTR DoMethodA(ULONG methodid, IPTR *methoddata) (D0,A1) +##end functionlist diff --git a/rom/usb/classes/felsunxi/felsunxi_intern.h b/rom/usb/classes/felsunxi/felsunxi_intern.h new file mode 100644 index 0000000000..2c83097935 --- /dev/null +++ b/rom/usb/classes/felsunxi/felsunxi_intern.h @@ -0,0 +1,42 @@ +/* + Copyright © 2014, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: english +*/ +#ifndef FELSUNXI_INTERN_H +#define FELSUNXI_INTERN_H + +#include + +#include +#include +#include +#include +#include +#include + +#include LC_LIBDEFS_FILE + +#define MYBUG_LEVEL 1 +#define mybug(l, x) D(if ((l>=MYBUG_LEVEL)||(l==-1)) { do { { bug x; } } while (0); } ) +#define mybug_unit(l, x) D(if ((l>=MYBUG_LEVEL)||(l==-1)) { do { { bug("%s %s: ", unit->name, __FUNCTION__); bug x; } } while (0); } ) + +struct FELSunxiDevice { + struct Node node; +}; + +struct FELSunxiBase { + struct Library library; + + struct List device_list; + struct SignalSemaphore device_listlock; +}; + +struct FELSunxiDevice * AttemptDeviceBinding(LIBBASETYPEPTR LIBBASE, struct PsdDevice *pd); +struct FELSunxiDevice * ForceDeviceBinding(LIBBASETYPEPTR LIBBASE, struct PsdDevice *pd); +void ReleaseDeviceBinding(LIBBASETYPEPTR LIBBASE, struct FELSunxiDevice *FELSunxiDevice); + +#endif /* FELSUNXI_INTERN_H */ + diff --git a/rom/usb/classes/felsunxi/mmakefile.src b/rom/usb/classes/felsunxi/mmakefile.src new file mode 100644 index 0000000000..8948cd84c6 --- /dev/null +++ b/rom/usb/classes/felsunxi/mmakefile.src @@ -0,0 +1,12 @@ +# $Id$ +include $(TOP)/config/make.cfg + +FUNCS := class_Library class_DoMethodA class_GetAttrsA class_SetAttrsA class_DeviceBinding + +#MM- kernel-usb-classes-felsunxi : kernel-usb-usbclass kernel-usb-poseidon-includes + +%build_module mmake=kernel-usb-classes-felsunxi \ + modname=felsunxi modtype=usbclass modsuffix="class" \ + files=$(FUNCS) + +%common diff --git a/rom/usb/classes/mmakefile.src b/rom/usb/classes/mmakefile.src index 26de07ed83..ec016816d4 100644 --- a/rom/usb/classes/mmakefile.src +++ b/rom/usb/classes/mmakefile.src @@ -27,7 +27,8 @@ include $(TOP)/config/make.cfg #MM kernel-usb-classes-serialpl2303 \ #MM kernel-usb-classes-simplemidi \ #MM kernel-usb-classes-stir4200 \ -#MM kernel-usb-classes-rndis +#MM kernel-usb-classes-rndis \ +#MM kernel-usb-classes-felsunxi # Build complete set of classes on disk #MM kernel-usb-classes : \ @@ -71,7 +72,8 @@ include $(TOP)/config/make.cfg #MM kernel-usb-classes-serialpl2303-clean \ #MM kernel-usb-classes-simplemidi-clean \ #MM kernel-usb-classes-stir4200-clean \ -#MM kernel-usb-classes-rndis-clean +#MM kernel-usb-classes-rndis-clean \ +#MM kernel-usb-classes-felsunxi-clean .PHONY: kernel-usb-classes .PHONY: kernel-usb-classes-kobj -- 2.11.4.GIT