Skip to content

Instantly share code, notes, and snippets.

View dvdhrm's full-sized avatar
✔️
Fixing Whitespace, what else would you do at this time?

David Rheinsberg dvdhrm

✔️
Fixing Whitespace, what else would you do at this time?
View GitHub Profile
//! UEFI Memory Allocators
//!
//! XXX
use r_efi::efi;
// UEFI guarantees 8-byte alignments through `AllocatePool()`. Any request higher than this
// alignment needs to take special precautions to align the returned pointer, and revert that step
// when freeing the memory block again.
const POOL_ALIGNMENT: usize = 8usize;
@dvdhrm
dvdhrm / hello-world.rs
Created December 5, 2018 10:36
UEFI Hello World in Rust
//
// Example: Hello World!
//
// This is an example UEFI application that prints "Hello World!", then waits for key input before
// it exits. It serves as base example how to write UEFI applications without any helper modules
// other than the UEFI protocol definitions.
//
// The `efi_main` function serves as entry-point. Depending on your target-configuration, this
// entry point might be called differently. If you use the target-configuration shipped with
// r-efi, then `efi_main` is the selected PE/COFF entry point.
fn unquote_single<'a>(acc: &mut String, source: &'a str) -> Option<&'a str> {
if let Some(end) = source.find('\'') {
acc.push_str(&source[..end]);
Some(&source[end + 1..])
} else {
None
}
}
fn unquote_double<'a>(acc: &mut String, source: &'a str) -> Option<&'a str> {
@dvdhrm
dvdhrm / c-ini.h
Created October 11, 2018 16:36
API Proposal for c-ini
#pragma once
/**
* Ini-File Handling
*
* XXX
*
* Possible extensions:
*
* * For now the API does not include serializers / writers, but was written
% git diff
diff --git a/dbus.spec b/dbus.spec
index 331fac9..4b2e139 100644
--- a/dbus.spec
+++ b/dbus.spec
@@ -206,6 +206,14 @@ find %{buildroot} -name '*.la' -type f -delete
rm -rf %{buildroot}%{_libdir}/cmake
%endif
+# Delete upstream units
@dvdhrm
dvdhrm / bus1.h
Created July 3, 2018 17:58
Bus1 API Proposal
/* SPDX-License-Identifier: LGPL-2.1+ */
#ifndef _UAPI_LINUX_BUS1_H
#define _UAPI_LINUX_BUS1_H
/**
* DOC: Public Bus1 API
*
* XXX
*/
/* root type and misc */
#define POLICY_T "(" POLICY_T_CONNECT POLICY_T_OWN POLICY_T_XMIT POLICY_T_XMIT ")"
#define POLICY_T_VERDICT "(bt)"
/* connect policies */
#define POLICY_T_CONNECT "(" POLICY_T_CONNECT_ENTRY POLICY_T_CONNECT_MAP POLICY_T_CONNECT_MAP ")"
#define POLICY_T_CONNECT_MAP "a(u" POLICY_T_CONNECT_ENTRY ")"
#define POLICY_T_CONNECT_ENTRY POLICY_T_VERDICT
/* own policies */
static void test_lpm_map(int keysize)
{
size_t i, j, n_matches, n_nodes, n_lookups;
struct tlpm_node *t, *list = NULL;
struct bpf_lpm_trie_key *key;
uint8_t data[keysize], value[keysize + 1] = {};
int r, map;
/* Compare behavior of tlpm vs. bpf-lpm. Create a randomized set of
* prefixes and insert it into both tlpm and bpf-lpm. Then run some
diff --git a/samples/bpf/map_perf_test_kern.c b/samples/bpf/map_perf_test_kern.c
index 311538e5a701..f712ad3528ea 100644
--- a/samples/bpf/map_perf_test_kern.c
+++ b/samples/bpf/map_perf_test_kern.c
@@ -42,6 +42,14 @@ struct bpf_map_def SEC("maps") percpu_hash_map_alloc = {
.map_flags = BPF_F_NO_PREALLOC,
};
+struct bpf_map_def SEC("maps") lpm_trie_map_alloc = {
+ .type = BPF_MAP_TYPE_LPM_TRIE,
#pragma once
/*
* IPv6 Neighbor Discovery Protocol
*
* This is the public header of the n-ndp library, implementing IPv6 Neighbor
* Discovery Protocol as described in RFC-4861. This header defines the public
* API and all entry points of n-ndp.
*/