cpa.c

来自「一个用在mips体系结构中的操作系统」· C语言 代码 · 共 61 行

C
61
字号
/* * 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.  * *//* * CPA.c -- run on top of SimOS to obtain info about the CPA *          (Cell Private Area) of the specified cell. * * Output: *    n_cells cellid tick magic[hex] *    stat[hex] fcpu lcpu fpg[hex] lpg[hex] *    stat[hex] fcpu lcpu fpg[hex] lpg[hex] *    ... * */#define HIVE#include "stdio.h"#include "stdlib.h"#include "sys/sysmp.h"#define BSIZE 1000int b[BSIZE]; /* buffer for CELLINFO result */int n = BSIZE;/* buffer size / number of ints returned */int main(int argc, char** argv){   int cellid;   int i;   int err;   if (argc != 2) {      if (argc == 1)	 cellid = -1;      else {         fprintf(stderr, "usage: %s cellid\n", argv[0]);         exit(1);      }   } else      cellid = atoi(argv[1]);   err = sysmp(MP_HIVE, MPHI_CELLINFO, cellid, b, &n);   if (err) {      printf("1 0\n");      exit(1);   }   printf("%d %d %u %#010x\n", b[0], b[1], b[2], b[3]);   for (i = 4; (i-4)/5 < b[0]; i += 5)      printf("%#010x %d %d %#010x %#010x\n", b[i], b[i+1], b[i+2], b[i+3], b[i+4]);   return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?