disable debug
[AROS.git] / workbench / tools / SysExplorer / Modules / ATA / ataunit_window_cl.c
blobfe4cdbd621f6c10105837ad44d8ddf126da6a4aa
1 /*
2 Copyright (C) 2013-2019, The AROS Development Team.
3 $Id$
4 */
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/ata.h>
29 #include "locale.h"
31 #include "ata_classes.h"
32 #include "ata_intern.h"
34 #include <ctype.h>
35 #include <stdio.h>
36 #include <stdlib.h>
38 extern OOP_AttrBase HiddATAUnitAB;
39 extern OOP_AttrBase HiddStorageUnitAB;
41 struct MUI_CustomClass * ATAUnitWindow_CLASS;
43 /*** Instance Data **********************************************************/
44 struct ATAUnitWindow_DATA
46 /* Nothing to add */
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",
56 NULL
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)
67 i = (IPTR)*names;
68 continue;
70 if (flags & (1 << i))
72 strcpy(str, *names);
73 str += strlen(*names);
74 if ((done % 5) == 4)
75 *str++ = '\n';
76 else
77 *str++ = ' ';
78 done++;
80 i++;
83 *str = 0;
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];
93 IPTR val;
95 if (!dev)
96 return NULL;
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
109 cl, self, NULL,
110 Child, (IPTR)(atagroup = (ColGroup(2),
111 MUIA_Group_SameSize, TRUE,
112 MUIA_FrameTitle, (IPTR)"IDE/ATA",
113 GroupFrame,
114 MUIA_Background, MUII_GroupBack,
115 Child, (IPTR)Label(_(MSG_TRANSFER_MODES)),
116 Child, (IPTR)(ScrollgroupObject,
117 TextFrame,
118 MUIA_Background, MUII_TextBack,
119 MUIA_Scrollgroup_Contents, (IPTR)(NFloattextObject,
120 NoFrame,
121 MUIA_Background, MUII_TextBack,
122 MUIA_CycleChain, 1,
123 MUIA_Floattext_Text, (IPTR)xfermodes_str,
124 End),
125 End),
126 Child, (IPTR)Label(_(MSG_CONFIG_MODES)),
127 Child, (IPTR)(ScrollgroupObject,
128 TextFrame,
129 MUIA_Background, MUII_TextBack,
130 MUIA_Scrollgroup_Contents, (IPTR)(NFloattextObject,
131 NoFrame,
132 MUIA_Background, MUII_TextBack,
133 MUIA_CycleChain, 1,
134 MUIA_Floattext_Text, (IPTR)usemodes_str,
135 End),
136 End),
137 Child, (IPTR)Label(_(MSG_MULTISECTOR)),
138 Child, (IPTR)(TextObject,
139 TextFrame,
140 MUIA_Background, MUII_TextBack,
141 MUIA_CycleChain, 1,
142 MUIA_Text_Contents, (IPTR)multisector_str,
143 End),
144 End)),
145 TAG_MORE, (IPTR) msg->ops_AttrList,
146 TAG_DONE
148 if (window)
150 IPTR unitdev;
151 OOP_GetAttr(dev, aHidd_StorageUnit_Device, &unitdev);
152 OOP_GetAttr(dev, aHidd_StorageUnit_Number, &val);
153 QueryATAStorageFeatures(atagroup, (char *)unitdev, val);
155 return window;
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)
164 case OM_NEW:
165 return (IPTR) ATAUnitWindow__OM_NEW(__class, __self, (struct opSet *)__msg);
167 default:
168 return DoSuperMethodA(__class, __self, __msg);
171 return (IPTR) NULL;
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));
182 if (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)
199 __showerror
200 ( (char *)
201 "Failed to create `ATAUnitWindow' custom class.", NULL
204 return 0;
207 return 1;
210 void ATAUnitWindow_Deinitialize(struct SysexpBase *SysexpBase)
212 struct SysexpATABase *AtaBase = GetBase("ATA.Module");
213 MUI_DeleteCustomClass(AtaBase->seab_ATAUnitWindowCLASS);