Adding support for uname
This commit is contained in:
parent
a4d2742e3e
commit
50818a8350
|
@ -17,6 +17,8 @@
|
|||
* Current
|
||||
** Added
|
||||
Added support for envp in cc_x86.s
|
||||
Added support for --POSIX-MODE to allow cross-platform testing to be easier
|
||||
Expanded the disassembler's support of HALCODE to include POSIX instructions
|
||||
|
||||
** Changed
|
||||
Reduced stack usage thanks to akkartik
|
||||
|
|
|
@ -1384,6 +1384,11 @@ void decode_HALCODE(struct Instruction* c)
|
|||
strncpy(Name, "EXIT", 19);
|
||||
break;
|
||||
}
|
||||
case 0x00003F: /* UNAME */
|
||||
{
|
||||
strncpy(Name, "UNAME", 19);
|
||||
break;
|
||||
}
|
||||
case 0x00005A: /* CHMOD */
|
||||
{
|
||||
strncpy(Name, "CHMOD", 19);
|
||||
|
|
|
@ -471,6 +471,7 @@ mappings have been exposed for use.
|
|||
| 42 00 00 03 | FCLOSE | close(int FD) using R0 |
|
||||
| 42 00 00 08 | FSEEK | seek(int FD, off_t OFFSET, int WHENCE) using R0, R1 and R2 respectively |
|
||||
| 42 00 00 3C | EXIT | exit(int ERROR_CODE) using R0 |
|
||||
| 42 00 00 3F | UNAME | uname(struct utsname* BUF) using R0 |
|
||||
| 42 00 00 5A | CHMOD | chmod(char* PATHNAME, int MODE) using R0 and R1 respectively |
|
||||
|-------------+--------+----------------------------------------------------------------------------|
|
||||
| 42 10 01 00 | FGETC | read 1 byte into register 0 from device who's ID is in register 1 |
|
||||
|
|
6
vm.h
6
vm.h
|
@ -29,6 +29,7 @@ typedef __uint256_t unsigned_vm_register;
|
|||
#define umax 256
|
||||
#define imax 255
|
||||
#define reg_size 32
|
||||
#define arch_name "knight256-base"
|
||||
#elif VM128
|
||||
typedef __int256_t signed_wide_register;
|
||||
typedef __uint256_t unsigned_wide_register;
|
||||
|
@ -37,6 +38,7 @@ typedef __uint128_t unsigned_vm_register;
|
|||
#define umax 128
|
||||
#define imax 127
|
||||
#define reg_size 16
|
||||
#define arch_name "knight128-base"
|
||||
#elif VM64
|
||||
typedef __int128_t signed_wide_register;
|
||||
typedef __uint128_t unsigned_wide_register;
|
||||
|
@ -45,6 +47,7 @@ typedef uint64_t unsigned_vm_register;
|
|||
#define umax 64
|
||||
#define imax 63
|
||||
#define reg_size 8
|
||||
#define arch_name "knight64-base"
|
||||
#elif VM32
|
||||
typedef int64_t signed_wide_register;
|
||||
typedef uint64_t unsigned_wide_register;
|
||||
|
@ -53,6 +56,7 @@ typedef uint32_t unsigned_vm_register;
|
|||
#define umax 32
|
||||
#define imax 31
|
||||
#define reg_size 4
|
||||
#define arch_name "knight32-base"
|
||||
#else
|
||||
typedef int32_t signed_wide_register;
|
||||
typedef uint32_t unsigned_wide_register;
|
||||
|
@ -61,6 +65,7 @@ typedef uint16_t unsigned_vm_register;
|
|||
#define umax 16
|
||||
#define imax 15
|
||||
#define reg_size 2
|
||||
#define arch_name "knight16-base"
|
||||
#endif
|
||||
|
||||
/* Virtual machine state */
|
||||
|
@ -96,6 +101,7 @@ struct Instruction
|
|||
/* Prototypes for functions in vm_instructions.c*/
|
||||
void vm_EXIT(struct lilith* vm, uint64_t performance_counter);
|
||||
void vm_CHMOD(struct lilith* vm);
|
||||
void vm_UNAME(struct lilith* vm);
|
||||
void vm_FOPEN(struct lilith* vm);
|
||||
void vm_FOPEN_READ(struct lilith* vm);
|
||||
void vm_FOPEN_WRITE(struct lilith* vm);
|
||||
|
|
11
vm_decode.c
11
vm_decode.c
|
@ -280,6 +280,17 @@ bool eval_HALCODE(struct lilith* vm, struct Instruction* c)
|
|||
vm_EXIT(vm, performance_counter);
|
||||
break;
|
||||
}
|
||||
case 0x00003F: /* UNAME */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "UNAME", 19);
|
||||
#elif TRACE
|
||||
record_trace("UNAME");
|
||||
#endif
|
||||
|
||||
vm_UNAME(vm);
|
||||
break;
|
||||
}
|
||||
case 0x00005A: /* CHMOD */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -55,6 +55,16 @@ void writeout_bytes(struct lilith* vm, unsigned_vm_register pointer, unsigned_vm
|
|||
}
|
||||
}
|
||||
|
||||
void writeout_string(struct lilith* vm, char* s, unsigned_vm_register pointer)
|
||||
{
|
||||
while(0 != s[0])
|
||||
{
|
||||
vm->memory[pointer] = s[0];
|
||||
pointer = pointer + 1;
|
||||
s = s + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allow the use of native data format for Register operations */
|
||||
unsigned_vm_register readin_bytes(struct lilith* vm, unsigned_vm_register pointer, bool Signed, int count)
|
||||
{
|
||||
|
@ -154,6 +164,15 @@ void vm_CHMOD(struct lilith* vm)
|
|||
free(s);
|
||||
}
|
||||
|
||||
void vm_UNAME(struct lilith* vm)
|
||||
{
|
||||
writeout_string(vm, "sysname", vm->reg[0]);
|
||||
writeout_string(vm, "nodename", vm->reg[0] + 65);
|
||||
writeout_string(vm, "release", vm->reg[0] + 130);
|
||||
writeout_string(vm, "version", vm->reg[0] + 195);
|
||||
writeout_string(vm, arch_name, vm->reg[0] + 260);
|
||||
}
|
||||
|
||||
void vm_FOPEN(struct lilith* vm)
|
||||
{
|
||||
char* s = string_copy(vm, vm->reg[0]);
|
||||
|
|
Loading…
Reference in New Issue