-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregs.c
More file actions
executable file
·48 lines (39 loc) · 1.03 KB
/
regs.c
File metadata and controls
executable file
·48 lines (39 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* regs.c - SPARC V8 architected registers state routines */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "host.h"
#include "misc.h"
#include "machine.h"
#include "loader.h"
#include "regs.h"
/* create a register file */
struct regs_t *
regs_create(void)
{
struct regs_t *regs;
regs = calloc(1, sizeof(struct regs_t));
if (!regs)
fatal("out of virtual memory");
return regs;
}
/* initialize architected register state */
void
regs_init(struct regs_t *regs) /* register file to initialize */
{
/* SPARC requires specific initialization beyond just zeroing memory */
memset(regs, 0, sizeof(*regs));
/* Initialize the CWP to the first window */
regs->regs_R.CWP = 0;
/* The PSR's CWP field should also be initialized.
The 5 bits for CWP are bits 0-4 of the PSR. */
regs->regs_C.PSR &= ~0x1F; // Clear CWP bits
regs->regs_C.PSR |= (regs->regs_R.CWP & 0x1F);
}
/* destroy a register file */
void
regs_destroy(struct regs_t *regs) /* register file to release */
{
if (regs)
free(regs);
}