Skip to content

Instantly share code, notes, and snippets.

View abelardojarab's full-sized avatar

Abelardo Jara-Berrocal abelardojarab

View GitHub Profile
@abelardojarab
abelardojarab / compile_verilate.sh
Created November 7, 2017 19:55
Compile a System Verilog project with Verilator
#!/bin/bash
verilator -Wno-STMTDLY -Wno-PINMISSING -Wno-LITENDIAN -Wno-CASEX -Wno-CASEINCOMPLETE -Wno-COMBDLY -Wno-WIDTH -Wno-UNOPTFLAT -f vlog_files.list +define+VENDOR_ALTERA +define+TOOL_QUARTUS +define+NUM_AFUS=1 +define+NLB400_MODE_0 +define+ASE_PLATFORM_MCP_SKYLAKE -I./nlb_rtl/rtl/include_files/common -I./sim_lib_verilated -I./sim_lib --top-module ccip_std_afu -cc test.c
@abelardojarab
abelardojarab / configure_emacs.sh
Created November 7, 2017 19:57
Configure Emacs for compilation
#!/bin/bash
./configure --with-x-toolkit=gtk3 --with-gif=no --enable-link-time-optimization --without-xim --without-sync-input --without-dbus CPPFLAGS="-fgnu89-inline" CFLAGS="-flto -O2 -march=native" LDFLAGS="-flto"
@abelardojarab
abelardojarab / launch_qemu.sh
Created November 7, 2017 20:01
Using qemu and gdb stub for debugging Linux kernel
#!/bin/bash
sudo ~/Downloads/qemu-2.9.0/x86_64-softmmu/qemu-system-x86_64 -hda backups/ubuntu15u10_amd64.img -append "root=/dev/sda1 console=hvc0 ip=dhcp rd.shell=1" -chardev stdio,id=stdio,mux=on -device virtio-serial-pci -device virtconsole,chardev=stdio -mon chardev=stdio -m 16000 -net nic,model=virtio,macaddr=52:54:00:12:34:56 -net user,hostfwd=tcp:127.0.0.1:4444-:22 -net tap,id=network0,ifname=tap0,script=no,downscript=no -display none -fsdev local,id=fs1,path=$HOME/shared,security_model=none -kernel /mnt/data/ajaraber/VMs/linux-4.8/arch/x86_64/boot/bzImage -smp 16 -runas lab -s -enable-kvm
@abelardojarab
abelardojarab / ssh_port_forwarding.sh
Created November 7, 2017 20:48
SSH port forwarding to remote machine
#!/bin/bash
autossh -M 20000 -R 9922:localhost:22 -R 9989:localhost:5900 -R 9991:cpt-swdev1:5901 -R 9992:cpt-swdev1:5902 -R 8822:cpt-swdev1:22 ubuntu01
@abelardojarab
abelardojarab / fix_code_vnc.sh
Created November 7, 2017 22:10
Fix Visual Studio Code not launching in Ubuntu under VNC
#!/bin/bash
# make a copy of the relevant library
mkdir ~/lib
cp /usr/lib/x86_64-linux-gnu/libxcb.so.1 ~/lib
sed -i 's/BIG-REQUESTS/_IG-REQUESTS/' ~/lib/libxcb.so.1
# set the dynamic loader path to put your library first before executing VS Code
LD_LIBRARY_PATH=$HOME/lib code
@abelardojarab
abelardojarab / create_singleton.cpp
Created November 7, 2017 22:14
Create singleton class in C++
// Example program
#include <iostream>
#include <string>
#include <memory>
class singleton
{
static std::shared_ptr<singleton> instance(int a)
{
if (!instance_)
@abelardojarab
abelardojarab / IOMMU support in Linux kernel.md
Last active November 16, 2021 06:10
Verifying IOMMU support in Linux kernel

Basic stuff

ACPI enumerates and lists the different DMA engines in the platform, and device scope relationships between PCI devices and which DMA engine controls them.

How is IOVA generated?

@abelardojarab
abelardojarab / show_and_filter_gtest.md
Created November 8, 2017 21:02
Howto print full list of google tests and define a gtest filter

Get list of all the available google tests

Get all testcases by running tests with --gtest_list_tests

Run specific google tests

To run only some unit tests you could use --gtest_filter=Test_Cases1* command line option with value which is regular expression.

@abelardojarab
abelardojarab / add_and_update_git_subtree.md
Created November 9, 2017 21:26
Add and update a git subtree

Add a new git subtree

The common practice is to not store the entire history of the subproject in your main repository, but If you want to preserve it just omit the –squash flag

git subtree add --prefix .emacs.d/rtags https://github.com/abelardojarab/rtags master --squash

Update a git subtree

@abelardojarab
abelardojarab / advice_emacs_function.md
Created November 12, 2017 18:41
Advice functions in Emacs (defadvice, around, add-do-it)

Around means that the advice is executed instead of the function. You can still call the original with ad-do-it.

Just to add a small example:

(defun foo (x)
  (* 2 x))

(defadvice foo (around bar activate)
 (setq ad-return-value