parent
b1e7a2d07e
commit
60bc1a54d2
@ -1,3 +1,4 @@
|
|||||||
build/
|
build/
|
||||||
target/
|
target/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"arch": "mips",
|
||||||
|
"cpu": "mips32r2",
|
||||||
|
"llvm-target": "mipsel-unknown-none",
|
||||||
|
"data-layout": "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64",
|
||||||
|
"target-endian": "little",
|
||||||
|
"target-pointer-width": "32",
|
||||||
|
"target-c-int-width": "32",
|
||||||
|
"os": "none",
|
||||||
|
"features": "+mips32r2,+soft-float",
|
||||||
|
"max-atomic-width": "32",
|
||||||
|
"linker": "rust-lld",
|
||||||
|
"linker-flavor": "ld.lld",
|
||||||
|
"executables": true,
|
||||||
|
"panic-strategy": "abort",
|
||||||
|
"relocation-model": "static",
|
||||||
|
"abi-blacklist": [
|
||||||
|
"cdecl",
|
||||||
|
"stdcall",
|
||||||
|
"fastcall",
|
||||||
|
"vectorcall",
|
||||||
|
"thiscall",
|
||||||
|
"aapcs",
|
||||||
|
"win64",
|
||||||
|
"sysv64",
|
||||||
|
"ptx-kernel",
|
||||||
|
"msp430-interrupt",
|
||||||
|
"x86-interrupt"
|
||||||
|
],
|
||||||
|
"eliminate-frame-pointer": false
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
|||||||
|
// See LICENSE for license details.
|
||||||
|
|
||||||
|
#ifndef __LIBS_MIPSEL_H__
|
||||||
|
#define __LIBS_MIPSEL_H__
|
||||||
|
|
||||||
|
#define do_div(n, base) \
|
||||||
|
({ \
|
||||||
|
int __res; \
|
||||||
|
__res = ((unsigned long)n) % (unsigned)base; \
|
||||||
|
n = ((unsigned long)n) / (unsigned)base; \
|
||||||
|
__res; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,75 @@
|
|||||||
|
#ifndef __LIBS_ATOMIC_H__
|
||||||
|
#define __LIBS_ATOMIC_H__
|
||||||
|
|
||||||
|
// TODO: implement atomic operations for aarch64
|
||||||
|
|
||||||
|
/* Atomic operations that C can't guarantee us. Useful for resource counting etc.. */
|
||||||
|
|
||||||
|
static inline void set_bit(int nr, volatile void *addr) __attribute__((always_inline));
|
||||||
|
static inline void clear_bit(int nr, volatile void *addr) __attribute__((always_inline));
|
||||||
|
static inline void change_bit(int nr, volatile void *addr) __attribute__((always_inline));
|
||||||
|
static inline bool test_and_set_bit(int nr, volatile void *addr) __attribute__((always_inline));
|
||||||
|
static inline bool test_and_clear_bit(int nr, volatile void *addr) __attribute__((always_inline));
|
||||||
|
static inline bool test_bit(int nr, volatile void *addr) __attribute__((always_inline));
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* set_bit - Atomically set a bit in memory
|
||||||
|
* @nr: the bit to set
|
||||||
|
* @addr: the address to start counting from
|
||||||
|
*
|
||||||
|
* Note that @nr may be almost arbitrarily large; this function is not
|
||||||
|
* restricted to acting on a single-word quantity.
|
||||||
|
* */
|
||||||
|
static inline void set_bit(int nr, volatile void *addr) {
|
||||||
|
/* unimplemented */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* clear_bit - Atomically clears a bit in memory
|
||||||
|
* @nr: the bit to clear
|
||||||
|
* @addr: the address to start counting from
|
||||||
|
* */
|
||||||
|
static inline void clear_bit(int nr, volatile void *addr) {
|
||||||
|
/* unimplemented */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* change_bit - Atomically toggle a bit in memory
|
||||||
|
* @nr: the bit to change
|
||||||
|
* @addr: the address to start counting from
|
||||||
|
* */
|
||||||
|
static inline void change_bit(int nr, volatile void *addr) {
|
||||||
|
/* unimplemented */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* test_bit - Determine whether a bit is set
|
||||||
|
* @nr: the bit to test
|
||||||
|
* @addr: the address to count from
|
||||||
|
* */
|
||||||
|
static inline bool test_bit(int nr, volatile void *addr) {
|
||||||
|
/* unimplemented */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* test_and_set_bit - Atomically set a bit and return its old value
|
||||||
|
* @nr: the bit to set
|
||||||
|
* @addr: the address to count from
|
||||||
|
* */
|
||||||
|
static inline bool test_and_set_bit(int nr, volatile void *addr) {
|
||||||
|
/* unimplemented */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* test_and_clear_bit - Atomically clear a bit and return its old value
|
||||||
|
* @nr: the bit to clear
|
||||||
|
* @addr: the address to count from
|
||||||
|
* */
|
||||||
|
static inline bool test_and_clear_bit(int nr, volatile void *addr) {
|
||||||
|
/* unimplemented */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !__LIBS_ATOMIC_H__ */
|
@ -0,0 +1,10 @@
|
|||||||
|
#include <regdef.h>
|
||||||
|
|
||||||
|
.text
|
||||||
|
.globl _start
|
||||||
|
_start:
|
||||||
|
# call user-program function
|
||||||
|
lw a0, 0(sp)
|
||||||
|
addiu a1, sp, 8
|
||||||
|
b umain
|
||||||
|
nop
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* This file is subject to the terms and conditions of the GNU General Public
|
||||||
|
* License. See the file "COPYING" in the main directory of this archive
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* Copyright (C) 1985 MIPS Computer Systems, Inc.
|
||||||
|
* Copyright (C) 1994, 95, 99, 2003 by Ralf Baechle
|
||||||
|
* Copyright (C) 1990 - 1992, 1999 Silicon Graphics, Inc.
|
||||||
|
*/
|
||||||
|
#ifndef _ASM_REGDEF_H
|
||||||
|
#define _ASM_REGDEF_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Symbolic register names for 32 bit ABI
|
||||||
|
*/
|
||||||
|
#define zero $0 /* wired zero */
|
||||||
|
#define AT $1 /* assembler temp - uppercase because of ".set at" */
|
||||||
|
#define v0 $2 /* return value */
|
||||||
|
#define v1 $3
|
||||||
|
#define a0 $4 /* argument registers */
|
||||||
|
#define a1 $5
|
||||||
|
#define a2 $6
|
||||||
|
#define a3 $7
|
||||||
|
#define t0 $8 /* caller saved */
|
||||||
|
#define t1 $9
|
||||||
|
#define t2 $10
|
||||||
|
#define t3 $11
|
||||||
|
#define t4 $12
|
||||||
|
#define t5 $13
|
||||||
|
#define t6 $14
|
||||||
|
#define t7 $15
|
||||||
|
#define s0 $16 /* callee saved */
|
||||||
|
#define s1 $17
|
||||||
|
#define s2 $18
|
||||||
|
#define s3 $19
|
||||||
|
#define s4 $20
|
||||||
|
#define s5 $21
|
||||||
|
#define s6 $22
|
||||||
|
#define s7 $23
|
||||||
|
#define t8 $24 /* caller saved */
|
||||||
|
#define t9 $25
|
||||||
|
#define jp $25 /* PIC jump register */
|
||||||
|
#define k0 $26 /* kernel scratch */
|
||||||
|
#define k1 $27
|
||||||
|
#define gp $28 /* global pointer */
|
||||||
|
#define sp $29 /* stack pointer */
|
||||||
|
#define fp $30 /* frame pointer */
|
||||||
|
#define s8 $30 /* same like fp! */
|
||||||
|
#define ra $31 /* return address */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _ASM_REGDEF_H */
|
Loading…
Reference in new issue