~ubuntu-branches/debian/stretch/grub2/stretch

« back to all changes in this revision

Viewing changes to video/i386/pc/vga.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-07-02 17:42:56 UTC
  • mto: (1.14.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20100702174256-34ptp93nl2zmmi0v
Tags: upstream-1.98+20100702
ImportĀ upstreamĀ versionĀ 1.98+20100702

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <grub/types.h>
28
28
#include <grub/dl.h>
29
29
#include <grub/misc.h>
 
30
#include <grub/vga.h>
30
31
 
31
32
#define VGA_WIDTH       640
32
33
#define VGA_HEIGHT      350
45
46
  int back_page;
46
47
} framebuffer;
47
48
 
48
 
#define SEQUENCER_ADDR_PORT     0x3C4
49
 
#define SEQUENCER_DATA_PORT     0x3C5
50
 
#define MAP_MASK_REGISTER       0x02
51
 
 
52
 
#define CRTC_ADDR_PORT          0x3D4
53
 
#define CRTC_DATA_PORT          0x3D5
54
 
#define START_ADDR_HIGH_REGISTER 0x0C
55
 
#define START_ADDR_LOW_REGISTER 0x0D
56
 
 
57
 
#define GRAPHICS_ADDR_PORT      0x3CE
58
 
#define GRAPHICS_DATA_PORT      0x3CF
59
 
#define READ_MAP_REGISTER       0x04
60
 
 
61
 
#define INPUT_STATUS1_REGISTER  0x3DA
62
 
#define INPUT_STATUS1_VERTR_BIT 0x08
63
 
 
64
49
static inline void
65
50
wait_vretrace (void)
66
51
{
67
52
  /* Wait until there is a vertical retrace.  */
68
 
  while (! (grub_inb (INPUT_STATUS1_REGISTER) & INPUT_STATUS1_VERTR_BIT));
 
53
  while (! (grub_inb (GRUB_VGA_IO_INPUT_STATUS1_REGISTER)
 
54
            & GRUB_VGA_IO_INPUT_STATUS1_VERTR_BIT));
69
55
}
70
56
 
71
57
/* Get Map Mask Register.  */
72
58
static unsigned char
73
59
get_map_mask (void)
74
60
{
75
 
  unsigned char old_addr;
76
 
  unsigned char old_data;
77
 
 
78
 
  old_addr = grub_inb (SEQUENCER_ADDR_PORT);
79
 
  grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
80
 
 
81
 
  old_data = grub_inb (SEQUENCER_DATA_PORT);
82
 
 
83
 
  grub_outb (old_addr, SEQUENCER_ADDR_PORT);
84
 
 
85
 
  return old_data;
 
61
  return grub_vga_sr_read (GRUB_VGA_SR_MAP_MASK_REGISTER);
86
62
}
87
63
 
88
64
/* Set Map Mask Register.  */
89
65
static void
90
66
set_map_mask (unsigned char mask)
91
67
{
92
 
  unsigned char old_addr;
93
 
 
94
 
  old_addr = grub_inb (SEQUENCER_ADDR_PORT);
95
 
  grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
96
 
 
97
 
  grub_outb (mask, SEQUENCER_DATA_PORT);
98
 
 
99
 
  grub_outb (old_addr, SEQUENCER_ADDR_PORT);
 
68
  grub_vga_sr_write (mask, GRUB_VGA_SR_MAP_MASK_REGISTER);
100
69
}
101
70
 
102
71
#if 0
104
73
static void
105
74
set_read_map (unsigned char map)
106
75
{
107
 
  unsigned char old_addr;
108
 
 
109
 
  old_addr = grub_inb (GRAPHICS_ADDR_PORT);
110
 
 
111
 
  grub_outb (READ_MAP_REGISTER, GRAPHICS_ADDR_PORT);
112
 
  grub_outb (map, GRAPHICS_DATA_PORT);
113
 
 
114
 
  grub_outb (old_addr, GRAPHICS_ADDR_PORT);
 
76
  grub_vga_gr_write (map, GRUB_VGA_GR_READ_MAP_REGISTER);
115
77
}
116
78
#endif
117
79
 
119
81
static void
120
82
set_start_address (unsigned int start)
121
83
{
122
 
  unsigned char old_addr;
123
 
 
124
 
  old_addr = grub_inb (CRTC_ADDR_PORT);
125
 
 
126
 
  grub_outb (START_ADDR_LOW_REGISTER, CRTC_ADDR_PORT);
127
 
  grub_outb (start & 0xFF, CRTC_DATA_PORT);
128
 
 
129
 
  grub_outb (START_ADDR_HIGH_REGISTER, CRTC_ADDR_PORT);
130
 
  grub_outb (start >> 8, CRTC_DATA_PORT);
131
 
 
132
 
  grub_outb (old_addr, CRTC_ADDR_PORT);
 
84
  grub_vga_cr_write (start & 0xFF, GRUB_VGA_CR_START_ADDR_LOW_REGISTER);
 
85
  grub_vga_cr_write (start >> 8, GRUB_VGA_CR_START_ADDR_HIGH_REGISTER);
133
86
}
134
87
 
135
88
static int setup = 0;
375
328
    .name = "VGA Video Driver",
376
329
    .id = GRUB_VIDEO_DRIVER_VGA,
377
330
 
 
331
    .prio = GRUB_VIDEO_ADAPTER_PRIO_FALLBACK,
 
332
 
378
333
    .init = grub_video_vga_init,
379
334
    .fini = grub_video_vga_fini,
380
335
    .setup = grub_video_vga_setup,