mirror of
https://github.com/0Nera/BMOSP.git
synced 2024-11-26 02:20:16 +03:00
Добавлен модуль cpubench
This commit is contained in:
parent
b135289a08
commit
2c9cde1e40
1
build.sh
1
build.sh
@ -4,5 +4,6 @@ dos2unix */*.sh
|
|||||||
cd helloworld/ && chmod +x build.sh && ./build.sh && cd ..
|
cd helloworld/ && chmod +x build.sh && ./build.sh && cd ..
|
||||||
cd music/ && chmod +x build.sh && ./build.sh && cd ..
|
cd music/ && chmod +x build.sh && ./build.sh && cd ..
|
||||||
cd simd/ && chmod +x build.sh && ./build.sh && cd ..
|
cd simd/ && chmod +x build.sh && ./build.sh && cd ..
|
||||||
|
cd cpubench/ && chmod +x build.sh && ./build.sh && cd ..
|
||||||
cd ..
|
cd ..
|
||||||
python3 pbuild.py
|
python3 pbuild.py
|
@ -21,6 +21,9 @@ BACKGROUND_PATH=boot:///boot.tga
|
|||||||
MODULE_PATH=boot:///mod/simd.ko
|
MODULE_PATH=boot:///mod/simd.ko
|
||||||
MODULE_CMDLINE=[MOD]simd.ko
|
MODULE_CMDLINE=[MOD]simd.ko
|
||||||
|
|
||||||
|
MODULE_PATH=boot:///mod/cpubench.ko
|
||||||
|
MODULE_CMDLINE=[MOD]cpubench.ko
|
||||||
|
|
||||||
MODULE_PATH=boot:///mod/hello.ko
|
MODULE_PATH=boot:///mod/hello.ko
|
||||||
MODULE_CMDLINE=[MOD]hello.ko
|
MODULE_CMDLINE=[MOD]hello.ko
|
||||||
|
|
||||||
|
6
modules/cpubench/build.sh
Normal file
6
modules/cpubench/build.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#/bin/sh
|
||||||
|
echo "Название: CPUBENCH"
|
||||||
|
echo "Лицензия: Публичное достояние"
|
||||||
|
gcc -I../../modlib -O0 -finput-charset=UTF-8 -fexec-charset=cp1251 -c -fPIC -nostdlib main.c -o cpubench.o
|
||||||
|
gcc -Wl,--entry=init -fPIC -shared -nostdlib cpubench.o -o cpubench.ko
|
||||||
|
echo "Сборка завершена, файл: cpubench.ko"
|
61
modules/cpubench/main.c
Normal file
61
modules/cpubench/main.c
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include <system.h>
|
||||||
|
|
||||||
|
static char fxsave_region[512] __attribute__((aligned(16)));
|
||||||
|
|
||||||
|
static inline void cpuid(uint32_t leaf, uint32_t *eax, uint32_t *ebx,
|
||||||
|
uint32_t *ecx, uint32_t *edx) {
|
||||||
|
asm volatile("cpuid"
|
||||||
|
: "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx)
|
||||||
|
: "a"(leaf));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void L1_cache_size( ) {
|
||||||
|
uint32_t eax, ebx, ecx, edx;
|
||||||
|
cpuid(0x80000006, &eax, &ebx, &ecx, &edx);
|
||||||
|
if ((edx & 0xFF) == 0) {
|
||||||
|
fb_printf("L1 кэш недоступен\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fb_printf(
|
||||||
|
"L1: Размер строки: %u B, Тип ассоциации: %u, Размер кэша: %u КБ\n",
|
||||||
|
ecx & 0xff, (ecx >> 12) & 0x07, (ecx >> 16) & 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void L2_cache_size( ) {
|
||||||
|
uint32_t eax, ebx, ecx, edx;
|
||||||
|
cpuid(0x80000006, &eax, &ebx, &ecx, &edx);
|
||||||
|
if ((edx & 0xFF) == 0) {
|
||||||
|
fb_printf("L2 кэш недоступен\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fb_printf(
|
||||||
|
"L2: Размер строки: %u B, Тип ассоциации: %u, Размер кэша: %u КБ\n",
|
||||||
|
ecx & 0xff, (ecx >> 12) & 0x0F, (ecx >> 16) & 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void L3_cache_size( ) {
|
||||||
|
uint32_t eax, ebx, ecx, edx;
|
||||||
|
cpuid(0x80000006, &eax, &ebx, &ecx, &edx);
|
||||||
|
if ((edx & 0xFF) == 0) {
|
||||||
|
fb_printf("L3 кэш недоступен\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fb_printf(
|
||||||
|
"L3: Размер строки: %u B, Тип ассоциации: %u, Размер кэша: %u КБ\n",
|
||||||
|
edx & 0xff, (edx >> 12) & 0x0F, (edx >> 16) & 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
module_info_t init(env_t *env) {
|
||||||
|
init_env(env);
|
||||||
|
|
||||||
|
L1_cache_size( );
|
||||||
|
L2_cache_size( );
|
||||||
|
L3_cache_size( );
|
||||||
|
|
||||||
|
return (module_info_t){
|
||||||
|
.name = (char *)"CPUBENCH",
|
||||||
|
.message = (char *)"Дополнительная информация о процессоре",
|
||||||
|
.err_code = 0,
|
||||||
|
.func_count = 1
|
||||||
|
};
|
||||||
|
}
|
@ -133,7 +133,7 @@ def create_hdd(IMAGE_NAME):
|
|||||||
os.system("mformat -i {}.hdd@@1M".format(IMAGE_NAME))
|
os.system("mformat -i {}.hdd@@1M".format(IMAGE_NAME))
|
||||||
os.system("mmd -i {}.hdd@@1M ::/mod ::/EFI ::/EFI/BOOT ::/user".format(IMAGE_NAME))
|
os.system("mmd -i {}.hdd@@1M ::/mod ::/EFI ::/EFI/BOOT ::/user".format(IMAGE_NAME))
|
||||||
os.system("mcopy -i {}.hdd@@1M kernel.elf configs/limine.cfg limine/limine-bios.sys ::/".format(IMAGE_NAME))
|
os.system("mcopy -i {}.hdd@@1M kernel.elf configs/limine.cfg limine/limine-bios.sys ::/".format(IMAGE_NAME))
|
||||||
os.system("mcopy -i {}.hdd@@1M modules/music/music.ko modules/simd/simd.ko modules/helloworld/hello.ko ::/mod".format(IMAGE_NAME))
|
os.system("mcopy -i {}.hdd@@1M modules/music/music.ko modules/simd/simd.ko modules/cpubench/cpubench.ko modules/helloworld/hello.ko ::/mod".format(IMAGE_NAME))
|
||||||
os.system("mcopy -i {}.hdd@@1M limine/BOOTX64.EFI limine/BOOTIA32.EFI ::/EFI/BOOT".format(IMAGE_NAME))
|
os.system("mcopy -i {}.hdd@@1M limine/BOOTX64.EFI limine/BOOTIA32.EFI ::/EFI/BOOT".format(IMAGE_NAME))
|
||||||
os.system("mcopy -i {}.hdd@@1M boot.tga ::/".format(IMAGE_NAME))
|
os.system("mcopy -i {}.hdd@@1M boot.tga ::/".format(IMAGE_NAME))
|
||||||
os.system("./limine/limine bios-install {}.hdd".format(IMAGE_NAME))
|
os.system("./limine/limine bios-install {}.hdd".format(IMAGE_NAME))
|
||||||
@ -150,6 +150,7 @@ def create_iso(IMAGE_NAME):
|
|||||||
os.system("cp -v modules/helloworld/hello.ko iso_root/mod/")
|
os.system("cp -v modules/helloworld/hello.ko iso_root/mod/")
|
||||||
os.system("cp -v modules/music/music.ko iso_root/mod/")
|
os.system("cp -v modules/music/music.ko iso_root/mod/")
|
||||||
os.system("cp -v modules/simd/simd.ko iso_root/mod/")
|
os.system("cp -v modules/simd/simd.ko iso_root/mod/")
|
||||||
|
os.system("cp -v modules/cpubench/cpubench.ko iso_root/mod/")
|
||||||
os.system("cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/")
|
os.system("cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/")
|
||||||
os.system("cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/")
|
os.system("cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/")
|
||||||
os.system("xorriso -as mkisofs -b limine-bios-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-uefi-cd.bin -efi-boot-part --efi-boot-image --protective-msdos-label iso_root -o {}.iso".format(IMAGE_NAME))
|
os.system("xorriso -as mkisofs -b limine-bios-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-uefi-cd.bin -efi-boot-part --efi-boot-image --protective-msdos-label iso_root -o {}.iso".format(IMAGE_NAME))
|
||||||
|
Loading…
Reference in New Issue
Block a user