The Pedigree Project  0.1
kernel/machine/ppc_common/Vga.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef MACHINE_PPC_VGA_H
21 #define MACHINE_PPC_VGA_H
22 
23 #include "pedigree/kernel/machine/Vga.h"
24 #include "pedigree/kernel/processor/MemoryRegion.h"
25 #include "pedigree/kernel/processor/types.h"
26 // include <machine/openfirmware/OpenFirmware.h>
27 // include <machine/openfirmware/Device.h>
28 
29 // We make an assumption about the device size.
30 #define MAX_WIDTH 1024
31 #define MAX_HEIGHT 800
32 
33 #define FONT_WIDTH 8
34 #define FONT_HEIGHT 16
35 
36 // Routines for taking a 0-255 set of RGB values and converting them to a 8,16
37 // or 32 bpp specific form.
38 #ifdef BIG_ENDIAN
39 #define RGB_8(r, g, b) (((r & 0x3) << 6) | ((g & 0x7) << 3) | (b & 0x7))
40 #define RGB_16(r, g, b) \
41  (((r & 0x1f) << 11) | ((g & 0x1f) << 6) | ((b & 0x1f) << 1))
42 #define RGB_32(r, g, b) (0 | r << 24 | g << 16 | b << 8)
43 #else
44 #error Little endian not implemented here.
45 #endif
46 
50 class PPCVga : public Vga
51 {
52  public:
53  PPCVga();
54  virtual ~PPCVga();
55 
56  void initialise();
57 
66  virtual bool setMode(int mode)
67  {
68  return false;
69  }
70 
75  virtual bool setLargestTextMode()
76  {
77  return false;
78  }
79 
84  virtual bool
85  isMode(size_t nCols, size_t nRows, bool bIsText, size_t nBpp = 0)
86  {
87  return false;
88  }
89 
94  virtual bool isLargestTextMode()
95  {
96  return true;
97  }
98 
102  virtual size_t getNumCols()
103  {
104  return m_Width / FONT_WIDTH;
105  }
106 
110  virtual size_t getNumRows()
111  {
112  return m_Height / FONT_HEIGHT;
113  }
114 
118  virtual void rememberMode()
119  {
120  }
121 
125  virtual void restoreMode()
126  {
127  }
128 
139  virtual void pokeBuffer(uint8_t *pBuffer, size_t nBufLen);
140 
149  virtual void peekBuffer(uint8_t *pBuffer, size_t nBufLen);
150 
156  virtual void moveCursor(size_t nX, size_t nY)
157  {
158  }
159 
160  operator uint16_t *() const
161  {
162  return const_cast<uint16_t *>(m_pTextBuffer);
163  }
164 
165  private:
166  PPCVga(const PPCVga &);
167  PPCVga &operator=(const PPCVga &);
168 
169  void putChar(char c, int x, int y, unsigned int f, unsigned int b);
170 
173  uint16_t
174  m_pTextBuffer[(MAX_WIDTH / FONT_WIDTH) * (MAX_HEIGHT / FONT_HEIGHT)];
175 
176  MemoryRegion m_Framebuffer;
177 
181  uint8_t *m_pFramebuffer;
182 
184  uint32_t m_Width;
186  uint32_t m_Height;
188  uint32_t m_Depth;
190  uint32_t m_Stride;
192  uint32_t m_pColours[16];
193 };
194 
195 #endif
uint16_t m_pTextBuffer[(MAX_WIDTH/FONT_WIDTH)*(MAX_HEIGHT/FONT_HEIGHT)]
virtual void pokeBuffer(uint8_t *pBuffer, size_t nBufLen)
virtual void peekBuffer(uint8_t *pBuffer, size_t nBufLen)
virtual size_t getNumRows()
virtual void restoreMode()
Special memory entity in the kernel&#39;s virtual address space.
Definition: MemoryRegion.h:35
virtual void rememberMode()
virtual bool isLargestTextMode()
virtual bool setMode(int mode)
virtual size_t getNumCols()
virtual void moveCursor(size_t nX, size_t nY)
virtual bool isMode(size_t nCols, size_t nRows, bool bIsText, size_t nBpp=0)
virtual bool setLargestTextMode()