예제 #1
0
파일: vm.c 프로젝트: vantran24/p4b
// Set up CPU's kernel segment descriptors.
// Run once at boot time on each CPU.
void
seginit(void)
{
  struct cpu *c;

  // Map virtual addresses to linear addresses using identity map.
  // Cannot share a CODE descriptor for both kernel and user
  // because it would have to have DPL_USR, but the CPU forbids
  // an interrupt from CPL=0 to DPL=3.
  c = &cpus[cpunum()];
  c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0);
  c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
  c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER);
  c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER);

  // Map cpu, and curproc
  c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0);

  lgdt(c->gdt, sizeof(c->gdt));
  loadgs(SEG_KCPU << 3);
  
  // Initialize cpu-local storage.
  cpu = c;
  proc = 0;
}
예제 #2
0
파일: proc.c 프로젝트: HVNT/6.828
// Set up CPU's kernel segment descriptors.
// Run once at boot time on each CPU.
void
ksegment(void)
{
  struct cpu *c;

  c = &cpus[cpunum()];
  c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0x100000 + 64*1024-1, 0);
  c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
  c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0);
  lgdt(c->gdt, sizeof(c->gdt));
  loadgs(SEG_KCPU << 3);
  
  // Initialize cpu-local storage.
  cpu = c;
  proc = 0;
}
예제 #3
0
파일: ptest.c 프로젝트: LarBob/executor
int PASCAL
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
  PRINTDLG pd;
  int retval;

  freopen ("stdout.txt", "w", stdout);
  setbuf (stdout, 0);
  freopen ("stderr.txt", "w", stderr);
  setbuf (stderr, 0);

  loadgs ();

  memset (&pd, 0, sizeof pd);
  pd.nCopies = 1;
  pd.hwndOwner = main_window ();
  pd.lStructSize = sizeof pd;
  pd.Flags = (PD_HIDEPRINTTOFILE    |
	      PD_NOPAGENUMS         |
	      PD_NOSELECTION        |
	      PD_RETURNDC           |
	      PD_USEDEVMODECOPIES);
  retval = PrintDlg (&pd);
  if (!retval)
    {
      fprintf (stderr, "PrintDlg failed\n");
    }
  else
    {
      static const char *argv[] =
      {
	"executor",
	"-IC:\\GS;C:\\GS\\FONTS",
	"-q",
	"-dNOPAUSE",
	"-sDEVICE=mswindll",
	"-dBitsPerPixel=1",
	NULL, /* -g%dx%d (papersize) */
	NULL, /* -r%dx%d (resolution)*/
	"calibrate.ps", /* %s (filename) */
	"-c quit",
	NULL,
      };
      char *papersize;
      char *resolution;

      global_hdc = pd.hDC;
      global_src.top = 0;
      global_src.left = 0;
      global_src.bottom = GetDeviceCaps (pd.hDC, VERTRES);
      global_src.right = GetDeviceCaps (pd.hDC, HORZRES);
      global_dest = global_src;

      printf ("top = %ld, left = %ld, bottom = %ld, right = %ld\n",
	      global_src.top, global_src.left,
	      global_src.bottom, global_src.right);

      {
	DOCINFO di;
	int job_identifier;

	memset (&di, 0, sizeof di);
	di.cbSize = sizeof di;
	di.lpszDocName = "Test Document";
	job_identifier = StartDoc (global_hdc, &di);
	if (job_identifier <= 0)
	  {
	    retval = 1;
	    MessageBox (NULL, "Couldn't StartDoc", "Print Failure", MB_OK);
	  }
      }

      papersize = alloca (128);
      sprintf (papersize, "-g%ldx%ld", global_src.right, global_src.bottom);

      resolution = alloca (128);
      sprintf (resolution, "-r%dx%d",
	       GetDeviceCaps (pd.hDC, LOGPIXELSX),
	       GetDeviceCaps (pd.hDC, LOGPIXELSY));

      argv[6] = papersize;
      argv[7] = resolution;


      {
	int i;

	for (i = 0; i <= 9; ++i)
	  printf ("argv[%d] = '%s'\n", i, argv[i]);
      }
      
      if (gsdll_init (gsdll_callback, NULL, NELEM (argv)-1, argv) != 0)
	{
	  fprintf (stderr, "gsdll_init failed\n");
	}
      else
	{
	  int code;
	  
	  gsdll_execute_begin ();
	  code = gsdll_execute_cont ("", 0);
	  printf ("code = %d\n", code);
	  if (code > -100)
	    gsdll_execute_end ();
	  gsdll_exit ();
	  retval = TRUE;
	  EndDoc (global_hdc);
	}
    }
  return 0;
}