Initial commit: Schunix as it stands before the SchOS rename
An x86-64 operating system built from xv6, now largely rewritten: SMP, a copy-on-write root filesystem (SchFS), PCI/USB/virtio drivers, a TTF rasteriser, and a Linux-numbered syscall ABI. No history before this point -- the tree was never under version control. This commit exists so the rename that follows has something to undo to.
This commit is contained in:
commit
d0f7acf9eb
275 changed files with 51417 additions and 0 deletions
79
include/types.h
Normal file
79
include/types.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#pragma once
|
||||
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned char uchar;
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
typedef signed int int32;
|
||||
|
||||
// uint64 has to be 64 bits everywhere this header is used, and `unsigned long`
|
||||
// is not that everywhere. Linux and the x86_64-elf kernel target are LP64, so
|
||||
// long is 64-bit; Windows is LLP64, where long is 32-bit and only long long is
|
||||
// 64-bit.
|
||||
//
|
||||
// This matters far more than a portability nicety. The host tools -- mkfs,
|
||||
// mkschfs, the SchFS suites -- include this header *and* the on-disk structure
|
||||
// definitions in fs.h and schfs.h. Building them on Windows with a 32-bit
|
||||
// uint64 does not fail: it quietly produces images whose inode numbers, sizes
|
||||
// and block pointers are half the width the kernel reads back, which shows up
|
||||
// as a corrupt filesystem long after the tool that wrote it has exited.
|
||||
//
|
||||
// Spelled as long/long long rather than <stdint.h>'s uint64_t so the `%l`
|
||||
// format specifiers used throughout the kernel stay correct and untouched.
|
||||
// Conditioned on the actual width of `long` rather than on the platform,
|
||||
// because there are three cases and only one of them is about Windows:
|
||||
// x86_64-elf / Linux LP64 -> long is 64-bit
|
||||
// Windows LLP64 -> long is 32-bit, long long is 64
|
||||
// i386-elf (boot/) ILP32 -> long is 32-bit, and stage2main.c includes
|
||||
// this header too
|
||||
#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8
|
||||
typedef unsigned long uint64;
|
||||
typedef signed long int64;
|
||||
#else
|
||||
typedef unsigned long long uint64;
|
||||
typedef signed long long int64;
|
||||
#endif
|
||||
|
||||
// Belt and braces: if the above is ever wrong on some new host, say so at
|
||||
// compile time rather than in a filesystem image.
|
||||
_Static_assert(sizeof(uint64) == 8, "uint64 must be 64 bits");
|
||||
_Static_assert(sizeof(int64) == 8, "int64 must be 64 bits");
|
||||
|
||||
typedef uint64 uintptr_t;
|
||||
typedef int64 intptr_t;
|
||||
typedef int64 ptrdiff_t;
|
||||
|
||||
typedef uint64 addr_t;
|
||||
typedef uint64 size_t;
|
||||
typedef int64 ssize_t;
|
||||
|
||||
#ifndef MKFS
|
||||
#ifndef _SIGSET_T
|
||||
#define _SIGSET_T
|
||||
typedef uint64 sigset_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef addr_t pte_t;
|
||||
typedef addr_t pde_t;
|
||||
typedef addr_t pdpe_t;
|
||||
typedef addr_t pml4e_t;
|
||||
|
||||
struct mouse_data {
|
||||
int x;
|
||||
int y;
|
||||
uint8 buttons;
|
||||
};
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
Loading…
Reference in a new issue