+struct saveDACcolors {
+ u8 rwmode;
+ u8 peladdr;
+ u8 pelmask;
+ u8 dac[768];
+ u8 color_select;
+};
+
+static void
+stdvga_save_dac_state(u16 seg, struct saveDACcolors *info)
+{
+ /* XXX: check this */
+ SET_FARVAR(seg, info->rwmode, inb(VGAREG_DAC_STATE));
+ SET_FARVAR(seg, info->peladdr, inb(VGAREG_DAC_WRITE_ADDRESS));
+ SET_FARVAR(seg, info->pelmask, stdvga_pelmask_read());
+ stdvga_dac_read(seg, info->dac, 0, 256);
+ SET_FARVAR(seg, info->color_select, 0);
+}
+
+static void
+stdvga_restore_dac_state(u16 seg, struct saveDACcolors *info)
+{
+ stdvga_pelmask_write(GET_FARVAR(seg, info->pelmask));
+ stdvga_dac_write(seg, info->dac, 0, 256);
+ outb(GET_FARVAR(seg, info->peladdr), VGAREG_DAC_WRITE_ADDRESS);
+}
+
+int
+stdvga_size_state(int states)
+{
+ int size = 0;
+ if (states & 1)
+ size += sizeof(struct saveVideoHardware);
+ if (states & 2)
+ size += sizeof(struct saveBDAstate);
+ if (states & 4)
+ size += sizeof(struct saveDACcolors);
+ return size;
+}
+
+int
+stdvga_save_state(u16 seg, void *data, int states)
+{
+ if (states & 1) {
+ stdvga_save_hw_state(seg, data);
+ data += sizeof(struct saveVideoHardware);
+ }
+ if (states & 2) {
+ save_bda_state(seg, data);
+ data += sizeof(struct saveBDAstate);
+ }
+ if (states & 4)
+ stdvga_save_dac_state(seg, data);
+ return 0;
+}
+
+int
+stdvga_restore_state(u16 seg, void *data, int states)
+{
+ if (states & 1) {
+ stdvga_restore_hw_state(seg, data);
+ data += sizeof(struct saveVideoHardware);
+ }
+ if (states & 2) {
+ restore_bda_state(seg, data);
+ data += sizeof(struct saveBDAstate);
+ }
+ if (states & 4)
+ stdvga_restore_dac_state(seg, data);
+ return 0;
+}
+