Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudophpt committed Sep 2, 2018
2 parents d9d808a + 8fc5239 commit bd60a4c
Show file tree
Hide file tree
Showing 51 changed files with 3,972 additions and 37 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## [Unreleased](https://github.com/pseudophpt/pseultra/compare/master...develop)

## [1.2.0](https://github.com/pseudophpt/pseultra/compare/v1.1.0...v1.2.0) - 2018-09-02

### Added
- Debug functionality
- RSP vector load/store fixer
- PSM3D microcode

### Fixed
- Bug involving a coprocessor 0 delay slot which would cause arbitrary kernel reg data to be written to cop0 status reg, and usually an xtlb exception
- Bug in util.h where the macro input to endian switchers isn't wrapped

## [1.1.0](https://github.com/pseudophpt/pseultra/compare/v1.0.1...v1.1.0) - 2018-08-18

### Added
Expand Down
7 changes: 7 additions & 0 deletions SConsopt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ AddOption(
metavar = 'CC_PREFIX',
help = 'MIPS cross compiler prefix'
)

AddOption(
'--oslib-debug',
dest = 'oslib_debug',
action = 'store_true',
help = 'Generate debug version of os library'
)
12 changes: 5 additions & 7 deletions tools/makerom/src/elf.h → include/elf.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
* pseultra/tools/makerom/src/elf.h
* ELF header
* pseultra/include/elf.h
* ELF definitions
*
* (C) pseudophpt 2018
*/

#ifndef MAKEROM_ELF_H_GUARD
#define MAKEROM_ELF_H_GUARD

#include <stdint.h>

#ifndef ELF_H_GUARD
#define ELF_H_GUARD

