├── CNAME
├── .github
└── FUNDING.yml
├── part2-building
├── kernel.c
├── link.ld
├── Makefile
├── Makefile.gcc
└── boot.S
├── part1-bootstrapping
├── kernel.c
├── link.ld
└── boot.S
├── google69636ed483fc239e.html
├── part3-helloworld
├── io.h
├── images
│ ├── 3-helloworld-cable.jpg
│ ├── 3-helloworld-pinloc.png
│ └── 3-helloworld-ctlpanel.png
├── kernel.c
├── link.ld
├── Makefile
├── Makefile.gcc
└── boot.S
├── part12-wgt
├── bin
│ ├── wgt1.blk
│ ├── wgt2.blk
│ ├── break.spr
│ ├── mouse.spr
│ ├── space.spr
│ ├── BCM4345C0.hcd
│ ├── invader.spr
│ ├── letters.spr
│ └── wgt1.pal
├── include
│ ├── mem.h
│ ├── multicore.h
│ ├── bt.h
│ ├── io.h
│ └── mb.h
├── controller-ios
│ ├── rpi4-osdev-ioscontrol
│ │ ├── Assets.xcassets
│ │ │ ├── Contents.json
│ │ │ └── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ └── AppDelegate.swift
│ └── rpi4-osdev-ioscontrol.xcodeproj
│ │ ├── xcuserdata
│ │ ├── Akshata.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ │ └── xcschememanagement.plist
│ │ └── agb.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── project.xcworkspace
│ │ ├── xcuserdata
│ │ ├── agb.xcuserdatad
│ │ │ ├── UserInterfaceState.xcuserstate
│ │ │ └── WorkspaceSettings.xcsettings
│ │ └── Akshata.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ ├── WorkspaceSettings.xcsettings
│ │ └── IDEWorkspaceChecks.plist
├── samples
│ ├── wgt01.c
│ ├── wgt45.c
│ ├── wgt46.c
│ ├── wgt21.c
│ ├── wgt10.c
│ ├── wgt08.c
│ ├── wgt09.c
│ ├── wgt07.c
│ ├── wgt15.c
│ ├── wgt41.c
│ ├── wgt16.c
│ ├── wgt27.c
│ ├── wgt02.c
│ ├── wgt33.c
│ ├── wgt39.c
│ ├── wgt11.c
│ └── wgt36.c
├── wgt
│ ├── wpixel.c
│ ├── wmiscb.c
│ ├── wclip.c
│ ├── wbutt.c
│ ├── winitply.c
│ ├── wdissolve.c
│ ├── wblock.c
│ ├── wsetcol.c
│ ├── wvertres.c
│ ├── wbox.c
│ ├── wxor.c
│ ├── wwipe.c
│ ├── wticker.c
│ ├── wbezier.c
│ ├── wflipb.c
│ ├── wsetmode.c
│ ├── wwarp.c
│ └── wskew.c
├── boot
│ ├── link.ld
│ └── sysregs.h
├── lib
│ ├── multicore.c
│ └── mem.c
├── controller-node
│ ├── characteristic.js
│ └── main.js
└── Makefile
├── part9-sound
├── audio.bin
├── audio.wav
├── link.ld
├── io.h
├── fb.h
├── Makefile
├── Makefile.gcc
├── mb.h
├── boot.S
└── mb.c
├── part10-multicore
├── audio.bin
├── audio.wav
├── images
│ └── 10-multicore-running.jpg
├── multicore.h
├── io.h
├── fb.h
├── Makefile
├── Makefile.gcc
├── mb.h
├── link.ld
├── multicore.c
├── mb.c
└── boot.S
├── part7-bluetooth
├── BCM4345C0.hcd
├── images
│ └── 7-eddystone-beacon.png
├── bt.h
├── io.h
├── link.ld
├── fb.h
├── Makefile
├── Makefile.gcc
├── mb.h
├── boot.S
└── mb.c
├── part11-breakout-smp
├── bin
│ ├── audio.bin
│ └── BCM4345C0.hcd
├── include
│ ├── multicore.h
│ ├── bt.h
│ ├── io.h
│ ├── fb.h
│ ├── mb.h
│ └── audio.h
├── breakout_snd.c
├── boot
│ ├── link.ld
│ └── boot.S
├── lib
│ ├── multicore.c
│ └── mb.c
├── Makefile
├── breakout.h
└── README.md
├── part8-breakout-ble
├── BCM4345C0.hcd
├── images
│ └── 8-opcode-1b.png
├── bt.h
├── io.h
├── link.ld
├── fb.h
├── Makefile
├── Makefile.gcc.windows
├── Makefile.gcc
├── mb.h
├── boot.S
├── controller
│ ├── main.js
│ └── characteristic.js
└── mb.c
├── part14-spi-ethernet
├── net
│ ├── enc28j60.c
│ ├── enc28j60.h
│ └── encspi.c
├── images
│ ├── 14-spi-ethernet-arp.jpg
│ └── 14-spi-ethernet-photo.jpg
├── include
│ ├── spi.h
│ ├── multicore.h
│ ├── fb.h
│ ├── io.h
│ └── mb.h
├── kernel
│ ├── utils.S
│ ├── irq.c
│ └── kernel.h
├── Makefile
├── Makefile.gcc
├── boot
│ ├── link.ld
│ └── sysregs.h
└── lib
│ ├── multicore.c
│ └── mb.c
├── part15-tcpip-webserver
├── net
│ ├── enc28j60.c
│ ├── enc28j60.h
│ └── encspi.c
├── kernel
│ └── kernel.h
├── images
│ ├── 15-tcpip-webserver-browser.png
│ └── 15-tcpip-webserver-pinging.jpg
├── include
│ ├── spi.h
│ ├── multicore.h
│ ├── fb.h
│ ├── mb.h
│ └── io.h
├── Makefile
├── Makefile.gcc
├── boot
│ ├── link.ld
│ └── sysregs.h
├── lib
│ ├── multicore.c
│ └── mb.c
└── tcpip
│ └── ip_config.h
├── part6-breakout
├── images
│ ├── 6-breakout-wozniak.jpg
│ └── 6-breakout-thefinishedgame.jpg
├── io.h
├── fb.h
├── link.ld
├── Makefile
├── Makefile.gcc
├── mb.h
├── boot.S
└── mb.c
├── part13-interrupts
├── images
│ └── 13-interrupts-running.jpg
├── kernel
│ ├── utils.S
│ ├── irq.c
│ └── kernel.h
├── include
│ ├── multicore.h
│ ├── io.h
│ ├── fb.h
│ └── mb.h
├── Makefile
├── Makefile.gcc
├── boot
│ ├── link.ld
│ └── sysregs.h
└── lib
│ ├── multicore.c
│ └── mb.c
├── part5-framebuffer
├── images
│ └── 5-framebuffer-screen.jpg
├── io.h
├── fb.h
├── kernel.c
├── link.ld
├── Makefile
├── Makefile.gcc
├── mb.h
├── boot.S
└── mb.c
├── _config.yml
└── part4-miniuart
├── kernel.c
├── io.h
├── link.ld
├── Makefile
├── Makefile.gcc
└── boot.S
/CNAME:
--------------------------------------------------------------------------------
1 | www.rpi4os.com
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: isometimes
2 |
--------------------------------------------------------------------------------
/part2-building/kernel.c:
--------------------------------------------------------------------------------
1 | void main()
2 | {
3 | while (1);
4 | }
5 |
--------------------------------------------------------------------------------
/part1-bootstrapping/kernel.c:
--------------------------------------------------------------------------------
1 | void main()
2 | {
3 | while (1);
4 | }
5 |
--------------------------------------------------------------------------------
/google69636ed483fc239e.html:
--------------------------------------------------------------------------------
1 | google-site-verification: google69636ed483fc239e.html
--------------------------------------------------------------------------------
/part3-helloworld/io.h:
--------------------------------------------------------------------------------
1 | void uart_init();
2 | void uart_writeText(char *buffer);
3 |
--------------------------------------------------------------------------------
/part12-wgt/bin/wgt1.blk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/bin/wgt1.blk
--------------------------------------------------------------------------------
/part12-wgt/bin/wgt2.blk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/bin/wgt2.blk
--------------------------------------------------------------------------------
/part9-sound/audio.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part9-sound/audio.bin
--------------------------------------------------------------------------------
/part9-sound/audio.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part9-sound/audio.wav
--------------------------------------------------------------------------------
/part12-wgt/bin/break.spr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/bin/break.spr
--------------------------------------------------------------------------------
/part12-wgt/bin/mouse.spr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/bin/mouse.spr
--------------------------------------------------------------------------------
/part12-wgt/bin/space.spr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/bin/space.spr
--------------------------------------------------------------------------------
/part12-wgt/include/mem.h:
--------------------------------------------------------------------------------
1 | void mem_init();
2 | void *malloc(unsigned int size);
3 | void free(void *ptr);
4 |
--------------------------------------------------------------------------------
/part10-multicore/audio.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part10-multicore/audio.bin
--------------------------------------------------------------------------------
/part10-multicore/audio.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part10-multicore/audio.wav
--------------------------------------------------------------------------------
/part12-wgt/bin/BCM4345C0.hcd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/bin/BCM4345C0.hcd
--------------------------------------------------------------------------------
/part12-wgt/bin/invader.spr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/bin/invader.spr
--------------------------------------------------------------------------------
/part12-wgt/bin/letters.spr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/bin/letters.spr
--------------------------------------------------------------------------------
/part7-bluetooth/BCM4345C0.hcd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part7-bluetooth/BCM4345C0.hcd
--------------------------------------------------------------------------------
/part11-breakout-smp/bin/audio.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part11-breakout-smp/bin/audio.bin
--------------------------------------------------------------------------------
/part8-breakout-ble/BCM4345C0.hcd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part8-breakout-ble/BCM4345C0.hcd
--------------------------------------------------------------------------------
/part14-spi-ethernet/net/enc28j60.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part14-spi-ethernet/net/enc28j60.c
--------------------------------------------------------------------------------
/part14-spi-ethernet/net/enc28j60.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part14-spi-ethernet/net/enc28j60.h
--------------------------------------------------------------------------------
/part11-breakout-smp/bin/BCM4345C0.hcd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part11-breakout-smp/bin/BCM4345C0.hcd
--------------------------------------------------------------------------------
/part15-tcpip-webserver/net/enc28j60.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part15-tcpip-webserver/net/enc28j60.c
--------------------------------------------------------------------------------
/part15-tcpip-webserver/net/enc28j60.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part15-tcpip-webserver/net/enc28j60.h
--------------------------------------------------------------------------------
/part8-breakout-ble/images/8-opcode-1b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part8-breakout-ble/images/8-opcode-1b.png
--------------------------------------------------------------------------------
/part6-breakout/images/6-breakout-wozniak.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part6-breakout/images/6-breakout-wozniak.jpg
--------------------------------------------------------------------------------
/part7-bluetooth/images/7-eddystone-beacon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part7-bluetooth/images/7-eddystone-beacon.png
--------------------------------------------------------------------------------
/part10-multicore/images/10-multicore-running.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part10-multicore/images/10-multicore-running.jpg
--------------------------------------------------------------------------------
/part3-helloworld/images/3-helloworld-cable.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part3-helloworld/images/3-helloworld-cable.jpg
--------------------------------------------------------------------------------
/part3-helloworld/images/3-helloworld-pinloc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part3-helloworld/images/3-helloworld-pinloc.png
--------------------------------------------------------------------------------
/part13-interrupts/images/13-interrupts-running.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part13-interrupts/images/13-interrupts-running.jpg
--------------------------------------------------------------------------------
/part14-spi-ethernet/images/14-spi-ethernet-arp.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part14-spi-ethernet/images/14-spi-ethernet-arp.jpg
--------------------------------------------------------------------------------
/part3-helloworld/images/3-helloworld-ctlpanel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part3-helloworld/images/3-helloworld-ctlpanel.png
--------------------------------------------------------------------------------
/part5-framebuffer/images/5-framebuffer-screen.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part5-framebuffer/images/5-framebuffer-screen.jpg
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/part14-spi-ethernet/images/14-spi-ethernet-photo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part14-spi-ethernet/images/14-spi-ethernet-photo.jpg
--------------------------------------------------------------------------------
/part3-helloworld/kernel.c:
--------------------------------------------------------------------------------
1 | #include "io.h"
2 |
3 | void main()
4 | {
5 | uart_init();
6 | uart_writeText("Hello world!\n");
7 | while (1);
8 | }
9 |
--------------------------------------------------------------------------------
/part6-breakout/images/6-breakout-thefinishedgame.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part6-breakout/images/6-breakout-thefinishedgame.jpg
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | remote_theme: isometimes/cayman-ga4
2 | google_analytics: G-YL02TRV3C8
3 | url: "https://www.rpi4os.com"
4 | plugins:
5 | - jekyll-sitemap
6 |
--------------------------------------------------------------------------------
/part15-tcpip-webserver/kernel/kernel.h:
--------------------------------------------------------------------------------
1 | void enc28j60PacketSend(unsigned short buflen, void *buffer);
2 | void *memcpy(void *dest, const void *src, unsigned short len);
3 |
--------------------------------------------------------------------------------
/part15-tcpip-webserver/images/15-tcpip-webserver-browser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part15-tcpip-webserver/images/15-tcpip-webserver-browser.png
--------------------------------------------------------------------------------
/part15-tcpip-webserver/images/15-tcpip-webserver-pinging.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part15-tcpip-webserver/images/15-tcpip-webserver-pinging.jpg
--------------------------------------------------------------------------------
/part4-miniuart/kernel.c:
--------------------------------------------------------------------------------
1 | #include "io.h"
2 |
3 | void main()
4 | {
5 | uart_init();
6 | uart_writeText("Hello world!\n");
7 |
8 | while (1) uart_update();
9 | }
10 |
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/xcuserdata/Akshata.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/part4-miniuart/io.h:
--------------------------------------------------------------------------------
1 | void uart_init();
2 | void uart_writeText(char *buffer);
3 | void uart_loadOutputFifo();
4 | unsigned char uart_readByte();
5 | unsigned int uart_isReadByteReady();
6 | void uart_writeByteBlocking(unsigned char ch);
7 | void uart_update();
8 |
--------------------------------------------------------------------------------
/part14-spi-ethernet/include/spi.h:
--------------------------------------------------------------------------------
1 | void spi_init();
2 | void spi_send_recv(unsigned char *sbuffer, unsigned char *rbuffer, unsigned int size);
3 | void spi_send(unsigned char *data, unsigned int size);
4 | void spi_recv(unsigned char *data, unsigned int size);
5 | void spi_chip_select(unsigned char chip_select);
6 |
--------------------------------------------------------------------------------
/part13-interrupts/kernel/utils.S:
--------------------------------------------------------------------------------
1 | .globl irq_init_vectors
2 | irq_init_vectors:
3 | adr x0, vectors
4 | msr vbar_el1, x0
5 | ret
6 |
7 | .globl irq_enable
8 | irq_enable:
9 | msr daifclr, #2
10 | ret
11 |
12 | .globl irq_disable
13 | irq_disable:
14 | msr daifset, #2
15 | ret
16 |
--------------------------------------------------------------------------------
/part14-spi-ethernet/kernel/utils.S:
--------------------------------------------------------------------------------
1 | .globl irq_init_vectors
2 | irq_init_vectors:
3 | adr x0, vectors
4 | msr vbar_el1, x0
5 | ret
6 |
7 | .globl irq_enable
8 | irq_enable:
9 | msr daifclr, #2
10 | ret
11 |
12 | .globl irq_disable
13 | irq_disable:
14 | msr daifset, #2
15 | ret
16 |
--------------------------------------------------------------------------------
/part15-tcpip-webserver/include/spi.h:
--------------------------------------------------------------------------------
1 | void spi_init();
2 | void spi_send_recv(unsigned char *sbuffer, unsigned char *rbuffer, unsigned int size);
3 | void spi_send(unsigned char *data, unsigned int size);
4 | void spi_recv(unsigned char *data, unsigned int size);
5 | void spi_chip_select(unsigned char chip_select);
6 |
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/project.xcworkspace/xcuserdata/agb.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/project.xcworkspace/xcuserdata/agb.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/project.xcworkspace/xcuserdata/Akshata.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patterns/rpi4-osdev/master/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/project.xcworkspace/xcuserdata/Akshata.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/part12-wgt/samples/wgt01.c:
--------------------------------------------------------------------------------
1 | #include "include/wgt.h"
2 |
3 | // ######## WGT EXAMPLES ########
4 |
5 | void wgt01()
6 | {
7 | vga256 (); /* Initializes WGT system */
8 | wsetcolor (vgapal[15]);
9 | wline (0, 0, 319, 199); /* Draw a line */
10 | }
11 |
12 | void main()
13 | {
14 | wgt01();
15 | while (1);
16 | }
17 |
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/part10-multicore/multicore.h:
--------------------------------------------------------------------------------
1 | extern unsigned int spin_cpu0;
2 | extern unsigned int spin_cpu1;
3 | extern unsigned int spin_cpu2;
4 | extern unsigned int spin_cpu3;
5 |
6 | void start_core1(void (*func)(void));
7 | void start_core2(void (*func)(void));
8 | void start_core3(void (*func)(void));
9 | void clear_core1(void);
10 | void clear_core2(void);
11 | void clear_core3(void);
12 |
--------------------------------------------------------------------------------
/part12-wgt/include/multicore.h:
--------------------------------------------------------------------------------
1 | extern unsigned int spin_cpu0;
2 | extern unsigned int spin_cpu1;
3 | extern unsigned int spin_cpu2;
4 | extern unsigned int spin_cpu3;
5 |
6 | void start_core1(void (*func)(void));
7 | void start_core2(void (*func)(void));
8 | void start_core3(void (*func)(void));
9 | void clear_core1(void);
10 | void clear_core2(void);
11 | void clear_core3(void);
12 |
--------------------------------------------------------------------------------
/part11-breakout-smp/include/multicore.h:
--------------------------------------------------------------------------------
1 | extern unsigned int spin_cpu0;
2 | extern unsigned int spin_cpu1;
3 | extern unsigned int spin_cpu2;
4 | extern unsigned int spin_cpu3;
5 |
6 | void start_core1(void (*func)(void));
7 | void start_core2(void (*func)(void));
8 | void start_core3(void (*func)(void));
9 | void clear_core1(void);
10 | void clear_core2(void);
11 | void clear_core3(void);
12 |
--------------------------------------------------------------------------------
/part13-interrupts/include/multicore.h:
--------------------------------------------------------------------------------
1 | extern unsigned int spin_cpu0;
2 | extern unsigned int spin_cpu1;
3 | extern unsigned int spin_cpu2;
4 | extern unsigned int spin_cpu3;
5 |
6 | void start_core1(void (*func)(void));
7 | void start_core2(void (*func)(void));
8 | void start_core3(void (*func)(void));
9 | void clear_core1(void);
10 | void clear_core2(void);
11 | void clear_core3(void);
12 |
--------------------------------------------------------------------------------
/part14-spi-ethernet/include/multicore.h:
--------------------------------------------------------------------------------
1 | extern unsigned int spin_cpu0;
2 | extern unsigned int spin_cpu1;
3 | extern unsigned int spin_cpu2;
4 | extern unsigned int spin_cpu3;
5 |
6 | void start_core1(void (*func)(void));
7 | void start_core2(void (*func)(void));
8 | void start_core3(void (*func)(void));
9 | void clear_core1(void);
10 | void clear_core2(void);
11 | void clear_core3(void);
12 |
--------------------------------------------------------------------------------
/part15-tcpip-webserver/include/multicore.h:
--------------------------------------------------------------------------------
1 | extern unsigned int spin_cpu0;
2 | extern unsigned int spin_cpu1;
3 | extern unsigned int spin_cpu2;
4 | extern unsigned int spin_cpu3;
5 |
6 | void start_core1(void (*func)(void));
7 | void start_core2(void (*func)(void));
8 | void start_core3(void (*func)(void));
9 | void clear_core1(void);
10 | void clear_core2(void);
11 | void clear_core3(void);
12 |
--------------------------------------------------------------------------------
/part5-framebuffer/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 |
3 | void uart_init();
4 | void uart_writeText(char *buffer);
5 | void uart_loadOutputFifo();
6 | unsigned char uart_readByte();
7 | unsigned int uart_isReadByteReady();
8 | void uart_writeByteBlocking(unsigned char ch);
9 | void uart_update();
10 | void mmio_write(long reg, unsigned int val);
11 | unsigned int mmio_read(long reg);
12 |
--------------------------------------------------------------------------------
/part12-wgt/wgt/wpixel.c:
--------------------------------------------------------------------------------
1 | #include "../include/wgt.h"
2 |
3 | unsigned int wgetpixel (short x, short y)
4 | {
5 | return abuf[y * WGT_SYS.xres + x];
6 | }
7 |
8 | void wputpixel (short x, short y)
9 | {
10 | if ((y <= by) & (x <= bx) & (y >= ty) & (x >= tx))
11 | abuf[y * WGT_SYS.xres + x] = currentcolor;
12 | }
13 |
14 | void wfastputpixel (short x, short y)
15 | {
16 | abuf[y * WGT_SYS.xres + x] = currentcolor;
17 | }
18 |
--------------------------------------------------------------------------------
/part5-framebuffer/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr);
4 | void drawString(int x, int y, char *s, unsigned char attr);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 |
--------------------------------------------------------------------------------
/part6-breakout/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 | #define SAFE_ADDRESS 0x00210000 // Somewhere safe to store a lot of data
3 |
4 | void uart_init();
5 | void uart_writeText(char *buffer);
6 | void uart_loadOutputFifo();
7 | unsigned char uart_readByte();
8 | unsigned int uart_isReadByteReady();
9 | void uart_writeByteBlocking(unsigned char ch);
10 | void uart_update();
11 | void mmio_write(long reg, unsigned int val);
12 | unsigned int mmio_read(long reg);
13 |
--------------------------------------------------------------------------------
/part12-wgt/wgt/wmiscb.c:
--------------------------------------------------------------------------------
1 | #include "../include/wgt.h"
2 | #include "../include/mem.h"
3 |
4 | extern short bx,by,tx,ty;
5 |
6 | void wfreeblock (block ptr)
7 | {
8 | free (ptr);
9 | }
10 |
11 | short wgetblockwidth (block ptr)
12 | {
13 | return *(short *)ptr; /* Width is first 2 bytes of data */
14 | }
15 |
16 | short wgetblockheight (block ptr)
17 | {
18 | ptr ++; /* Skip width */
19 | return *(short *)ptr; /* Height is second 2 bytes of data */
20 | }
21 |
--------------------------------------------------------------------------------
/part5-framebuffer/kernel.c:
--------------------------------------------------------------------------------
1 | #include "io.h"
2 | #include "fb.h"
3 |
4 | void main()
5 | {
6 | uart_init();
7 | fb_init();
8 |
9 | drawRect(150,150,400,400,0x03,0);
10 | drawRect(300,300,350,350,0x2e,1);
11 |
12 | drawCircle(960,540,250,0x0e,0);
13 | drawCircle(960,540,50,0x13,1);
14 |
15 | drawPixel(250,250,0x0e);
16 |
17 | drawChar('O',500,500,0x05);
18 | drawString(100,100,"Hello world!",0x0f);
19 |
20 | drawLine(100,500,350,700,0x0c);
21 |
22 | while (1);
23 | }
24 |
--------------------------------------------------------------------------------
/part7-bluetooth/bt.h:
--------------------------------------------------------------------------------
1 | void bt_reset();
2 | void bt_loadfirmware();
3 | void bt_setbaud();
4 | void bt_setbdaddr();
5 | void bt_getbdaddr(unsigned char *bdaddr);
6 | void bt_init();
7 | unsigned int bt_isReadByteReady();
8 | unsigned char bt_readByte();
9 | unsigned char bt_waitReadByte();
10 | void setLEeventmask(unsigned char mask);
11 | void startActiveScanning();
12 | void stopScanning();
13 | void startActiveAdvertising();
14 | void connect(unsigned char *addr);
15 | void sendACLsubscribe(unsigned int handle);
16 |
--------------------------------------------------------------------------------
/part12-wgt/include/bt.h:
--------------------------------------------------------------------------------
1 | void bt_reset();
2 | void bt_loadfirmware();
3 | void bt_setbaud();
4 | void bt_setbdaddr();
5 | void bt_getbdaddr(unsigned char *bdaddr);
6 | void bt_init();
7 | unsigned int bt_isReadByteReady();
8 | unsigned char bt_readByte();
9 | unsigned char bt_waitReadByte();
10 | void setLEeventmask(unsigned char mask);
11 | void startActiveScanning();
12 | void stopScanning();
13 | void startActiveAdvertising();
14 | void connect(unsigned char *addr);
15 | void sendACLsubscribe(unsigned int handle);
16 |
--------------------------------------------------------------------------------
/part7-bluetooth/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 |
3 | void uart_init();
4 | void uart_writeText(char *buffer);
5 | void uart_loadOutputFifo();
6 | unsigned char uart_readByte();
7 | unsigned int uart_isReadByteReady();
8 | void uart_writeByteBlockingActual(unsigned char ch);
9 | void uart_update();
10 | void mmio_write(long reg, unsigned int val);
11 | unsigned int mmio_read(long reg);
12 | void gpio_useAsAlt3(unsigned int pin_number);
13 | void uart_hex(unsigned int d);
14 | void uart_byte(unsigned char b);
15 |
--------------------------------------------------------------------------------
/part8-breakout-ble/bt.h:
--------------------------------------------------------------------------------
1 | void bt_reset();
2 | void bt_loadfirmware();
3 | void bt_setbaud();
4 | void bt_setbdaddr();
5 | void bt_getbdaddr(unsigned char *bdaddr);
6 | void bt_init();
7 | unsigned int bt_isReadByteReady();
8 | unsigned char bt_readByte();
9 | unsigned char bt_waitReadByte();
10 | void setLEeventmask(unsigned char mask);
11 | void startActiveScanning();
12 | void stopScanning();
13 | void startActiveAdvertising();
14 | void connect(unsigned char *addr);
15 | void sendACLsubscribe(unsigned int handle);
16 |
--------------------------------------------------------------------------------
/part11-breakout-smp/include/bt.h:
--------------------------------------------------------------------------------
1 | void bt_reset();
2 | void bt_loadfirmware();
3 | void bt_setbaud();
4 | void bt_setbdaddr();
5 | void bt_getbdaddr(unsigned char *bdaddr);
6 | void bt_init();
7 | unsigned int bt_isReadByteReady();
8 | unsigned char bt_readByte();
9 | unsigned char bt_waitReadByte();
10 | void setLEeventmask(unsigned char mask);
11 | void startActiveScanning();
12 | void stopScanning();
13 | void startActiveAdvertising();
14 | void connect(unsigned char *addr);
15 | void sendACLsubscribe(unsigned int handle);
16 |
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/xcuserdata/Akshata.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | BLEPeripheralApp.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/part12-wgt/include/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 |
3 | void uart_init();
4 | void uart_writeText(char *buffer);
5 | void uart_loadOutputFifo();
6 | unsigned char uart_readByte();
7 | unsigned int uart_isReadByteReady();
8 | void uart_writeByteBlockingActual(unsigned char ch);
9 | void uart_update();
10 | void mmio_write(long reg, unsigned int val);
11 | unsigned int mmio_read(long reg);
12 | void gpio_useAsAlt0(unsigned int pin_number);
13 | void gpio_useAsAlt3(unsigned int pin_number);
14 | void uart_hex(unsigned int d);
15 | void uart_byte(unsigned char b);
16 |
--------------------------------------------------------------------------------
/part11-breakout-smp/breakout_snd.c:
--------------------------------------------------------------------------------
1 | #include "include/multicore.h"
2 | #include "include/audio.h"
3 |
4 | void snd_core(void)
5 | {
6 | clear_core2();
7 |
8 | // Initialise the audio
9 | audio_init();
10 |
11 | // Write data out to FIFO and loop infinitely
12 |
13 | extern unsigned char _binary_bin_audio_bin_start[];
14 | extern unsigned char _binary_bin_audio_bin_size[];
15 |
16 | unsigned int size = (long)&_binary_bin_audio_bin_size;
17 | unsigned char *data = &(_binary_bin_audio_bin_start[0]);
18 |
19 | while (1) audio_play_cpu(data, size);
20 | }
21 |
--------------------------------------------------------------------------------
/part8-breakout-ble/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 | #define SAFE_ADDRESS 0x00210000 // Somewhere safe to store a lot of data
3 |
4 | void uart_init();
5 | void uart_writeText(char *buffer);
6 | void uart_loadOutputFifo();
7 | unsigned char uart_readByte();
8 | unsigned int uart_isReadByteReady();
9 | void uart_writeByteBlockingActual(unsigned char ch);
10 | void uart_update();
11 | void mmio_write(long reg, unsigned int val);
12 | unsigned int mmio_read(long reg);
13 | void gpio_useAsAlt3(unsigned int pin_number);
14 | void uart_hex(unsigned int d);
15 | void uart_byte(unsigned char b);
16 |
--------------------------------------------------------------------------------
/part12-wgt/wgt/wclip.c:
--------------------------------------------------------------------------------
1 | #include "../include/wgt.h"
2 |
3 | void wclip (short x, short y, short x2, short y2)
4 | {
5 | tx = x; /* Upper x limit */
6 | ty = y; /* Upper y limit */
7 | bx = x2; /* Lower x limit */
8 | by = y2; /* Lower y limit */
9 | /* Stay within screen bounds, no negatives */
10 | if (tx < 0) tx = 0;
11 | if (ty < 0) ty = 0;
12 | if (bx >= WGT_SYS.xres) bx = WGT_SYS.xres - 1;
13 | if (by >= WGT_SYS.yres) by = WGT_SYS.yres - 1;
14 | }
15 |
--------------------------------------------------------------------------------
/part6-breakout/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr, int zoom);
4 | void drawString(int x, int y, char *s, unsigned char attr, int zoom);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 | void moveRect(int oldx, int oldy, int width, int height, int shiftx, int shifty, unsigned char attr);
9 | void wait_msec(unsigned int n);
10 |
--------------------------------------------------------------------------------
/part11-breakout-smp/include/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 | #define LEGACY_BASE 0x7E000000
3 |
4 | void uart_init();
5 | void uart_writeText(char *buffer);
6 | void uart_loadOutputFifo();
7 | unsigned char uart_readByte();
8 | unsigned int uart_isReadByteReady();
9 | void uart_writeByteBlockingActual(unsigned char ch);
10 | void uart_update();
11 | void mmio_write(long reg, unsigned int val);
12 | unsigned int mmio_read(long reg);
13 | void gpio_useAsAlt0(unsigned int pin_number);
14 | void gpio_useAsAlt3(unsigned int pin_number);
15 | void uart_hex(unsigned int d);
16 | void uart_byte(unsigned char b);
17 |
--------------------------------------------------------------------------------
/part2-building/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part4-miniuart/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part6-breakout/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part7-bluetooth/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part9-sound/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part1-bootstrapping/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part3-helloworld/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part5-framebuffer/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part8-breakout-ble/link.ld:
--------------------------------------------------------------------------------
1 | SECTIONS
2 | {
3 | . = 0x80000; /* Kernel load address for AArch64 */
4 | .text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
5 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
6 | PROVIDE(_data = .);
7 | .data : { *(.data .data.* .gnu.linkonce.d*) }
8 | .bss (NOLOAD) : {
9 | . = ALIGN(16);
10 | __bss_start = .;
11 | *(.bss .bss.*)
12 | *(COMMON)
13 | __bss_end = .;
14 | }
15 | _end = .;
16 |
17 | /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
18 | }
19 | __bss_size = (__bss_end - __bss_start)>>3;
20 |
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/xcuserdata/agb.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | BLEPeripheralApp.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 | rpi4-osdev-ioscontrol.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 0
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/part13-interrupts/kernel/irq.c:
--------------------------------------------------------------------------------
1 | #include "kernel.h"
2 |
3 | void enable_interrupt_controller() {
4 | REGS_IRQ->irq0_enable_0 = SYS_TIMER_IRQ_1 | SYS_TIMER_IRQ_3;
5 | }
6 |
7 | void disable_interrupt_controller() {
8 | REGS_IRQ->irq0_enable_0 = 0;
9 | }
10 |
11 | void handle_irq() {
12 | unsigned int irq = REGS_IRQ->irq0_pending_0;
13 |
14 | while(irq) {
15 | if (irq & SYS_TIMER_IRQ_1) {
16 | irq &= ~SYS_TIMER_IRQ_1;
17 |
18 | handle_timer_1();
19 | }
20 |
21 | if (irq & SYS_TIMER_IRQ_3) {
22 | irq &= ~SYS_TIMER_IRQ_3;
23 |
24 | handle_timer_3();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/part14-spi-ethernet/kernel/irq.c:
--------------------------------------------------------------------------------
1 | #include "kernel.h"
2 |
3 | void enable_interrupt_controller() {
4 | REGS_IRQ->irq0_enable_0 = SYS_TIMER_IRQ_1 | SYS_TIMER_IRQ_3;
5 | }
6 |
7 | void disable_interrupt_controller() {
8 | REGS_IRQ->irq0_enable_0 = 0;
9 | }
10 |
11 | void handle_irq() {
12 | unsigned int irq = REGS_IRQ->irq0_pending_0;
13 |
14 | while(irq) {
15 | if (irq & SYS_TIMER_IRQ_1) {
16 | irq &= ~SYS_TIMER_IRQ_1;
17 |
18 | handle_timer_1();
19 | }
20 |
21 | if (irq & SYS_TIMER_IRQ_3) {
22 | irq &= ~SYS_TIMER_IRQ_3;
23 |
24 | handle_timer_3();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/part9-sound/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 | #define LEGACY_BASE 0x7E000000
3 | #define SAFE_ADDRESS 0x00400000 // Somewhere safe to store a lot of data
4 |
5 | void uart_init();
6 | void uart_writeText(char *buffer);
7 | void uart_loadOutputFifo();
8 | unsigned char uart_readByte();
9 | unsigned int uart_isReadByteReady();
10 | void uart_writeByteBlockingActual(unsigned char ch);
11 | void uart_update();
12 | void mmio_write(long reg, unsigned int val);
13 | unsigned int mmio_read(long reg);
14 | void gpio_useAsAlt0(unsigned int pin_number);
15 | void gpio_useAsAlt3(unsigned int pin_number);
16 | void uart_hex(unsigned int d);
17 | void uart_byte(unsigned char b);
18 |
--------------------------------------------------------------------------------
/part10-multicore/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 | #define LEGACY_BASE 0x7E000000
3 | #define SAFE_ADDRESS 0x00400000 // Somewhere safe to store a lot of data
4 |
5 | void uart_init();
6 | void uart_writeText(char *buffer);
7 | void uart_loadOutputFifo();
8 | unsigned char uart_readByte();
9 | unsigned int uart_isReadByteReady();
10 | void uart_writeByteBlockingActual(unsigned char ch);
11 | void uart_update();
12 | void mmio_write(long reg, unsigned int val);
13 | unsigned int mmio_read(long reg);
14 | void gpio_useAsAlt0(unsigned int pin_number);
15 | void gpio_useAsAlt3(unsigned int pin_number);
16 | void uart_hex(unsigned int d);
17 | void uart_byte(unsigned char b);
18 |
--------------------------------------------------------------------------------
/part13-interrupts/include/io.h:
--------------------------------------------------------------------------------
1 | #define PERIPHERAL_BASE 0xFE000000
2 | #define LEGACY_BASE 0x7E000000
3 | #define SAFE_ADDRESS 0x00400000 // Somewhere safe to store a lot of data
4 |
5 | void uart_init();
6 | void uart_writeText(char *buffer);
7 | void uart_loadOutputFifo();
8 | unsigned char uart_readByte();
9 | unsigned int uart_isReadByteReady();
10 | void uart_writeByteBlockingActual(unsigned char ch);
11 | void uart_update();
12 | void mmio_write(long reg, unsigned int val);
13 | unsigned int mmio_read(long reg);
14 | void gpio_useAsAlt0(unsigned int pin_number);
15 | void gpio_useAsAlt3(unsigned int pin_number);
16 | void uart_hex(unsigned int d);
17 | void uart_byte(unsigned char b);
18 |
--------------------------------------------------------------------------------
/part2-building/Makefile:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | LLVMPATH = /opt/homebrew/opt/llvm/bin
4 | CLANGFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -mcpu=cortex-a72+nosimd
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part3-helloworld/Makefile:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | LLVMPATH = /opt/homebrew/opt/llvm/bin
4 | CLANGFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -mcpu=cortex-a72+nosimd
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part4-miniuart/Makefile:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | LLVMPATH = /opt/homebrew/opt/llvm/bin
4 | CLANGFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -mcpu=cortex-a72+nosimd
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part5-framebuffer/Makefile:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | LLVMPATH = /opt/homebrew/opt/llvm/bin
4 | CLANGFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -mcpu=cortex-a72+nosimd
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part6-breakout/Makefile:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | LLVMPATH = /opt/homebrew/opt/llvm/bin
4 | CLANGFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -mcpu=cortex-a72+nosimd
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part2-building/Makefile.gcc:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | GCCFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles
4 | GCCPATH = ../../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(GCCPATH)/aarch64-none-elf-ld -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(GCCPATH)/aarch64-none-elf-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part3-helloworld/Makefile.gcc:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | GCCFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles
4 | GCCPATH = ../../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(GCCPATH)/aarch64-none-elf-ld -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(GCCPATH)/aarch64-none-elf-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part4-miniuart/Makefile.gcc:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | GCCFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles
4 | GCCPATH = ../../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(GCCPATH)/aarch64-none-elf-ld -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(GCCPATH)/aarch64-none-elf-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part5-framebuffer/Makefile.gcc:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | GCCFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles
4 | GCCPATH = ../../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(GCCPATH)/aarch64-none-elf-ld -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(GCCPATH)/aarch64-none-elf-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part6-breakout/Makefile.gcc:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c)
2 | OFILES = $(CFILES:.c=.o)
3 | GCCFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles
4 | GCCPATH = ../../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin
5 |
6 | all: clean kernel8.img
7 |
8 | boot.o: boot.S
9 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c boot.S -o boot.o
10 |
11 | %.o: %.c
12 | $(GCCPATH)/aarch64-none-elf-gcc $(GCCFLAGS) -c $< -o $@
13 |
14 | kernel8.img: boot.o $(OFILES)
15 | $(GCCPATH)/aarch64-none-elf-ld -nostdlib boot.o $(OFILES) -T link.ld -o kernel8.elf
16 | $(GCCPATH)/aarch64-none-elf-objcopy -O binary kernel8.elf kernel8.img
17 |
18 | clean:
19 | /bin/rm kernel8.elf *.o *.img > /dev/null 2> /dev/null || true
20 |
--------------------------------------------------------------------------------
/part9-sound/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr, int zoom);
4 | void drawString(int x, int y, char *s, unsigned char attr, int zoom);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 | void moveRect(int oldx, int oldy, int width, int height, int shiftx, int shifty, unsigned char attr);
9 | void wait_msec(unsigned int n);
10 | void debugstr(char *str);
11 | void debugcrlf(void);
12 | void debugch(unsigned char b);
13 | void debughex(unsigned int d);
14 |
--------------------------------------------------------------------------------
/part10-multicore/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr, int zoom);
4 | void drawString(int x, int y, char *s, unsigned char attr, int zoom);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 | void moveRect(int oldx, int oldy, int width, int height, int shiftx, int shifty, unsigned char attr);
9 | void wait_msec(unsigned int n);
10 | void debugstr(char *str);
11 | void debugcrlf(void);
12 | void debugch(unsigned char b);
13 | void debughex(unsigned int d);
14 |
--------------------------------------------------------------------------------
/part7-bluetooth/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr, int zoom);
4 | void drawString(int x, int y, char *s, unsigned char attr, int zoom);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 | void moveRect(int oldx, int oldy, int width, int height, int shiftx, int shifty, unsigned char attr);
9 | void wait_msec(unsigned int n);
10 | void debugstr(char *str);
11 | void debugcrlf(void);
12 | void debugch(unsigned char b);
13 | void debughex(unsigned int d);
14 |
--------------------------------------------------------------------------------
/part8-breakout-ble/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr, int zoom);
4 | void drawString(int x, int y, char *s, unsigned char attr, int zoom);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 | void moveRectAbs(int oldx, int oldy, int width, int height, int newx, int newy, unsigned char attr);
9 | void wait_msec(unsigned int n);
10 | void debugstr(char *str);
11 | void debugcrlf(void);
12 | void debugch(unsigned char b);
13 | void debughex(unsigned int d);
14 |
--------------------------------------------------------------------------------
/part11-breakout-smp/include/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr, int zoom);
4 | void drawString(int x, int y, char *s, unsigned char attr, int zoom);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 | void moveRectAbs(int oldx, int oldy, int width, int height, int newx, int newy, unsigned char attr);
9 | void wait_msec(unsigned int n);
10 | void debugstr(char *str);
11 | void debugcrlf(void);
12 | void debugch(unsigned char b);
13 | void debughex(unsigned int d);
14 |
--------------------------------------------------------------------------------
/part13-interrupts/include/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr, int zoom);
4 | void drawString(int x, int y, char *s, unsigned char attr, int zoom);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 | void moveRect(int oldx, int oldy, int width, int height, int shiftx, int shifty, unsigned char attr);
9 | void wait_msec(unsigned int n);
10 | void debugstr(char *str);
11 | void debugcrlf(void);
12 | void debugch(unsigned char b);
13 | void debughex(unsigned int d);
14 |
--------------------------------------------------------------------------------
/part14-spi-ethernet/include/fb.h:
--------------------------------------------------------------------------------
1 | void fb_init();
2 | void drawPixel(int x, int y, unsigned char attr);
3 | void drawChar(unsigned char ch, int x, int y, unsigned char attr, int zoom);
4 | void drawString(int x, int y, char *s, unsigned char attr, int zoom);
5 | void drawRect(int x1, int y1, int x2, int y2, unsigned char attr, int fill);
6 | void drawCircle(int x0, int y0, int radius, unsigned char attr, int fill);
7 | void drawLine(int x1, int y1, int x2, int y2, unsigned char attr);
8 | void moveRect(int oldx, int oldy, int width, int height, int shiftx, int shifty, unsigned char attr);
9 | void wait_msec(unsigned int n);
10 | void debugstr(char *str);
11 | void debugcrlf(void);
12 | void debugch(unsigned char b);
13 | void debughex(unsigned int d);
14 |
--------------------------------------------------------------------------------
/part12-wgt/controller-ios/rpi4-osdev-ioscontrol.xcodeproj/project.xcworkspace/xcuserdata/agb.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildLocationStyle
6 | UseAppPreferences
7 | CustomBuildLocationType
8 | RelativeToDerivedData
9 | DerivedDataLocationStyle
10 | Default
11 | IssueFilterStyle
12 | ShowActiveSchemeOnly
13 | LiveSourceIssuesEnabled
14 |
15 | ShowSharedSchemesAutomaticallyEnabled
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/part13-interrupts/Makefile:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c lib/*.c kernel/*.c)
2 | SFILES = $(wildcard boot/*.S lib/*.S kernel/*.S)
3 | OFILES = $(CFILES:.c=.o) $(SFILES:.S=.o)
4 | LLVMPATH = /opt/homebrew/opt/llvm/bin
5 | CLANGFLAGS = -Wall -O2 -ffreestanding -nostdlib -mcpu=cortex-a72+nosimd
6 |
7 | all: clean kernel8.img
8 |
9 | %.o: %.c
10 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
11 |
12 | %.o: %.S
13 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
14 |
15 | kernel8.img: $(OFILES)
16 | $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib $(OFILES) -T boot/link.ld -o kernel8.elf
17 | $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img
18 |
19 | clean:
20 | /bin/rm kernel8.elf */*.o *.img > /dev/null 2> /dev/null || true
21 |
--------------------------------------------------------------------------------
/part14-spi-ethernet/Makefile:
--------------------------------------------------------------------------------
1 | CFILES = $(wildcard *.c lib/*.c kernel/*.c net/*.c)
2 | SFILES = $(wildcard boot/*.S lib/*.S kernel/*.S)
3 | OFILES = $(CFILES:.c=.o) $(SFILES:.S=.o)
4 | LLVMPATH = /opt/homebrew/opt/llvm/bin
5 | CLANGFLAGS = -Wall -O0 -ffreestanding -nostdlib -mcpu=cortex-a72+nosimd
6 |
7 | all: clean kernel8.img
8 |
9 | %.o: %.c
10 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
11 |
12 | %.o: %.S
13 | $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@
14 |
15 | kernel8.img: $(OFILES)
16 | $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib $(OFILES) -T boot/link.ld -o kernel8.elf
17 | $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img
18 |
19 | clean:
20 | /bin/rm kernel8.elf */*.o *.img > /dev/null 2> /dev/null || true
21 |
--------------------------------------------------------------------------------
/part14-spi-ethernet/net/encspi.c:
--------------------------------------------------------------------------------
1 | #include "../include/spi.h"
2 |
3 | void ENC_SPI_Select(unsigned char truefalse) {
4 | spi_chip_select(!truefalse); // If it's true, select 0 (the ENC), if false, select 1 (i.e. deselect the ENC)
5 | }
6 |
7 | void ENC_SPI_SendBuf(unsigned char *master2slave, unsigned char *slave2master, unsigned short bufferSize) {
8 | spi_chip_select(0);
9 | spi_send_recv(master2slave, slave2master, bufferSize);
10 | spi_chip_select(1); // De-select the ENC
11 | }
12 |
13 | void ENC_SPI_Send(unsigned char command) {
14 | spi_chip_select(0);
15 | spi_send(&command, 1);
16 | spi_chip_select(1); // De-select the ENC
17 | }
18 |
19 | void ENC_SPI_SendWithoutSelection(unsigned char command) {
20 | spi_send(&command, 1);
21 | }
22 |
--------------------------------------------------------------------------------
/part15-tcpip-webserver/net/encspi.c:
--------------------------------------------------------------------------------
1 | #include "../include/spi.h"
2 |
3 | void ENC_SPI_Select(unsigned char truefalse) {
4 | spi_chip_select(!truefalse); // If it's true, select 0 (the ENC), if false, select 1 (i.e. deselect the ENC)
5 | }
6 |
7 | void ENC_SPI_SendBuf(unsigned char *master2slave, unsigned char *slave2master, unsigned short bufferSize) {
8 | spi_chip_select(0);
9 | spi_send_recv(master2slave, slave2master, bufferSize);
10 | spi_chip_select(1); // De-select the ENC
11 | }
12 |
13 | void ENC_SPI_Send(unsigned char command) {
14 | spi_chip_select(0);
15 | spi_send(&command, 1);
16 | spi_chip_select(1); // De-select the ENC
17 | }
18 |
19 | void ENC_SPI_SendWithoutSelection(unsigned char command) {
20 | spi_send(&command, 1);
21 | }
22 |
--------------------------------------------------------------------------------
/part12-wgt/bin/wgt1.pal:
--------------------------------------------------------------------------------
1 | ??????<<<:::777555222000---***(((%%%### 8?6=5;392806.4-3+1*/(-',%*$("'!%#!
8?6<4:2806.3,1*/(-&*$("& $!
2 | ? <