Ejemplo n.º 1
0
        public KModule( Kernel kernel, BiosModule metaModule, Module module )
        {
            Kernel = kernel;

            MetaModule = metaModule;
            Module = module;
        }
Ejemplo n.º 2
0
 public KFixedPool( Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize, int blockCount )
     : base(kernel, partition, name, attributes, blockSize)
 {
     Debug.Assert( blockCount > 0 );
     Debug.Assert( blockSize > 0 );
     this.BlockCount = blockCount;
 }
Ejemplo n.º 3
0
		public Module( Kernel kernel )
		{
			Debug.Assert( kernel != null );
			_kernel = kernel;

			_memory = _kernel.Memory;
			_memorySystem = _kernel.MemorySystem;
		}
Ejemplo n.º 4
0
 public KMessageBox(Kernel kernel, string name, int attr)
 {
     this.Kernel = kernel;
     this.Name = name;
     this.Attributes = attr;
     this.Messages = new FastLinkedList<int>();
     this.WaitingThreads = new FastLinkedList<KThread>();
 }
Ejemplo n.º 5
0
 public KMessagePipe( Kernel kernel, KPartition partition, string name, int size )
 {
     Kernel = kernel;
     Partition = partition;
     Name = name;
     Stream = new System.IO.MemoryStream(size);
     WaitingThreads = new FastLinkedList<KThread>();
 }
Ejemplo n.º 6
0
 public KFile( Kernel kernel )
 {
     Kernel = kernel;
     IsOpen = true;
     CanWrite = true;
     CanSeek = false;
     IsValid = true;
 }
Ejemplo n.º 7
0
		public KDevice( Kernel kernel, string name, string[] aliases, IMediaDevice device )
		{
			Kernel = kernel;
			Name = name;
			Aliases = aliases;
			Device = device;
			ReadOnly = device.IsReadOnly;
			IsBlockDevice = false;
		}
Ejemplo n.º 8
0
		public KDevice( Kernel kernel, string name, string[] aliases, bool readOnly, int blockSize )
		{
			Kernel = kernel;
			Name = name;
			Aliases = aliases;
			ReadOnly = readOnly;
			IsBlockDevice = true;
			BlockSize = blockSize;
		}
Ejemplo n.º 9
0
        public KMutex( Kernel kernel, string name, uint attributes )
        {
            Kernel = kernel;

            Name = name;
            Attributes = attributes;

            WaitingThreads = new FastLinkedList<KThread>();
        }
Ejemplo n.º 10
0
        public KEvent( Kernel kernel, string name, KEventAttributes attributes, uint initialValue )
        {
            Kernel = kernel;
            Name = name;
            Attributes = attributes;
            InitialValue = initialValue;
            Value = initialValue;

            WaitingThreads = new FastLinkedList<KThread>();
        }
Ejemplo n.º 11
0
		public KCallback( Kernel kernel, string name, KThread thread, uint address, uint commonAddress )
		{
			Kernel = kernel;
			Name = name;
			Thread = thread;
			Address = address;
			CommonAddress = commonAddress;

			NotifyCount = 0;
			NotifyArguments = 0;
		}
Ejemplo n.º 12
0
        public KIntHandler( Kernel kernel, int interruptNumber, int slot, uint address, uint argument )
        {
            Kernel = kernel;

            InterruptNumber = interruptNumber;
            Slot = slot;

            Address = address;
            Argument = argument;

            CallCount = 0;
        }
Ejemplo n.º 13
0
        public KFile( Kernel kernel, KDevice device, IMediaItem item )
        {
            Kernel = kernel;
            Device = device;
            Item = item;

            FolderOffset = 0;

            IsOpen = true;
            CanWrite = !( ( item.Attributes & MediaItemAttributes.ReadOnly ) == MediaItemAttributes.ReadOnly );
            CanSeek = false;
            IsValid = true;
        }
