mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Updated vga code to newer coding conventions.
This commit is contained in:
parent
b2814db927
commit
d75a7145ef
5 changed files with 275 additions and 250 deletions
|
@ -26,27 +26,12 @@
|
||||||
#ifndef LIBMAXSI_SORTIX_VGA_H
|
#ifndef LIBMAXSI_SORTIX_VGA_H
|
||||||
#define LIBMAXSI_SORTIX_VGA_H
|
#define LIBMAXSI_SORTIX_VGA_H
|
||||||
|
|
||||||
|
#include <sortix/vga.h>
|
||||||
|
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
namespace VGA
|
namespace VGA
|
||||||
{
|
{
|
||||||
// TODO: Move these to a better place
|
|
||||||
#define COLOR8_BLACK 0
|
|
||||||
#define COLOR8_BLUE 1
|
|
||||||
#define COLOR8_GREEN 2
|
|
||||||
#define COLOR8_CYAN 3
|
|
||||||
#define COLOR8_RED 4
|
|
||||||
#define COLOR8_MAGENTA 5
|
|
||||||
#define COLOR8_BROWN 6
|
|
||||||
#define COLOR8_LIGHT_GREY 7
|
|
||||||
#define COLOR8_DARK_GREY 8
|
|
||||||
#define COLOR8_LIGHT_BLUE 9
|
|
||||||
#define COLOR8_LIGHT_GREEN 10
|
|
||||||
#define COLOR8_LIGHT_CYAN 11
|
|
||||||
#define COLOR8_LIGHT_RED 12
|
|
||||||
#define COLOR8_LIGHT_MAGENTA 13
|
|
||||||
#define COLOR8_LIGHT_BROWN 14
|
|
||||||
#define COLOR8_WHITE 15
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
52
sortix/include/sortix/vga.h
Normal file
52
sortix/include/sortix/vga.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
||||||
|
|
||||||
|
This file is part of Sortix.
|
||||||
|
|
||||||
|
Sortix is free software: you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
sortix/vga.h
|
||||||
|
Standard symbolic constants and types for Sortix.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef INC_SORTIX_VGA_H
|
||||||
|
#define INC_SORTIX_VGA_H
|
||||||
|
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
#define COLOR8_BLACK 0
|
||||||
|
#define COLOR8_BLUE 1
|
||||||
|
#define COLOR8_GREEN 2
|
||||||
|
#define COLOR8_CYAN 3
|
||||||
|
#define COLOR8_RED 4
|
||||||
|
#define COLOR8_MAGENTA 5
|
||||||
|
#define COLOR8_BROWN 6
|
||||||
|
#define COLOR8_LIGHT_GREY 7
|
||||||
|
#define COLOR8_DARK_GREY 8
|
||||||
|
#define COLOR8_LIGHT_BLUE 9
|
||||||
|
#define COLOR8_LIGHT_GREEN 10
|
||||||
|
#define COLOR8_LIGHT_CYAN 11
|
||||||
|
#define COLOR8_LIGHT_RED 12
|
||||||
|
#define COLOR8_LIGHT_MAGENTA 13
|
||||||
|
#define COLOR8_LIGHT_BROWN 14
|
||||||
|
#define COLOR8_WHITE 15
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -35,11 +35,10 @@
|
||||||
|
|
||||||
using namespace Maxsi;
|
using namespace Maxsi;
|
||||||
|
|
||||||
namespace Sortix
|
namespace Sortix {
|
||||||
{
|
namespace VGA {
|
||||||
namespace VGA
|
|
||||||
{
|
uint8_t* const VGA = (byte* const) 0xB8000;
|
||||||
byte* const VGA = (byte* const) 0xB8000;
|
|
||||||
const unsigned WIDTH = 80;
|
const unsigned WIDTH = 80;
|
||||||
const unsigned HEIGHT = 25;
|
const unsigned HEIGHT = 25;
|
||||||
const size_t VGA_SIZE = sizeof(uint16_t) * WIDTH * HEIGHT;
|
const size_t VGA_SIZE = sizeof(uint16_t) * WIDTH * HEIGHT;
|
||||||
|
@ -133,7 +132,7 @@ namespace Sortix
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changes the position of the hardware cursor.
|
// Changes the position of the hardware cursor.
|
||||||
void SetCursor(nat x, nat y)
|
void SetCursor(unsigned x, unsigned y)
|
||||||
{
|
{
|
||||||
nat value = x + y * WIDTH;
|
nat value = x + y * WIDTH;
|
||||||
|
|
||||||
|
@ -146,7 +145,8 @@ namespace Sortix
|
||||||
CPU::OutPortB(0x3D4, 15);
|
CPU::OutPortB(0x3D4, 15);
|
||||||
CPU::OutPortB(0x3D5, (value >> 0) & 0xFF);
|
CPU::OutPortB(0x3D5, (value >> 0) & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // namespace VGA
|
||||||
|
|
||||||
DevVGA::DevVGA()
|
DevVGA::DevVGA()
|
||||||
{
|
{
|
||||||
|
@ -224,4 +224,5 @@ namespace Sortix
|
||||||
Error::Set(ENOSPC);
|
Error::Set(ENOSPC);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // namespace Sortix
|
||||||
|
|
34
sortix/vga.h
34
sortix/vga.h
|
@ -28,38 +28,23 @@
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
|
|
||||||
namespace Sortix
|
namespace Sortix {
|
||||||
{
|
|
||||||
const size_t VGA_FONT_WIDTH = 8UL;
|
const size_t VGA_FONT_WIDTH = 8UL;
|
||||||
const size_t VGA_FONT_HEIGHT = 16UL;
|
const size_t VGA_FONT_HEIGHT = 16UL;
|
||||||
const size_t VGA_FONT_NUMCHARS = 256UL;
|
const size_t VGA_FONT_NUMCHARS = 256UL;
|
||||||
const size_t VGA_FONT_CHARSIZE = VGA_FONT_WIDTH * VGA_FONT_HEIGHT / 8UL;
|
const size_t VGA_FONT_CHARSIZE = VGA_FONT_WIDTH * VGA_FONT_HEIGHT / 8UL;
|
||||||
|
|
||||||
namespace VGA
|
namespace VGA {
|
||||||
{
|
|
||||||
// TODO: Move these to a better place
|
|
||||||
#define COLOR8_BLACK 0
|
|
||||||
#define COLOR8_BLUE 1
|
|
||||||
#define COLOR8_GREEN 2
|
|
||||||
#define COLOR8_CYAN 3
|
|
||||||
#define COLOR8_RED 4
|
|
||||||
#define COLOR8_MAGENTA 5
|
|
||||||
#define COLOR8_BROWN 6
|
|
||||||
#define COLOR8_LIGHT_GREY 7
|
|
||||||
#define COLOR8_DARK_GREY 8
|
|
||||||
#define COLOR8_LIGHT_BLUE 9
|
|
||||||
#define COLOR8_LIGHT_GREEN 10
|
|
||||||
#define COLOR8_LIGHT_CYAN 11
|
|
||||||
#define COLOR8_LIGHT_RED 12
|
|
||||||
#define COLOR8_LIGHT_MAGENTA 13
|
|
||||||
#define COLOR8_LIGHT_BROWN 14
|
|
||||||
#define COLOR8_WHITE 15
|
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void SetCursor(nat x, nat y);
|
void SetCursor(unsigned x, unsigned y);
|
||||||
const uint8_t* GetFont();
|
const uint8_t* GetFont();
|
||||||
}
|
|
||||||
|
|
||||||
|
} // namespace VGA
|
||||||
|
|
||||||
|
// TODO: This class shouldn't be exposed publicly; it is used in a hack in the
|
||||||
|
// /dev filesystem. However, vga.cpp should register /dev/vga instead.
|
||||||
class DevVGA : public DevBuffer
|
class DevVGA : public DevBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -84,7 +69,8 @@ namespace Sortix
|
||||||
virtual bool Resize(uintmax_t size);
|
virtual bool Resize(uintmax_t size);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // namespace Sortix
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <sortix/kernel/platform.h>
|
#include <sortix/kernel/platform.h>
|
||||||
#include <sortix/kernel/log.h>
|
#include <sortix/kernel/log.h>
|
||||||
|
#include <sortix/vga.h>
|
||||||
#include <libmaxsi/memory.h>
|
#include <libmaxsi/memory.h>
|
||||||
#include "vga.h"
|
#include "vga.h"
|
||||||
#include "vgaterminal.h"
|
#include "vgaterminal.h"
|
||||||
|
|
Loading…
Add table
Reference in a new issue