Page 2 of 2

Re: An interesting operating system design

Posted: Sun Nov 23, 2008 7:55 pm
by thre3dee
01000101 wrote:This reminds me a lot of the AS/400 OS. It's files, 'folders', and libraries are all objects and so are programs and objects that compile them.

If you go the route of objects, please look at that OS and do 'almost' everything aesthetically different! It takes the complexity of a command line, and increases it 10-fold due to the odd sentence-like commands and object-based everything.
Well actually that was almost my exact idea. Even down to the kernel code. Since we have a C++ kernel project booting in Bochs there's no reason that we have to adhere to all the posix and 'standard' C/C++ conventions.

For example, instead of code like this:

Code: Select all

char tmp[256];
sprintf(tmp, "%d", myNum);
puts(tmp);
gets(tmp);
if (!strcmp(tmp, "EXIT"))
  _kexit();
Why can't our kernel code functions be like this? Using a little template object encapsulation in the process (like .NET formatting using argument indexes for better flexibity and safety such as the use of Arg<T>(arg)).

Code: Select all

char tmp[256];
FormatToBuffer(tmp, "{0:%d}{0:%02d}", Arg(myNum));
PrintString(tmp);
GetString(tmp);
if (!Compare(tmp, "Exit"))
    KernelExit();
As much as this is merely cosmetic change to standard C conventions, surely kernel code readability could benefit from not using obscure shorthand names like memcpy and strftime and vcnprintf etc. Even things like port I/O and other such low-level functions:

Code: Select all

PortOut(...);
PortIn(...);

// or this
OS::Port *OpenPort(...);
p->In();
p->Out();

// some threading code
OS::Thread *CreateThread(...);
OS::Thread *CallingThread(...);
thread->Terminate();
thread->Sleep();
if (thread->DidAwaken())
    scheduler->Schedule(thread);

// some console code
OS::Console *CreateConsole(...);
console->PrintFormat(...);
console->Clear();
OS::Stream *stdout = console->GetOutStream();

Re: An interesting operating system design

Posted: Sun Nov 23, 2008 10:59 pm
by Colonel Kernel
JAAman wrote:actually, windows already does this (and has since at least win95, iirc) unfortunately most driver writers have refused to comply with this, and instead use the old ring0 driver system
Do you have a source for this? AFAIK, for all Windows versions prior to Vista, drivers must run in ring 0, with a few exceptions like printer drivers. The only use of ring 1 I'm aware of in Windows is when virtualization software runs a guest OS' "kernel mode" via ring compression instead of using the new VT extensions.

Re: An interesting operating system design

Posted: Mon Nov 24, 2008 10:10 am
by JAAman
never said it uses ring1 -- windows avoids use of ring1 at all, due to the OS-independent structure (windows was designed so that its applications (and maybe drivers) could run seamlessly on any OS, not just windows) and also for hardware portability

it actually uses ring3, and i know winXP drivers were ring3, i thought it was before that also, but i could be wrong...

there were however some exceptions -- certain 'core' drivers required for the basic operation of the kernel were required to be ring0 (not sure what all was in that though)

and all x86-64 windows versions require all drivers to be ring3... ring0 drivers have never been allowed in 64bit versions, since the drivers would need to be rewritten anyway, there was no reason to support ring0 there

the greatest advantage of vista is not visible to the user -- its the complete rewrite of the security layer and driver interface that make it so much more stable and secure than any previous version of windows, and its just too bad it has gotten such bad (and completely undeserved) press

Re: An interesting operating system design

Posted: Mon Nov 24, 2008 10:36 am
by AJ
Hi,
JAAman wrote:it actually uses ring3, and i know winXP drivers were ring3
The public user mode driver framework was introduced with Vista, but was made available for XP (I have it installed as a separate update on XP if I go to add/remove programs). See here . MS had previously used ring 3 drivers with WMP10, but didn't make the interface public.
JAAman wrote:and all x86-64 windows versions require all drivers to be ring3
MS Website wrote:Kernel-mode drivers run in the same address space as 64-bit Windows.
Original quote here
Wikipedia also mentions on the XP versions page that "Only 64 bit kernel-mode drivers are supported" for XP64, which would indicate that they are ring 0.

As well as allowing ring 3 drivers (IIRC you can have ring0 elements for e.g. a video driver), I think one of the biggest changes in the vista driver interface is that all 64 bit drivers must be signed. On Vista 32 bit, you are warned about unsigned drivers but can continue anyway.

Cheers,
Adam