mirror of
https://github.com/JannisHeydemann/BoredOS.git
synced 2026-05-30 10:26:59 +00:00
Compare commits
2 Commits
26.4-stabl
...
26.4.1-pat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8dd756f25b | ||
|
|
d13fca2d4a |
@@ -5,6 +5,7 @@
|
|||||||
#include "limine.h"
|
#include "limine.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "kutils.h"
|
||||||
static volatile struct limine_hhdm_request hhdm_request __attribute__((used, section(".requests"))) = {
|
static volatile struct limine_hhdm_request hhdm_request __attribute__((used, section(".requests"))) = {
|
||||||
.id = LIMINE_HHDM_REQUEST,
|
.id = LIMINE_HHDM_REQUEST,
|
||||||
.revision = 0,
|
.revision = 0,
|
||||||
@@ -80,3 +81,73 @@ void platform_get_cpu_vendor(char *vendor) {
|
|||||||
*((uint32_t *)&p[8]) = ecx;
|
*((uint32_t *)&p[8]) = ecx;
|
||||||
p[12] = '\0';
|
p[12] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void platform_get_cpu_info(cpu_info_t *info) {
|
||||||
|
uint32_t eax, ebx, ecx, edx;
|
||||||
|
|
||||||
|
// CPUID leaf 1: basic feature information
|
||||||
|
asm volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(1));
|
||||||
|
|
||||||
|
info->stepping = eax & 0xF;
|
||||||
|
info->model = (eax >> 4) & 0xF;
|
||||||
|
info->family = (eax >> 8) & 0xF;
|
||||||
|
info->microcode = (ebx >> 8) & 0xFF;
|
||||||
|
info->flags = ((uint64_t)ecx << 32) | edx; // ECX and EDX contain feature flags
|
||||||
|
info->cache_size = (ebx >> 16) & 0xFF; // Cache line size in bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform_get_cpu_flags(char *flags_str) {
|
||||||
|
uint32_t eax, ebx, ecx, edx;
|
||||||
|
|
||||||
|
flags_str[0] = '\0';
|
||||||
|
|
||||||
|
// CPUID leaf 1
|
||||||
|
asm volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(1));
|
||||||
|
|
||||||
|
// ECX flags
|
||||||
|
if (ecx & (1 << 0)) k_strcpy(flags_str + k_strlen(flags_str), "sse3 ");
|
||||||
|
if (ecx & (1 << 1)) k_strcpy(flags_str + k_strlen(flags_str), "pclmulqdq ");
|
||||||
|
if (ecx & (1 << 3)) k_strcpy(flags_str + k_strlen(flags_str), "monitor ");
|
||||||
|
if (ecx & (1 << 6)) k_strcpy(flags_str + k_strlen(flags_str), "ssse3 ");
|
||||||
|
if (ecx & (1 << 9)) k_strcpy(flags_str + k_strlen(flags_str), "sdbg ");
|
||||||
|
if (ecx & (1 << 12)) k_strcpy(flags_str + k_strlen(flags_str), "fma ");
|
||||||
|
if (ecx & (1 << 13)) k_strcpy(flags_str + k_strlen(flags_str), "cx16 ");
|
||||||
|
if (ecx & (1 << 19)) k_strcpy(flags_str + k_strlen(flags_str), "sse4_1 ");
|
||||||
|
if (ecx & (1 << 20)) k_strcpy(flags_str + k_strlen(flags_str), "sse4_2 ");
|
||||||
|
if (ecx & (1 << 23)) k_strcpy(flags_str + k_strlen(flags_str), "popcnt ");
|
||||||
|
if (ecx & (1 << 25)) k_strcpy(flags_str + k_strlen(flags_str), "aes ");
|
||||||
|
if (ecx & (1 << 26)) k_strcpy(flags_str + k_strlen(flags_str), "xsave ");
|
||||||
|
if (ecx & (1 << 28)) k_strcpy(flags_str + k_strlen(flags_str), "avx ");
|
||||||
|
|
||||||
|
// EDX flags
|
||||||
|
if (edx & (1 << 0)) k_strcpy(flags_str + k_strlen(flags_str), "fpu ");
|
||||||
|
if (edx & (1 << 3)) k_strcpy(flags_str + k_strlen(flags_str), "pse ");
|
||||||
|
if (edx & (1 << 4)) k_strcpy(flags_str + k_strlen(flags_str), "tsc ");
|
||||||
|
if (edx & (1 << 6)) k_strcpy(flags_str + k_strlen(flags_str), "pae ");
|
||||||
|
if (edx & (1 << 8)) k_strcpy(flags_str + k_strlen(flags_str), "cx8 ");
|
||||||
|
if (edx & (1 << 9)) k_strcpy(flags_str + k_strlen(flags_str), "apic ");
|
||||||
|
if (edx & (1 << 11)) k_strcpy(flags_str + k_strlen(flags_str), "sep ");
|
||||||
|
if (edx & (1 << 15)) k_strcpy(flags_str + k_strlen(flags_str), "cmov ");
|
||||||
|
if (edx & (1 << 23)) k_strcpy(flags_str + k_strlen(flags_str), "mmx ");
|
||||||
|
if (edx & (1 << 24)) k_strcpy(flags_str + k_strlen(flags_str), "fxsr ");
|
||||||
|
if (edx & (1 << 25)) k_strcpy(flags_str + k_strlen(flags_str), "sse ");
|
||||||
|
if (edx & (1 << 26)) k_strcpy(flags_str + k_strlen(flags_str), "sse2 ");
|
||||||
|
|
||||||
|
// Extended leaf 0x80000001 for advanced flags
|
||||||
|
asm volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(0x80000001));
|
||||||
|
|
||||||
|
if (edx & (1 << 11)) k_strcpy(flags_str + k_strlen(flags_str), "syscall ");
|
||||||
|
if (edx & (1 << 20)) k_strcpy(flags_str + k_strlen(flags_str), "nx ");
|
||||||
|
if (edx & (1 << 26)) k_strcpy(flags_str + k_strlen(flags_str), "pdpe1gb ");
|
||||||
|
if (edx & (1 << 27)) k_strcpy(flags_str + k_strlen(flags_str), "rdtscp ");
|
||||||
|
if (edx & (1 << 29)) k_strcpy(flags_str + k_strlen(flags_str), "lm ");
|
||||||
|
|
||||||
|
if (ecx & (1 << 0)) k_strcpy(flags_str + k_strlen(flags_str), "lahf_lm ");
|
||||||
|
if (ecx & (1 << 5)) k_strcpy(flags_str + k_strlen(flags_str), "abm ");
|
||||||
|
|
||||||
|
// Remove trailing space
|
||||||
|
int len = k_strlen(flags_str);
|
||||||
|
if (len > 0 && flags_str[len-1] == ' ') {
|
||||||
|
flags_str[len-1] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,10 +6,21 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t family;
|
||||||
|
uint32_t model;
|
||||||
|
uint32_t stepping;
|
||||||
|
uint32_t microcode;
|
||||||
|
uint64_t flags;
|
||||||
|
uint32_t cache_size;
|
||||||
|
} cpu_info_t;
|
||||||
|
|
||||||
void platform_init(void);
|
void platform_init(void);
|
||||||
uint64_t p2v(uint64_t phys);
|
uint64_t p2v(uint64_t phys);
|
||||||
uint64_t v2p(uint64_t virt);
|
uint64_t v2p(uint64_t virt);
|
||||||
void platform_get_cpu_model(char *model);
|
void platform_get_cpu_model(char *model);
|
||||||
void platform_get_cpu_vendor(char *vendor);
|
void platform_get_cpu_vendor(char *vendor);
|
||||||
|
void platform_get_cpu_info(cpu_info_t *info);
|
||||||
|
void platform_get_cpu_flags(char *flags_str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void get_os_info(os_info_t *info) {
|
|||||||
const char *os_version = "26.4";
|
const char *os_version = "26.4";
|
||||||
const char *os_codename = "Voyager";
|
const char *os_codename = "Voyager";
|
||||||
const char *kernel_name = "Boredkernel";
|
const char *kernel_name = "Boredkernel";
|
||||||
const char *kernel_version = "4.0.0-stable";
|
const char *kernel_version = "4.0.1-stable";
|
||||||
const char *build_date = __DATE__;
|
const char *build_date = __DATE__;
|
||||||
const char *build_time = __TIME__;
|
const char *build_time = __TIME__;
|
||||||
const char *build_arch = "x86_64";
|
const char *build_arch = "x86_64";
|
||||||
|
|||||||
199
src/fs/procfs.c
199
src/fs/procfs.c
@@ -4,6 +4,7 @@
|
|||||||
#include "../dev/disk.h"
|
#include "../dev/disk.h"
|
||||||
#include "memory_manager.h"
|
#include "memory_manager.h"
|
||||||
#include "core/kutils.h"
|
#include "core/kutils.h"
|
||||||
|
#include "core/platform.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t pid;
|
uint32_t pid;
|
||||||
@@ -55,7 +56,8 @@ int procfs_read(void *fs_private, void *handle, void *buf, int size) {
|
|||||||
procfs_handle_t *h = (procfs_handle_t*)handle;
|
procfs_handle_t *h = (procfs_handle_t*)handle;
|
||||||
if (!h) return -1;
|
if (!h) return -1;
|
||||||
|
|
||||||
char out[1024];
|
char *out = (char*)kmalloc(16384);
|
||||||
|
if (!out) return -1;
|
||||||
out[0] = 0;
|
out[0] = 0;
|
||||||
|
|
||||||
if (h->pid == 0xFFFFFFFF) {
|
if (h->pid == 0xFFFFFFFF) {
|
||||||
@@ -88,34 +90,173 @@ int procfs_read(void *fs_private, void *handle, void *buf, int size) {
|
|||||||
} else if (k_strcmp(h->type, "cpuinfo") == 0) {
|
} else if (k_strcmp(h->type, "cpuinfo") == 0) {
|
||||||
extern uint32_t smp_cpu_count(void);
|
extern uint32_t smp_cpu_count(void);
|
||||||
extern void platform_get_cpu_model(char *model);
|
extern void platform_get_cpu_model(char *model);
|
||||||
char model[64];
|
extern void platform_get_cpu_vendor(char *vendor);
|
||||||
platform_get_cpu_model(model);
|
extern void platform_get_cpu_info(cpu_info_t *info);
|
||||||
|
extern void platform_get_cpu_flags(char *flags_str);
|
||||||
|
|
||||||
k_strcpy(out, "Processor: ");
|
char model[64];
|
||||||
k_strcpy(out + k_strlen(out), model);
|
char vendor[16];
|
||||||
k_strcpy(out + k_strlen(out), "\nCores: ");
|
char flags[1024];
|
||||||
char c_s[16]; k_itoa(smp_cpu_count(), c_s);
|
cpu_info_t info;
|
||||||
k_strcpy(out + k_strlen(out), c_s);
|
|
||||||
k_strcpy(out + k_strlen(out), "\nArchitecture: x86_64\n");
|
platform_get_cpu_model(model);
|
||||||
|
platform_get_cpu_vendor(vendor);
|
||||||
|
platform_get_cpu_info(&info);
|
||||||
|
platform_get_cpu_flags(flags);
|
||||||
|
|
||||||
|
uint32_t cpu_count = smp_cpu_count();
|
||||||
|
out[0] = '\0';
|
||||||
|
|
||||||
|
// Output info for each processor
|
||||||
|
for (uint32_t i = 0; i < cpu_count; i++) {
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "processor\t: ");
|
||||||
|
k_itoa(i, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "vendor_id\t: ");
|
||||||
|
k_strcpy(out + k_strlen(out), vendor);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "cpu family\t: ");
|
||||||
|
k_itoa(info.family, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "model\t\t: ");
|
||||||
|
k_itoa(info.model, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "model name\t: ");
|
||||||
|
k_strcpy(out + k_strlen(out), model);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "stepping\t: ");
|
||||||
|
k_itoa(info.stepping, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "microcode\t: 0x");
|
||||||
|
char hex[16];
|
||||||
|
int temp = info.microcode;
|
||||||
|
int hex_pos = 0;
|
||||||
|
for (int j = 7; j >= 0; j--) {
|
||||||
|
int digit = (temp >> (j * 4)) & 0xF;
|
||||||
|
hex[hex_pos++] = digit < 10 ? '0' + digit : 'a' + (digit - 10);
|
||||||
|
}
|
||||||
|
hex[hex_pos] = '\0';
|
||||||
|
k_strcpy(out + k_strlen(out), hex);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "cache size\t: ");
|
||||||
|
k_itoa(info.cache_size, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), " KB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "physical id\t: 0\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "siblings\t: ");
|
||||||
|
k_itoa(cpu_count, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "core id\t\t: ");
|
||||||
|
k_itoa(i, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "cpu cores\t: ");
|
||||||
|
k_itoa(cpu_count, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "apicid\t\t: ");
|
||||||
|
k_itoa(i, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "initial apicid\t: ");
|
||||||
|
k_itoa(i, buf);
|
||||||
|
k_strcpy(out + k_strlen(out), buf);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "fpu\t\t: yes\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "fpu_exception\t: yes\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "cpuid level\t: 13\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "wp\t\t: yes\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "flags\t\t: ");
|
||||||
|
k_strcpy(out + k_strlen(out), flags);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "bugs\t\t: \n");
|
||||||
|
k_strcpy(out + k_strlen(out), "bogomips\t: 4800.00\n");
|
||||||
|
|
||||||
|
if (i < cpu_count - 1) {
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (k_strcmp(h->type, "meminfo") == 0) {
|
} else if (k_strcmp(h->type, "meminfo") == 0) {
|
||||||
extern MemStats memory_get_stats(void);
|
extern MemStats memory_get_stats(void);
|
||||||
MemStats stats = memory_get_stats();
|
MemStats stats = memory_get_stats();
|
||||||
k_strcpy(out, "MemTotal: ");
|
char m_s[32];
|
||||||
char m_s[32]; k_itoa(stats.total_memory / 1024, m_s);
|
|
||||||
|
k_strcpy(out, "MemTotal:\t");
|
||||||
|
k_itoa(stats.total_memory / 1024, m_s);
|
||||||
k_strcpy(out + k_strlen(out), m_s);
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
k_strcpy(out + k_strlen(out), " kB\nMemFree: ");
|
k_strcpy(out + k_strlen(out), " kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "MemFree:\t");
|
||||||
k_itoa(stats.available_memory / 1024, m_s);
|
k_itoa(stats.available_memory / 1024, m_s);
|
||||||
k_strcpy(out + k_strlen(out), m_s);
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
k_strcpy(out + k_strlen(out), " kB\nMemUsed: ");
|
k_strcpy(out + k_strlen(out), " kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "MemAvailable:\t");
|
||||||
|
k_itoa(stats.available_memory / 1024, m_s);
|
||||||
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
|
k_strcpy(out + k_strlen(out), " kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "Buffers:\t0 kB\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "Cached:\t\t0 kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "MemUsed:\t");
|
||||||
k_itoa(stats.used_memory / 1024, m_s);
|
k_itoa(stats.used_memory / 1024, m_s);
|
||||||
k_strcpy(out + k_strlen(out), m_s);
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
k_strcpy(out + k_strlen(out), " kB\nPeak: ");
|
k_strcpy(out + k_strlen(out), " kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "MemPeak:\t");
|
||||||
k_itoa(stats.peak_memory_used / 1024, m_s);
|
k_itoa(stats.peak_memory_used / 1024, m_s);
|
||||||
k_strcpy(out + k_strlen(out), m_s);
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
k_strcpy(out + k_strlen(out), " kB\nBlocks: ");
|
k_strcpy(out + k_strlen(out), " kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "SwapTotal:\t0 kB\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "SwapFree:\t0 kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "Dirty:\t\t0 kB\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "Writeback:\t0 kB\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "AnonPages:\t");
|
||||||
|
k_itoa(stats.used_memory / 1024, m_s);
|
||||||
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
|
k_strcpy(out + k_strlen(out), " kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "Mapped:\t\t0 kB\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "Shmem:\t\t0 kB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "Blocks:\t\t");
|
||||||
k_itoa(stats.allocated_blocks, m_s);
|
k_itoa(stats.allocated_blocks, m_s);
|
||||||
k_strcpy(out + k_strlen(out), m_s);
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
k_strcpy(out + k_strlen(out), "\nFragmentation: ");
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "FreeBlocks:\t");
|
||||||
|
k_itoa(stats.free_blocks, m_s);
|
||||||
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "Fragmentation:\t");
|
||||||
k_itoa(stats.fragmentation_percent, m_s);
|
k_itoa(stats.fragmentation_percent, m_s);
|
||||||
k_strcpy(out + k_strlen(out), m_s);
|
k_strcpy(out + k_strlen(out), m_s);
|
||||||
k_strcpy(out + k_strlen(out), "%\n");
|
k_strcpy(out + k_strlen(out), "%\n");
|
||||||
@@ -123,20 +264,35 @@ int procfs_read(void *fs_private, void *handle, void *buf, int size) {
|
|||||||
extern int disk_get_count(void);
|
extern int disk_get_count(void);
|
||||||
extern Disk* disk_get_by_index(int index);
|
extern Disk* disk_get_by_index(int index);
|
||||||
int dcount = disk_get_count();
|
int dcount = disk_get_count();
|
||||||
k_strcpy(out, "Block Devices:\n");
|
out[0] = '\0';
|
||||||
|
|
||||||
|
k_strcpy(out, "Character devices:\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " 1 mem\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " 4 tty\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " 5 cua\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " 7 vcs\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " 8 stdin\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " 13 input\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " 14 sound\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " 29 fb\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "189 usb\n\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "Block devices:\n");
|
||||||
for (int i = 0; i < dcount; i++) {
|
for (int i = 0; i < dcount; i++) {
|
||||||
Disk *d = disk_get_by_index(i);
|
Disk *d = disk_get_by_index(i);
|
||||||
if (d) {
|
if (d && !d->is_partition) {
|
||||||
k_strcpy(out + k_strlen(out), " - ");
|
k_strcpy(out + k_strlen(out), " 8 ");
|
||||||
k_strcpy(out + k_strlen(out), d->devname);
|
k_strcpy(out + k_strlen(out), d->devname);
|
||||||
k_strcpy(out + k_strlen(out), "\n");
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
k_strcpy(out + k_strlen(out), " 11 sr\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "253 virtblk\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
process_t *proc = process_get_by_pid(h->pid);
|
process_t *proc = process_get_by_pid(h->pid);
|
||||||
if (!proc) return -1;
|
if (!proc) { kfree(out); return -1; }
|
||||||
|
|
||||||
if (k_strcmp(h->type, "name") == 0 || k_strcmp(h->type, "cmdline") == 0) {
|
if (k_strcmp(h->type, "name") == 0 || k_strcmp(h->type, "cmdline") == 0) {
|
||||||
k_strcpy(out, proc->name);
|
k_strcpy(out, proc->name);
|
||||||
@@ -165,13 +321,14 @@ int procfs_read(void *fs_private, void *handle, void *buf, int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int len = k_strlen(out);
|
int len = k_strlen(out);
|
||||||
if (h->offset >= len) return 0;
|
if (h->offset >= len) { kfree(out); return 0; }
|
||||||
|
|
||||||
int to_copy = len - h->offset;
|
int to_copy = len - h->offset;
|
||||||
if (to_copy > size) to_copy = size;
|
if (to_copy > size) to_copy = size;
|
||||||
|
|
||||||
k_memcpy(buf, out + h->offset, to_copy);
|
k_memcpy(buf, out + h->offset, to_copy);
|
||||||
h->offset += to_copy;
|
h->offset += to_copy;
|
||||||
|
kfree(out);
|
||||||
return to_copy;
|
return to_copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -415,10 +415,18 @@ static uint64_t syscall_handler_inner(registers_t *regs) {
|
|||||||
int baseline = uy + font_manager_get_font_ascent_scaled(font, font->pixel_height) - 2;
|
int baseline = uy + font_manager_get_font_ascent_scaled(font, font->pixel_height) - 2;
|
||||||
int cur_x = ux;
|
int cur_x = ux;
|
||||||
const char *s = kernel_str;
|
const char *s = kernel_str;
|
||||||
|
int start_x = cur_x;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
uint32_t codepoint = utf8_decode(&s);
|
uint32_t codepoint = utf8_decode(&s);
|
||||||
font_manager_render_char_scaled(font, cur_x, baseline, codepoint, color, font->pixel_height, put_pixel);
|
if (codepoint == '\n') {
|
||||||
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, font->pixel_height);
|
cur_x = start_x;
|
||||||
|
baseline += font_manager_get_font_line_height_scaled(font, font->pixel_height);
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, ' ', font->pixel_height) * 4;
|
||||||
|
} else {
|
||||||
|
font_manager_render_char_scaled(font, cur_x, baseline, codepoint, color, font->pixel_height, put_pixel);
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, font->pixel_height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_string(ux, uy, kernel_str, color);
|
draw_string(ux, uy, kernel_str, color);
|
||||||
@@ -430,10 +438,18 @@ static uint64_t syscall_handler_inner(registers_t *regs) {
|
|||||||
int baseline = win->y + uy + font_manager_get_font_ascent_scaled(font, font->pixel_height) - 2;
|
int baseline = win->y + uy + font_manager_get_font_ascent_scaled(font, font->pixel_height) - 2;
|
||||||
int cur_x = win->x + ux;
|
int cur_x = win->x + ux;
|
||||||
const char *s = kernel_str;
|
const char *s = kernel_str;
|
||||||
|
int start_x = cur_x;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
uint32_t codepoint = utf8_decode(&s);
|
uint32_t codepoint = utf8_decode(&s);
|
||||||
font_manager_render_char_scaled(font, cur_x, baseline, codepoint, color, font->pixel_height, put_pixel);
|
if (codepoint == '\n') {
|
||||||
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, font->pixel_height);
|
cur_x = start_x;
|
||||||
|
baseline += font_manager_get_font_line_height_scaled(font, font->pixel_height);
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, ' ', font->pixel_height) * 4;
|
||||||
|
} else {
|
||||||
|
font_manager_render_char_scaled(font, cur_x, baseline, codepoint, color, font->pixel_height, put_pixel);
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, font->pixel_height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_string(win->x + ux, win->y + uy, kernel_str, color);
|
draw_string(win->x + ux, win->y + uy, kernel_str, color);
|
||||||
@@ -519,10 +535,18 @@ static uint64_t syscall_handler_inner(registers_t *regs) {
|
|||||||
int baseline = uy + font_manager_get_font_ascent_scaled(font, scale) - 2;
|
int baseline = uy + font_manager_get_font_ascent_scaled(font, scale) - 2;
|
||||||
int cur_x = ux;
|
int cur_x = ux;
|
||||||
const char *s = kernel_str;
|
const char *s = kernel_str;
|
||||||
|
int start_x = cur_x;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
uint32_t codepoint = utf8_decode(&s);
|
uint32_t codepoint = utf8_decode(&s);
|
||||||
font_manager_render_char_scaled(font, cur_x, baseline, codepoint, color, scale, put_pixel);
|
if (codepoint == '\n') {
|
||||||
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, scale);
|
cur_x = start_x;
|
||||||
|
baseline += font_manager_get_font_line_height_scaled(font, scale);
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, ' ', scale) * 4;
|
||||||
|
} else {
|
||||||
|
font_manager_render_char_scaled(font, cur_x, baseline, codepoint, color, scale, put_pixel);
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_string_scaled(ux, uy, kernel_str, color, scale);
|
draw_string_scaled(ux, uy, kernel_str, color, scale);
|
||||||
@@ -534,10 +558,18 @@ static uint64_t syscall_handler_inner(registers_t *regs) {
|
|||||||
int baseline = win->y + uy + font_manager_get_font_ascent_scaled(font, scale) - 2;
|
int baseline = win->y + uy + font_manager_get_font_ascent_scaled(font, scale) - 2;
|
||||||
int cur_x = win->x + ux;
|
int cur_x = win->x + ux;
|
||||||
const char *s = kernel_str;
|
const char *s = kernel_str;
|
||||||
|
int start_x = cur_x;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
uint32_t codepoint = utf8_decode(&s);
|
uint32_t codepoint = utf8_decode(&s);
|
||||||
font_manager_render_char_scaled(font, cur_x, baseline, codepoint, color, scale, put_pixel);
|
if (codepoint == '\n') {
|
||||||
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, scale);
|
cur_x = start_x;
|
||||||
|
baseline += font_manager_get_font_line_height_scaled(font, scale);
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, ' ', scale) * 4;
|
||||||
|
} else {
|
||||||
|
font_manager_render_char_scaled(font, cur_x, baseline, codepoint, color, scale, put_pixel);
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_string_scaled(win->x + ux, win->y + uy, kernel_str, color, scale);
|
draw_string_scaled(win->x + ux, win->y + uy, kernel_str, color, scale);
|
||||||
@@ -595,11 +627,19 @@ static uint64_t syscall_handler_inner(registers_t *regs) {
|
|||||||
int baseline = uy + font_manager_get_font_ascent_scaled(font, scale) - 2;
|
int baseline = uy + font_manager_get_font_ascent_scaled(font, scale) - 2;
|
||||||
int cur_x = ux;
|
int cur_x = ux;
|
||||||
const char *s = kernel_str;
|
const char *s = kernel_str;
|
||||||
|
int start_x = cur_x;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
extern void font_manager_render_char_sloped(ttf_font_t *font, int x, int y, uint32_t codepoint, uint32_t color, float scale, float slope, void (*put_pixel_fn)(int, int, uint32_t));
|
extern void font_manager_render_char_sloped(ttf_font_t *font, int x, int y, uint32_t codepoint, uint32_t color, float scale, float slope, void (*put_pixel_fn)(int, int, uint32_t));
|
||||||
uint32_t codepoint = utf8_decode(&s);
|
uint32_t codepoint = utf8_decode(&s);
|
||||||
font_manager_render_char_sloped(font, cur_x, baseline, codepoint, color, scale, slope, put_pixel);
|
if (codepoint == '\n') {
|
||||||
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, scale);
|
cur_x = start_x;
|
||||||
|
baseline += font_manager_get_font_line_height_scaled(font, scale);
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, ' ', scale) * 4;
|
||||||
|
} else {
|
||||||
|
font_manager_render_char_sloped(font, cur_x, baseline, codepoint, color, scale, slope, put_pixel);
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_string_scaled_sloped(ux, uy, kernel_str, color, scale, slope);
|
draw_string_scaled_sloped(ux, uy, kernel_str, color, scale, slope);
|
||||||
@@ -611,11 +651,19 @@ static uint64_t syscall_handler_inner(registers_t *regs) {
|
|||||||
int baseline = win->y + uy + font_manager_get_font_ascent_scaled(font, scale) - 2;
|
int baseline = win->y + uy + font_manager_get_font_ascent_scaled(font, scale) - 2;
|
||||||
int cur_x = win->x + ux;
|
int cur_x = win->x + ux;
|
||||||
const char *s = kernel_str;
|
const char *s = kernel_str;
|
||||||
|
int start_x = cur_x;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
extern void font_manager_render_char_sloped(ttf_font_t *font, int x, int y, uint32_t codepoint, uint32_t color, float scale, float slope, void (*put_pixel_fn)(int, int, uint32_t));
|
extern void font_manager_render_char_sloped(ttf_font_t *font, int x, int y, uint32_t codepoint, uint32_t color, float scale, float slope, void (*put_pixel_fn)(int, int, uint32_t));
|
||||||
uint32_t codepoint = utf8_decode(&s);
|
uint32_t codepoint = utf8_decode(&s);
|
||||||
font_manager_render_char_sloped(font, cur_x, baseline, codepoint, color, scale, slope, put_pixel);
|
if (codepoint == '\n') {
|
||||||
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, scale);
|
cur_x = start_x;
|
||||||
|
baseline += font_manager_get_font_line_height_scaled(font, scale);
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, ' ', scale) * 4;
|
||||||
|
} else {
|
||||||
|
font_manager_render_char_sloped(font, cur_x, baseline, codepoint, color, scale, slope, put_pixel);
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(font, codepoint, scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_string_scaled_sloped(win->x + ux, win->y + uy, kernel_str, color, scale, slope);
|
draw_string_scaled_sloped(win->x + ux, win->y + uy, kernel_str, color, scale, slope);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "core/kutils.h"
|
#include "core/kutils.h"
|
||||||
#include "wm/graphics.h"
|
#include "wm/graphics.h"
|
||||||
#include "core/platform.h"
|
#include "core/platform.h"
|
||||||
|
#include "dev/disk.h"
|
||||||
|
|
||||||
// --- Helper: itoa ---
|
// --- Helper: itoa ---
|
||||||
static void sys_itoa(int n, char *s) {
|
static void sys_itoa(int n, char *s) {
|
||||||
@@ -131,15 +132,172 @@ static int read_pci_bus(char *buf, int size, int offset) {
|
|||||||
|
|
||||||
// --- CPU System Implementation ---
|
// --- CPU System Implementation ---
|
||||||
static int read_cpu_info(char *buf, int size, int offset) {
|
static int read_cpu_info(char *buf, int size, int offset) {
|
||||||
|
char *out = (char*)kmalloc(16384);
|
||||||
|
if (!out) return 0;
|
||||||
|
out[0] = 0;
|
||||||
|
|
||||||
|
char vendor[16];
|
||||||
|
char model[64];
|
||||||
|
char flags[1024];
|
||||||
|
cpu_info_t info;
|
||||||
|
|
||||||
|
platform_get_cpu_vendor(vendor);
|
||||||
|
platform_get_cpu_model(model);
|
||||||
|
platform_get_cpu_info(&info);
|
||||||
|
platform_get_cpu_flags(flags);
|
||||||
|
|
||||||
|
uint32_t cpu_count = smp_cpu_count();
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < cpu_count; i++) {
|
||||||
|
char c_s[32];
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "processor\t: ");
|
||||||
|
k_itoa(i, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "vendor_id\t: ");
|
||||||
|
k_strcpy(out + k_strlen(out), vendor);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "cpu family\t: ");
|
||||||
|
k_itoa(info.family, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "model\t\t: ");
|
||||||
|
k_itoa(info.model, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "model name\t: ");
|
||||||
|
k_strcpy(out + k_strlen(out), model);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "stepping\t: ");
|
||||||
|
k_itoa(info.stepping, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "microcode\t: 0x");
|
||||||
|
char hex[16];
|
||||||
|
int temp = info.microcode;
|
||||||
|
int hex_pos = 0;
|
||||||
|
for (int j = 7; j >= 0; j--) {
|
||||||
|
int digit = (temp >> (j * 4)) & 0xF;
|
||||||
|
hex[hex_pos++] = digit < 10 ? '0' + digit : 'a' + (digit - 10);
|
||||||
|
}
|
||||||
|
hex[hex_pos] = '\0';
|
||||||
|
k_strcpy(out + k_strlen(out), hex);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "cache size\t: ");
|
||||||
|
k_itoa(info.cache_size, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), " KB\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "physical id\t: 0\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "siblings\t: ");
|
||||||
|
k_itoa(cpu_count, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "core id\t\t: ");
|
||||||
|
k_itoa(i, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "cpu cores\t: ");
|
||||||
|
k_itoa(cpu_count, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "apicid\t\t: ");
|
||||||
|
k_itoa(i, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "initial apicid\t: ");
|
||||||
|
k_itoa(i, c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), c_s);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "fpu\t\t: yes\n");
|
||||||
|
k_strcpy(out + k_strlen(out), "fpu_exception\t: yes\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "cpuid level\t: 13\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "wp\t\t: yes\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "flags\t\t: ");
|
||||||
|
k_strcpy(out + k_strlen(out), flags);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "bugs\t\t: \n");
|
||||||
|
k_strcpy(out + k_strlen(out), "bogomips\t: 4800.00\n");
|
||||||
|
|
||||||
|
if (i < cpu_count - 1) {
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int len = (int)k_strlen(out);
|
||||||
|
if (offset >= len) { kfree(out); return 0; }
|
||||||
|
int to_copy = len - offset;
|
||||||
|
if (to_copy > size) to_copy = size;
|
||||||
|
k_memcpy(buf, out + offset, to_copy);
|
||||||
|
kfree(out);
|
||||||
|
return to_copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Devices Implementation ---
|
||||||
|
static int read_sys_devices(char *buf, int size, int offset) {
|
||||||
|
char out[2048];
|
||||||
|
k_memset(out, 0, 2048);
|
||||||
|
|
||||||
|
extern int disk_get_count(void);
|
||||||
|
extern Disk* disk_get_by_index(int index);
|
||||||
|
|
||||||
|
int dcount = disk_get_count();
|
||||||
|
k_strcpy(out, "Block Devices:\n");
|
||||||
|
for (int i = 0; i < dcount; i++) {
|
||||||
|
Disk *d = disk_get_by_index(i);
|
||||||
|
if (d && !d->is_partition) {
|
||||||
|
k_strcpy(out + k_strlen(out), " ");
|
||||||
|
k_strcpy(out + k_strlen(out), d->devname);
|
||||||
|
k_strcpy(out + k_strlen(out), " - ");
|
||||||
|
k_strcpy(out + k_strlen(out), d->label);
|
||||||
|
k_strcpy(out + k_strlen(out), "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
k_strcpy(out + k_strlen(out), "\nCharacter Devices:\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " console - System console\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " tty - Terminal devices\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " psmouse - Mouse input\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " keyboard - Keyboard input\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " framebuffer - Framebuffer device\n");
|
||||||
|
|
||||||
|
int len = (int)k_strlen(out);
|
||||||
|
if (offset >= len) return 0;
|
||||||
|
int to_copy = len - offset;
|
||||||
|
if (to_copy > size) to_copy = size;
|
||||||
|
k_memcpy(buf, out + offset, to_copy);
|
||||||
|
return to_copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Class Implementation ---
|
||||||
|
static int read_sys_class(char *buf, int size, int offset) {
|
||||||
char out[1024];
|
char out[1024];
|
||||||
k_memset(out, 0, 1024);
|
k_memset(out, 0, 1024);
|
||||||
char vendor[16];
|
|
||||||
platform_get_cpu_vendor(vendor);
|
k_strcpy(out, "Classes:\n");
|
||||||
k_strcpy(out + k_strlen(out), vendor);
|
k_strcpy(out + k_strlen(out), " block - Block device class\n");
|
||||||
k_strcpy(out + k_strlen(out), "\nCores: ");
|
k_strcpy(out + k_strlen(out), " input - Input device class\n");
|
||||||
char c_s[16]; k_itoa(smp_cpu_count(), c_s);
|
k_strcpy(out + k_strlen(out), " tty - TTY device class\n");
|
||||||
k_strcpy(out + k_strlen(out), c_s);
|
k_strcpy(out + k_strlen(out), " sound - Sound device class\n");
|
||||||
k_strcpy(out + k_strlen(out), "\nSpeed: ~3.00 GHz\nFeatures: sse sse2 sse3 apic smp\n");
|
k_strcpy(out + k_strlen(out), " video - Video device class\n");
|
||||||
|
k_strcpy(out + k_strlen(out), " net - Network device class\n");
|
||||||
|
|
||||||
int len = (int)k_strlen(out);
|
int len = (int)k_strlen(out);
|
||||||
if (offset >= len) return 0;
|
if (offset >= len) return 0;
|
||||||
@@ -174,6 +332,12 @@ void sysfs_init_subsystems(void) {
|
|||||||
subsystem_register("class", &class);
|
subsystem_register("class", &class);
|
||||||
subsystem_register("kernel/debug", &debug);
|
subsystem_register("kernel/debug", &debug);
|
||||||
|
|
||||||
|
// Devices info
|
||||||
|
subsystem_add_file(devices, "list", read_sys_devices, NULL);
|
||||||
|
|
||||||
|
// Class info
|
||||||
|
subsystem_add_file(class, "list", read_sys_class, NULL);
|
||||||
|
|
||||||
// CPU info
|
// CPU info
|
||||||
subsystem_add_file(kernel, "cpuinfo", read_cpu_info, NULL);
|
subsystem_add_file(kernel, "cpuinfo", read_cpu_info, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -330,6 +330,13 @@ int font_manager_get_string_width_scaled(ttf_font_t *font, const char *s, float
|
|||||||
while (*s) {
|
while (*s) {
|
||||||
int advance, lsb;
|
int advance, lsb;
|
||||||
uint32_t codepoint = utf8_decode(&s);
|
uint32_t codepoint = utf8_decode(&s);
|
||||||
|
|
||||||
|
if (codepoint == '\t') {
|
||||||
|
stbtt_GetCodepointHMetrics(info, ' ', &advance, &lsb);
|
||||||
|
width += (int)(advance * real_scale + 0.5f) * 4;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
stbtt_fontinfo *current_info = info;
|
stbtt_fontinfo *current_info = info;
|
||||||
float current_scale = real_scale;
|
float current_scale = real_scale;
|
||||||
|
|
||||||
@@ -350,6 +357,12 @@ int font_manager_get_codepoint_width_scaled(ttf_font_t *font, uint32_t codepoint
|
|||||||
stbtt_fontinfo *info = (stbtt_fontinfo *)font->info;
|
stbtt_fontinfo *info = (stbtt_fontinfo *)font->info;
|
||||||
float real_scale = stbtt_ScaleForPixelHeight(info, scale);
|
float real_scale = stbtt_ScaleForPixelHeight(info, scale);
|
||||||
|
|
||||||
|
if (codepoint == '\t') {
|
||||||
|
int advance, lsb;
|
||||||
|
stbtt_GetCodepointHMetrics(info, ' ', &advance, &lsb);
|
||||||
|
return (int)(advance * real_scale + 0.5f) * 4;
|
||||||
|
}
|
||||||
|
|
||||||
if (stbtt_FindGlyphIndex(info, codepoint) == 0 && fallback_font) {
|
if (stbtt_FindGlyphIndex(info, codepoint) == 0 && fallback_font) {
|
||||||
info = (stbtt_fontinfo *)fallback_font->info;
|
info = (stbtt_fontinfo *)fallback_font->info;
|
||||||
real_scale = stbtt_ScaleForPixelHeight(info, scale);
|
real_scale = stbtt_ScaleForPixelHeight(info, scale);
|
||||||
|
|||||||
@@ -555,6 +555,8 @@ void draw_string_bitmap(int x, int y, const char *str, uint32_t color) {
|
|||||||
if (*s == '\n') {
|
if (*s == '\n') {
|
||||||
cur_x = x;
|
cur_x = x;
|
||||||
cur_y += 10;
|
cur_y += 10;
|
||||||
|
} else if (*s == '\t') {
|
||||||
|
cur_x += 8 * 4;
|
||||||
} else {
|
} else {
|
||||||
draw_char_bitmap(cur_x, cur_y, *s, color);
|
draw_char_bitmap(cur_x, cur_y, *s, color);
|
||||||
cur_x += 8;
|
cur_x += 8;
|
||||||
@@ -583,8 +585,9 @@ int graphics_get_string_width_scaled(const char *s, float scale) {
|
|||||||
}
|
}
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while (s && *s) {
|
while (s && *s) {
|
||||||
utf8_decode(&s);
|
uint32_t codepoint = utf8_decode(&s);
|
||||||
len++;
|
if (codepoint == '\t') len += 4;
|
||||||
|
else len++;
|
||||||
}
|
}
|
||||||
return len * 8; // Fallback bitmap width
|
return len * 8; // Fallback bitmap width
|
||||||
}
|
}
|
||||||
@@ -607,6 +610,8 @@ void draw_string_scaled(int x, int y, const char *s, uint32_t color, float scale
|
|||||||
if (codepoint == '\n') {
|
if (codepoint == '\n') {
|
||||||
cur_x = x;
|
cur_x = x;
|
||||||
baseline += line_height;
|
baseline += line_height;
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(g_current_ttf, ' ', scale) * 4;
|
||||||
} else {
|
} else {
|
||||||
font_manager_render_char_scaled(g_current_ttf, cur_x, baseline, codepoint, color, scale, put_pixel);
|
font_manager_render_char_scaled(g_current_ttf, cur_x, baseline, codepoint, color, scale, put_pixel);
|
||||||
cur_x += font_manager_get_codepoint_width_scaled(g_current_ttf, codepoint, scale);
|
cur_x += font_manager_get_codepoint_width_scaled(g_current_ttf, codepoint, scale);
|
||||||
@@ -621,6 +626,8 @@ void draw_string_scaled(int x, int y, const char *s, uint32_t color, float scale
|
|||||||
if (codepoint == '\n') {
|
if (codepoint == '\n') {
|
||||||
cur_x = x;
|
cur_x = x;
|
||||||
cur_y += 10;
|
cur_y += 10;
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += 8 * 4;
|
||||||
} else {
|
} else {
|
||||||
draw_char(cur_x, cur_y, (codepoint < 128) ? (char)codepoint : '?', color);
|
draw_char(cur_x, cur_y, (codepoint < 128) ? (char)codepoint : '?', color);
|
||||||
cur_x += 8;
|
cur_x += 8;
|
||||||
@@ -646,6 +653,8 @@ void draw_string_scaled_sloped(int x, int y, const char *s, uint32_t color, floa
|
|||||||
if (codepoint == '\n') {
|
if (codepoint == '\n') {
|
||||||
cur_x = x;
|
cur_x = x;
|
||||||
baseline += line_height;
|
baseline += line_height;
|
||||||
|
} else if (codepoint == '\t') {
|
||||||
|
cur_x += font_manager_get_codepoint_width_scaled(g_current_ttf, ' ', scale) * 4;
|
||||||
} else {
|
} else {
|
||||||
font_manager_render_char_sloped(g_current_ttf, cur_x, baseline, codepoint, color, scale, slope, put_pixel);
|
font_manager_render_char_sloped(g_current_ttf, cur_x, baseline, codepoint, color, scale, slope, put_pixel);
|
||||||
cur_x += font_manager_get_codepoint_width_scaled(g_current_ttf, codepoint, scale);
|
cur_x += font_manager_get_codepoint_width_scaled(g_current_ttf, codepoint, scale);
|
||||||
|
|||||||
Reference in New Issue
Block a user