Ejemplo n.º 14
0
        public KSemaphore( Kernel kernel, string name, uint attributes, int initialCount, int maximumCount )
        {
            Kernel = kernel;

            Name = name;
            Attributes = attributes;

            InitialCount = initialCount;
            CurrentCount = initialCount;
            MaximumCount = maximumCount;

            WaitingThreads = new FastLinkedList<KThread>();
        }
Ejemplo n.º 15
0
        public KFile( Kernel kernel, KDevice device, IMediaItem item, Stream stream )
        {
            Kernel = kernel;
            Device = device;
            Item = item;

            FolderOffset = 0;

            Stream = stream;

            IsOpen = true;
            CanWrite = stream.CanWrite;
            CanSeek = stream.CanSeek;
            IsValid = true;
        }
Ejemplo n.º 16
0
        public Bios( IEmulationInstance emulator, ComponentParameters parameters )
        {
            Debug.Assert( emulator != null );
            Debug.Assert( parameters != null );
            _emulator = emulator;
            _parameters = parameters;

            Diag.Instance.Database = new DebugDatabase();

            _kernel = new Kernel( this );
            _loader = new Loader( this );

            _gameSetEvent = new AutoResetEvent( false );

            this.GatherModulesAndFunctions();
        }
Ejemplo n.º 17
0
        public KPartition( Kernel kernel, uint baseAddress, uint size )
        {
            Kernel = kernel;

            BaseAddress = baseAddress;
            Size = size;
            UpperBound = baseAddress + size;
            FreeSize = size;

            Blocks = new FastLinkedList<KMemoryBlock>();
            FreeList = new FastLinkedList<KMemoryBlock>();

            // Initial empty block
            KMemoryBlock block = new KMemoryBlock( this, baseAddress, size, true );
            Blocks.Enqueue( block );
            FreeList.Enqueue( block );
        }
Ejemplo n.º 18
0
        public KPool( Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize )
        {
            Debug.Assert( partition != null );
            Debug.Assert( name != null );
            Debug.Assert( blockSize > 0 );

            Kernel = kernel;

            Name = name;
            Attributes = attributes;
            BlockSize = blockSize;
            Partition = partition;

            Blocks = new FastLinkedList<KMemoryBlock>();
            UsedBlocks = new FastLinkedList<KMemoryBlock>();
            FreeBlocks = new FastLinkedList<KMemoryBlock>();

            WaitingThreads = new FastLinkedList<KThread>();
        }
