Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A122062 lab0 #129

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

79 changes: 0 additions & 79 deletions README.org

This file was deleted.

72 changes: 0 additions & 72 deletions git-usage.org

This file was deleted.

Binary file removed images/clone_url.jpg
Binary file not shown.
Binary file removed images/create_fork.jpg
Binary file not shown.
Binary file removed images/fork_button.jpg
Binary file not shown.
Binary file removed images/forked_repo.jpg
Binary file not shown.
Binary file removed images/pr_base_selection.jpg
Binary file not shown.
Binary file removed images/pr_button.jpg
Binary file not shown.
Binary file removed images/pr_desc.jpg
Binary file not shown.
1 change: 1 addition & 0 deletions lab1/build/boot_s.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/boot_s.o: src/boot.S
Binary file added lab1/build/boot_s.o
Binary file not shown.
Binary file added lab1/build/kernel8.elf
Binary file not shown.
1 change: 1 addition & 0 deletions lab1/build/main_c.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/main_c.o: src/main.c include/uart1.h include/shell.h
Binary file added lab1/build/main_c.o
Binary file not shown.
2 changes: 2 additions & 0 deletions lab1/build/mbox_c.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/mbox_c.o: src/mbox.c include/bcm2837/rpi_mbox.h \
include/bcm2837/rpi_base.h include/mbox.h
Binary file added lab1/build/mbox_c.o
Binary file not shown.
2 changes: 2 additions & 0 deletions lab1/build/shell_c.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/shell_c.o: src/shell.c include/shell.h include/uart1.h \
include/mbox.h include/power.h
Binary file added lab1/build/shell_c.o
Binary file not shown.
2 changes: 2 additions & 0 deletions lab1/build/uart1_c.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/uart1_c.o: src/uart1.c include/bcm2837/rpi_gpio.h \
include/bcm2837/rpi_base.h include/bcm2837/rpi_uart1.h include/uart1.h
Binary file added lab1/build/uart1_c.o
Binary file not shown.
2 changes: 2 additions & 0 deletions lab1/debug.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
file build/kernel8.elf
target remote :1234
6 changes: 6 additions & 0 deletions lab1/include/bcm2837/rpi_base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _RPI_BASE_H_
#define _RPI_BASE_H_

#define PERIPHERAL_BASE 0x3F000000

#endif /*_RPI_BASE_H_ */
25 changes: 25 additions & 0 deletions lab1/include/bcm2837/rpi_gpio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef _RPI_GPIO_H_
#define _RPI_GPIO_H_

#include "bcm2837/rpi_base.h"

#define GPFSEL0 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200000))
#define GPFSEL1 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200004))
#define GPFSEL2 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200008))
#define GPFSEL3 ((volatile unsigned int*)(PERIPHERAL_BASE+0x0020000C))
#define GPFSEL4 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200010))
#define GPFSEL5 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200014))
#define GPSET0 ((volatile unsigned int*)(PERIPHERAL_BASE+0x0020001C))
#define GPSET1 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200020))
#define GPCLR0 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200028))
#define GPLEV0 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200034))
#define GPLEV1 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200038))
#define GPEDS0 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200040))
#define GPEDS1 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200044))
#define GPHEN0 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200064))
#define GPHEN1 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200068))
#define GPPUD ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200094))
#define GPPUDCLK0 ((volatile unsigned int*)(PERIPHERAL_BASE+0x00200098))
#define GPPUDCLK1 ((volatile unsigned int*)(PERIPHERAL_BASE+0x0020009C))

#endif /*_RPI_GPIO_H_*/
17 changes: 17 additions & 0 deletions lab1/include/bcm2837/rpi_mbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef _RPI_MBOX_H_
#define _RPI_MBOX_H_

#include "bcm2837/rpi_base.h"

#define MBOX_BASE (PERIPHERAL_BASE+0x0000B880)

// The register access to a mailbox
// https://jsandler18.github.io/extra/mailbox.html
#define MBOX_READ ((volatile unsigned int*)(MBOX_BASE+0x00))
#define MBOX_POLL ((volatile unsigned int*)(MBOX_BASE+0x10))
#define MBOX_SENDER ((volatile unsigned int*)(MBOX_BASE+0x14))
#define MBOX_STATUS ((volatile unsigned int*)(MBOX_BASE+0x18))
#define MBOX_CONFIG ((volatile unsigned int*)(MBOX_BASE+0x1C))
#define MBOX_WRITE ((volatile unsigned int*)(MBOX_BASE+0x20))

#endif /*_RPI_MBOX_H_ */
19 changes: 19 additions & 0 deletions lab1/include/bcm2837/rpi_uart1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _RPI_UART1_H_
#define _RPI_UART1_H_

