Skip to content

Instantly share code, notes, and snippets.

🕶️
DEAL WITH IT.

Cameron Kaiser classilla

🕶️
DEAL WITH IT.
View GitHub Profile
@classilla
classilla / pnorex.pl
Created Jun 22, 2020
Perl script to extract partitions from OpenPOWER PNOR firmware images.
View pnorex.pl
#!/usr/bin/perl -s
# v1.0 by Cameron Kaiser, talospace@floodgap.com
# Public domain
# By default extract Skiboot and Petitboot.
# Say -parts=DIFFERENT,PARTS to extract, you know, different parts.
# We do not support obtaining the 'part' partition yet (you can just do
# that by truncating the rest of the file anyway).
# Specifying a part multiple times is considered undefined behaviour.
@classilla
classilla / qemu-pnv-kvm.diff
Created Jun 22, 2020
A desperate attempt to get PowerNV KVM acceleration working. See if you can triumph where I have failed.
View qemu-pnv-kvm.diff
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index c9cb6fa3..c1f43310 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -23,16 +23,17 @@
#include "qapi/error.h"
#include "sysemu/sysemu.h"
#include "sysemu/numa.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
@classilla
classilla / digits_of_pi.dc
Created Nov 18, 2018
Compute 50 digits of pi using the venerable old dc utility.
View digits_of_pi.dc
[K 1+k 0 1 1lxlx*+v--lx/sxlf 2*sflx .5<=]s=
[K 1+k 0 1 1lxlx*+v--lx/sxlf 2*sflx 0 .5->>]s>
[ltklxlc*ld/Lxs.Las.Lbs.Lcs.Lds.Les.Lfs.Lgs.Lss.Lts. 3Q]s@
[lbls*sblcla*ldlb*+scldla*sdlcld/sglgle=@ lgsela 2+dsas. 1 1=?]s?
[0St0Ss0Sg0Sf0Se0Sd0Sc0Sb0SaSxlx 0=< Kst 1sflx .5<= lx 0 .5->> 0lx-lx*sslfsblfsc 1sd 1se 3dsas. 1 1=? Lxs.Las.Lbs.Lcs.Lds.Les.Lfs.Lgs.Lss.Lts.0 1Q]sQ
50k
4 1lQx*ps.
@classilla
classilla / lvds.sh
Created Jun 8, 2019
Modified /usr/bin/lvds.sh to enable S/PDIF over HDMI on the Raptor Blackbird (with thanks to @madscientist159).
View lvds.sh
#!/bin/bash
#
# Copyright 2018 - 2019 Raptor Engineering, LLC
# Released under the terms of the GPL v3
# ***** BMC PINMUX *****
# HACK
# Work around pinmux hog failure on cold boot
# Remove this block once the pinmux is fixed in the kernel!
@classilla
classilla / ipmifans.sh
Created Feb 10, 2020
BitBar and Argos-compatible shell script for getting system fan information over IPMI.
View ipmifans.sh
#!/usr/bin/env bash
IPMITOOL=/usr/bin/ipmitool
AWK=/usr/bin/awk
output=`$IPMITOOL sdr type fan | $AWK '{if($5=="ok")print $9}'`
echo -n $output | $AWK 'BEGIN{RS=" ";k=0} {if($1>k)k=$1} END{print k"rpm"}'
echo "---"
echo -n $output | $AWK 'BEGIN{RS=" ";ORS="rpm\n"} {if($1>0)print}'
@classilla
classilla / ppc64le_dosbox.diff
Created Jan 7, 2020
DOSBox for ppc64le. Place risc_ppc64le.h in src/cpu/core_dynrec and apply the diff. ./autogen.sh ; ./configure CFLAGS="-O3 -mcpu=power9" CXXFLAGS="-O3 -mcpu=power9" ; make -j24
View ppc64le_dosbox.diff
Index: configure.ac
===================================================================
--- configure.ac (revision 4296)
+++ configure.ac (working copy)
@@ -292,9 +292,16 @@
c_targetcpu="x86"
c_unalignedmemory=yes
;;
+ powerpc64le*)
+ AC_DEFINE(C_TARGETCPU,PPC64LE)
@classilla
classilla / jitlab2.c
Created Jan 7, 2020
Simple ppc64/ppc64le generated machine code example that's a little more complicated
View jitlab2.c
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/memfd.h>
uint32_t* jitcode;
@classilla
classilla / jitlab1.c
Created Jan 7, 2020
Simple ppc64/ppc64le generated machine code example
View jitlab1.c
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/memfd.h>
uint32_t* jitcode;
@classilla
classilla / microwatt-wait-instruction.diff
Created Sep 15, 2019
Example of adding a "wait" instruction to Microwatt, the VHDL OpenPOWER ISA core.
View microwatt-wait-instruction.diff
diff --git a/core.vhdl b/core.vhdl
index d34bf71..60c8cdf 100644
--- a/core.vhdl
+++ b/core.vhdl
@@ -17,17 +17,18 @@ entity core is
wishbone_insn_in : in wishbone_slave_out;
wishbone_insn_out : out wishbone_master_out;
wishbone_data_in : in wishbone_slave_out;
wishbone_data_out : out wishbone_master_out;
@classilla
classilla / lamevsx.diff
Created Jul 27, 2019
Enable SSE intrinsic acceleration with VMX/VSX for LAME 3.100 on ppc64le (configure with CFLAGS="-O3 -mcpu=power9 -DNO_WARN_X86_INTRINSICS" ./configure)
View lamevsx.diff
diff --git a/configure b/configure
index 52dbf02..1354f27 100755
--- a/configure
+++ b/configure
@@ -17226,16 +17226,28 @@ powerpc)
# use internal knowledge of the IEEE 754 layout
$as_echo "#define TAKEHIRO_IEEE754_HACK 1" >>confdefs.h
You can’t perform that action at this time.