Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Kronquist iankronquist

View GitHub Profile
View gist:0fd9e27d92f8713f54e0f479b71e6a48
#define MPP_MACHINE (0b11 << 11)
#define MPP_SUPERVISOR (0b01 << 11)
#define SPP_SUPERVISOR (1 << 8)
#define MPIE_YES (1 << 7)
#define SPIE_YES (1 << 5)
#define MIE_YES (1 << 3)
#define SIE_YES (1 << 1)
/* Machine external interrupt enable */
#define MIE_MEIE (1 << 11)
@iankronquist
iankronquist / i3toswayarchmigration.md
Created Oct 20, 2017
Migrating from i3 to Sway on Arch Linux
View i3toswayarchmigration.md

Migrating from i3 to Sway on Arch Linux

Refer to the arch wiki: https://wiki.archlinux.org/index.php/Sway

  1. Install packages: pacman -S sway weston
  2. Copy configuration:
mkdir -p ~/.config/sway
cp ~/.i3/config ~/.config/sway/config
  1. When you log in, start sway:
@iankronquist
iankronquist / 0-Intro.md
Last active May 7, 2017
A Young Lady's C++ Primer
View 0-Intro.md

A Young Lady's C++ Primer

(I have been enjoying The Diamond Age, thank you)

C++ was developed in 198X by Bjourne Strousap. It is an improved version of the venerable C programming language. C is excellent at describing low level details in a way which is portable across computers. It is the most influential language of our lifetimes, but unless you're writing an operating system, a hypervisor (AKA Virtual Machine Monitor), or working on an embedded system on a tiny ass microcontroller, it's probably not the right tool for the job.

@iankronquist
iankronquist / 0-Programming-Paradigms.md
Last active Sep 9, 2020
The Fundamentals of Programming
View 0-Programming-Paradigms.md

Programming Paradigms

In programming, a paradigm is an abstract way to understand and solve a problem. A paradigm is like a perspective, a high point from which you can survey the terrain and try to decide the path your journey will take.

Toay, there are three major programming paradigms:

  1. Imperative Programming.
  2. Object Oriented Programming (OOP).
  3. Functional Programming (FP).

In principle any language can be used to program in any paradigm, but in practice certain languages tend to favor certain paradigms.

View page fault.txt
This file has been truncated, but you can view the full file.
CPU Reset (CPU 0)
EAX=00000000 EBX=00000000 ECX=00000000 EDX=00000000
ESI=00000000 EDI=00000000 EBP=00000000 ESP=00000000
EIP=00000000 EFL=00000000 [-------] CPL=0 II=0 A20=0 SMM=0 HLT=0
ES =0000 00000000 00000000 00000000
CS =0000 00000000 00000000 00000000
SS =0000 00000000 00000000 00000000
DS =0000 00000000 00000000 00000000
FS =0000 00000000 00000000 00000000
@iankronquist
iankronquist / 0_typing.md
Last active Oct 17, 2016
An Introduction to Python
View 0_typing.md

Typing

When programmers talk about typing, most of the time they aren't talking about the odious task of pressing keys on a keyboard (watch any programmer and look to see how much of their time they spend actually typing out code. What you'll see instead is a lot of frowning and staring at the screen with an expression of great consternation as you can see them think "why the hell didn't my code do what I thought?"). Instead they're talking about the types of variables. Now you're probably familiar with the idea that there are numbers and strings and

View actual objdump.txt
00000000000000c0 <vmxoff>:
c0: e8 00 00 00 00 callq c5 <vmxoff+0x5>
c5: 55 push %rbp
c6: 48 89 e5 mov %rsp,%rbp
c9: 48 83 ec 10 sub $0x10,%rsp
cd: 65 48 8b 04 25 28 00 mov %gs:0x28,%rax
d4: 00 00
d6: 48 89 45 f8 mov %rax,-0x8(%rbp)
da: 31 c0 xor %eax,%eax
dc: 0f 01 c4 vmxoff
@iankronquist
iankronquist / memory.md
Last active Sep 2, 2016
Design of the Kernel of Truth Memory System
View memory.md

Design of the Kernel of Truth Memory System

  • Uses PAE paging.
  • Higher half memory model.

Initialized in this order:

  1. Bootstrap PAE paging.
  2. Kernel heap.
  3. Physical allocator.
  4. Init process PAE paging.
View c functions.md

We're going to focus on x86 because it's the easiest to understand. I'll then explain how x86_64 is more efficient.

So the stack is where local variables are stored. It is just a chunk of memory available for the program. The top of the stack is stored in a special register called the stack pointer, or esp on x86. It grows from higher addresses to lower addresses. To put a value on the stack you can

@iankronquist
iankronquist / OSU CS444 Instructions.md
Last active May 19, 2016
Instructions for OSU CS444 assignment 3
View OSU CS444 Instructions.md

You made a device driver! Let's say you named it sbd.

Let's start by recalling that on Linux, everything is a file. There is a file on the filesystem representing every device. On many linux laptops you can see things like /dev/mouse, /dev/speakers, and /dev/cpu. Your driver acts like a hard drive as far as Linux is concerned.

Now, if you start up the vm, you'll see that the device isn't loaded by default:

$ ls /dev/sbd
No such file or directory
You can’t perform that action at this time.