Skip to content

Instantly share code, notes, and snippets.

View jarlostensen's full-sized avatar

Jarl Ostensen jarlostensen

View GitHub Profile
@jarlostensen
jarlostensen / pagetables.c
Created November 14, 2021 12:31
4 level page table traversal
// from josx64, but this code is pretty generic.
// [kernel] fills in the pagetable entries from the given address
//
// see for example Intel Dev Guide Vol 3 4.2
_JOS_API_FUNC void pagetables_traverse_tables(void* at, uintptr_t * entries, size_t num_entries) {
_JOS_ASSERT(entries &&_4_level_paging && num_entries>=4);
memset(entries, 0, 4*sizeof(uintptr_t));
//NOTE: this relies on identity mapping in order to get access to the pagetables themselves
@jarlostensen
jarlostensen / client_side.py
Created August 13, 2021 08:06
python Flask POST binary float array using numpy
def post_bin_example():
import requests
import numpy as np
#NOTE! the dtype used here and on the server have to match and byte ordering isn't considered in this example
x = np.random.rand(10).astype(np.float32)
print(f'sending {len(x)} floats : {x}')
res = requests.post(url=ROOT_PATH+r'/readbin',
data=x.tobytes(),
headers={'Content-Type': 'application/octet-stream'})
print(res)
@jarlostensen
jarlostensen / CMakeLists.txt
Created May 7, 2021 12:54
a modern (at the time of writing) minimal CMake file to build a basic EFI hello world application.
# a *very* simple CMake file which will build a valid PE+ 64 bit EFI executable using Clang + LLD-LINK on Windows
# with LLVM clang+linker present in an "external" folder as specified below.
#
# To generate Ninja build scripts for this example:
# cmake.exe -H. -G Ninja -Bbuild^
# -DCMAKE_SYSTEM_NAME="Generic"^
# -DCMAKE_C_COMPILER:PATH="%CD%\external\LLVM\bin\clang.exe" -DCMAKE_C_COMPILER_ID="Clang"^
# -DCMAKE_CXX_COMPILER:PATH="%CD%\external\LLVM\bin\clang.exe" -DCMAKE_CXX_COMPILER_ID="Clang"^
# -DCMAKE_LINKER:PATH="%CD%\external\LLVM\bin\lld-link.exe"
#