2 Copyright (C) 2013-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>
31 #include "ata_classes.h"
32 #include "ata_intern.h"
38 extern OOP_AttrBase HiddATAUnitAB
;
39 extern OOP_AttrBase HiddStorageUnitAB
;
41 struct MUI_CustomClass
* ATAUnitWindow_CLASS
;
43 /*** Instance Data **********************************************************/
44 struct ATAUnitWindow_DATA
49 static const char *const xferModeNames
[] =
51 "PIO0" , "PIO1" , "PIO2 ", "PIO3" , "PIO4" ,
52 "MDMA0", "MDMA1", "MDMA2",
53 "UDMA0", "UDMA1", "UDMA2", "UDMA3", "UDMA4", "UDMA5", "UDMA6",
54 (const char *)AB_XFER_48BIT
,
55 "LBA48", "Multisector", "ATAPI", "LBA", "PIO32",
59 static void DecodeBits(char *str
, ULONG flags
, const char *const *names
)
61 unsigned char i
, done
;
63 for (i
= 0, done
= 0; *names
; names
++)
65 if ((IPTR
)*names
< 32)
73 str
+= strlen(*names
);
86 static Object
*ATAUnitWindow__OM_NEW(Class
*cl
, Object
*self
, struct opSet
*msg
)
88 Object
*window
, *atagroup
;
89 OOP_Object
*dev
= (OOP_Object
*)GetTagData(MUIA_PropertyWin_Object
, 0, msg
->ops_AttrList
);
90 char xfermodes_str
[256];
91 char usemodes_str
[256];
92 char multisector_str
[4];
98 /* ATA specific attributes ... */
99 OOP_GetAttr(dev
, aHidd_ATAUnit_XferModes
, &val
);
100 DecodeBits(xfermodes_str
, val
, xferModeNames
);
102 OOP_GetAttr(dev
, aHidd_ATAUnit_ConfiguredModes
, &val
);
103 DecodeBits(usemodes_str
, val
, xferModeNames
);
105 OOP_GetAttr(dev
, aHidd_ATAUnit_MultiSector
, &val
);
106 snprintf(multisector_str
, sizeof(multisector_str
), "%ld", val
);
107 window
= (Object
*) DoSuperNewTags
110 Child
, (IPTR
)(atagroup
= (ColGroup(2),
111 MUIA_Group_SameSize
, TRUE
,
112 MUIA_FrameTitle
, (IPTR
)"IDE/ATA",
114 MUIA_Background
, MUII_GroupBack
,
115 Child
, (IPTR
)Label(_(MSG_TRANSFER_MODES
)),
116 Child
, (IPTR
)(ScrollgroupObject
,
118 MUIA_Background
, MUII_TextBack
,
119 MUIA_Scrollgroup_Contents
, (IPTR
)(NFloattextObject
,
121 MUIA_Background
, MUII_TextBack
,
123 MUIA_Floattext_Text
, (IPTR
)xfermodes_str
,
126 Child
, (IPTR
)Label(_(MSG_CONFIG_MODES
)),
127 Child
, (IPTR
)(ScrollgroupObject
,
129 MUIA_Background
, MUII_TextBack
,
130 MUIA_Scrollgroup_Contents
, (IPTR
)(NFloattextObject
,
132 MUIA_Background
, MUII_TextBack
,
134 MUIA_Floattext_Text
, (IPTR
)usemodes_str
,
137 Child
, (IPTR
)Label(_(MSG_MULTISECTOR
)),
138 Child
, (IPTR
)(TextObject
,
140 MUIA_Background
, MUII_TextBack
,
142 MUIA_Text_Contents
, (IPTR
)multisector_str
,
145 TAG_MORE
, (IPTR
) msg
->ops_AttrList
,
151 OOP_GetAttr(dev
, aHidd_StorageUnit_Device
, &unitdev
);
152 OOP_GetAttr(dev
, aHidd_StorageUnit_Number
, &val
);
153 QueryATAStorageFeatures(atagroup
, (char *)unitdev
, val
);
158 /*** Setup ******************************************************************/
159 BOOPSI_DISPATCHER_PROTO(IPTR
, ATAUnitWindow_Dispatcher
, __class
, __self
, __msg
);
160 BOOPSI_DISPATCHER(IPTR
, ATAUnitWindow_Dispatcher
, __class
, __self
, __msg
)
162 switch (__msg
->MethodID
)
165 return (IPTR
) ATAUnitWindow__OM_NEW(__class
, __self
, (struct opSet
*)__msg
);
168 return DoSuperMethodA(__class
, __self
, __msg
);
173 BOOPSI_DISPATCHER_END
175 int ATAUnitWindow_Initialize(struct SysexpBase
*SysexpBase
)
177 struct SysexpATABase
*AtaBase
= GetBase("ATA.Module");
178 struct MUI_CustomClass
*SUWClass
;
180 D(bug("[ata.sysexp] %s: AtaBase @ %p\n", __func__
, AtaBase
));
184 SUWClass
= GetBase("StorageUnitWindow.Class");
185 D(bug("[ata.sysexp] %s: StorageUnitWindow.Class @ %p\n", __func__
, SUWClass
));
186 AtaBase
->seab_ATAUnitWindowCLASS
= MUI_CreateCustomClass
188 NULL
, NULL
, SUWClass
,
189 sizeof(struct ATAUnitWindow_DATA
), (APTR
) ATAUnitWindow_Dispatcher
191 if (AtaBase
->seab_ATAUnitWindowCLASS
)
193 D(bug("[ata.sysexp] %s: ATAUnitWindowCLASS @ %p\n", __func__
, AtaBase
->seab_ATAUnitWindowCLASS
));
194 AtaBase
->seab_ATAUnitWindowCLASS
->mcc_Class
->cl_UserData
= (IPTR
)AtaBase
;
197 if (!AtaBase
|| !AtaBase
->seab_ATAUnitWindowCLASS
)
201 "Failed to create `ATAUnitWindow' custom class.", NULL
210 void ATAUnitWindow_Deinitialize(struct SysexpBase
*SysexpBase
)
212 struct SysexpATABase
*AtaBase
= GetBase("ATA.Module");
213 MUI_DeleteCustomClass(AtaBase
->seab_ATAUnitWindowCLASS
);