mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:47:34 +00:00
Add the basic character devices to kernel.
This commit is contained in:
parent
12e515735b
commit
aec8ab0a60
13 changed files with 52 additions and 58 deletions
|
@ -2,8 +2,7 @@
|
|||
#include "Limits.h"
|
||||
#include "sys-errno.h"
|
||||
#include <AK/StdLib.h>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <AK/kstdio.h>
|
||||
|
||||
FullDevice::FullDevice()
|
||||
{
|
||||
|
@ -15,7 +14,7 @@ FullDevice::~FullDevice()
|
|||
|
||||
Unix::ssize_t FullDevice::read(byte* buffer, Unix::size_t bufferSize)
|
||||
{
|
||||
printf("read from full device\n");
|
||||
kprintf("FullDevice: read from full\n");
|
||||
Unix::size_t count = min(GoodBufferSize, bufferSize);
|
||||
memset(buffer, 0, count);
|
||||
return count;
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include "UnixTypes.h"
|
||||
|
||||
#ifdef SERENITY_KERNEL
|
||||
inline static const Unix::off_t maxFileOffset = 9223372036854775807LL;
|
||||
#else
|
||||
#include <limits>
|
||||
inline static const Unix::off_t maxFileOffset = std::numeric_limits<Unix::off_t>::max();
|
||||
#endif
|
||||
|
||||
static const Unix::size_t GoodBufferSize = 4096;
|
||||
|
||||
inline static const Unix::off_t maxFileOffset = std::numeric_limits<Unix::off_t>::max();
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include "NullDevice.h"
|
||||
#include "Limits.h"
|
||||
#include <AK/StdLib.h>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <AK/kstdio.h>
|
||||
|
||||
NullDevice::NullDevice()
|
||||
{
|
||||
|
@ -14,7 +13,7 @@ NullDevice::~NullDevice()
|
|||
|
||||
Unix::ssize_t NullDevice::read(byte*, Unix::size_t)
|
||||
{
|
||||
printf("read from null\n");
|
||||
kprintf("NullDevice: read from null\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "RandomDevice.h"
|
||||
#include "Limits.h"
|
||||
#include <AK/StdLib.h>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
RandomDevice::RandomDevice()
|
||||
{
|
||||
|
@ -23,10 +21,12 @@ static int myrand()
|
|||
return((unsigned)(next/((MY_RAND_MAX + 1) * 2)) % (MY_RAND_MAX + 1));
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void mysrand(unsigned seed)
|
||||
{
|
||||
next = seed;
|
||||
}
|
||||
#endif
|
||||
|
||||
Unix::ssize_t RandomDevice::read(byte* buffer, Unix::size_t bufferSize)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include "ZeroDevice.h"
|
||||
#include "Limits.h"
|
||||
#include <AK/StdLib.h>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <AK/kstdio.h>
|
||||
|
||||
ZeroDevice::ZeroDevice()
|
||||
{
|
||||
|
@ -14,7 +13,7 @@ ZeroDevice::~ZeroDevice()
|
|||
|
||||
Unix::ssize_t ZeroDevice::read(byte* buffer, Unix::size_t bufferSize)
|
||||
{
|
||||
printf("read from zero device\n");
|
||||
kprintf("ZeroDevice: read from zero\n");
|
||||
Unix::size_t count = min(GoodBufferSize, bufferSize);
|
||||
memset(buffer, 0, count);
|
||||
return count;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue