Skip to content

Instantly share code, notes, and snippets.

View knknkn1162's full-sized avatar

Kenta Nakajima knknkn1162

View GitHub Profile
@knknkn1162
knknkn1162 / opensbi_build.sh
Last active October 15, 2019 23:53
OpenSBI "No payload case"
$ make CROSS_COMPILE=riscv64-unknown-elf- PLATFORM=qemu/virt
CC lib/sbi/riscv_asm.o
CC lib/sbi/riscv_atomic.o
AS lib/sbi/riscv_hardfp.o
CC lib/sbi/riscv_locks.o
CC lib/sbi/riscv_unpriv.o
CC lib/sbi/sbi_console.o
CC lib/sbi/sbi_ecall.o
CC lib/sbi/sbi_emulate_csr.o
CC lib/sbi/sbi_fifo.o
// https://www.hackerrank.com/challenges/count-triplets-1/problem
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
```sh
make PLATFORM=qemu/virt
qemu-system-riscv64 -M virt -m 256M -nographic -kernel build/platform/qemu/virt/firmware/fw_payload.elf
```
qemu-system-riscv64: warning: No -bios option specified. Not loading a firmware.
qemu-system-riscv64: warning: This default will change in a future QEMU release. Please use the -bios option to avoid breakages when this happens.
qemu-system-riscv64: warning: See QEMU's deprecation documentation for details.
OpenSBI v0.5 (Oct 13 2019 13:07:42)
$ tree ../linux-stable/arch/riscv/boot
../linux-stable/arch/riscv/boot
├── Image
├── Image.gz
├── Makefile
├── dts
│   ├── Makefile
│   └── sifive
│   ├── Makefile
│   ├── fu540-c000.dtsi
qemu-system-riscv64: warning: No -bios option specified. Not loading a firmware.
qemu-system-riscv64: warning: This default will change in a future QEMU release. Please use the -bios option to avoid breakages when this happens.
qemu-system-riscv64: warning: See QEMU's deprecation documentation for details.
OpenSBI v0.5 (Oct 14 2019 06:54:36)
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
@knknkn1162
knknkn1162 / alloc_page.yml
Last active August 4, 2019 07:21
sb_bread
alloc_page:
- alloc_pages(gfp_mask, 0)
- alloc_pages_node(numa_node_id()=0, gfp_mask, order=0)
- __alloc_pages(gfp_mask, order, node_data[0]->node_zonelists + (gfp_mask & GFP_ZONEMASK));
// assume that ELEVATOR_NO_MERGE
static int __make_request(request_queue_t *q, struct bio *bio)
{
struct request *req, *freereq = NULL;
int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, err;
sector_t sector;
sector = bio->bi_sector;
nr_sectors = bio_sectors(bio);
cur_nr_sectors = bio_cur_sectors(bio);
// I/O for the block layer
struct bio {
sector_t bi_sector;
struct bio *bi_next; /* request queue link */
struct block_device *bi_bdev;
unsigned long bi_flags; /* status, command, etc */
unsigned long bi_rw; /* bottom bits READ/WRITE,
* top bits priority
*/
$ ag "tty_operations"
net/irda/ircomm/ircomm_tty.c
83:static struct tty_operations ops = {
net/bluetooth/rfcomm/tty.c
877:static struct tty_operations rfcomm_ops = {
drivers/sbus/char/aurora.c
2200:static struct tty_operations aurora_ops = {
@knknkn1162
knknkn1162 / as_io.c
Last active July 16, 2019 02:46
anticipatory I/O scheduler
struct as_rq {
/*
* rbtree index, key is the starting offset
*/
struct rb_node rb_node;
sector_t rb_key;
struct request *request;
struct io_context *io_context; /* The submitting task */