void ioplthread2(void *dummy) { int val; while (1) { if (io_init1() != 0) { fprintf(stderr,"thread 3: cannot raise IOPL\n"); exit(1); } fprintf(stderr,"thread 2: raising iopl=3 PSW=%04X\n",psw()); sleep(1); val = c_inb1(0x3cc); /* do some I/O, causing core if */ /* thread has no right*/ fprintf(stderr,"thread 2: read port 0x3cc=%02X, PSW=%04X\n", val, psw()); sleep(1); if (io_exit1() != 0) { fprintf(stderr,"thread 3: cannot reset IOPL\n"); exit(1); } fprintf(stderr,"thread 2: resetting iopl=2 PSW=%04X\n",psw()); sleep(1); } }
int main(int argc,char*argv[]) { int rc; int i; int base, port; unsigned int regs[19]; /* initialize the I/O once */ printf("diagnostic before IOINIT: PSW=%04X\n", psw()); rc = io_init1(); printf("diagnostic after IOINIT: PSW=%04X\n", psw()); if (rc != 0) { fprintf(stderr,"Error %d calling io_init\n",rc); exit(1); } /* warn the user */ fprintf(stderr, "This example will read out the VGA CRT registers\n"); fprintf(stderr, "If you don't have a VGA or SVGA compatible adapter\n"); fprintf(stderr, "or are not sure, press CTRL-C now. Otherwise\n"); fprintf(stderr, "proceed with RETURN\n"); getchar(); printf("diagnostic: PSW=%04X\n", psw()); /* This checks whether the VGA card is in mono or color mode */ base = c_inb1(0x3cc) & 1; printf("\n\nThe VGA card is in %s mode\n", base ? "COLOR" : "MONO"); /* depending on the mode, the registers are a address 0x3d4 or 0x3b4 */ port = base ? 0x3d4 : 0x3b4; /* read the CRT registers */ for (i=0; i<0x19; i++) { c_outb1(port, i); /* address the index register */ regs[i] = c_inb1(port+1) & 0xff; /* read the data register */ } /* print the result */ for (i=0; i<0x19; i++) printf("CRT Register %2d = 0x%02X\n",i,regs[i]); exit(0); }
void thread1(void* dummy) { int i; for (i=0; i<10; i++) { fprintf(stderr,"thread 1(%d): PSW=%04X\n",i,psw()); sleep(1); } fprintf(stderr,"thread 1(%d): Next activation of thread1 will intentionally cause\n",i); fprintf(stderr,"thread 1(%d): a core dump:\n",i); fflush(stderr); sleep(1); /* schedule others again */ fprintf(stderr,"thread 1(%d): PSW=%04X read port=%02X\n", i,psw(),c_inb1(0x3cc)); exit(1); }
int main(int argc,char*argv[]) { int rc; int i; /* warn the user */ fprintf(stderr, "This example will read out VGA registers for demonstration\n"); fprintf(stderr, "of I/O threads.\n"); fprintf(stderr, "If you don't have a VGA or SVGA compatible adapter\n"); fprintf(stderr, "or are not sure, press CTRL-C now. Otherwise\n"); fprintf(stderr, "proceed with RETURN\n"); getchar(); fprintf(stderr, "The example will create three threads, the second of\n"); fprintf(stderr, "which gains I/O privilege via the fastio$ driver\n"); fprintf(stderr, "The others just check whether they have IOPL right\n"); fprintf(stderr, "and suspend. Eventually, thread 1 will try I/O\n"); fprintf(stderr, "without having I/O privilege and crash the program\n"); fprintf(stderr, "This is correct. RETURN to proceed\n"); getchar(); _beginthread(thread1, NULL, 16384, NULL); _beginthread(ioplthread2, NULL, 16384, NULL); while (1) { fprintf(stderr,"thread 3: PSW=%04X\n",psw()); sleep(1); } return 0; }
// ---------------------------------------------------------------------- void SimulationTaskLocalizationEvaluation:: print_ps( const SimulationController& sc, const HeaderInfo& header ) const throw() { std::string fname = sc.environment().optional_string_param( "loc_ps_out", "" ); if ( fname == "" ) return; std::ofstream psout( fname.c_str() ); LocalizationPsWriter psw( psout, false ); std::string info = "Dist: " + header.dist_algo + "; Pos: " + header.pos_algo + "; Ref: " + header.ref_algo; psw.paint_color( sc.world(), info, true ); }