1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Correct usage of deprecated nat and byte data types.

This commit is contained in:
Jonas 'Sortie' Termansen 2012-09-21 19:25:22 +02:00
parent 9cf092d32e
commit 3095503b9b
23 changed files with 150 additions and 150 deletions

View file

@ -223,8 +223,8 @@ public:
virtual ~DevCOMPort();
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -258,7 +258,7 @@ bool DevCOMPort::IsWritable() { return true; }
const unsigned TRIES = 1000;
ssize_t DevCOMPort::Read(byte* dest, size_t count)
ssize_t DevCOMPort::Read(uint8_t* dest, size_t count)
{
if ( !count ) { return 0; }
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; }
@ -301,7 +301,7 @@ ssize_t DevCOMPort::Read(byte* dest, size_t count)
return sofar;
}
ssize_t DevCOMPort::Write(const byte* src, size_t count)
ssize_t DevCOMPort::Write(const uint8_t* src, size_t count)
{
if ( !count ) { return 0; }
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; };
@ -347,7 +347,7 @@ ssize_t DevCOMPort::Write(const byte* src, size_t count)
#else
ssize_t DevCOMPort::Read(byte* dest, size_t count)
ssize_t DevCOMPort::Read(uint8_t* dest, size_t count)
{
if ( !count ) { return 0; }
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; }
@ -376,7 +376,7 @@ ssize_t DevCOMPort::Read(byte* dest, size_t count)
return sofar;
}
ssize_t DevCOMPort::Write(const byte* src, size_t count)
ssize_t DevCOMPort::Write(const uint8_t* src, size_t count)
{
if ( !count ) { return 0; }
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; };

View file

@ -83,7 +83,7 @@ namespace Sortix
size_t bytesused = sizeof(sortix_dirent) + dirent->d_namelen + 1;
ASSERT(bytesused <= size);
size -= bytesused;
dirent = (sortix_dirent*) ( ((byte*) dirent) + bytesused );
dirent = (sortix_dirent*) ( ((uint8_t*) dirent) + bytesused );
}
}

View file

@ -129,8 +129,8 @@ namespace Sortix
process->segments = segment;
// Copy as much data as possible and memset the rest to 0.
byte* memdest = (byte*) virtualaddr;
byte* memsource = (byte*) ( ((addr_t)file) + pht->offset);
uint8_t* memdest = (uint8_t*) virtualaddr;
uint8_t* memsource = (uint8_t*) ( ((addr_t)file) + pht->offset);
Maxsi::Memory::Copy(memdest, memsource, pht->filesize);
Maxsi::Memory::Set(memdest + pht->filesize, 0, pht->memorysize - pht->filesize);
}
@ -215,8 +215,8 @@ namespace Sortix
process->segments = segment;
// Copy as much data as possible and memset the rest to 0.
byte* memdest = (byte*) virtualaddr;
byte* memsource = (byte*) ( ((addr_t)file) + pht->offset);
uint8_t* memdest = (uint8_t*) virtualaddr;
uint8_t* memsource = (uint8_t*) ( ((addr_t)file) + pht->offset);
Maxsi::Memory::Copy(memdest, memsource, pht->filesize);
Maxsi::Memory::Set(memdest + pht->filesize, 0, pht->memorysize - pht->filesize);
}

View file

