XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions | Variables
srvfs.c File Reference
#include <Fs/srvfs.h>
#include <Fs/vfs.h>
#include <Ipc/auipc.h>
#include <Fs/Dev/devhw.h>
#include <Cred/group.h>
#include <Mm/kmalloc.h>
#include <Drivers/uart.h>
#include <Hal/AA64/aa64lowlevel.h>
#include <Hal/AA64/sched.h>
#include <Serv/sysserv.h>
#include <process.h>
#include <auipc.h>
#include <fssrv.h>
#include <string.h>
#include <_null.h>
Include dependency graph for srvfs.c:

Classes

struct  Op
 
struct  Hist
 

Macros

#define SRV_TIMEOUT_MS   3000
 
#define MAX_HIST   8
 
#define MAX_OPS   16
 
#define HIST_STALE_US   (15ULL * 1000 * 1000)
 

Enumerations

enum  { OP_FREE = 0 , OP_WAIT , OP_DONE }
 

Functions

uint64_t AuGetCurrentUS ()
 
void AuSrvfsNoteOpenMode (int mode)
 AuSrvfsNoteOpenMode – OpenFile tells the proxy the mode of the open it is about to do.
 
void AuSrvfsSyscallEnterSlow (AA64Thread *thr)
 
void AuSrvfsSyscallExitSlow (AA64Thread *thr)
 
int AuSrvfsRemove (const char *path)
 AuSrvfsRemove – remove a /srv file for the RemoveFile syscall; 0 on success.
 
bool AuSrvfsOwns (AuVFSNode *fsys)
 AuSrvfsOwns – true if fsys is the /srv proxy.
 
void AuSrvfsInitialize (void)
 AuSrvfsInitialize – mount the /srv proxy file system.
 

Variables

int g_srvfs_active
 syscall bracket hooks: restartable operations replay per-syscall history
 

Macro Definition Documentation

◆ HIST_STALE_US

#define HIST_STALE_US   (15ULL * 1000 * 1000)

◆ MAX_HIST

#define MAX_HIST   8

◆ MAX_OPS

#define MAX_OPS   16

◆ SRV_TIMEOUT_MS

#define SRV_TIMEOUT_MS   3000

srvfs.c – /srv, a file system served by a user-space process.

The kernel keeps no file data and no directory: every open/read/write on a /srv path becomes a request to the IPC endpoint "fs" (BaseHdr/fssrv.h), stamped with the caller's uid. The server (Process/fssrv) owns the namespace.

The hard part is waiting. A syscall that sleeps does not return up the C stack: the thread resumes after the svc instruction. So a proxy operation that has to wait for the server does this instead:

  1. first execution: queue the request, remember it, rewind ELR_EL1 by one instruction and sleep – the thread resumes by re-executing the svc;
  2. re-execution: the syscall runs again from its entry. Each proxy operation is matched, in order, against this thread's history for the syscall; a finished one returns its saved answer without asking the server again, a pending one polls (and sleeps again if still unanswered).

Positions are restored on replay so side effects of an earlier pass are not applied twice. The history is dropped when the syscall finally returns (the dispatcher calls AuSrvfsSyscallExit). A request the server does not answer in SRV_TIMEOUT_MS fails with an error, so a dead or stuck server never hangs a client. Reads and writes move at most one page per operation.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OP_FREE 
OP_WAIT 
OP_DONE 

Function Documentation

◆ AuGetCurrentUS()

uint64_t AuGetCurrentUS ( )
extern

◆ AuSrvfsInitialize()

void AuSrvfsInitialize ( void  )

AuSrvfsInitialize – mount the /srv proxy file system.

◆ AuSrvfsNoteOpenMode()

void AuSrvfsNoteOpenMode ( int  mode)

AuSrvfsNoteOpenMode – OpenFile tells the proxy the mode of the open it is about to do.

◆ AuSrvfsOwns()

bool AuSrvfsOwns ( AuVFSNode *  fsys)

AuSrvfsOwns – true if fsys is the /srv proxy.

◆ AuSrvfsRemove()

int AuSrvfsRemove ( const char *  path)

AuSrvfsRemove – remove a /srv file for the RemoveFile syscall; 0 on success.

◆ AuSrvfsSyscallEnterSlow()

void AuSrvfsSyscallEnterSlow ( AA64Thread *  thr)

◆ AuSrvfsSyscallExitSlow()

void AuSrvfsSyscallExitSlow ( AA64Thread *  thr)

Variable Documentation

◆ g_srvfs_active

int g_srvfs_active

syscall bracket hooks: restartable operations replay per-syscall history