This commit is contained in:
nakst 2021-09-21 13:35:06 +01:00
parent a50f4df623
commit bb9e90941b
11 changed files with 24 additions and 9 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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.
};

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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?

View File

@ -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);

View File

@ -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));
}
}

View File

@ -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);