From bb9e90941b4ae715074569f424ed894c89d284ca Mon Sep 17 00:00:00 2001 From: nakst <> Date: Tue, 21 Sep 2021 13:35:06 +0100 Subject: [PATCH] misc --- apps/system_monitor.cpp | 10 ++++++---- desktop/api.cpp | 2 +- desktop/os.header | 5 +++-- drivers/esfs2.cpp | 1 + drivers/fat.cpp | 1 + drivers/iso9660.cpp | 3 +++ drivers/ntfs.cpp | 2 ++ kernel/files.cpp | 1 - kernel/module.h | 1 + kernel/scheduler.cpp | 1 - kernel/syscall.cpp | 6 ++++++ 11 files changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/system_monitor.cpp b/apps/system_monitor.cpp index 3e25449..22a986d 100644 --- a/apps/system_monitor.cpp +++ b/apps/system_monitor.cpp @@ -24,10 +24,11 @@ struct Instance : EsInstance { EsListViewColumn listViewProcessesColumns[] = { { EsLiteral("Name"), 0, 150 }, - { EsLiteral("PID"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 150 }, - { EsLiteral("Memory"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 150 }, - { EsLiteral("CPU"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 150 }, - { EsLiteral("Handles"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 150 }, + { EsLiteral("PID"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 120 }, + { EsLiteral("Memory"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 120 }, + { EsLiteral("CPU"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 120 }, + { EsLiteral("Handles"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 120 }, + { EsLiteral("Threads"), ES_LIST_VIEW_COLUMN_RIGHT_ALIGNED, 120 }, }; EsListViewColumn listViewContextSwitchesColumns[] = { @@ -316,6 +317,7 @@ int ListViewProcessesCallback(EsElement *element, EsMessage *message) { else if (column == 2) GET_CONTENT("%D", item->data.memoryUsage); else if (column == 3) GET_CONTENT("%d%%", item->cpuUsage); else if (column == 4) GET_CONTENT("%d", item->data.handleCount); + else if (column == 5) GET_CONTENT("%d", item->data.threadCount); else EsAssert(false); } else if (message->type == ES_MSG_LIST_VIEW_IS_SELECTED) { message->selectItem.isSelected = processes[message->selectItem.index].data.pid == selectedPID; diff --git a/desktop/api.cpp b/desktop/api.cpp index 29732c7..6680ed3 100644 --- a/desktop/api.cpp +++ b/desktop/api.cpp @@ -1330,7 +1330,7 @@ void EsInstanceSaveComplete(EsMessage *message, bool success) { } uintptr_t EsSystemGetOptimalWorkQueueThreadCount() { - return api.startupInformation->optimalWorkQueueThreadCount; + return EsSyscall(ES_SYSCALL_PROCESSOR_COUNT, 0, 0, 0, 0); } void ThreadInitialise(ThreadLocalStorage *local) { diff --git a/desktop/os.header b/desktop/os.header index ac1fa36..0e28448 100644 --- a/desktop/os.header +++ b/desktop/os.header @@ -867,6 +867,7 @@ enum EsSyscallType { ES_SYSCALL_PRINT ES_SYSCALL_SHUTDOWN ES_SYSCALL_SYSTEM_TAKE_SNAPSHOT + ES_SYSCALL_PROCESSOR_COUNT // End. @@ -1256,7 +1257,7 @@ struct EsDebuggerMessage { } struct EsSnapshotProcessesItem { - int64_t pid, memoryUsage, cpuTimeSlices, idleTimeSlices, handleCount; + int64_t pid, memoryUsage, cpuTimeSlices, idleTimeSlices, handleCount, threadCount; char name[ES_SNAPSHOT_MAX_PROCESS_NAME_LENGTH]; uint8_t nameBytes; bool isKernel; @@ -1284,7 +1285,6 @@ struct EsProcessStartupInformation { uintptr_t tlsImageBytes; uintptr_t tlsBytes; // All bytes after the image are to be zeroed. uintptr_t timeStampTicksPerMs; - uintptr_t optimalWorkQueueThreadCount; EsProcessCreateData data; }; @@ -1526,6 +1526,7 @@ struct EsVolumeInformation { EsObjectID id; EsFileOffset spaceTotal; EsFileOffset spaceUsed; + EsUniqueIdentifier identifier; EsUniqueIdentifier installationIdentifier; // Currently only supported by EsFS. }; diff --git a/drivers/esfs2.cpp b/drivers/esfs2.cpp index 746b515..9e3d0c6 100644 --- a/drivers/esfs2.cpp +++ b/drivers/esfs2.cpp @@ -1971,6 +1971,7 @@ static void Register(KDevice *_parent) { volume->spaceUsed = volume->superblock.blocksUsed * volume->superblock.blockSize; volume->spaceTotal = volume->superblock.blockCount * volume->superblock.blockSize; + volume->identifier = volume->superblock.identifier; volume->read = Read; volume->scan = Scan; diff --git a/drivers/fat.cpp b/drivers/fat.cpp index f9258b4..be3d095 100644 --- a/drivers/fat.cpp +++ b/drivers/fat.cpp @@ -433,6 +433,7 @@ static void DeviceAttach(KDevice *parent) { volume->directoryEntryDataBytes = sizeof(DirectoryEntryReference); volume->nodeDataBytes = sizeof(FSNode); + EsMemoryCopy(&volume->identifier, volume->type == TYPE_FAT32 ? &volume->sb32.serial : &volume->sb16.serial, sizeof(uint32_t)); FSRegisterFileSystem(volume); } diff --git a/drivers/iso9660.cpp b/drivers/iso9660.cpp index f1bf050..ad641f1 100644 --- a/drivers/iso9660.cpp +++ b/drivers/iso9660.cpp @@ -512,6 +512,9 @@ static void DeviceAttach(KDevice *parent) { volume->spaceUsed = volume->primaryDescriptor.volumeSize.x * volume->primaryDescriptor.logicalBlockSize.x; volume->spaceTotal = volume->spaceUsed; + uint64_t crc64 = CalculateCRC64(&volume->primaryDescriptor, sizeof(PrimaryDescriptor)); + EsMemoryCopy(&volume->identifier, &crc64, sizeof(crc64)); + volume->nameBytes = sizeof(volume->primaryDescriptor.volumeIdentifier); if (volume->nameBytes > sizeof(volume->name)) volume->nameBytes = sizeof(volume->name); EsMemoryCopy(volume->name, volume->primaryDescriptor.volumeIdentifier, volume->nameBytes); diff --git a/drivers/ntfs.cpp b/drivers/ntfs.cpp index 4703c63..4d649b0 100644 --- a/drivers/ntfs.cpp +++ b/drivers/ntfs.cpp @@ -1255,6 +1255,8 @@ static void DeviceAttach(KDevice *parent) { volume->fileSystem->enumerate = Enumerate; volume->fileSystem->close = Close; + EsMemoryCopy(&volume->fileSystem->identifier, &volume->bootSector.serialNumber, sizeof(volume->bootSector.serialNumber)); + KernelLog(LOG_INFO, "NTFS", "register file system", "EntryNTFS - Registering file system with name '%s'.\n", volume->fileSystem->nameBytes, volume->fileSystem->name); FSRegisterFileSystem(volume->fileSystem); diff --git a/kernel/files.cpp b/kernel/files.cpp index d9389c0..83178b8 100644 --- a/kernel/files.cpp +++ b/kernel/files.cpp @@ -7,7 +7,6 @@ // - Prevent launching executables without read permission. // // TODO Drivers: -// - Parsing GPT partition tables. // - Get NTFS driver working again. // // TODO Allocate nodes/directory entries from arenas? diff --git a/kernel/module.h b/kernel/module.h index 3e998f7..88c0f44 100644 --- a/kernel/module.h +++ b/kernel/module.h @@ -862,6 +862,7 @@ struct KFileSystem : KDevice { EsFileOffsetDifference rootDirectoryInitialChildren; EsFileOffset spaceTotal, spaceUsed; + EsUniqueIdentifier identifier; size_t (*read) (KNode *node, void *buffer, EsFileOffset offset, EsFileOffset count); size_t (*write) (KNode *node, const void *buffer, EsFileOffset offset, EsFileOffset count); diff --git a/kernel/scheduler.cpp b/kernel/scheduler.cpp index f4bfe5e..348c204 100644 --- a/kernel/scheduler.cpp +++ b/kernel/scheduler.cpp @@ -630,7 +630,6 @@ void NewProcess() { startupInformation->tlsImageBytes = application.tlsImageBytes; startupInformation->tlsBytes = application.tlsBytes; startupInformation->timeStampTicksPerMs = timeStampTicksPerMs; - startupInformation->optimalWorkQueueThreadCount = scheduler.currentProcessorID; // TODO Update this as processors are added/removed. EsMemoryCopy(&startupInformation->data, &thisProcess->data, sizeof(EsProcessCreateData)); } } diff --git a/kernel/syscall.cpp b/kernel/syscall.cpp index 13a342c..768b49f 100644 --- a/kernel/syscall.cpp +++ b/kernel/syscall.cpp @@ -761,6 +761,7 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_VOLUME_GET_INFORMATION) { information.id = fileSystem->objectID; information.flags = fileSystem->write ? ES_FLAGS_DEFAULT : ES_VOLUME_READ_ONLY; information.installationIdentifier = fileSystem->installationIdentifier; + information.identifier = fileSystem->identifier; SYSCALL_WRITE(argument1, &information, sizeof(EsVolumeInformation)); SYSCALL_RETURN(ES_SUCCESS, false); @@ -1429,6 +1430,7 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_SYSTEM_TAKE_SNAPSHOT) { snapshot->processes[index].cpuTimeSlices = process->cpuTimeSlices; snapshot->processes[index].idleTimeSlices = process->idleTimeSlices; snapshot->processes[index].handleCount = process->handleTable.handleCount; + snapshot->processes[index].threadCount = process->threads.count; snapshot->processes[index].isKernel = process->type == PROCESS_KERNEL; snapshot->processes[index].nameBytes = EsCStringLength(process->cExecutableName); @@ -1455,6 +1457,10 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_SYSTEM_TAKE_SNAPSHOT) { SYSCALL_RETURN(MakeConstantBuffer(buffer, bufferSize, currentProcess), false); } +SYSCALL_IMPLEMENT(ES_SYSCALL_PROCESSOR_COUNT) { + SYSCALL_RETURN(scheduler.currentProcessorID, false); +} + SYSCALL_IMPLEMENT(ES_SYSCALL_PROCESS_OPEN) { SYSCALL_PERMISSION(ES_PERMISSION_PROCESS_OPEN);