From fc42b02a283154d0c4684085b7bcc02540f17f52 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 22 Dec 2015 11:40:34 +0000 Subject: [PATCH] Add arch/amd64 PRO MEMORIA: in arch/amd64/include/ureg.h the commented registers are preserved. They were removed at https://github.com/Harvey-OS/harvey/commit/6ab2e16c9f1058aab427f79d4516d281c8e6039b but apparently the es register is used by vesavga (386 version) in both Plan9, 9front and 9atom. --- arch/amd64/bin/auth/disable | 5 ++ arch/amd64/bin/auth/enable | 5 ++ arch/amd64/bin/auth/status | 36 +++++++++++++ arch/amd64/include/cflags.json | 28 ++++++++++ arch/amd64/include/u.h | 97 ++++++++++++++++++++++++++++++++++ arch/amd64/include/ureg.h | 42 +++++++++++++++ 6 files changed, 213 insertions(+) create mode 100755 arch/amd64/bin/auth/disable create mode 100755 arch/amd64/bin/auth/enable create mode 100755 arch/amd64/bin/auth/status create mode 100644 arch/amd64/include/cflags.json create mode 100644 arch/amd64/include/u.h create mode 100644 arch/amd64/include/ureg.h diff --git a/arch/amd64/bin/auth/disable b/arch/amd64/bin/auth/disable new file mode 100755 index 0000000..7ef7149 --- /dev/null +++ b/arch/amd64/bin/auth/disable @@ -0,0 +1,5 @@ +#!/bin/rc +if(test -e /mnt/keys/$1) + echo -n disabled > /mnt/keys/$1/status +if(test -e /mnt/netkeys/$1) + echo -n disabled > /mnt/netkeys/$1/status diff --git a/arch/amd64/bin/auth/enable b/arch/amd64/bin/auth/enable new file mode 100755 index 0000000..f7a9118 --- /dev/null +++ b/arch/amd64/bin/auth/enable @@ -0,0 +1,5 @@ +#!/bin/rc +if(test -e /mnt/keys/$1) + echo -n ok > /mnt/keys/$1/status +if(test -e /mnt/netkeys/$1) + echo -n ok > /mnt/netkeys/$1/status diff --git a/arch/amd64/bin/auth/status b/arch/amd64/bin/auth/status new file mode 100755 index 0000000..4dc0323 --- /dev/null +++ b/arch/amd64/bin/auth/status @@ -0,0 +1,36 @@ +#!/bin/rc +cd /mnt/keys/$1 > /dev/null >[2=1] && { + stat=`{cat status} + exp=`{cat expire} + switch($exp){ + case never 0 + exp='never expires' + case * + exp=(expires on `{date $exp}) + } + switch($stat){ + case expired + echo user $1: plan 9 key has expired + case * + echo user $1: plan 9 key status is $stat and $exp + } + grep '^'$1'[ ]' /adm/keys.who | tail -1 +} +cd /mnt/netkeys/$1 > /dev/null >[2=1] && { + stat=`{cat status} + exp=`{cat expire} + switch($exp){ + case never 0 + exp='never expires' + case * + exp=(expires on `{date $exp}) + } + switch($stat){ + case expired + echo user $1: network key has expired + case * + echo user $1: network key status is $stat and $exp + auth/printnetkey $1 + } + grep '^'$1'[ ]' /adm/netkeys.who | tail -1 +} diff --git a/arch/amd64/include/cflags.json b/arch/amd64/include/cflags.json new file mode 100644 index 0000000..c824bda --- /dev/null +++ b/arch/amd64/include/cflags.json @@ -0,0 +1,28 @@ +{ + "buildflags": { + "Cflags": [ + "-std=c11", + "-c", + "-I/$JEHANNE/arch/$ARCH/include", + "-I/$JEHANNE/sys/include", + "-I.", + "-ffreestanding", + "-fno-builtin", + "-fno-omit-frame-pointer", + "-fplan9-extensions", + "-fvar-tracking", + "-fvar-tracking-assignments", + "-g", + "-gdwarf-2", + "-ggdb", + "-mcmodel=small", + "-mno-red-zone", + "-O0", + "-static", + "-Wall", + "-Wno-missing-braces", + "-Wno-parentheses", + "-Wno-unknown-pragmas" + ] + } +} diff --git a/arch/amd64/include/u.h b/arch/amd64/include/u.h new file mode 100644 index 0000000..43a05ac --- /dev/null +++ b/arch/amd64/include/u.h @@ -0,0 +1,97 @@ +/* + * This file is part of the UCB release of Plan 9. It is subject to the license + * terms in the LICENSE file found in the top-level directory of this + * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No + * part of the UCB release of Plan 9, including this file, may be copied, + * modified, propagated, or distributed except according to the terms contained + * in the LICENSE file. + */ + +#define nil ((void*)0) +typedef unsigned char uint8_t; +typedef signed char int8_t; +typedef unsigned short uint16_t; +typedef signed short int16_t; +typedef unsigned int uint32_t; +typedef unsigned int uint; +typedef signed int int32_t; +typedef unsigned long long uint64_t; +typedef long long int64_t; +typedef uint64_t uintptr; +typedef uint64_t uintptr_t; +typedef uint32_t usize; +typedef int64_t size_t; +typedef uint32_t Rune; +typedef union FPdbleword FPdbleword; +typedef uintptr jmp_buf[10]; // for registers. + +#define JMPBUFSP 6 +#define JMPBUFPC 7 +#define JMPBUFARG1 8 +#define JMPBUFARG2 9 + +#define JMPBUFDPC 0 +typedef unsigned int mpdigit; /* for /sys/include/mp.h */ + +/* MXCSR */ +/* fcr */ +#define FPFTZ (1<<15) /* amd64 */ +#define FPINEX (1<<12) +#define FPUNFL (1<<11) +#define FPOVFL (1<<10) +#define FPZDIV (1<<9) +#define FPDNRM (1<<8) /* amd64 */ +#define FPINVAL (1<<7) +#define FPDAZ (1<<6) /* amd64 */ +#define FPRNR (0<<13) +#define FPRZ (3<<13) +#define FPRPINF (2<<13) +#define FPRNINF (1<<13) +#define FPRMASK (3<<13) +#define FPPEXT 0 +#define FPPSGL 0 +#define FPPDBL 0 +#define FPPMASK 0 +/* fsr */ +#define FPAINEX (1<<5) +#define FPAUNFL (1<<4) +#define FPAOVFL (1<<3) +#define FPAZDIV (1<<2) +#define FPADNRM (1<<1) /* not in plan 9 */ +#define FPAINVAL (1<<0) +union FPdbleword +{ + double x; + struct { /* little endian */ + uint lo; + uint hi; + }; +}; + +/* +#if 0 +typedef char* va_list; +#define va_start(list, start) list =\ + (sizeof(start) < 8?\ + (char*)((int64_t*)&(start)+1):\ + (char*)(&(start)+1)) +#define va_end(list)\ + USED(list) +#define va_arg(list, mode)\ + ((sizeof(mode) == 1)?\ + ((list += 8), (mode*)list)[-8]:\ + (sizeof(mode) == 2)?\ + ((list += 8), (mode*)list)[-4]:\ + (sizeof(mode) == 4)?\ + ((list += 8), (mode*)list)[-2]:\ + ((list += sizeof(mode)), (mode*)list)[-1]) +#endif +*/ + +typedef __builtin_va_list va_list; + +#define va_start(v,l) __builtin_va_start(v,l) +#define va_end(v) __builtin_va_end(v) +#define va_arg(v,l) __builtin_va_arg(v,l) +#define va_copy(v,l) __builtin_va_copy(v,l) + diff --git a/arch/amd64/include/ureg.h b/arch/amd64/include/ureg.h new file mode 100644 index 0000000..d1b17bd --- /dev/null +++ b/arch/amd64/include/ureg.h @@ -0,0 +1,42 @@ +/* + * This file is part of the UCB release of Plan 9. It is subject to the license + * terms in the LICENSE file found in the top-level directory of this + * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No + * part of the UCB release of Plan 9, including this file, may be copied, + * modified, propagated, or distributed except according to the terms contained + * in the LICENSE file. + */ + +struct Ureg { + uint64_t ax; + uint64_t bx; + uint64_t cx; + uint64_t dx; + uint64_t si; + uint64_t di; + uint64_t bp; + uint64_t r8; + uint64_t r9; + uint64_t r10; + uint64_t r11; + uint64_t r12; + uint64_t r13; + uint64_t r14; + uint64_t r15; + + // these are pointless and I don't want to waste a second on them. + // I'm sure it will break something but let's see. + // Not pushing them simplifies the interrupt handler a lot. + // uint16_t ds; + // uint16_t es; + // uint16_t fs; + // uint16_t gs; + + uint64_t type; + uint64_t error; /* error code (or zero) */ + uint64_t ip; /* pc */ + uint64_t cs; /* old context */ + uint64_t flags; /* old flags */ + uint64_t sp; /* sp */ + uint64_t ss; /* old stack segment */ +};