2 Copyright (C) 2018-2019, The AROS Development Team.
6 #include <aros/debug.h>
8 #define MUIMASTER_YES_INLINE_STDARG
10 #include <proto/sysexp.h>
11 #include <proto/storage.h>
13 #include <proto/alib.h>
14 #include <proto/exec.h>
15 #include <proto/muimaster.h>
16 #include <proto/utility.h>
17 #include <proto/intuition.h>
19 #include <exec/memory.h>
20 #include <libraries/mui.h>
21 #include <zune/customclasses.h>
22 #include <mui/NFloattext_mcc.h>
23 #include <utility/tagitem.h>
24 #include <utility/hooks.h>
26 #include <hidd/storage.h>
27 #include <hidd/ahci.h>
31 #include "ahci_classes.h"
32 #include "ahci_intern.h"
38 extern OOP_AttrBase HiddAHCIUnitAB
;
39 extern OOP_AttrBase HiddStorageUnitAB
;
41 /*** Instance Data **********************************************************/
42 struct AHCIUnitWindow_DATA
47 static const char *const featNames
[] =
49 "Write Cache" , "Read Ahead" , "Security Freeze Lock ",
53 static void DecodeBits(char *str
, ULONG flags
, const char *const *names
)
55 unsigned char i
, done
;
57 for (i
= 0, done
= 0; *names
; names
++)
59 if ((IPTR
)*names
< 32)
67 str
+= strlen(*names
);
80 static Object
*AHCIUnitWindow__OM_NEW(Class
*cl
, Object
*self
, struct opSet
*msg
)
82 Object
*window
, *ahcigroup
;
83 OOP_Object
*dev
= (OOP_Object
*)GetTagData(MUIA_PropertyWin_Object
, 0, msg
->ops_AttrList
);
84 char feature_str
[256];
90 /* AHCI specific attributes ... */
91 OOP_GetAttr(dev
, aHidd_AHCIUnit_Features
, &val
);
92 DecodeBits(feature_str
, val
, featNames
);
94 window
= (Object
*) DoSuperNewTags
97 Child
, (IPTR
)(ahcigroup
= (ColGroup(2),
98 MUIA_Group_SameSize
, TRUE
,
99 MUIA_FrameTitle
, (IPTR
)"AHCI",
101 MUIA_Background
, MUII_GroupBack
,
102 Child
, (IPTR
)Label("Features"),
103 Child
, (IPTR
)(ScrollgroupObject
,
105 MUIA_Background
, MUII_TextBack
,
106 MUIA_Scrollgroup_Contents
, (IPTR
)(NFloattextObject
,
108 MUIA_Background
, MUII_TextBack
,
110 MUIA_Floattext_Text
, (IPTR
)feature_str
,
114 TAG_MORE
, (IPTR
) msg
->ops_AttrList
,
120 OOP_GetAttr(dev
, aHidd_StorageUnit_Device
, &unitdev
);
121 OOP_GetAttr(dev
, aHidd_StorageUnit_Number
, &val
);
122 QueryATAStorageFeatures(ahcigroup
, (char *)unitdev
, val
);
127 /*** Setup ******************************************************************/
128 BOOPSI_DISPATCHER_PROTO(IPTR
, AHCIUnitWindow_Dispatcher
, cl
, self
, msg
);
129 BOOPSI_DISPATCHER(IPTR
, AHCIUnitWindow_Dispatcher
, cl
, self
, msg
)
131 switch (msg
->MethodID
)
134 return (IPTR
) AHCIUnitWindow__OM_NEW(cl
, self
, (struct opSet
*)msg
);
137 return DoSuperMethodA(cl
, self
, msg
);
142 BOOPSI_DISPATCHER_END
144 int AHCIUnitWindow_Initialize(struct SysexpBase
*SysexpBase
)
146 struct SysexpAHCIBase
*AhciBase
= GetBase("AHCI.Module");
147 struct MUI_CustomClass
*SUWClass
;
149 D(bug("[ahci.sysexp] %s: AhciBase @ %p\n", __func__
, AhciBase
));
153 SUWClass
= GetBase("StorageUnitWindow.Class");
154 D(bug("[ahci.sysexp] %s: StorageUnitWindow.Class @ %p\n", __func__
, SUWClass
));
155 AhciBase
->seab_AHCIUnitWindowCLASS
= MUI_CreateCustomClass
157 NULL
, NULL
, SUWClass
,
158 sizeof(struct AHCIUnitWindow_DATA
), (APTR
) AHCIUnitWindow_Dispatcher
160 if (AhciBase
->seab_AHCIUnitWindowCLASS
)
162 D(bug("[ahci.sysexp] %s: AHCIUnitWindowCLASS @ %p\n", __func__
, AhciBase
->seab_AHCIUnitWindowCLASS
));
163 AhciBase
->seab_AHCIUnitWindowCLASS
->mcc_Class
->cl_UserData
= (IPTR
)AhciBase
;
166 if (!AhciBase
|| !AhciBase
->seab_AHCIUnitWindowCLASS
)
170 "Failed to create `AHCIUnitWindow' custom class.", NULL
179 void AHCIUnitWindow_Deinitialize(struct SysexpBase
*SysexpBase
)
181 struct SysexpAHCIBase
*AhciBase
= GetBase("AHCI.Module");
182 MUI_DeleteCustomClass(AhciBase
->seab_AHCIUnitWindowCLASS
);