typedef struct __attribute__((__packed__)) elf32_header_t {
uint32_t magic; // Magic number
uint8_t class; // 64- or 32-bit
Expand Down Expand Up @@ -48,6 +48,4 @@ typedef struct __attribute__((__packed__)) elf32_shentry_t {
uint32_t entsize; // Entry size for those with fixed entries
} elf32_shentry;

elf32_shentry get_section (char *buffer, const char *section_name);

#endif
8 changes: 4 additions & 4 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#ifndef UTIL_H_GUARD
#define UTIL_H_GUARD

#define BE_TO_LE32(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24))
#define LE_TO_BE32(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24))
#define BE_TO_LE32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24))
#define LE_TO_BE32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24))

#define BE_TO_LE16(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8))
#define LE_TO_BE16(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8))
#define BE_TO_LE16(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
#define LE_TO_BE16(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))

#endif
1 change: 1 addition & 0 deletions n64/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ SConscript('./SConsmips')

# Call build scripts
SConscript('./os/SConscript')
SConscript('./ucode/SConscript')
SConscript('./boot/SConscript')
2 changes: 1 addition & 1 deletion n64/SConsmips
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mips_env.Replace(OBJDUMP = cc_prefix + '-objdump')
mips_env.Replace(OBJCOPY = cc_prefix + '-objcopy')
mips_env.Replace(AR = cc_prefix + '-ar')

mips_env.Replace(CCFLAGS = '-G0 -EB')
mips_env.Replace(CCFLAGS = '-G0 -EB -ffreestanding')
mips_env.Replace(ASFLAGS = '-G0 -EB -Iinclude -I../../include')

mips_env.Replace(ENV = os.environ)
Expand Down
18 changes: 17 additions & 1 deletion n64/os/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ path = Dir('.').abspath
mips_env.Append(CPPPATH = ['./include', './../../include'])

includes = [
'./include/os/assert.h',
'./include/os/boot.h',
'./include/os/event.h',
'./include/os/memory.h',
Expand All @@ -17,7 +18,9 @@ includes = [
'./include/os/memory/memcpy.h',
'./include/os/memory/cache.h',
'./include/os/boot/boot.h',
'./include/os/boot/debug.h',
'./include/os/interfaces/pi.h',
'./include/os/interfaces/rsp.h',
'./include/os/interfaces/vi.h',
]

Expand All @@ -26,16 +29,29 @@ sources = [
'./src/event/exception.c',
'./src/event/exception_s.sx',
'./src/boot/boot.c',
'./src/boot/debug.c',
'./src/boot/font.h',
'./src/boot/reg.h',
'./src/boot/boot_s.sx',
'./src/memory/malloc.c',
'./src/memory/memcpy.c',
'./src/memory/cache_s.sx',
'./src/interfaces/pi.c',
'./src/interfaces/rsp.c',
'./src/interfaces/vi.c',
] + includes

oslib_debug = mips_env.GetOption('oslib_debug')

if oslib_debug:
libpseultra = './lib/libpseultra_d.a'
mips_env.Append(CCFLAGS = ' -g -D__debug__')
mips_env.Append(ASFLAGS = ' -g -D__debug__')
else:
libpseultra = './lib/libpseultra.a'

pseultra = mips_env.Library(
target = './lib/libpseultra.a',
target = libpseultra,
source = sources
)

Expand Down
7 changes: 7 additions & 0 deletions n64/os/include/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@ typedef unsigned long u32;
/** @brief Signed 32 bit type */
typedef signed long s32;

/** @brief Unsigned 64 bit type */
typedef unsigned long long u64;
/** @brief Signed 64 bit type */
typedef signed long long s64;

#endif

/** @brief Void pointer to 0 */
#define NULL ((void *) 0)
/** @brief Default OS stack size */
#define OS_STACK_SIZE 0x4000

#include <os/assert.h>

#include <os/memory.h>
#include <os/event.h>
#include <os/boot.h>
Expand Down
34 changes: 34 additions & 0 deletions n64/os/include/os/assert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* pseultra/n64/os/include/os/assert.h
* OS Assert Header
*
* (C) pseudophpt 2018
*/

/**
* @file include/os/assert.h
* @brief OS Assert Header
* @date 20 Aug 2018
* @author pseudophpt
*
* This file defines the assert macro which halts the game if the specified condition is not true
*/

#ifndef OS_ASSERT_H_GUARD
#define OS_ASSERT_H_GUARD

#define OS_ASSERT_STRINGIFY2(x) #x
#define OS_ASSERT_STRINGIFY(x) OS_ASSERT_STRINGIFY2(x)

#ifdef __asm__



#else

#define assert(x) \
if (!(x)) __osError("Assertion Failed: " OS_ASSERT_STRINGIFY(x) "\nLine " OS_ASSERT_STRINGIFY(__LINE__) " in " OS_ASSERT_STRINGIFY(__FILE__));

#endif

#endif
1 change: 1 addition & 0 deletions n64/os/include/os/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
*/

#include <os/boot/boot.h>
#include <os/boot/debug.h>
100 changes: 100 additions & 0 deletions n64/os/include/os/boot/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* pseultra/n64/os/include/os/boot/boot.h
* Boot process header
*
* (C) pseudophpt 2018
*/

/**
* @file include/os/boot/boot.h
* @brief Boot process headers
* @date 1 Aug 2018
* @author pseudophpt
*
* This file provides definitions for structs and constants related to the boot process
*/

#ifndef OS_BOOT_DEBUG_H_GUARD
#define OS_BOOT_DEBUG_H_GUARD

/*
* Macros
*/

/*
* Structs
*/

#ifndef __asm__

#endif

/*
* Public functions
*/

/*
* Public variables
*/

#ifdef __asm__
.extern osDebugFont
#else
extern u8 osDebugFont [];
#endif

#ifdef __asm__
.extern osDebugRegNames
#else
extern char *osDebugRegNames [];
#endif

#ifdef __os_internal__

/*
* Internal functions
*/

#ifdef __asm__
.extern __osDebugInit
#else
void __osDebugInit ();
#endif

#ifdef __asm__
.extern __osDebugWriteChar
#else
void __osDebugWriteChar (int x, int y, u8 ch);
#endif

#ifdef __asm__
.extern __osDebugPrint
#else
void __osDebugPrint (int x, int y, char *str);
#endif

#ifdef __asm__
.extern __osDebugDumpRegisters
#else
void __osDebugDumpRegisters ();
#endif

#ifdef __asm__
.extern __osDebugFormatHex
#else
void __osDebugFormatHex (u32 value, char *str);
#endif

#ifdef __asm__
.extern __osError
#else
void __osError (char *error_msg);
#endif

/*
* Internal variables
*/

#endif

#endif
5 changes: 3 additions & 2 deletions n64/os/include/os/event/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* Macros
*/

/** @brief Size for OS defined event queues */
#define OS_EVENT_QUEUE_SIZE 32

/** @brief Type for an event which is added to the main queue on an SP interrupt */
#define OS_EVENT_TYPE_SP 0
/** @brief Type for an event which is added to the main queue on a DP interrupt */
Expand All @@ -37,8 +40,6 @@
#define OS_EVENT_TYPE_MAIN 8 // User scheduled events
/** @brief Type for an event which is never executed */
#define OS_EVENT_TYPE_NONE 255 // No event (used if no event could be dequeued)
/** @brief Size for OS defined event queues */
#define OS_EVENT_QUEUE_SIZE 32

/*
* Structs
Expand Down
12 changes: 12 additions & 0 deletions n64/os/include/os/event/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void osSetIntMask(u32 mask);
* Public variables
*/

#ifdef __asm__
.extern osDebugExceptStr
#else
extern char *osDebugExceptStr [];
#endif

#ifdef __os_internal__

/*
Expand Down Expand Up @@ -119,6 +125,12 @@ extern u32 __osHandlerStart;
extern u32 __osHandlerEnd;
#endif

#ifdef __asm__
.extern __osExceptionRegSave
#else
extern u32 __osExceptionRegSave [];
#endif

#endif

#endif
1 change: 1 addition & 0 deletions n64/os/include/os/interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
* This file includes all interface related OS headers
*/

#include <os/interfaces/rsp.h>
#include <os/interfaces/vi.h>
#include <os/interfaces/pi.h>
Loading

0 comments on commit bd60a4c

Please sign in to comment.