@ -268,7 +268,7 @@ namespace Sortix
return buffer->Resize(size);
}
ssize_t DevFileWrapper::Read(byte* dest, size_t count)
ssize_t DevFileWrapper::Read(uint8_t* dest, size_t count)
{
// TODO: Enforce read permission!
if ( !buffer->Seek(offset) ) { return -1; }
@ -278,7 +278,7 @@ namespace Sortix
return result;
}
ssize_t DevFileWrapper::Write(const byte* src, size_t count)
ssize_t DevFileWrapper::Write(const uint8_t* src, size_t count)
{
// TODO: Enforce write permission!
if ( !buffer->Seek(offset) ) { return -1; }

View file

@ -54,8 +54,8 @@ namespace Sortix
uintmax_t offset;
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
virtual size_t BlockSize();

View file

@ -53,8 +53,8 @@ namespace Sortix
off_t offset;
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
virtual size_t BlockSize();
@ -75,7 +75,7 @@ namespace Sortix
{
}
ssize_t DevATA::Read(byte* dest, size_t count)
ssize_t DevATA::Read(uint8_t* dest, size_t count)
{
if ( SIZE_MAX < count ) { count = SIZE_MAX; }
if ( drive->GetSize() - offset < count ) { count = drive->GetSize() - offset; }
@ -85,7 +85,7 @@ namespace Sortix
return amount;
}
ssize_t DevATA::Write(const byte* src, size_t count)
ssize_t DevATA::Write(const uint8_t* src, size_t count)
{
if ( SIZE_MAX < count ) { count = SIZE_MAX; }
if ( drive->GetSize() <= offset && count ) { Error::Set(ENOSPC); return -1; }
@ -144,8 +144,8 @@ namespace Sortix
virtual ~DevNull();
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -159,12 +159,12 @@ namespace Sortix
{
}
ssize_t DevNull::Read(byte* /*dest*/, size_t /*count*/)
ssize_t DevNull::Read(uint8_t* /*dest*/, size_t /*count*/)
{
return 0; // Return EOF
}
ssize_t DevNull::Write(const byte* /*src*/, size_t count)
ssize_t DevNull::Write(const uint8_t* /*src*/, size_t count)
{
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; }

View file

@ -44,7 +44,7 @@ namespace Sortix
public:
// Transfers ownership of name.
DevInitFSFile(char* name, const byte* buffer, size_t buffersize);
DevInitFSFile(char* name, const uint8_t* buffer, size_t buffersize);
virtual ~DevInitFSFile();
public:
@ -52,7 +52,7 @@ namespace Sortix
private:
size_t offset;
const byte* buffer;
const uint8_t* buffer;
size_t buffersize;
kthread_mutex_t filelock;
@ -62,14 +62,14 @@ namespace Sortix
virtual uintmax_t Position();
virtual bool Seek(uintmax_t position);
virtual bool Resize(uintmax_t size);
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
};
DevInitFSFile::DevInitFSFile(char* name, const byte* buffer, size_t buffersize)
DevInitFSFile::DevInitFSFile(char* name, const uint8_t* buffer, size_t buffersize)
{
this->name = name;
this->buffer = buffer;
@ -113,7 +113,7 @@ namespace Sortix
return false;
}
ssize_t DevInitFSFile::Read(byte* dest, size_t count)
ssize_t DevInitFSFile::Read(uint8_t* dest, size_t count)
{
ScopedLock lock(&filelock);
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; }
@ -125,7 +125,7 @@ namespace Sortix
return available;
}
ssize_t DevInitFSFile::Write(const byte* /*src*/, size_t /*count*/)
ssize_t DevInitFSFile::Write(const uint8_t* /*src*/, size_t /*count*/)
{
Error::Set(EBADF);
return false;
@ -228,7 +228,7 @@ namespace Sortix
uint32_t ino = InitRD::Traverse(InitRD::Root(), path);
if ( !ino ) { return NULL; }
const byte* buffer = InitRD::Open(ino, &buffersize);
const uint8_t* buffer = InitRD::Open(ino, &buffersize);
if ( !buffer ) { return NULL; }
if ( lowerflags == O_SEARCH ) { Error::Set(ENOTDIR); return NULL; }

View file

@ -50,7 +50,7 @@ namespace Sortix
private:
size_t offset;
byte* buffer;
uint8_t* buffer;
size_t bufferused;
size_t buffersize;
@ -60,8 +60,8 @@ namespace Sortix
virtual uintmax_t Position();
virtual bool Seek(uintmax_t position);
virtual bool Resize(uintmax_t size);
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -106,7 +106,7 @@ namespace Sortix
bool DevRAMFSFile::Resize(uintmax_t size)
{
if ( SIZE_MAX < size ) { Error::Set(EOVERFLOW); return false; }
byte* newbuffer = new byte[size];
uint8_t* newbuffer = new uint8_t[size];
if ( !newbuffer ) { Error::Set(ENOSPC); return false; }
size_t sharedmemsize = ( size < bufferused ) ? size : bufferused;
Memory::Copy(newbuffer, buffer, sharedmemsize);
@ -117,7 +117,7 @@ namespace Sortix
return true;
}
ssize_t DevRAMFSFile::Read(byte* dest, size_t count)
ssize_t DevRAMFSFile::Read(uint8_t* dest, size_t count)
{
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; }
size_t available = count;
@ -128,7 +128,7 @@ namespace Sortix
return available;
}
ssize_t DevRAMFSFile::Write(const byte* src, size_t count)
ssize_t DevRAMFSFile::Write(const uint8_t* src, size_t count)
{
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; }
if ( buffersize < offset + count )

