Sortix now uses the Device class.

This class is very WIP and is just experimental.
This commit is contained in:
Jonas 'Sortie' Termansen 2011-08-08 15:15:55 +02:00
parent e95eb60d31
commit 1026354e98
3 changed files with 26 additions and 25 deletions

View File

@ -43,7 +43,7 @@ DEFINES:=$(DEFINES) -DINITRD
CPPFLAGSRELEASE=-s -O3 CPPFLAGSRELEASE=-s -O3
CPPFLAGSDEBUG= CPPFLAGSDEBUG=
CPPFLAGS=-I.. $(CPUDEFINES) $(CPUFLAGS) -std=gnu++0x -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector $(DEFINES) $(CPPFLAGSRELEASE) CPPFLAGS=-I.. $(CPUDEFINES) $(CPUFLAGS) -std=gnu++0x -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector $(DEFINES) $(CPPFLAGSRELEASE)
OBJS=$(CPUOBJS) kernel.o descriptor_tables.o isr.o time.o log.o iprintable.o panic.o keyboard.o memorymanagement.o scheduler.o syscall.o application.o pong.o sound.o pci.o uart.o conway.o test.o http.o vgaterminal.o serialterminal.o descriptors.o ../libmaxsi/libmaxsi-sortix.a OBJS=$(CPUOBJS) kernel.o descriptor_tables.o isr.o time.o log.o iprintable.o panic.o keyboard.o memorymanagement.o scheduler.o syscall.o application.o pong.o sound.o pci.o uart.o conway.o test.o http.o vgaterminal.o serialterminal.o descriptors.o device.o ../libmaxsi/libmaxsi-sortix.a
JSOBJS:=$(subst .o,-js.o,$(OBJS)) JSOBJS:=$(subst .o,-js.o,$(OBJS))
all: sortix.bin all: sortix.bin

View File

@ -23,17 +23,19 @@
******************************************************************************/ ******************************************************************************/
#include "platform.h" #include "platform.h"
#include <libmaxsi/memory.h>
#include "device.h" #include "device.h"
namespace Sortix namespace Sortix
{ {
void Device::close() bool Device::Close()
{ {
_refCount--; _refCount--;
if ( _refCount == 0 ) if ( _refCount == 0 )
{ {
delete this; delete this;
} }
return true;
} }
void Device::Think() void Device::Think()
@ -52,5 +54,3 @@ namespace Sortix
} }
} }
#endif

View File

@ -33,33 +33,34 @@ namespace Sortix
{ {
public: public:
// Flags // Flags
const nat READABLE = (1<<0); static const nat READABLE = (1<<0);
const nat WRITABLE = (1<<1); static const nat WRITABLE = (1<<1);
const nat SEEKABLE = (1<<2); static const nat SEEKABLE = (1<<2);
const nat SIZEABLE = (1<<3); static const nat SIZEABLE = (1<<3);
const nat BLOCK = (1<<4); static const nat BLOCK = (1<<4);
const nat FLAGMASK = ((1<<5)-1); static const nat FLAGMASK = ((1<<5)-1);
// Types // Types
const nat TYPEMASK = ~FLAGMASK; static const nat TYPEMASK = ~FLAGMASK;
const nat STREAM = (1<<5); static const nat STREAM = (1<<5);
const nat BUFFER = (2<<5); static const nat BUFFER = (2<<5);
const nat DIRECTORY = (3<<5); static const nat DIRECTORY = (3<<5);
const nat FILESYSTEM = (4<<5); static const nat FILESYSTEM = (4<<5);
const nat NETWORK = (5<<5); static const nat NETWORK = (5<<5);
const nat SOUND = (6<<5); static const nat SOUND = (6<<5);
const nat GRAPHICS = (7<<5); static const nat GRAPHICS = (7<<5);
const nat MOUSE = (8<<5); static const nat MOUSE = (8<<5);
const nat KEYBOARD = (9<<5); static const nat KEYBOARD = (9<<5);
const nat PRINTER = (10<<5); static const nat PRINTER = (10<<5);
const nat SCANNER = (11<<5); static const nat SCANNER = (11<<5);
const nat OTHER = TYPEMASK; static const nat VGABUFFER = (12<<5);
static const nat OTHER = TYPEMASK;
public: public:
volatile size_t _refCount; volatile size_t _refCount;
public: public:
Device() { RefCount = 1; } Device() { _refCount = 1; }
virtual ~Device() { } virtual ~Device() { }
private: private:
@ -80,7 +81,7 @@ namespace Sortix
virtual nat Flags() = 0; virtual nat Flags() = 0;
public: public:
bool IsType(nat type) { return Flags() & TYPEMASK == type); } bool IsType(nat type) { return (Flags() & TYPEMASK) == type; }
}; };
} }