Skip to content

Instantly share code, notes, and snippets.

View karaketir16's full-sized avatar
๐Ÿ˜‘

Osman Karaketir karaketir16

๐Ÿ˜‘
  • ASELSAN
  • Ankara
  • 17:52 (UTC +03:00)
View GitHub Profile
@karaketir16
karaketir16 / model_add.py
Created March 15, 2025 13:44
Ollama Model Install
import os
import sys
import shutil
import hashlib
from pathlib import Path
def get_models_path(custom_path=None):
if custom_path:
return custom_path

The machine level has the highest privileges and is the only mandatory privilege level for a RISC-V hardware platform. Code run in machine-mode (M-mode) is usually inherently trusted, as it has low-level access to the machine implementation. M-mode can be used to manage secure execution environments on RISC-V. User-mode (U-mode) and supervisor-mode (S-mode) are intended for conventional application and operating system usage respectively.

The lock feature of the optional PMP facility can provide some limited protection even with only M-mode implemented.

The SYSTEM major opcode is used to encode all privileged instructions in the RISC-V ISA. These can be divided into two main classes: those that atomically read-modify-write control and status registers

Simple CPU Instruction Set

Overview

  • 12-bit registers: R0--R7 (3-bit register indices).
  • R0 is hardwired to zero.
  • All instructions are 16 bits.
  • Instruction groups by opcode patterns:
    • 0000 (0x0): Arithmetic & Shift Instructions (with funct field)
    • 0001 (0x1): Logical Instructions (with funct field)
@karaketir16
karaketir16 / Prerequisites
Last active November 10, 2024 13:43
Prerequisites for RISC-V GNU Compiler Toolchain on OpenSUSE
sudo zypper install make autoconf automake python3 mpc-devel mpfr-devel gmp-devel gawk bison flex texinfo patchutils gcc gcc-c++ zlib-devel libexpat-devel libslirp-devel
@karaketir16
karaketir16 / entry.s
Created October 14, 2024 18:42
RISC-V privilege levels example. Alternative for https://danielmangum.com/posts/risc-v-bytes-privilege-levels/ when pmp enabled. pmp disabled not worked for me
.section .text
.globl start
# riscv64-unknown-elf-as -g entry.s -o entry.o && riscv64-unknown-elf-ld -T baremetal.ld entry.o -o entry
# qemu-system-riscv64 -machine virt -cpu sifive-u54 -smp 1 -s -S -nographic -bios none -kernel entry
# or
# qemu-system-riscv64 -machine virt -cpu rv64 -smp 1 -s -S -nographic -bios none -kernel entry
start:
# Load address of 'supervisor' into t0 and set mepc
#include <iostream>
int multiply(int number_a, int number_b){
return number_a * number_b;
}
int my_function()
{
int c;
c = 5;
@karaketir16
karaketir16 / vscode_qt
Created November 10, 2023 14:25
VS Code Clangd and Qt
CMAKE_PREFIX_PATH="~/Qt/6.5.3/gcc_64/" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
@karaketir16
karaketir16 / gist:d5c6b798ecc1fe651b8a7668754aeb76
Created November 9, 2023 19:54
Ubuntu Python Version Install
https://web.archive.org/web/20231005145415/https://www.linuxcapable.com/install-python-3-8-on-ubuntu-linux/
@karaketir16
karaketir16 / disableDPMS
Created October 19, 2023 13:59
disable DPMS -- disable screen off / yocto mini-x-session
#!/bin/sh
#/etc/mini_x/session.d/disableDPMS
/usr/bin/xset -dpms s off s noblank s 0 0 s noexpose
@karaketir16
karaketir16 / 20-wired.network
Created October 18, 2023 14:54
static ip for systems with systemd
#/etc/systemd/network/20-wired.network
[Match]
Name=eth0
[Network]
Address=192.168.8.55/24