2 Copyright (C) 2013, The AROS Development Team.
6 #include <aros/debug.h>
8 #define MUIMASTER_YES_INLINE_STDARG
10 #include <proto/alib.h>
11 #include <proto/exec.h>
12 #include <proto/muimaster.h>
13 #include <proto/utility.h>
14 #include <proto/intuition.h>
16 #include <exec/memory.h>
17 #include <libraries/mui.h>
18 #include <zune/customclasses.h>
19 #include <mui/NFloattext_mcc.h>
20 #include <utility/tagitem.h>
21 #include <utility/hooks.h>
32 extern OOP_AttrBase HiddATAUnitAB
;
34 /*** Instance Data **********************************************************/
35 struct ATAUnitWindow_DATA
40 static const char *const xferModeNames
[] =
42 "PIO0" , "PIO1" , "PIO2 ", "PIO3" , "PIO4" ,
43 "MDMA0", "MDMA1", "MDMA2",
44 "UDMA0", "UDMA1", "UDMA2", "UDMA3", "UDMA4", "UDMA5", "UDMA6",
45 (const char *)AB_XFER_48BIT
,
46 "LBA48", "Multisector", "ATAPI", "LBA", "PIO32",
50 static void DecodeBits(char *str
, ULONG flags
, const char *const *names
)
52 unsigned char i
, done
;
54 for (i
= 0, done
= 0; *names
; names
++)
56 if ((IPTR
)*names
< 32)
64 str
+= strlen(*names
);
77 static Object
*ATAUnitWindow__OM_NEW(Class
*cl
, Object
*self
, struct opSet
*msg
)
79 OOP_Object
*dev
= (OOP_Object
*)GetTagData(MUIA_PropertyWin_Object
, 0, msg
->ops_AttrList
);
80 IPTR model
, revision
, serial
;
82 char xfermodes_str
[256];
83 char usemodes_str
[256];
84 char multisector_str
[4];
88 OOP_GetAttr(dev
, aHidd_ATAUnit_Model
, &model
);
89 OOP_GetAttr(dev
, aHidd_ATAUnit_Revision
, &revision
);
90 OOP_GetAttr(dev
, aHidd_ATAUnit_Serial
, &serial
);
92 removable
= OOP_GET(dev
, aHidd_ATAUnit_Removable
) ? IDS_SELECTED
: IDS_NORMAL
;
94 OOP_GetAttr(dev
, aHidd_ATAUnit_Number
, &val
);
95 snprintf(unit_str
, sizeof(unit_str
), "%ld", val
);
97 OOP_GetAttr(dev
, aHidd_ATAUnit_XferModes
, &val
);
98 DecodeBits(xfermodes_str
, val
, xferModeNames
),
100 OOP_GetAttr(dev
, aHidd_ATAUnit_ConfiguredModes
, &val
);
101 DecodeBits(usemodes_str
, val
, xferModeNames
),
103 OOP_GetAttr(dev
, aHidd_ATAUnit_MultiSector
, &val
);
104 snprintf(multisector_str
, sizeof(multisector_str
), "%ld", val
);
106 return (Object
*) DoSuperNewTags
109 MUIA_Window_Title
, __(MSG_ATA_UNIT_PROPERTIES
),
110 MUIA_Window_ID
, MAKE_ID('A', 'U', 'N', 'P'),
111 WindowContents
, (IPTR
)(ColGroup(2),
112 Child
, (IPTR
)Label(_(MSG_UNIT_NUMBER
)),
113 Child
, (IPTR
)(TextObject
,
115 MUIA_Background
, MUII_TextBack
,
117 MUIA_Text_Contents
, (IPTR
)unit_str
,
119 Child
, (IPTR
)Label(_(MSG_MODEL
)),
120 Child
, (IPTR
)(TextObject
,
122 MUIA_Background
, MUII_TextBack
,
124 MUIA_Text_Contents
, model
,
126 Child
, (IPTR
)Label(_(MSG_REVISION
)),
127 Child
, (IPTR
)(TextObject
,
129 MUIA_Background
, MUII_TextBack
,
131 MUIA_Text_Contents
, revision
,
133 Child
, (IPTR
)Label(_(MSG_SERIAL
)),
134 Child
, (IPTR
)(TextObject
,
136 MUIA_Background
, MUII_TextBack
,
138 MUIA_Text_Contents
, serial
,
140 Child
, (IPTR
)Label(_(MSG_TRANSFER_MODES
)),
141 Child
, (IPTR
)(NFloattextObject
,
143 MUIA_Background
, MUII_TextBack
,
145 MUIA_Floattext_Text
, (IPTR
)xfermodes_str
,
147 Child
, (IPTR
)Label(_(MSG_CONFIG_MODES
)),
148 Child
, (IPTR
)(NFloattextObject
,
150 MUIA_Background
, MUII_TextBack
,
152 MUIA_Floattext_Text
, (IPTR
)usemodes_str
,
154 Child
, (IPTR
)Label(_(MSG_MULTISECTOR
)),
155 Child
, (IPTR
)(TextObject
,
157 MUIA_Background
, MUII_TextBack
,
159 MUIA_Text_Contents
, (IPTR
)multisector_str
,
161 Child
, (IPTR
)Label(_(MSG_REMOVABLE
)),
162 Child
, (IPTR
)(HGroup
,
163 Child
, (IPTR
)(ImageObject
,
164 MUIA_Image_Spec
, MUII_CheckMark
,
165 MUIA_Image_State
, removable
,
168 MUIA_Background
, MUII_TextBack
,
170 Child
, (IPTR
)HSpace(0),
177 /*** Setup ******************************************************************/
180 ATAUnitWindow
, NULL
, MUIC_Window
, NULL
,
181 OM_NEW
, struct opSet
*