View file

@ -72,7 +72,7 @@ bool DevStringBuffer::Resize(uintmax_t size)
return false;
}
ssize_t DevStringBuffer::Read(byte* dest, size_t count)
ssize_t DevStringBuffer::Read(uint8_t* dest, size_t count)
{
size_t available = strlength - off;
if ( available < count ) { count = available; }
@ -81,7 +81,7 @@ ssize_t DevStringBuffer::Read(byte* dest, size_t count)
return count;
}
ssize_t DevStringBuffer::Write(const byte* /*src*/, size_t /*count*/)
ssize_t DevStringBuffer::Write(const uint8_t* /*src*/, size_t /*count*/)
{
Error::Set(EBADF);
return -1;
@ -110,13 +110,13 @@ DevLineCommand::~DevLineCommand()
{
}
ssize_t DevLineCommand::Read(byte* /*dest*/, size_t /*count*/)
ssize_t DevLineCommand::Read(uint8_t* /*dest*/, size_t /*count*/)
{
Error::Set(EBADF);
return -1;
}
ssize_t DevLineCommand::Write(const byte* src, size_t count)
ssize_t DevLineCommand::Write(const uint8_t* src, size_t count)
{
if ( handled ) { Error::Set(EINVAL); return -1; }
size_t available = CMDMAX - sofar;
@ -184,7 +184,7 @@ bool DevMemoryBuffer::Resize(uintmax_t size)
return true;
}
ssize_t DevMemoryBuffer::Read(byte* dest, size_t count)
ssize_t DevMemoryBuffer::Read(uint8_t* dest, size_t count)
{
if ( bufsize <= off ) { return 0; }
size_t available = bufsize - off;
@ -194,7 +194,7 @@ ssize_t DevMemoryBuffer::Read(byte* dest, size_t count)
return count;
}
ssize_t DevMemoryBuffer::Write(const byte* src, size_t count)
ssize_t DevMemoryBuffer::Write(const uint8_t* src, size_t count)
{
if ( !write ) { Error::Set(EBADF); return -1; }
if ( bufsize <= off ) { Error::Set(EPERM); return -1; }

View file

@ -46,8 +46,8 @@ public:
virtual uintmax_t Position();
virtual bool Seek(uintmax_t position);
virtual bool Resize(uintmax_t size);
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -58,8 +58,8 @@ class DevLineCommand : public DevStream
public:
DevLineCommand(bool (*handler)(void*, const char*), void* user);
virtual ~DevLineCommand();
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -93,8 +93,8 @@ public:
virtual uintmax_t Position();
virtual bool Seek(uintmax_t position);
virtual bool Resize(uintmax_t size);
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();

View file

@ -50,8 +50,8 @@ public:
virtual uintmax_t Position();
virtual bool Seek(uintmax_t position);
virtual bool Resize(uintmax_t size);
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -93,14 +93,14 @@ bool DevFrameBuffer::Resize(uintmax_t /*size*/)
return false;
}
ssize_t DevFrameBuffer::Read(byte* dest, size_t count)
ssize_t DevFrameBuffer::Read(uint8_t* dest, size_t count)
{
ssize_t result = Video::ReadAt(off, dest, count);
if ( 0 <= result ) { off += result; }
return result;
}
ssize_t DevFrameBuffer::Write(const byte* src, size_t count)
ssize_t DevFrameBuffer::Write(const uint8_t* src, size_t count)
{
ssize_t result = Video::WriteAt(off, src, count);
if ( 0 <= result ) { off += result; }

View file

@ -43,14 +43,14 @@ namespace Sortix
struct SysWrite_t
{
union { size_t align1; int fd; };
union { size_t align2; const byte* buffer; };
union { size_t align2; const uint8_t* buffer; };
union { size_t align3; size_t count; };
};
STATIC_ASSERT(sizeof(SysWrite_t) <= sizeof(Thread::scstate));
#endif
ssize_t SysWrite(int fd, const byte* buffer, size_t count)
ssize_t SysWrite(int fd, const uint8_t* buffer, size_t count)
{
// TODO: Check that buffer is a valid user-space buffer.
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; }
@ -86,7 +86,7 @@ namespace Sortix
}
// TODO: Not implemented yet due to stupid internal kernel design.
ssize_t SysPWrite(int fd, const byte* buffer, size_t count, off_t off)
ssize_t SysPWrite(int fd, const uint8_t* buffer, size_t count, off_t off)
{
Error::Set(ENOSYS);
return -1;
@ -96,14 +96,14 @@ namespace Sortix
struct SysRead_t
{
union { size_t align1; int fd; };
union { size_t align2; byte* buffer; };
union { size_t align2; uint8_t* buffer; };
union { size_t align3; size_t count; };
};
STATIC_ASSERT(sizeof(SysRead_t) <= sizeof(Thread::scstate));
#endif
ssize_t SysRead(int fd, byte* buffer, size_t count)
ssize_t SysRead(int fd, uint8_t* buffer, size_t count)
{
// TODO: Check that buffer is a valid user-space buffer.
if ( SSIZE_MAX < count ) { count = SSIZE_MAX; }
@ -139,7 +139,7 @@ namespace Sortix
}
// TODO: Not implemented yet due to stupid internal kernel design.
ssize_t SysPRead(int fd, byte* buffer, size_t count, off_t off)
ssize_t SysPRead(int fd, uint8_t* buffer, size_t count, off_t off)
{
Error::Set(ENOSYS);
return -1;

View file

@ -217,7 +217,7 @@ namespace Sortix
#endif
}
ssize_t LogTerminal::Read(byte* dest, size_t count)
ssize_t LogTerminal::Read(uint8_t* dest, size_t count)
{
ScopedLockSignal lock(&termlock);
if ( !lock.IsAcquired() ) { Error::Set(EINTR); return -1; }
@ -253,7 +253,7 @@ namespace Sortix
if ( !(mode & TERMMODE_UNICODE) && !kbkey ) { ignore = true; }
if ( ignore ) { linebuffer.Pop(); continue; }
byte* buf;
uint8_t* buf;
size_t bufsize;
uint8_t codepointbuf[4];
char utf8buf[6];
@ -266,7 +266,7 @@ namespace Sortix
Log::PrintF("Warning: logterminal driver dropping invalid "
"codepoint 0x%x\n", codepoint);
}
buf = (byte*) utf8buf;
buf = (uint8_t*) utf8buf;
bufsize = numbytes;
}
else
@ -275,13 +275,13 @@ namespace Sortix
codepointbuf[1] = (codepoint >> 16U) & 0xFFU;
codepointbuf[2] = (codepoint >> 8U) & 0xFFU;
codepointbuf[3] = (codepoint >> 0U) & 0xFFU;
buf = (byte*) &codepointbuf;
buf = (uint8_t*) &codepointbuf;
bufsize = sizeof(codepointbuf);
// TODO: Whoops, the above is big-endian and the user programs
// expect the data to be in the host endian. That's bad. For now
// just send the data in host endian, but this will break when
// terminals are accessed over the network.
buf = (byte*) &codepoint;
buf = (uint8_t*) &codepoint;
}
if ( bufsize < partiallywritten ) { partiallywritten = bufsize; }
buf += partiallywritten;
@ -307,7 +307,7 @@ namespace Sortix
return sofar;
}
ssize_t LogTerminal::Write(const byte* src, size_t count)
ssize_t LogTerminal::Write(const uint8_t* src, size_t count)
{
Log::PrintData(src, count);
return count;

View file

@ -43,8 +43,8 @@ namespace Sortix
virtual ~LogTerminal();
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();

View file

@ -46,11 +46,11 @@ namespace Sortix
typedef Device BaseClass;
public:
DevPipeStorage(byte* buffer, size_t buffersize);
DevPipeStorage(uint8_t* buffer, size_t buffersize);
~DevPipeStorage();
private:
byte* buffer;
uint8_t* buffer;
size_t buffersize;
size_t bufferoffset;
size_t bufferused;
@ -65,8 +65,8 @@ namespace Sortix
kthread_cond_t writecond;
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -76,7 +76,7 @@ namespace Sortix
};
DevPipeStorage::DevPipeStorage(byte* buffer, size_t buffersize)
DevPipeStorage::DevPipeStorage(uint8_t* buffer, size_t buffersize)
{
this->buffer = buffer;
this->buffersize = buffersize;
@ -97,7 +97,7 @@ namespace Sortix
bool DevPipeStorage::IsReadable() { return true; }
bool DevPipeStorage::IsWritable() { return true; }
ssize_t DevPipeStorage::Read(byte* dest, size_t count)
ssize_t DevPipeStorage::Read(uint8_t* dest, size_t count)
{
if ( count == 0 ) { return 0; }
#ifdef GOT_ACTUAL_KTHREAD
@ -145,7 +145,7 @@ namespace Sortix
#endif
}
ssize_t DevPipeStorage::Write(const byte* src, size_t count)
ssize_t DevPipeStorage::Write(const uint8_t* src, size_t count)
{
if ( count == 0 ) { return 0; }
#ifdef GOT_ACTUAL_KTHREAD
@ -223,8 +223,8 @@ namespace Sortix
DevStream* stream;
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -242,12 +242,12 @@ namespace Sortix
stream->Unref();
}
ssize_t DevPipeReading::Read(byte* dest, size_t count)
ssize_t DevPipeReading::Read(uint8_t* dest, size_t count)
{
return stream->Read(dest, count);
}
ssize_t DevPipeReading::Write(const byte* /*src*/, size_t /*count*/)
ssize_t DevPipeReading::Write(const uint8_t* /*src*/, size_t /*count*/)
{
Error::Set(EBADF);
return -1;
@ -276,8 +276,8 @@ namespace Sortix
DevStream* stream;
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
@ -295,13 +295,13 @@ namespace Sortix
stream->Unref();
}
ssize_t DevPipeWriting::Read(byte* /*dest*/, size_t /*count*/)
ssize_t DevPipeWriting::Read(uint8_t* /*dest*/, size_t /*count*/)
{
Error::Set(EBADF);
return -1;
}
ssize_t DevPipeWriting::Write(const byte* src, size_t count)
ssize_t DevPipeWriting::Write(const uint8_t* src, size_t count)
{
return stream->Write(src, count);
}
@ -325,7 +325,7 @@ namespace Sortix
// TODO: Validate that pipefd is a valid user-space array!
size_t buffersize = BUFFER_SIZE;
byte* buffer = new byte[buffersize];
uint8_t* buffer = new uint8_t[buffersize];
if ( !buffer ) { return -1; /* TODO: ENOMEM */ }
// Transfer ownership of the buffer to the storage device.

View file

@ -505,7 +505,7 @@ namespace Sortix
ResetAddressSpace();
}
int Process::Execute(const char* programname, const byte* program,
int Process::Execute(const char* programname, const uint8_t* program,
size_t programsize, int argc, const char* const* argv,
int envc, const char* const* envp,
CPU::InterruptRegisters* regs)
@ -634,7 +634,7 @@ namespace Sortix
if ( !dev->IsReadable() ) { Error::Set(EBADF); goto cleanup_dev; }
count = needed;
buffer = new byte[count];
buffer = new uint8_t[count];
if ( !buffer ) { goto cleanup_dev; }
sofar = 0;
while ( sofar < count )

View file

@ -106,7 +106,7 @@ namespace Sortix
ProcessSegment* segments;
public:
int Execute(const char* programname, const byte* program,
int Execute(const char* programname, const uint8_t* program,
size_t programsize, int argc, const char* const* argv,
int envc, const char* const* envp,
CPU::InterruptRegisters* regs);

View file

@ -41,7 +41,7 @@ namespace Sortix
CPU::OutPortB(0x61, TMP);
}
void Play(nat Frequency)
void Play(unsigned Frequency)
{
ScopedLock lock(&soundlock);
//Set the PIT to the desired frequency

View file

@ -31,7 +31,7 @@ namespace Sortix
{
void Init();
void Mute();
void Play(nat Frequency);
void Play(unsigned Frequency);
}
}

View file

@ -38,8 +38,8 @@ namespace Sortix
virtual bool IsType(unsigned type) const { return type == Device::STREAM; }
public:
virtual ssize_t Read(byte* dest, size_t count) = 0;
virtual ssize_t Write(const byte* src, size_t count) = 0;
virtual ssize_t Read(uint8_t* dest, size_t count) = 0;
virtual ssize_t Write(const uint8_t* src, size_t count) = 0;
virtual bool IsReadable() = 0;
virtual bool IsWritable() = 0;

View file

@ -35,59 +35,59 @@ namespace Sortix
{
namespace UART
{
const nat TXR = 0; // Transmit register
const nat RXR = 0; // Receive register
const nat IER = 1; // Interrupt Enable
const nat IIR = 2; // Interrupt ID
const nat FCR = 2; // FIFO control
const nat LCR = 3; // Line control
const nat MCR = 4; // Modem control
const nat LSR = 5; // Line Status
const nat MSR = 6; // Modem Status
const nat DLL = 0; // Divisor Latch Low
const nat DLM = 1; // Divisor latch High
const unsigned TXR = 0; // Transmit register
const unsigned RXR = 0; // Receive register
const unsigned IER = 1; // Interrupt Enable
const unsigned IIR = 2; // Interrupt ID
const unsigned FCR = 2; // FIFO control
const unsigned LCR = 3; // Line control
const unsigned MCR = 4; // Modem control
const unsigned LSR = 5; // Line Status
const unsigned MSR = 6; // Modem Status
const unsigned DLL = 0; // Divisor Latch Low
const unsigned DLM = 1; // Divisor latch High
const nat LCR_DLAB = 0x80; // Divisor latch access bit
const nat LCR_SBC = 0x40; // Set break control
const nat LCR_SPAR = 0x20; // Stick parity (?)
const nat LCR_EPAR = 0x10; // Even parity select
const nat LCR_PARITY = 0x08; // Parity Enable
const nat LCR_STOP = 0x04; // Stop bits: 0=1 bit, 1=2 bits
const nat LCR_WLEN5 = 0x00; // Wordlength: 5 bits
const nat LCR_WLEN6 = 0x01; // Wordlength: 6 bits
const nat LCR_WLEN7 = 0x02; // Wordlength: 7 bits
const nat LCR_WLEN8 = 0x03; // Wordlength: 8 bits
const unsigned LCR_DLAB = 0x80; // Divisor latch access bit
const unsigned LCR_SBC = 0x40; // Set break control
const unsigned LCR_SPAR = 0x20; // Stick parity (?)
const unsigned LCR_EPAR = 0x10; // Even parity select
const unsigned LCR_PARITY = 0x08; // Parity Enable
const unsigned LCR_STOP = 0x04; // Stop bits: 0=1 bit, 1=2 bits
const unsigned LCR_WLEN5 = 0x00; // Wordlength: 5 bits
const unsigned LCR_WLEN6 = 0x01; // Wordlength: 6 bits
const unsigned LCR_WLEN7 = 0x02; // Wordlength: 7 bits
const unsigned LCR_WLEN8 = 0x03; // Wordlength: 8 bits
const nat LSR_TEMT = 0x40; // Transmitter empty
const nat LSR_THRE = 0x20; // Transmit-hold-register empty
const nat LSR_READY = 0x1;
const unsigned LSR_TEMT = 0x40; // Transmitter empty
const unsigned LSR_THRE = 0x20; // Transmit-hold-register empty
const unsigned LSR_READY = 0x1;
const nat Port = 0x3f8;
const unsigned Port = 0x3f8;
const nat BASE_BAUD = 1843200/16;
const nat BOTH_EMPTY = LSR_TEMT | LSR_THRE;
const unsigned BASE_BAUD = 1843200/16;
const unsigned BOTH_EMPTY = LSR_TEMT | LSR_THRE;
const unsigned FrameWidth = 80;
const unsigned FrameHeight = 25;
uint16_t VGALastFrame[FrameWidth * FrameHeight];
nat ProbeBaud(nat Port)
unsigned ProbeBaud(unsigned Port)
{
uint8_t lcr = CPU::InPortB(Port + LCR);
CPU::OutPortB(Port + LCR, lcr | LCR_DLAB);
uint8_t dll = CPU::InPortB(Port + DLL);
uint8_t dlm = CPU::InPortB(Port + DLM);
CPU::OutPortB(Port + LCR, lcr);
nat quot = (dlm << 8) | dll;
unsigned quot = (dlm << 8) | dll;
return BASE_BAUD / quot;
}
void WaitForEmptyBuffers(nat Port)
void WaitForEmptyBuffers(unsigned Port)
{
while ( true )
{
nat Status = CPU::InPortB(Port + LSR);
unsigned Status = CPU::InPortB(Port + LSR);
if ( (Status & BOTH_EMPTY) == BOTH_EMPTY )
{
@ -96,7 +96,7 @@ namespace Sortix
}
}
nat Baud;
unsigned Baud;
void Init()
{
@ -114,7 +114,7 @@ namespace Sortix
CPU::OutPortB(Port + FCR, 0); // No FIFO
CPU::OutPortB(Port + MCR, 0x3); // DTR + RTS
nat Divisor = 115200 / Baud;
unsigned Divisor = 115200 / Baud;
uint8_t C = CPU::InPortB(Port + LCR);
CPU::OutPortB(Port + LCR, C | LCR_DLAB);
CPU::OutPortB(Port + DLL, Divisor & 0xFF);
@ -125,7 +125,7 @@ namespace Sortix
void Read(uint8_t* Buffer, size_t Size)
{
// Save the IER and disable interrupts.
nat ier = CPU::InPortB(Port + IER);
unsigned ier = CPU::InPortB(Port + IER);
CPU::OutPortB(Port + IER, 0);
for ( size_t I = 0; I < Size; I++ )
@ -145,7 +145,7 @@ namespace Sortix
const uint8_t* Buffer = (const uint8_t*) B;
// Save the IER and disable interrupts.
nat ier = CPU::InPortB(Port + IER);
unsigned ier = CPU::InPortB(Port + IER);
CPU::OutPortB(Port + IER, 0);
for ( size_t I = 0; I < Size; I++ )
@ -163,7 +163,7 @@ namespace Sortix
void WriteChar(char C)
{
// Save the IER and disable interrupts.
nat ier = CPU::InPortB(Port + IER);
unsigned ier = CPU::InPortB(Port + IER);
CPU::OutPortB(Port + IER, 0);
WaitForEmptyBuffers(Port);
@ -178,7 +178,7 @@ namespace Sortix
int TryPopChar()
{
// Save the IER and disable interrupts.
nat ier = CPU::InPortB(Port + IER);
unsigned ier = CPU::InPortB(Port + IER);
CPU::OutPortB(Port + IER, 0);
int Result = -1;
@ -204,37 +204,37 @@ namespace Sortix
}
// Change from VGA color to another color system.
nat ConversionTable[16] = { 0, 4, 2, 6, 1, 5, 3, 7, 0, 4, 2, 6, 1, 5, 3, 7 };
unsigned ConversionTable[16] = { 0, 4, 2, 6, 1, 5, 3, 7, 0, 4, 2, 6, 1, 5, 3, 7 };
void InvalidateVGA()
{
for ( nat I = 0; I < FrameWidth * FrameHeight; I++ ) { VGALastFrame[I] = 0; }
for ( unsigned I = 0; I < FrameWidth * FrameHeight; I++ ) { VGALastFrame[I] = 0; }
}
void RenderVGA(const uint16_t* Frame)
{
const uint16_t* Source = Frame;
nat LastColor = 1337;
nat SkippedSince = 0;
unsigned LastColor = 1337;
unsigned SkippedSince = 0;
bool posundefined = true;
for ( nat Y = 0; Y < FrameHeight; Y++)
for ( unsigned Y = 0; Y < FrameHeight; Y++)
{
for ( nat X = 0; X < FrameWidth; X++ )
for ( unsigned X = 0; X < FrameWidth; X++ )
{
nat Index = Y * FrameWidth + X;
unsigned Index = Y * FrameWidth + X;
nat Element = Source[Index];
nat OldElement = VGALastFrame[Index];
unsigned Element = Source[Index];
unsigned OldElement = VGALastFrame[Index];
if ( Element == OldElement ) { continue; }
// Update the position if we skipped some characters.
if ( Index - SkippedSince > 8 || posundefined )
{
const nat LineId = Y + 1;
const nat ColumnId = X + 1;
const unsigned LineId = Y + 1;
const unsigned ColumnId = X + 1;
if ( ColumnId > 1 )
{
@ -260,20 +260,20 @@ namespace Sortix
posundefined = false;
}
for ( nat Pos = SkippedSince; Pos <= Index; Pos++ )
for ( unsigned Pos = SkippedSince; Pos <= Index; Pos++ )
{
Element = Source[Pos];
OldElement = VGALastFrame[Pos];
nat NewColor = (ConversionTable[ (Element >> 12) & 0xF ] << 3) | (ConversionTable[ (Element >> 8) & 0xF ]);
unsigned NewColor = (ConversionTable[ (Element >> 12) & 0xF ] << 3) | (ConversionTable[ (Element >> 8) & 0xF ]);
// Change the color if we need to.
if ( LastColor != NewColor )
{
nat OldFGColor = LastColor % 8;
nat OldBGColor = LastColor / 8;
nat FGColor = NewColor % 8;
nat BGColor = NewColor / 8;
unsigned OldFGColor = LastColor % 8;
unsigned OldBGColor = LastColor / 8;
unsigned FGColor = NewColor % 8;
unsigned BGColor = NewColor / 8;
if ( LastColor == 1337 ) { OldFGColor = 9; OldBGColor = 9; }
if ( (OldFGColor != FGColor) && (OldBGColor != BGColor) )

View file

@ -40,7 +40,7 @@ using namespace Maxsi;
namespace Sortix {
namespace VGA {
uint8_t* const VGA = (byte* const) 0xB8000;
uint8_t* const VGA = (uint8_t* const) 0xB8000;
const unsigned WIDTH = 80;
const unsigned HEIGHT = 25;
const size_t VGA_SIZE = sizeof(uint16_t) * WIDTH * HEIGHT;
@ -142,7 +142,7 @@ void Init()
// Changes the position of the hardware cursor.
void SetCursor(unsigned x, unsigned y)
{
nat value = x + y * WIDTH;
unsigned value = x + y * WIDTH;
// This sends a command to indicies 14 and 15 in the
// CRT Control Register of the VGA controller. These
@ -173,7 +173,7 @@ DevVGA::~DevVGA()
#endif
}
ssize_t DevVGA::Read(byte* dest, size_t count)
ssize_t DevVGA::Read(uint8_t* dest, size_t count)
{
if ( VGA::VGA_SIZE - offset < count ) { count = VGA::VGA_SIZE - offset; }
Maxsi::Memory::Copy(dest, VGA::VGA + offset, count);
@ -181,7 +181,7 @@ ssize_t DevVGA::Read(byte* dest, size_t count)
return count;
}
ssize_t DevVGA::Write(const byte* src, size_t count)
ssize_t DevVGA::Write(const uint8_t* src, size_t count)
{
if ( offset == VGA::VGA_SIZE && count ) { Error::Set(ENOSPC); return -1; }
if ( VGA::VGA_SIZE - offset < count ) { count = VGA::VGA_SIZE - offset; }

View file

@ -58,8 +58,8 @@ private:
size_t offset;
public:
virtual ssize_t Read(byte* dest, size_t count);
virtual ssize_t Write(const byte* src, size_t count);
virtual ssize_t Read(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
virtual bool IsReadable();
virtual bool IsWritable();
virtual size_t BlockSize();