Skip to content

Instantly share code, notes, and snippets.

@CrystalGamma
CrystalGamma / fetch-kde.awk
Last active January 7, 2021 21:37
KDE srcs.nix fetching script
# SPDX-License-Identifier: CC0-1.0
BEGIN {
print "{ fetchurl, mirror }: {"
}
{
print " " $2 " = {"
print " version = \"" $3 "\";"
print " src = fetchurl {"
filename = $2 "-" $3 ".tar.xz"
print " url = \"${mirror}/" path "/" filename "\";"
@CrystalGamma
CrystalGamma / rk3399 sgrf.rst
Last active April 9, 2024 19:00
RK3399 SGRF

RK3399 SGRF Documentation

Rockchip does not publish documentation about the contents of the (PMU)SGRF register block in the RK3399. This document attempts to compile what is known through various documents, code drops and experiments.

Conventions

Unless otherwise noted, SGRF registers are 16 bits wide and are accessed with 32-bit accesses (and 4-byte alignment), where the upper half is a write mask. Registers are identified by their offset, e. g. :reg:`R0x1C` would refer to the 8th register in the block. Bit ranges such as :reg:`R0x40[10:13]` are inclusive. Bit positions are counted from 0, the least significant bit.

{config, lib, pkgs, ...}: {options = let
mkFlag = desc: default: lib.mkOption {
inherit default;
example = !default;
type = lib.types.bool;
description = desc;
};
in {
do-graphical = mkFlag "build a graphical system" false;
services.udev.rk3399-public = mkFlag "make the RK3399 mask ROM mode accessible to all users" false;
@CrystalGamma
CrystalGamma / configure
Created April 6, 2020 15:59
usbtool for RK3399 mask ROM booting
#!/bin/sh
if [ "$CC" = "" ]; then CC=gcc; fi
if [ "$CFLAGS" = "" ]; then CFLAGS=-O3; fi
src=`realpath $0`
src=`dirname $src`
src=`echo -n "$src" | sed "s/[\$ :]/\$&/g"`
cat >build.ninja <<END
ninja_required_version = 1.3
@CrystalGamma
CrystalGamma / configuration.nix
Created January 11, 2020 01:19
NixOS on PBP
{ config, lib, pkgs, ... }: let do_graphical = true; in {
imports = [./hardware-configuration.nix];
nix = {
maxJobs = 2;
buildCores = 6;
buildMachines = [{
hostName="rockpro64-nixos.local";
sshUser="nixdistbuild";
sshKey="/root/.ssh/id_buildmaster";
system="aarch64-linux";
@CrystalGamma
CrystalGamma / iomem
Created June 7, 2019 18:35
Talos /proc/iomem
00000000-9ffffffff : System RAM
200000000000-2005ffffffff : System RAM
6000000000000-6003fbfffffff : pciex@600c3c0000000
6004000000000-6007f7fffffff : pciex@600c3c0100000
6008000000000-600bf7fffffff : pciex@600c3c0200000
600c000000000-600c07ffeffff : pciex@600c3c0000000
600c000000000-600c07fefffff : PCI Bus 0000:01
600c000000000-600c000003fff : 0000:01:00.0
600c000000000-600c000003fff : nvme
600c080000000-600c0fffeffff : pciex@600c3c0100000
@CrystalGamma
CrystalGamma / dolphin-kill-global-state.md
Last active September 6, 2018 08:10
Removing the global state from Dolphin's CPU emulation

Removing the global state from Dolphin's CPU emulation

Rationale

Removing global state will make it easier to instantiate a CPU in isolation, which will make creating a test suite for the PPC emulation much simpler.

Following proper object-oriented design (damn I hate that phrase, but I think here it is appropriate) might also have other maintainability benefits.

Design

@CrystalGamma
CrystalGamma / qwerty_neo.rs
Created March 27, 2016 14:15
Qwerty ⇔ Neo dictionary overlapp checker
use std::io::prelude::*;
use std::collections::{HashMap, BTreeSet};
use std::fs::File;
use std::io::BufReader;
fn main() {
let trans: HashMap<_, _> = [
('q', 'x'), ('w', 'v'), ('e', 'l'), ('r', 'c'), ('t', 'w'), ('y', 'k'), ('u', 'h'), ('i', 'g'), ('o', 'f'), ('p', 'q'),
('a', 'u'), ('s', 'i'), ('d', 'a'), ('f', 'e'), ('g', 'o'), ('h', 's'), ('j', 'n'), ('k', 'r'), ('l', 't'), // whatever is right of L => 'd', L+2 => 'y'
('v', 'p'), ('b', 'z'), ('n', 'b'), ('m', 'm') // 'z' => 'ü', '/' => 'j'
@CrystalGamma
CrystalGamma / cult_of_ignorance.md
Last active November 2, 2015 12:08 — forked from conspect/cult_of_ignorance.md
A Cult Of Ignorance, Isaac Asimov

It's hard to quarrel with that ancient justification of the free press: "America's right to know." It seems almost cruel to ask, ingenously, "America's right to know what, please? Science? Mathematics? Economics? Foreign languages?"

None of those things, of course. In fact, one might well suppose that the popular feeling is that Americans are a lot better off without any of that tripe.

There is a cult of ignorance in the United States, and there always has been. The strain of anti-intellectualism has been a constant thread winding its way through out political and cultural life, nurtured by the false notion that democracy means that "my ignorance is just as good as your knowledge."

Politicians have routinely striven to speak the language of Shakespeare and Milton as ungrammaticaly as possible in order to avoid offending their audiences by appearing to have gone to school. Thus, Adlai Stevenson, who incautiously allowed intelligence and learning and wit to peep out of his speeches, found the American people