73 lines
1.3 KiB
C
73 lines
1.3 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "sys/syssgi.h"
|
|
#include "sys/types.h"
|
|
|
|
char empty[] = {0};
|
|
|
|
extern int errno;
|
|
|
|
main(int argc, char *argv[])
|
|
{
|
|
__uint64_t pp[5];
|
|
int i;
|
|
volatile caddr_t addr;
|
|
volatile long long x;
|
|
pid_t pid = getpid();
|
|
|
|
printf("pid is %d\n", pid);
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
pp[i-1] = strtoull(argv[i], NULL, 0);
|
|
printf("Arg %d is 0x%llx\n", i, pp[i-1]);
|
|
}
|
|
|
|
fflush(stdout);
|
|
addr = malloc(65536);
|
|
if (addr == NULL) {
|
|
printf("unable to alloc mem\n");
|
|
exit(-1);
|
|
}
|
|
|
|
addr = (caddr_t)((__uint64_t)(addr + 0x3fff) & ~0x3fff);
|
|
if (pp[2] & 0x80)
|
|
x = *addr;
|
|
|
|
if (pp[2] & 0x100)
|
|
*addr = 5;
|
|
|
|
pp[1] = (__uint64_t)addr;
|
|
pp[2] |= 0x40;
|
|
if (syssgi(SGI_ERROR_FORCE, pp[0], pp[1], pp[2], pp[3], pp[4]) == -1) {
|
|
printf("error num %d\n", errno);
|
|
exit(-1);
|
|
}
|
|
if (pp[2] & 0x80)
|
|
x = *addr;
|
|
|
|
if (pp[2] & 0x100)
|
|
*addr = 5;
|
|
|
|
if (syssgi(SGI_ERROR_FORCE, 16, pp[1], 64|0x0f20000, pp[3], pp[4]) == -1) {
|
|
printf("flush error num %d\n", errno);
|
|
exit(-1);
|
|
}
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
int pid;
|
|
if ((pid = fork()) == 0) {
|
|
sleep(4);
|
|
if (pp[2] & 0x80)
|
|
x = *addr;
|
|
|
|
if (pp[2] & 0x100)
|
|
*addr = 5;
|
|
printf("Done accessing\n");
|
|
exit(0);
|
|
}
|
|
printf("Created pid %d\n", pid);
|
|
}
|
|
printf("parent exiting\n");
|
|
}
|
|
|