2 Copyright © 2013-2014, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/types.h>
9 #include <utility/tagitem.h>
10 #include <libraries/locale.h>
11 #include <libraries/mui.h>
12 #include <zune/customclasses.h>
13 #include <zune/prefseditor.h>
15 #include <proto/exec.h>
16 #include <proto/intuition.h>
17 #include <proto/utility.h>
18 #include <proto/muimaster.h>
19 #include <proto/dos.h>
24 #include "booteditor.h"
26 #include <proto/alib.h>
28 #define DEFAULT_WIDTH 1024
29 #define DEFAULT_HEIGHT 768
30 #define DEFAULT_REFRESH 60
31 #define MAX_LINE_LENGTH 500
33 static const TEXT grub_config_path
[] = "SYS:boot/pc/grub/grub.cfg";
34 static const TEXT grub_config_path_tmp
[] = "SYS:boot/pc/grub/grub.cfg.tmp";
35 static const TEXT accept_nums
[] = "0123456789";
36 static CONST_STRPTR ata_buses_list
[5] = {NULL
};
37 static CONST_STRPTR debug_output_list
[4] = {NULL
};
38 static CONST_STRPTR gfx_type_list
[5] = {NULL
};
39 static CONST_STRPTR vesa_depth_list
[4] = {NULL
};
41 struct BootEditor_DATA
51 *vesa_default_refresh
,
67 static BOOL
ReadBootArgs(CONST_STRPTR line
, struct BootEditor_DATA
*data
);
68 static BOOL
WriteBootArgs(BPTR file
, struct BootEditor_DATA
*data
);
70 static Object
*BootEditor__OM_NEW(Class
*CLASS
, Object
*self
,
71 struct opSet
*message
)
73 struct BootEditor_DATA temp_data
, *data
= &temp_data
;
75 gfx_type_list
[0] = _(MSG_GFX_TYPE_AUTO
);
76 gfx_type_list
[1] = _(MSG_GFX_TYPE_NATIVE
);
77 gfx_type_list
[2] = _(MSG_GFX_TYPE_VESA
);
78 gfx_type_list
[3] = _(MSG_GFX_TYPE_VGA
);
80 vesa_depth_list
[0] = _(MSG_GFX_DEPTH_TRUE
);
81 vesa_depth_list
[1] = _(MSG_GFX_DEPTH_HIGH
);
82 vesa_depth_list
[2] = _(MSG_GFX_DEPTH_LOW
);
84 ata_buses_list
[0] = _(MSG_ATA_BUS_ALL
);
85 ata_buses_list
[1] = _(MSG_ATA_BUS_PCI
);
86 ata_buses_list
[2] = _(MSG_ATA_BUS_LEGACY
);
87 ata_buses_list
[3] = _(MSG_ATA_BUS_NONE
);
89 debug_output_list
[0] = _(MSG_DEBUG_OUTPUT_NONE
);
90 debug_output_list
[1] = _(MSG_DEBUG_OUTPUT_MEMORY
);
91 debug_output_list
[2] = _(MSG_DEBUG_OUTPUT_SERIAL
);
93 self
= (Object
*)DoSuperNewTags(CLASS
, self
, NULL
,
94 MUIA_PrefsEditor_Name
, __(MSG_NAME
),
95 MUIA_PrefsEditor_Path
, (IPTR
)grub_config_path
,
96 MUIA_PrefsEditor_CanTest
, FALSE
,
97 MUIA_PrefsEditor_CanUse
, FALSE
,
98 Child
, (IPTR
)ColGroup(2),
100 GroupFrameT(_(MSG_GFX
)),
101 Child
, (IPTR
)ColGroup(2),
102 Child
, (IPTR
)Label2(__(MSG_GFX_TYPE
)),
103 Child
, (IPTR
)(data
->gfx_type
= (Object
*)CycleObject
,
104 MUIA_Cycle_Entries
, (IPTR
)gfx_type_list
,
106 Child
, (IPTR
)(data
->gfx_composition
=
107 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
109 Child
, (IPTR
)Label2(__(MSG_GFX_COMPOSITION
)),
110 Child
, (IPTR
)HVSpace
,
112 Child
, (IPTR
)HVSpace
,
113 Child
, (IPTR
)HVSpace
,
115 Child
, (IPTR
)(data
->vesa_group
= VGroup
,
116 GroupFrameT(_(MSG_GFX_VESAMODE
)),
118 Child
, (IPTR
)(data
->vesa_best_res
=
119 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
120 Child
, (IPTR
)Label2(__(MSG_GFX_BESTRES
)),
121 Child
, (IPTR
)HVSpace
,
123 Child
, (IPTR
)ColGroup(2),
124 Child
, (IPTR
)Label2(__(MSG_GFX_WIDTH
)),
126 Child
, (IPTR
)(data
->vesa_width
=
127 (Object
*)StringObject
,
130 MUIA_String_Accept
, (IPTR
)accept_nums
,
131 MUIA_FixWidthTxt
, (IPTR
)"00000",
133 Child
, (IPTR
)HVSpace
,
135 Child
, (IPTR
)Label2(__(MSG_GFX_HEIGHT
)),
137 Child
, (IPTR
)(data
->vesa_height
=
138 (Object
*)StringObject
,
141 MUIA_String_Accept
, (IPTR
)accept_nums
,
142 MUIA_FixWidthTxt
, (IPTR
)"00000",
144 Child
, (IPTR
)HVSpace
,
146 Child
, (IPTR
)Label2(__(MSG_GFX_DEPTH
)),
147 Child
, (IPTR
)(data
->vesa_depth
= (Object
*)CycleObject
,
148 MUIA_Cycle_Entries
, (IPTR
)vesa_depth_list
,
150 Child
, (IPTR
)Label2(__(MSG_GFX_REFRESH
)),
152 Child
, (IPTR
)(data
->vesa_refresh
=
153 (Object
*)StringObject
,
156 MUIA_String_Accept
, (IPTR
)accept_nums
,
157 MUIA_FixWidthTxt
, (IPTR
)"0000",
159 Child
, (IPTR
)Label2(__(MSG_GFX_HERTZ
)),
160 Child
, (IPTR
)HVSpace
,
164 Child
, (IPTR
)(data
->vesa_default_refresh
=
165 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
166 Child
, (IPTR
)Label2(__(MSG_GFX_DEFAULTREFRESH
)),
167 Child
, (IPTR
)HVSpace
,
173 GroupFrameT(_(MSG_ATA
)),
175 Child
, (IPTR
)Label2(__(MSG_ATA_BUSES
)),
176 Child
, (IPTR
)(data
->ata_buses
= (Object
*)CycleObject
,
177 MUIA_Cycle_Entries
, (IPTR
)ata_buses_list
,
180 Child
, (IPTR
)ColGroup(2),
181 Child
, (IPTR
)(data
->ata_dma
=
182 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
184 Child
, (IPTR
)Label2(__(MSG_ATA_DMA
)),
185 Child
, (IPTR
)HVSpace
,
187 Child
, (IPTR
)(data
->ata_multi
=
188 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
190 Child
, (IPTR
)Label2(__(MSG_ATA_MULTI
)),
191 Child
, (IPTR
)HVSpace
,
193 Child
, (IPTR
)(data
->ata_32bit
=
194 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
196 Child
, (IPTR
)Label2(__(MSG_ATA_32BIT
)),
197 Child
, (IPTR
)HVSpace
,
199 Child
, (IPTR
)(data
->ata_poll
=
200 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
202 Child
, (IPTR
)Label2(__(MSG_ATA_POLL
)),
203 Child
, (IPTR
)HVSpace
,
205 Child
, (IPTR
)HVSpace
,
206 Child
, (IPTR
)HVSpace
,
210 GroupFrameT(_(MSG_DEVICE
)),
211 Child
, (IPTR
)ColGroup(2),
212 Child
, (IPTR
)Label2(__(MSG_DEVICE_NAME
)),
214 Child
, (IPTR
)(data
->device_name
=
215 (Object
*)StringObject
,
218 MUIA_String_Reject
, (IPTR
)":; ",
219 MUIA_FixWidthTxt
, (IPTR
)"000000000",
221 Child
, (IPTR
)HVSpace
,
223 Child
, (IPTR
)Label2(__(MSG_DEVICE_DELAY
)),
225 Child
, (IPTR
)(data
->device_delay
=
226 (Object
*)StringObject
,
229 MUIA_String_Accept
, (IPTR
)accept_nums
,
230 MUIA_FixWidthTxt
, (IPTR
)"000",
232 Child
, (IPTR
)Label2(__(MSG_DEVICE_SECONDS
)),
233 Child
, (IPTR
)HVSpace
,
238 Child
, (IPTR
)ColGroup(2),
239 GroupFrameT(_(MSG_MISC
)),
240 Child
, (IPTR
)(data
->usb_enable
=
241 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
243 Child
, (IPTR
)Label2(__(MSG_USB_ENABLE
)),
244 Child
, (IPTR
)HVSpace
,
246 Child
, (IPTR
)(data
->acpi_enable
=
247 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
249 Child
, (IPTR
)Label2(__(MSG_ACPI_ENABLE
)),
250 Child
, (IPTR
)HVSpace
,
252 Child
, (IPTR
)(data
->floppy_enable
=
253 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
255 Child
, (IPTR
)Label2(__(MSG_FLOPPY_ENABLE
)),
256 Child
, (IPTR
)HVSpace
,
258 Child
, (IPTR
)HVSpace
,
259 Child
, (IPTR
)HVSpace
,
262 GroupFrameT(_(MSG_DEBUG
)),
264 Child
, (IPTR
)Label2(__(MSG_DEBUG_OUTPUT
)),
265 Child
, (IPTR
)(data
->debug_output
= (Object
*)CycleObject
,
266 MUIA_Cycle_Entries
, (IPTR
)debug_output_list
,
269 Child
, (IPTR
)ColGroup(2),
270 Child
, (IPTR
)(data
->debug_mungwall
=
271 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
273 Child
, (IPTR
)Label2(__(MSG_DEBUG_MUNGWALL
)),
274 Child
, (IPTR
)HVSpace
,
276 Child
, (IPTR
)(data
->debug_usb
=
277 MUI_MakeObject(MUIO_Checkmark
, NULL
)),
279 Child
, (IPTR
)Label2(__(MSG_DEBUG_USB
)),
280 Child
, (IPTR
)HVSpace
,
283 Child
, (IPTR
)HVSpace
,
291 data
= INST_DATA(CLASS
, self
);
294 /* Set up notifications */
296 DoMethod(data
->gfx_type
, MUIM_Notify
,
297 MUIA_Cycle_Active
, MUIV_EveryTime
,
298 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
299 DoMethod(data
->gfx_composition
, MUIM_Notify
,
300 MUIA_Selected
, MUIV_EveryTime
,
301 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
302 DoMethod(data
->vesa_width
, MUIM_Notify
,
303 MUIA_String_Acknowledge
, MUIV_EveryTime
,
304 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
305 DoMethod(data
->vesa_height
, MUIM_Notify
,
306 MUIA_String_Acknowledge
, MUIV_EveryTime
,
307 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
308 DoMethod(data
->vesa_depth
, MUIM_Notify
,
309 MUIA_Cycle_Active
, MUIV_EveryTime
,
310 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
311 DoMethod(data
->vesa_refresh
, MUIM_Notify
,
312 MUIA_String_Acknowledge
, MUIV_EveryTime
,
313 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
314 DoMethod(data
->vesa_default_refresh
, MUIM_Notify
,
315 MUIA_Selected
, MUIV_EveryTime
,
316 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
317 DoMethod(data
->vesa_best_res
, MUIM_Notify
,
318 MUIA_Selected
, MUIV_EveryTime
,
319 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
320 DoMethod(data
->ata_buses
, MUIM_Notify
,
321 MUIA_Cycle_Active
, MUIV_EveryTime
,
322 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
323 DoMethod(data
->ata_dma
, MUIM_Notify
,
324 MUIA_Selected
, MUIV_EveryTime
,
325 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
326 DoMethod(data
->ata_multi
, MUIM_Notify
,
327 MUIA_Selected
, MUIV_EveryTime
,
328 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
329 DoMethod(data
->ata_32bit
, MUIM_Notify
,
330 MUIA_Selected
, MUIV_EveryTime
,
331 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
332 DoMethod(data
->ata_poll
, MUIM_Notify
,
333 MUIA_Selected
, MUIV_EveryTime
,
334 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
335 DoMethod(data
->device_name
, MUIM_Notify
,
336 MUIA_String_Acknowledge
, MUIV_EveryTime
,
337 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
338 DoMethod(data
->device_delay
, MUIM_Notify
,
339 MUIA_String_Acknowledge
, MUIV_EveryTime
,
340 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
341 DoMethod(data
->usb_enable
, MUIM_Notify
,
342 MUIA_Selected
, MUIV_EveryTime
,
343 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
344 DoMethod(data
->acpi_enable
, MUIM_Notify
,
345 MUIA_Selected
, MUIV_EveryTime
,
346 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
347 DoMethod(data
->floppy_enable
, MUIM_Notify
,
348 MUIA_Selected
, MUIV_EveryTime
,
349 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
350 DoMethod(data
->debug_output
, MUIM_Notify
,
351 MUIA_Cycle_Active
, MUIV_EveryTime
,
352 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
353 DoMethod(data
->debug_mungwall
, MUIM_Notify
,
354 MUIA_Selected
, MUIV_EveryTime
,
355 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
356 DoMethod(data
->debug_usb
, MUIM_Notify
,
357 MUIA_Selected
, MUIV_EveryTime
,
358 (IPTR
)self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
360 DoMethod(data
->gfx_type
, MUIM_Notify
,
361 MUIA_Cycle_Active
, 0,
362 (IPTR
)data
->vesa_group
, 3, MUIM_Set
, MUIA_Disabled
, FALSE
);
363 DoMethod(data
->gfx_type
, MUIM_Notify
,
364 MUIA_Cycle_Active
, 1,
365 (IPTR
)data
->vesa_group
, 3, MUIM_Set
, MUIA_Disabled
, TRUE
);
366 DoMethod(data
->gfx_type
, MUIM_Notify
,
367 MUIA_Cycle_Active
, 2,
368 (IPTR
)data
->vesa_group
, 3, MUIM_Set
, MUIA_Disabled
, FALSE
);
369 DoMethod(data
->gfx_type
, MUIM_Notify
,
370 MUIA_Cycle_Active
, 3,
371 (IPTR
)data
->vesa_group
, 3, MUIM_Set
, MUIA_Disabled
, TRUE
);
373 DoMethod(data
->vesa_default_refresh
, MUIM_Notify
,
374 MUIA_Selected
, MUIV_EveryTime
,
375 (IPTR
)data
->vesa_refresh
, 3, MUIM_Set
, MUIA_Disabled
,
377 DoMethod(data
->vesa_best_res
, MUIM_Notify
,
378 MUIA_Selected
, MUIV_EveryTime
,
379 (IPTR
)data
->vesa_width
, 3, MUIM_Set
, MUIA_Disabled
,
381 DoMethod(data
->vesa_best_res
, MUIM_Notify
,
382 MUIA_Selected
, MUIV_EveryTime
,
383 (IPTR
)data
->vesa_height
, 3, MUIM_Set
, MUIA_Disabled
,
386 /* Set default values */
388 SET(data
->gfx_composition
, MUIA_Selected
, TRUE
);
389 SET(data
->vesa_width
, MUIA_String_Integer
, DEFAULT_WIDTH
);
390 SET(data
->vesa_height
, MUIA_String_Integer
, DEFAULT_HEIGHT
);
391 SET(data
->vesa_refresh
, MUIA_String_Integer
, DEFAULT_REFRESH
);
393 SET(data
->ata_dma
, MUIA_Selected
, TRUE
);
394 SET(data
->ata_multi
, MUIA_Selected
, TRUE
);
395 SET(data
->ata_32bit
, MUIA_Selected
, TRUE
);
397 SET(data
->device_delay
, MUIA_String_Integer
, 0);
399 SET(data
->usb_enable
, MUIA_Selected
, TRUE
);
400 SET(data
->acpi_enable
, MUIA_Selected
, TRUE
);
406 static IPTR
BootEditor__MUIM_Setup(Class
*CLASS
, Object
*self
, Msg message
)
408 if (!DoSuperMethodA(CLASS
, self
, message
))
414 static IPTR
BootEditor__MUIM_Cleanup(Class
*CLASS
, Object
*self
, Msg message
)
416 return DoSuperMethodA(CLASS
, self
, message
);
419 static IPTR
BootEditor__MUIM_PrefsEditor_ImportFH(Class
*CLASS
, Object
*self
,
420 struct MUIP_PrefsEditor_ImportFH
*message
)
422 struct BootEditor_DATA
*data
= INST_DATA(CLASS
, self
);
424 TEXT line_buffer
[MAX_LINE_LENGTH
], *line
;
425 BOOL success
= TRUE
, done
= FALSE
, found
= FALSE
;
427 /* Find first AROS boot entry, parse its arguments and put them in
430 file
= Open(grub_config_path
, MODE_OLDFILE
);
436 while (!done
&& !found
)
438 line
= FGets(file
, line_buffer
, MAX_LINE_LENGTH
);
441 else if (strstr(line
, "multiboot") != NULL
442 && strstr(line
, "bootstrap") != NULL
)
445 if (!ReadBootArgs(line
, data
))
457 static IPTR
BootEditor__MUIM_PrefsEditor_ExportFH(Class
*CLASS
, Object
*self
,
458 struct MUIP_PrefsEditor_ExportFH
*message
)
463 static IPTR
BootEditor__MUIM_PrefsEditor_Save(Class
*CLASS
, Object
*self
,
466 struct BootEditor_DATA
*data
= INST_DATA(CLASS
, self
);
467 BPTR old_file
, new_file
;
468 TEXT line_buffer
[MAX_LINE_LENGTH
], *line
;
469 BOOL success
= TRUE
, done
= FALSE
, found
= FALSE
;
471 /* Find first AROS boot entry and replace its arguments with those
472 * chosen in the GUI */
474 old_file
= Open(grub_config_path
, MODE_OLDFILE
);
475 new_file
= Open(grub_config_path_tmp
, MODE_NEWFILE
);
476 if (old_file
== BNULL
&& new_file
== BNULL
)
483 line
= FGets(old_file
, line_buffer
, MAX_LINE_LENGTH
);
486 else if (!found
&& strstr(line
, "multiboot") != NULL
487 && strstr(line
, "bootstrap") != NULL
)
490 strstr(line
, ".gz")[3] = '\0';
491 if (FPuts(new_file
, line
) != 0)
493 else if (!WriteBootArgs(new_file
, data
))
497 if (FPuts(new_file
, line
) != 0)
502 /* Close both files */
504 if (old_file
!= NULL
)
506 if (new_file
!= NULL
)
507 if (!Close(new_file
))
510 /* Replace old file with new one */
513 success
= DeleteFile(grub_config_path
);
516 success
= Rename(grub_config_path_tmp
, grub_config_path
);
521 static BOOL
ReadBootArgs(CONST_STRPTR line
, struct BootEditor_DATA
*data
)
523 UWORD choice
, width
= 0, height
= 0, depth
= 0, refresh
= 0, delay
= 0;
524 BOOL success
= TRUE
, best_res
= FALSE
, use_refresh
= FALSE
;
530 if (strstr(line
, "nomonitors") != NULL
531 && strstr(line
, "vesa=") == NULL
)
533 else if (strstr(line
, "nomonitors") != NULL
)
535 else if (strstr(line
, "vesa=") == NULL
)
539 SET(data
->gfx_type
, MUIA_Cycle_Active
, choice
);
541 NNSET(data
->gfx_composition
, MUIA_Selected
,
542 strstr(line
, "nocomposition") == NULL
);
546 options
= strstr(line
, "vesa=");
551 while (*options
>= '0' && *options
<= '9')
552 width
= width
* 10 + *options
++ - '0';
553 if (*options
++ == 'x')
555 while (*options
>= '0' && *options
<= '9')
556 height
= height
* 10 + *options
++ - '0';
557 if (*options
++ == 'x')
559 while (*options
>= '0' && *options
<= '9')
560 depth
= depth
* 10 + *options
++ - '0';
567 depth
= width
, width
= DEFAULT_WIDTH
, height
= DEFAULT_HEIGHT
;
570 NNSET(data
->vesa_width
, MUIA_String_Integer
, width
);
571 NNSET(data
->vesa_height
, MUIA_String_Integer
, height
);
572 SET(data
->vesa_best_res
, MUIA_Selected
, best_res
);
574 /* Check for user-set refresh rate */
575 if (*(options
- 1) == '@')
577 while (*options
>= '0' && *options
<= '9')
578 refresh
= refresh
* 10 + *options
++ - '0';
582 refresh
= DEFAULT_REFRESH
;
584 NNSET(data
->vesa_refresh
, MUIA_String_Integer
, refresh
);
585 SET(data
->vesa_default_refresh
, MUIA_Selected
, !use_refresh
);
593 NNSET(data
->vesa_depth
, MUIA_Cycle_Active
, choice
);
598 options
= strstr(line
, "ATA=");
601 if (strstr(options
, "nopci") != NULL
602 && strstr(options
, "nolegacy") != NULL
)
604 else if (strstr(options
, "nopci") != NULL
)
606 else if (strstr(options
, "nolegacy") != NULL
)
610 NNSET(data
->ata_buses
, MUIA_Cycle_Active
, choice
);
612 if (strstr(options
, "nodma") != NULL
)
613 NNSET(data
->ata_dma
, MUIA_Selected
, FALSE
);
614 if (strstr(options
, "nomulti") != NULL
)
615 NNSET(data
->ata_multi
, MUIA_Selected
, FALSE
);
616 if (strstr(options
, "32bit") == NULL
)
617 NNSET(data
->ata_multi
, MUIA_Selected
, FALSE
);
618 if (strstr(options
, "poll") != NULL
)
619 NNSET(data
->ata_poll
, MUIA_Selected
, TRUE
);
624 options
= strstr(line
, "bootdevice=");
629 for (p
= options
; *p
!= ' ' && *p
!= '\n' && *p
!= '\0'; p
++);
632 NNSET(data
->device_name
, MUIA_String_Contents
, options
);
636 options
= strstr(line
, "bootdelay=");
641 while (*options
>= '0' && *options
<= '9')
642 delay
= delay
* 10 + *options
++ - '0';
644 NNSET(data
->device_delay
, MUIA_String_Integer
, delay
);
648 NNSET(data
->usb_enable
, MUIA_Selected
,
649 strstr(line
, "enableusb") != NULL
);
650 NNSET(data
->acpi_enable
, MUIA_Selected
,
651 strstr(line
, "noacpi") == NULL
);
652 NNSET(data
->floppy_enable
, MUIA_Selected
,
653 strstr(line
, "floppy=disabled") == NULL
);
657 if (strstr(line
, "debug=serial") != NULL
)
659 else if (strstr(line
, "debug=memory") != NULL
)
663 NNSET(data
->debug_output
, MUIA_Cycle_Active
, choice
);
665 NNSET(data
->debug_mungwall
, MUIA_Selected
,
666 strstr(line
, "mungwall") != NULL
);
667 NNSET(data
->debug_usb
, MUIA_Selected
,
668 strstr(line
, "usbdebug") != NULL
);
673 static BOOL
WriteBootArgs(BPTR file
, struct BootEditor_DATA
*data
)
675 UWORD count
, choice
, width
, height
, depth
, delay
;
681 if((XGET(data
->gfx_type
, MUIA_Cycle_Active
) & 1) == 0)
683 FPrintf(file
, " vesa=");
684 if(!XGET(data
->vesa_best_res
, MUIA_Selected
))
686 width
= XGET(data
->vesa_width
, MUIA_String_Integer
);
687 height
= XGET(data
->vesa_height
, MUIA_String_Integer
);
689 FPrintf(file
, "%ux%ux", width
, height
);
691 FPrintf(file
, "%ux", width
);
692 FPrintf(file
, "%ux", height
);
695 choice
= XGET(data
->vesa_depth
, MUIA_Cycle_Active
);
698 else if (choice
== 1)
702 FPrintf(file
, "%u", depth
);
703 if(!XGET(data
->vesa_default_refresh
, MUIA_Selected
))
704 FPrintf(file
, "@%u", XGET(data
->vesa_refresh
, MUIA_String_Integer
));
709 if(XGET(data
->gfx_type
, MUIA_Cycle_Active
) > 1)
710 FPrintf(file
, " nomonitors");
711 if(!XGET(data
->gfx_composition
, MUIA_Selected
))
712 FPrintf(file
, " nocomposition");
716 if(!XGET(data
->ata_dma
, MUIA_Selected
) ||
717 !XGET(data
->ata_multi
, MUIA_Selected
) ||
718 XGET(data
->ata_32bit
, MUIA_Selected
) ||
719 XGET(data
->ata_poll
, MUIA_Selected
) ||
720 XGET(data
->ata_buses
, MUIA_Cycle_Active
) > 0)
723 FPrintf(file
, " ATA=");
725 choice
= XGET(data
->ata_buses
, MUIA_Cycle_Active
);
728 FPrintf(file
, "nolegacy");
731 else if (choice
== 2)
733 FPrintf(file
, "nopci");
736 else if (choice
== 3)
738 FPrintf(file
, "nopci,nolegacy");
742 if(!XGET(data
->ata_dma
, MUIA_Selected
))
746 FPrintf(file
, "nodma");
749 if(!XGET(data
->ata_multi
, MUIA_Selected
))
753 FPrintf(file
, "nomulti");
756 if(XGET(data
->ata_32bit
, MUIA_Selected
))
760 FPrintf(file
, "32bit");
763 if(XGET(data
->ata_poll
, MUIA_Selected
))
767 FPrintf(file
, "poll");
774 GET(data
->device_name
, MUIA_String_Contents
, &name
);
776 FPrintf(file
, " bootdevice=%s", name
);
777 delay
= XGET(data
->device_delay
, MUIA_String_Integer
);
779 FPrintf(file
, " bootdelay=%u", delay
);
783 if(XGET(data
->usb_enable
, MUIA_Selected
))
784 FPrintf(file
, " enableusb");
785 if(!XGET(data
->acpi_enable
, MUIA_Selected
))
786 FPrintf(file
, " noacpi");
787 if(!XGET(data
->floppy_enable
, MUIA_Selected
))
788 FPrintf(file
, " floppy=disabled");
792 if(XGET(data
->debug_output
, MUIA_Cycle_Active
) == 1)
793 FPrintf(file
, " debug=memory");
794 else if(XGET(data
->debug_output
, MUIA_Cycle_Active
) == 2)
795 FPrintf(file
, " debug=serial");
796 if(XGET(data
->debug_mungwall
, MUIA_Selected
))
797 FPrintf(file
, " mungwall");
798 if(XGET(data
->debug_usb
, MUIA_Selected
))
799 FPrintf(file
, " usbdebug");
801 if (FPrintf(file
, "\n") < 0)
809 BootEditor
, NULL
, MUIC_PrefsEditor
, NULL
,
810 OM_NEW
, struct opSet
*,
813 MUIM_PrefsEditor_ImportFH
, struct MUIP_PrefsEditor_ImportFH
*,
814 MUIM_PrefsEditor_ExportFH
, struct MUIP_PrefsEditor_ExportFH
*,
815 MUIM_PrefsEditor_Save
, Msg