#include "bcm2837/rpi_base.h"

#define AUX_ENABLES ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215004))
#define AUX_MU_IO_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215040))
#define AUX_MU_IER_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215044))
#define AUX_MU_IIR_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215048))
#define AUX_MU_LCR_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x0021504C))
#define AUX_MU_MCR_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215050))
#define AUX_MU_LSR_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215054))
#define AUX_MU_MSR_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215058))
#define AUX_MU_SCRATCH ((volatile unsigned int*)(PERIPHERAL_BASE+0x0021505C))
#define AUX_MU_CNTL_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215060))
#define AUX_MU_STAT_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215064))
#define AUX_MU_BAUD_REG ((volatile unsigned int*)(PERIPHERAL_BASE+0x00215068))

#endif /*_RPI_UART1_H_ */
63 changes: 63 additions & 0 deletions lab1/include/mbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef _MBOX_H_
#define _MBOX_H_

extern volatile unsigned int pt[64];

// Mailbox Register MMIO
// https://jsandler18.github.io/extra/mailbox.html
// include/bcm2837/rpi_mbox.h

// Mailbox Channels
// https://github.com/raspberrypi/firmware/wiki/Mailboxes
typedef enum {
MBOX_POWER_MANAGEMENT = 0,
MBOX_FRAMEBUFFER,
MBOX_VIRTUAL_UART,
MBOX_VCHIQ,
MBOX_LEDS,
MBOX_BUTTONS,
MBOX_TOUCHSCREEN,
MBOX_UNUSED,
MBOX_TAGS_ARM_TO_VC,
MBOX_TAGS_VC_TO_ARM,
} mbox_channel_type;

// Status Code from Broadcom Videocode Driver
// brcm_usrlib/dag/vmcsx/vcinclude/bcm2708_chip/arm_control.h
enum mbox_status_reg_bits {
BCM_ARM_VC_MS_FULL = 0x80000000,
BCM_ARM_VC_MS_EMPTY = 0x40000000,
BCM_ARM_VC_MS_LEVEL = 0x400000FF,
};

enum mbox_buffer_status_code {
MBOX_REQUEST_PROCESS = 0x00000000,
MBOX_REQUEST_SUCCEED = 0x80000000,
MBOX_REQUEST_FAILED = 0x80000001,
};

// Tag
// https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
// Included partition only
typedef enum {
/* Videocore */
MBOX_TAG_GET_FIRMWARE_VERSION = 0x1,

/* Hardware */
MBOX_TAG_GET_BOARD_MODEL = 0x10001,
MBOX_TAG_GET_BOARD_REVISION,
MBOX_TAG_GET_BOARD_MAC_ADDRESS,
MBOX_TAG_GET_BOARD_SERIAL,
MBOX_TAG_GET_ARM_MEMORY,
MBOX_TAG_GET_VC_MEMORY,
MBOX_TAG_GET_CLOCKS,

} mbox_tag_type;


#define MBOX_TAG_REQUEST_CODE 0x00000000
#define MBOX_TAG_LAST_BYTE 0x00000000

int mbox_call(mbox_channel_type, unsigned int);

#endif /*_MBOX_H_*/
8 changes: 8 additions & 0 deletions lab1/include/power.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _POWER_H_
#define _POWER_H_

#define PM_PASSWORD 0x5a000000
#define PM_RSTC 0x3F10001c
#define PM_WDOG 0x3F100024

#endif /*_POWER_H_*/
25 changes: 25 additions & 0 deletions lab1/include/shell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef _SHELL_H_
#define _SHELL_H_

#define CLI_MAX_CMD 4
#define CMD_MAX_LEN 32
#define MSG_MAX_LEN 128

typedef struct CLI_CMDS
{
char command[CMD_MAX_LEN];
char help[MSG_MAX_LEN];
} CLI_CMDS;

int cli_cmd_strcmp(const char*, const char*);
void cli_cmd_clear(char*, int);
void cli_cmd_read(char*);
void cli_cmd_exec(char*);
void cli_print_banner();

void do_cmd_help();
void do_cmd_hello();
void do_cmd_info();
void do_cmd_reboot();

#endif /* _SHELL_H_ */
10 changes: 10 additions & 0 deletions lab1/include/uart1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef _UART1_H_
#define _UART1_H_

void uart_init();
char uart_recv();
void uart_send(unsigned int c);
void uart_puts(char* str);
void uart_2hex(unsigned int d);

#endif /*_UART1_H_*/
Binary file added lab1/kernel8.img
Binary file not shown.
Loading