📄 cellkill.c
字号:
/* * Copyright (C) 1996-1998 by the Board of Trustees * of Leland Stanford Junior University. * * This file is part of the SimOS distribution. * See LICENSE file for terms of the license. * *//* * cellkill.c -- kill specified cells. First checks whether the cells * are indeed known to be alive. * Usage: * cellkill {c raise_fw how}+ * Where: * c = cell number * raise_fw = should cell raise its fwall? * how = 0: through fast, non-blocking RPC * 1: through fast, blocking RPC * 2: through queued, blocking RPC */#define HIVE#include "stdio.h"#include "stdlib.h"#include <string.h>#include <sys/sysmp.h>#include "simosapps.h"#define BSIZE 1000#define CSIZE 16typedef struct CellInfo { int live; int firstcpu; int lastcpu; int firstpg; int lastpg;} CellInfo;#define L_ALIVE 0x00000001 /* cell is alive */#define L_MASTER 0x00000002 /* this is the master cell */#define L_BOOTED 0x00000004 /* cell has been booted once */#define L_HARDFAIL 0x00000008 /* cell has a hardware failure */#define MAXCELLS 16typedef struct SysInfo { int ncells; int cellid; int tick; int magic; CellInfo c[MAXCELLS];} SysInfo;SysInfo s; /* buffer for CELLINFO result */int n = sizeof(s); /* buffer size/size of result structure */void print_sysconf(void){ int i; int flags; int err; err = sysmp(MP_HIVE, MPHI_CELLINFO, -1, &s, &n); if (err) { perror("sysmp(MP_HIVE, MPHI_CELLINFO,...) failed"); exit(1); } printf("CPA snapshot:\n" " Number of cells: %d\n" " Id of this cell: %d\n" " Current tick: %d\n" " Current magic: %d\n", s.ncells, s.cellid, s.tick, s.magic); for (i = 0; i < s.ncells; i++) { printf(" Cell %d: CPUs %d-%d pages 0x%x-0x%x flags ", i, s.c[i].firstcpu, s.c[i].lastcpu, s.c[i].firstpg, s.c[i].lastpg); flags = s.c[i].live; if (flags & L_ALIVE) printf("L_ALIVE "); if (flags & L_MASTER) printf("L_MASTER "); if (flags & L_BOOTED) printf("L_BOOTED "); if (flags & L_HARDFAIL) printf("L_HARDFAIL "); printf("\n"); }}int main(int argc, char** argv){ int err; int c, raise, how; int nc; if ((argc % 3) != 1) { fprintf(stderr, "Usage: cellkill {c raise_fw how}+\n"); exit(1); } /* 1. Obtain info on current config */ err = sysmp(MP_HIVE, MPHI_CELLINFO, -1, &s, &n); if (err) { perror("sysmp(MP_HIVE, MPHI_CELLINFO,...) failed"); exit(1); } /* 2. Print current system configuration */ print_sysconf(); printf("\n"); /* 3. Kill specified cells */ for (argc--, argv++, nc = 0; argc > 0; ) { c = atoi(*argv++); argc--; raise = atoi(*argv++); argc--; how = atoi(*argv++); argc--; if (c < 0 || c > s.ncells || raise < 0 || raise > 1 || how < 0 || how > 2) { fprintf(stderr, "Bad arguments\n"); exit(1); } printf("### Killing cell %d (raise=%d how=%d)\n", c, raise, how); err = sysmp(MP_HIVE, MPHI_CRASHCELLS, c, raise, how); if (err) { perror("sysmp(MP_HIVE, MPHI_CRASHCELLS, ...)"); exit(1); } else nc++; } if (nc) { printf("\n"); print_sysconf(); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -