Skip to content

Instantly share code, notes, and snippets.

View cwshu's full-sized avatar

Jim Shu cwshu

  • Hsinchu, Taiwan
View GitHub Profile
@cwshu
cwshu / gdbinit
Last active August 18, 2022 14:21
QEMU breakpoint at start_kernel
# For RISC-V Linux v5.18
# Add Linux symbol (before MMU setup)
add-symbol-file vmlinux -o -0xfffffffeffe00000
# OpenSBI symbol
add-symbol-file fw_jump.elf
# Linux kernel 1st line
br *0x80200000
Linux SMP + interrupt synchronization
- https://linux-kernel-labs.github.io/master/lectures/smp.html#process-and-interrupt-context-synchronization
- https://www.kernel.org/doc/html/v4.20/kernel-hacking/locking.html#hard-irq-context
- https://www.kernel.org/doc/html/v4.20/kernel-hacking/locking.html#table-of-minimum-requirements
Linux SPI driver
Slides:
- 2017, Groking the Linux SPI Subsystem: http://events17.linuxfoundation.org/sites/events/files/slides/Groking%20the%20Linux%20SPI%20Subsystem.pdf
- 2014, What’s going on with SPI?: https://elinux.org/images/2/20/Whats_going_on_with_SPI--mark_brown.pdf
Some reference:
- Overview of Linux kernel SPI support: https://www.kernel.org/doc/Documentation/spi/spi-summary
@cwshu
cwshu / foo.c
Last active November 18, 2018 06:32
arduino....
int foo(int a, int b)
{
return a+b;
}
Segger - Getting printf Output from Target to Debugger: https://blog.segger.com/getting-printf-output-from-target-to-debugger/
Tutorial: Using Single Wire Output SWO with ARM Cortex-M and Eclipse: https://mcuoneclipse.com/2016/10/17/tutorial-using-single-wire-output-swo-with-arm-cortex-m-and-eclipse/
#!/bin/sh
# requirement:
# install libcgroup
#
# usage:
# $ ./tc_cgroup.sh
# $ cgexec -g net_cls:gdrive fish
USER=susu
grep -R hw/ -e "TYPE_VIRTIO_DEVICE" | cut -d : -f 1 | xargs -I {} wc {} | column -t | sort -n
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <sys/time.h>
#include <sys/wait.h>
// Linux interrupt handler
// request_irq()
// Linux 4.9
// setup handler to irqaction
- request_threaded_irq()
- source: include/linux/interrupt.h, kernel/irq/manage.c
- irqaction is a chain(queue?) in irq_desc
- if IRQF_SHARED isn't set, there is only one irqaction in the chain.
vmi_read()
=> [VMI_TM_KERNEL_SYMBOL] vmi_translate_ksym2v()
=> vmi_pagetable_lookup_cache()
// dtb = vmi->kpgd if pid == 0
// = vmi_pid_to_dtb(vmi, ctx->pid, &dtb) if pid > 0
=> vmi_read_page(vmi, pfn)
vmi_pagetable_lookup_cache()