Skip to content

Instantly share code, notes, and snippets.

Pmu = 0x504d55,
// PMU function IDs.
pub const SBI_PMU_NUM_COUNTERS: usize = 0x00;
pub const SBI_PMU_COUNTER_CONFIG_MATCHING: usize = 0x02;
pub const SBI_PMU_COUNTER_START: usize = 0x03;
pub const SBI_PMU_COUNTER_STOP: usize = 0x04;
pub const SBI_PMU_COUNTER_FW_READ: usize = 0x05;
pub const SBI_PMU_COUNTER_FW_READ_HI: usize = 0x06;
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define _assert_fail(msg, ...) do { puts(msg); exit(1); } while (0)
#define CONST __attribute__((__const__))
#define seL4_Null ((void*)0)
#define LIBSEL4_INLINE_FUNC static inline
typedef uint32_t seL4_CPtr;
typedef uint32_t seL4_Word;
@nuta
nuta / sel4_send.c
Created November 13, 2022 05:01
seL4_Send inlining
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define _assert_fail(msg, ...) do { puts(msg); exit(1); } while (0)
#define CONST __attribute__((__const__))
#define seL4_Null ((void*)0)
#define LIBSEL4_INLINE_FUNC static inline
typedef uint32_t seL4_CPtr;
typedef uint32_t seL4_Word;
#[test]
fn grapheme_iter() {
let text = "a👩‍🔬";
let mut c = unicode_segmentation::GraphemeCursor::new(text.len(), text.len(), true);
dbg!(text.len());
dbg!(text.char_indices().map(|(i, c)| (i, c)).collect::<Vec<_>>());
assert_eq!(
c.prev_boundary(&text[(text.len() - 4)..], text.len() - 4),
Err(GraphemeIncomplete::PrevChunk)
@nuta
nuta / cache disabled
Created June 13, 2021 12:54
Cache memory experiment on Resea IPC on Raspberry Pi 3B+
Booting Resea v0.9.0 (dc57ce1)...
[kernel] Booted CPU #0
[vm] ready
[benchmark_server] starting benchmark server...
[benchmark] starting IPC benchmark...
{"type":"metric","key":"reading cycle counter","value":30}
[benchmark] reading cycle counter: cycles: avg=31, min=30, max=376
[benchmark] reading cycle counter: l1d_cache_access: avg=0, min=0, max=0
[benchmark] reading cycle counter: l2d_cache_access: avg=0, min=0, max=0
[benchmark] reading cycle counter: mem_access: avg=10, min=10, max=174
@nuta
nuta / intrusive_list.rs
Created May 10, 2021 16:45
intrusive_list.rs (not working)
use core::{marker::PhantomData, ptr::NonNull};
use memoffset::offset_of;
/// An intrusive doubly-linked list node.
pub struct ListNode<T> {
/// The previous node. It points to itself if the list has only sigle entry.
prev: NonNull<ListNode<T>>,
/// The next node. It points to itself if the list has only sigle entry.
next: NonNull<ListNode<T>>,
_pd: PhantomData<T>,
@nuta
nuta / interval_tree.rs
Created May 4, 2021 16:30
interval tree
use std::cmp::min;
use std::ops;
use std::slice;
pub trait Interval: Ord + Clone {
fn is_empty(&self) -> bool;
fn includes(&self, other: &Self) -> bool;
fn overlaps_with(&self, other: &Self) -> bool;
/// ```text
/// self: ...xxxx....
FROM ubuntu:latest
RUN apt update -y && apt install -y musl-tools
ADD hello.c /hello.c
RUN musl-gcc -static hello.c -o /hello
RUN mkdir /empty_dir
FROM scratch
WORKDIR /
COPY --from=0 /hello /hello
COPY --from=0 /empty_dir /tmp
@nuta
nuta / bochs.sh
Last active March 2, 2021 13:45
bochs build
wget http://bochs.sourceforge.net/svn-snapshot/bochs-20210227.tar.gz
./configure --enable-x86-debugger --enable-x86-64 --enable-cpu-level=6 --enable-readline \
--enable-smp --disable-show-ips --enable-all-optimizations --with-nogui --enable-logging --enable-debugger \
--enable-usb --enable-e1000 --enable-cdrom --enable-option-checking --enable-avx --enable-evex
@nuta
nuta / linux.config
Created December 20, 2020 06:33
Kernel config used for testing Resea hv
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.10.0-rc7 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=90300
CONFIG_LD_VERSION=234000000
CONFIG_CLANG_VERSION=0
CONFIG_LLD_VERSION=0