Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
foreach ($path in $customizationsPaths) {
Copy-Item nasmprops\* -Destination $path -Force -Recurse
}
$nasmPath = (Get-Command nasm.exe).Source
$vcDir = Join-Path $vsPath "VC"
Copy-Item $nasmPath -Destination $vcDir -Force

- name: Build Solution (Aurora.sln)
run: |
Expand Down
84 changes: 84 additions & 0 deletions BaseHdr/Hal/fault.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* BSD 2-Clause License
*
* Copyright (c) 2022-2026, Manas Kamal Choudhury
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**/

#ifndef __AU_FAULT_H__
#define __AU_FAULT_H__

#include <stdint.h>
#if defined(__GNUC__) || defined(__clang__)
#ifndef __cplusplus
#include <stdbool.h>
#endif
#endif
#include <aurora.h>
#include <process.h>

#define FAULT_ORIGIN_KERNEL 1
#define FAULT_ORIGIN_USER 2
#define FAULT_ORIGIN_DRIVER 3

#define FAULT_TYPE_PAGE_NOT_PRESENT 1
#define FAULT_TYPE_WRITE_VIOLATION 2
#define FAULT_TYPE_USER_ACCESS 3
#define FAULT_TYPE_RESERVED_BIT 4
#define FAULT_TYPE_INSTRUCTION_FETCH 5
#define FAULT_TYPE_GENERAL_PROTECTION 6
#define FAULT_TYPE_INVALID_OPCODE 7
#define FAULT_TYPE_STACK_FAULT 8
#define FAULT_TYPE_UNKNOWN 9

#pragma pack(push,1)
typedef struct _au_fault_info_ {
uint64_t fault_address;
uint64_t fault_pc;
uint8_t fault_type;
uint8_t origin;
uint16_t thread_id;
char thread_name[16];
int process_id;
char process_name[16];
uint64_t vma_start;
uint64_t vma_end;
}AuFaultInfo;
#pragma pack(pop)

/*
* AuFaultLogDiagnostics -- print structured fault diagnostics to serial
* @param info -- pointer to fault diagnostic info
*/
AU_EXTERN AU_EXPORT void AuFaultLogDiagnostics(AuFaultInfo* info);

/*
* AuFaultTerminateProcess -- gracefully terminate a faulting user process
* @param proc -- process slot to terminate
* @param info -- fault diagnostic info
*/
AU_EXTERN AU_EXPORT void AuFaultTerminateProcess(AuProcess* proc, AuFaultInfo* info);

#endif
24 changes: 7 additions & 17 deletions BaseHdr/stdarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern "C"
#endif


#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang__)
typedef __builtin_va_list va_list;
#else
/* va list parameter list */
Expand All @@ -55,7 +55,12 @@ extern "C"
((sizeof(TYPE)+sizeof(STACKITEM)-1) \
& ~(sizeof(STACKITEM)-1))

#if defined(ARCH_X64) || defined(__x86_64__)
#if defined(__GNUC__) || defined(__clang__)
#define va_start(ap, last) __builtin_va_start(ap, last)
#define va_arg(ap, type) __builtin_va_arg(ap, type)
#define va_end(ap) __builtin_va_end(ap)
#define va_copy(dest, src) __builtin_va_copy(dest, src)
#else
/* &(LASTARG) points to the LEFTMOST argument of the function call
(before the ...) */
#define va_start(AP, LASTARG) \
Expand All @@ -66,21 +71,6 @@ extern "C"

#define va_arg(AP, TYPE) \
(AP += VA_SIZE(TYPE), *((TYPE *)(AP - VA_SIZE(TYPE))))
#elif defined(ARCH_ARM64) || defined(__aarch64__)
#ifdef __GNUC__
#define va_start(ap, last) __builtin_va_start(ap, last)
#define va_arg(ap, type) __builtin_va_arg(ap, type)
#define va_end(ap) __builtin_va_end(ap)
#else
#define va_start(ap,last) \
((ap) = (va_list)(&(last)) + 8)

#define va_arg(ap,T) \
(*(T*)((ap) += 8, (ap) - 8))

#define va_end(ap) \
((ap) = (va_list)0)
#endif
#endif

#ifdef __cplusplus
Expand Down
24 changes: 14 additions & 10 deletions BaseHdr/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@
#ifndef __TIMER_H__
#define __TIMER_H__

#include <aurora.h>
#ifdef ARCH_X64
#include <Hal/x86_64_sched.h>
typedef struct _au_thread_ AuThreadType;
#elif defined(ARCH_ARM64)
#include <Hal/AA64/sched.h>
typedef AA64Thread AuThreadType;
#else
typedef void AuThreadType;
#endif
#if defined(__GNUC__) || defined(__clang__)
#ifndef __cplusplus
#include <stdbool.h>
Expand All @@ -48,7 +55,7 @@ typedef struct _kernel_timer_ {
AuroraTimerCallback handler;
void* param;
uint8_t active;
AA64Thread* owner;
AuThreadType* owner;
}AuKernelTimer;

#define AURORA_MAX_TIMER 32
Expand Down Expand Up @@ -105,27 +112,24 @@ AU_EXTERN AU_EXPORT uint64_t AuGetCurrentUS();
* @param thr -- pointer to thread which requires one-shot timer
* @param seconds -- amount of second to wait
*/
extern int AuTimerCalculateAlarm(AA64Thread* thr, uint64_t seconds);
extern int AuTimerCalculateAlarm(AuThreadType* thr, uint64_t seconds);

#include <time.h>

/* POSIX Timer API */
typedef struct _itimerval_ {
timeval it_interval;
timeval it_value;
}itimerval_t;

typedef struct _timeval_t_ {
long tv_sec;
long tv_usec;
}timeval_t;



/**
*@brief AuTimerSetITimer -- posix standard implementation of
* setting periodic timer
*/
extern int AuTimerSetITimer(AA64Thread* thr, int which, const itimerval_t* newval, itimerval_t* oldval);
extern int AuTimerGetITimer(AA64Thread* thr, int which, itimerval_t* curr_value);
extern int AuTimerSetITimer(AuThreadType* thr, int which, const itimerval_t* newval, itimerval_t* oldval);
extern int AuTimerGetITimer(AuThreadType* thr, int which, itimerval_t* curr_value);
extern void AuSetWalltime(int64_t sec, int64_t nsec);
extern void AuGetWalltime(int64_t* out_sec, int64_t* out_ns);

Expand Down
Loading
Loading