Ejemplo n.º 19
0
        public KModule( Kernel kernel, BiosModule metaModule )
        {
            Kernel = kernel;

            MetaModule = metaModule;

            if( metaModule != null )
            {
                Name = metaModule.Name;

                foreach( StubExport ex in metaModule.Exports )
                {
                    switch( ex.NID )
                    {
                        case 0xF01D73A7:
                            ModuleInfo = ex.Address;
                            break;
                        case 0xD3744BE0:
                            ModuleBootStart = ex.Address;
                            break;
                        case 0x2F064FA6:
                            ModuleRebootBefore = ex.Address;
                            break;
                        case 0xD632ACDB:
                            ModuleStart = ex.Address;
                            break;
                        case 0x0F7C276C:
                            ModuleStartThreadParam = ex.Address;
                            break;
                        case 0xCEE8593C:
                            ModuleStop = ex.Address;
                            break;
                        case 0xCF0CC697:
                            ModuleStopThreadParam = ex.Address;
                            break;
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public KThread( Kernel kernel, KModule module, KPartition partition, string name, uint entryAddress, int priority, KThreadAttributes attributes, uint stackSize )
        {
            Debug.Assert( partition != null );

            Kernel = kernel;

            Name = name;
            EntryAddress = entryAddress;
            InitialPriority = priority;
            Priority = priority;
            Attributes = attributes;
            Module = module;

            State = KThreadState.Stopped;

            ExitWaiters = new FastLinkedList<KThread>();
            NotifiedCallbacks = new FastLinkedList<KCallback>();

            //if( stackSize < 65535 )
            //{
            //    Log.WriteLine( Verbosity.Normal, Feature.Bios, "KThread: attempt to allocate thread with a stack of {0} - forcing up to the minimum of 64K", stackSize );
            //    stackSize = 65535;
            //}

            RunClocks = 0;
            InterruptPreemptionCount = 0;
            ThreadPreemptionCount = 0;

            Partition = partition;
            StackBlock = partition.Allocate( string.Format( "Thread '{0}' Stack", name ), KAllocType.High, 0, stackSize );
            Debug.Assert( StackBlock != null );
            TlsBlock = partition.Allocate( string.Format( "Thread '{0}' TLS", name ), KAllocType.High, 0, 0x4000 ); // 16k of thread local storage --- enough?
            Debug.Assert( TlsBlock != null );
        }
Ejemplo n.º 21
0
 public KFile(Kernel kernel, bool valid)
 {
     Kernel = kernel;
     IsOpen = false;
     CanWrite = true;
     CanSeek = false;
     IsValid = valid;
 }
Ejemplo n.º 22
0
        private bool FixupDelayedImports( Kernel kernel, LoadResults results )
        {
            int fixupCount = 0;
            foreach( KModule previous in kernel.UserModules )
            {
                if( previous.LoadResults.MissingImports.Count == 0 )
                    continue;

                LinkedListEntry<DelayedImport> e = previous.LoadResults.MissingImports.HeadEntry;
                while( e != null )
                {
                    LinkedListEntry<DelayedImport> next = e.Next;
                    DelayedImport import = e.Value;
                    if( results.ExportNames.Contains( import.StubImport.ModuleName ) == true )
                    {
                        // Find export
                        StubExport myExport = null;
                        foreach( StubExport export in results.Exports )
                        {
                            if( export.NID == import.StubImport.NID )
                            {
                                myExport = export;
                                break;
                            }
                        }
                        if( myExport != null )
                        {
                            previous.LoadResults.MissingImports.Remove( e );
                            fixupCount++;

                            // Fixup
                            Log.WriteLine( Verbosity.Verbose, Feature.Loader, "Fixing up module {0} delayed import 0x{1:X8}; value={2:X8}", previous.Name, import.StubImport.NID, myExport.Address );

                            Debug.Assert( myExport.Type == import.StubImport.Type );
                            if( myExport.Type == StubType.Function )
                            {
                                BiosFunction function = import.StubImport.Function;
                                // TODO: Change function module, etc?

                                // Perform fixup
                                uint* pcode = ( uint* )kernel.MemorySystem.Translate( function.StubAddress );
                                {
                                    // j {target}
                                    // nop
                                    *( pcode + 0 ) = ( uint )( ( 2 << 26 ) | ( ( myExport.Address >> 2 ) & 0x03FFFFFF ) );
                                    *( pcode + 1 ) = ( uint )0;
                                }
                            }
                            else
                            {
                                throw new NotImplementedException( "Cannot handle fixups of variable imports" );
                            }
                        }
                    }
                    e = next;
                }
            }
            return true;
        }
Ejemplo n.º 23
0
        public KStdFile( Kernel kernel, KSpecialFileHandle specialFileHandle )
            : base(kernel)
        {
            UID = ( uint )specialFileHandle;
            switch( specialFileHandle )
            {
                case KSpecialFileHandle.StdIn:
                    _name = "stdin";
                    break;
                case KSpecialFileHandle.StdOut:
                    _name = "stdout";
                    break;
                case KSpecialFileHandle.StdErr:
                    _name = "stderr";
                    break;
            }

            _sb = new StringBuilder();
        }
Ejemplo n.º 24
0
 public KVariablePool( Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize )
     : base(kernel, partition, name, attributes, blockSize)
 {
 }