예제 #1
0
/*
 * Get IORB. Wait until available.
 * -> errcode if interrupted.
 */
word
getIORB(ReqPtr p)
{
	int_off();
	while (reqpkt) {
		PUTS(4, "	Waiting for IORB\n");
		++waiting;
		if (Block(paddr_iorb1, Infinite, 1))
			return ERROR+DONE+Interrupted;
		int_off();
	}
	int_on();
	reqpkt = p;
	return 0;
}
예제 #2
0
파일: MAIN_B.C 프로젝트: zzy-driver/usb
main()
{
	int_off();
	t2_ini_load();
	t2_ind = 0;
	int_on();
	P2 = 0xFF;
	while(1)
		{
		if (P2 != 0xFF)
			{
			stsys = 1;
			main_app();
			}
		if (t2_ind == 1)
			{
			t2_ind = 0;
			P3 = 0x00;
			P3 = 0xFF;
			P3 = 0x00;
			P3 = 0xFF;
			P3 = 0x00;
			P3 = 0xFF;
			}
		}
}
예제 #3
0
/********************** upper half rotuine ***********************/
int getc()
{
  u8 c,sr;
  sr = int_off();
    while(kb.data == 0){
      int_on(sr);
        ksleep(&kb.data);
      sr = int_off();
    }

    c = kb.buf[kb.tail++] & 0x7F;
    kb.tail %= KBLEN;
    kb.data--;
  int_on(sr);
  return c;
}
예제 #4
0
static void term_int(int sig)
{
	exit_io();
	int_off();
	tcsetattr(0, TCSADRAIN, &old_term);
	puts("\nKilled by user");
	exit(0);
}
예제 #5
0
/*
 * Call ADD. Wait until done.
 */
void
callADDwait(IORBH *iorb)
{
	iorb->RequestControl |= IORB_ASYNC_POST;
	iorb->NotifyAddress = post;
	callADD(iorb);
	int_off();
	while (!(iorb->Status & IORB_DONE)) {
		PUTS(4, "	Waiting for POST\n");
		if (Block((dword)reqpkt, Infinite, 1)) {
			PUTS(1, "Abort\n");
			abort();
			continue;
		}
		int_off();
	}
	int_on();
}
예제 #6
0
파일: wait.c 프로젝트: thomdabeast/CS460-1
/********************************************************************
Copyright 2010-2015 K.C. Wang, <*****@*****.**>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
********************************************************************/
int ksleep(int event)
{
  int sr = int_off();
  running->status = SLEEP;
  running->event = event;
  // enter sleepList FIFO
  enqueue(&sleepList, running);
  int_on(sr);

  tswitch();
}
예제 #7
0
int P(SEMAPHORE *s)
{
  PROC *p; int ps;
  
  ps=int_off();

   s->value--;
   if (s->value < 0){
      running->status = BLOCK;
      enqueue(&s->queue, running);
   } 
   tswitch();
  int_on(ps);
}
예제 #8
0
파일: serial.c 프로젝트: dqhoang/schoolwork
int P(SEMAPHORE *s)
{
  int sr = int_off(); 

    s->value--;
    if (s->value < 0){
       printf("proc %d blocked in P() at semaphore = %x\n",unning->pid, s);
       running->status = BLOCK;
       enqueue(&s->queue, running);
       tswitch();
    }

    int_on(sr);
}
예제 #9
0
파일: serial.c 프로젝트: dqhoang/schoolwork
int V(SEMAPHORE *s)
{
   PROC *p;
   int sr = int_off();
   
   s->value++;
   if(s->value <= 0)
   {
     p = dequeue(&s->queue);
     p->status = READY;
     enqueue(&readyQueue, p);
     printf("proc %d unblocked in V()\n",p->pid);
   }
}
예제 #10
0
int V(SEMAPHORE *s)
{
  PROC *p; int ps;

  ps=int_off();

    s->value++;
    if (s->value <= 0){
        p = dequeue(&s->queue);
        p->status = READY;
        enqueue(&readyQueue, p);
    }
 int_on(ps);
}
예제 #11
0
파일: wait.c 프로젝트: thomdabeast/CS460-1
int kwakeup(int event)
{
  PROC *p, *q = 0;
  int sr = int_off();

  while(p = dequeue(&sleepList)){
    if (p->event == event){
       p->status = READY;
       enqueue(&readyQueue, p);
       continue;
    }
    enqueue(&q, p);
  }
  sleepList = q;
  int_on(sr);
}
예제 #12
0
파일: Semaphore.c 프로젝트: Cj-muse/Lab8
int V(SEMAPHORE *s)
{
    int sr; PROC *p;
    sr = int_off();

    s->value++;
    if (s->value<=0)
    {
       p = dequeue(&(s->queue));
       p->status = READY;
       p->sem = 0;               // no longer blocked at this semaphore
       enqueue(&readyQueue, p);
       // printf("proc %d unblocked in V()\n", p->pid); 
    }
    int_on(sr);
}
예제 #13
0
파일: pv.c 프로젝트: vonderborch/CS460
int P(struct semaphore *s)
{
    // write YOUR C code for P()
    int dasvalue = int_off();
    
    s->value--; // decrement semaphore value
    
    // if the value is less than 0, add the running process to the waiting queue
    if (s->value < 0)
    {
        running->status = BLOCK;
        enqueue(&s->queue, running);
        tswitch();
    }
    
    int_on(dasvalue);
}
예제 #14
0
파일: pv.c 프로젝트: vonderborch/CS460
int V(struct semaphore *s)
{
    // write YOUR C code for V()
    PROC *p;
    int dasvalue = int_off();
    
    s->value++; // increment semaphore value
    
    // if the value is less than or equal to 0, remove a process from the ready queue and wake it
    if (s->value <= 0)
    {
        p = dequeue(&s->queue);
        p->status = READY;
        enqueue(&readyQueue, p);
    }
    
    int_on(dasvalue);
}
예제 #15
0
int V(SEMAPHORE *s)
{
    int sr;
    PROC *p;
    sr = int_off(); //interrupt off

    s->value++;

    if (s->value<=0){
        p = dequeue(&(s->queue));
        p->status=READY;
        enqueue(&readyQueue, p);
    }
    else{
        //s->lock = 0;
        int_on(sr);
    }
}
예제 #16
0
int P(SEMAPHORE *s)
{
    int sr;

    sr = int_off(); //interrupt off

    s->value--;

    if (s->value < 0){
       running->status = BLOCK;
       enqueue(&(s->queue), running);
       //s->lock = 0;
       tswitch(); //switch proccess
       int_on(sr);
    }
    else{
       //s->lock = 0;
       int_on(sr);
    }
}
예제 #17
0
 static int play_intr (struct INT_DATA *idp)
#endif
{
      int_off ();

#ifndef __ZTC__
      (*n_oldtmint) ();                   /* Call Old timer interrupt.  */
#else
      int_prev(idp);
#endif

      if (play_duration == 0)
      {
            soundoff ();

            if (++n_head == (n_buff + n_buff_sz))
                  n_head = n_buff;

            if (n_head == n_tail)
            {
                  --n_head;
                  int_on ();
                  return;
            }

            play_duration = n_head->duration;
            if (0 != (play_freq = n_head->freq))
                  soundon();
            dosound (play_freq);
      }
      else  --play_duration;

      int_on ();

#ifdef __ZTC__
      return 1;                           /* Don't chain                */
#endif
}
예제 #18
0
int main(int argc, char *argv[])
{
	register char *s, *p;
	register int i;
	char *pn = basename(argv[0]);
	struct timeval tv;
#ifdef HAS_CONFIG
	struct stat sbuf;
#endif
#ifdef BOOTROM
	char *rom = "-r ";
#else
	char *rom = "";
#endif
#ifdef CPU_SPEED
	f_flag = CPU_SPEED;
	tmax = CPU_SPEED * 10000;
#endif

	while (--argc > 0 && (*++argv)[0] == '-')
		for (s = argv[0] + 1; *s != '\0'; s++)

			switch (*s) {
			case 's':	/* save core and CPU on exit */
				s_flag = 1;
				break;

			case 'l':	/* load core and CPU from file */
				l_flag = 1;
				break;

			case 'u':	/* trap undocumented ops */
				u_flag = 1;
				break;

			case 'i':	/* trap I/O on unused ports */
				i_flag = 1;
				break;

			case 'm':	/* initialise Z80 memory */
				if (*(s+1) != '\0') {
					m_flag = exatoi(s+1);
					s += strlen(s+1);
				} else {
					if (argc <= 1)
						goto usage;
					argc--;
					argv++;
					m_flag = exatoi(argv[0]);
				}
				break;

			case 'f':	/* set emulation speed */
				if (*(s+1) != '\0') {
					f_flag = atoi(s+1);
					s += strlen(s+1);
				} else {
					if (argc <= 1)
						goto usage;
					argc--;
					argv++;
					f_flag = atoi(argv[0]);
				}
				tmax = f_flag * 10000;
				break;

			case 'x':	/* get filename with Z80 executable */
				x_flag = 1;
				s++;
				if (*s == '\0') {
					if (argc <= 1)
						goto usage;
					argc--;
					argv++;
					s = argv[0];
				}
				p = xfn;
				while (*s)
					*p++ = *s++;
				*p = '\0';
				s--;
				break;

#ifdef BOOTROM
			case 'r':	/* load default boot ROM */
				x_flag = 1;
				strcpy(xfn, BOOTROM);
				break;
#endif

#ifdef HAS_DISKS
			case 'd':	/* get path for disk images */
				s++;
				if (*s == '\0') {
					if (argc <= 1)
						goto usage;
					argc--;
					argv++;
					s = argv[0];
				}
				p = diskdir = diskd;
				while (*s)
					*p++ = *s++;
				*p = '\0';
				s--;
				break;
#endif

			case '8':
				cpu = I8080;
				break;

			case 'z':
				cpu = Z80;
				break;

			case '?':
			case 'h':
				goto usage;

			default:
				printf("illegal option %c\n", *s);

usage:

#ifdef HAS_DISKS
				printf("usage:\t%s -z -8 -s -l -i -u %s-m val -f freq -x filename -d diskpath\n", pn, rom);
#else
				printf("usage:\t%s -z -8 -s -l -i -u %s-m val -f freq -x filename\n", pn, rom);
#endif
				puts("\t-z = emulate Zilog Z80");
				puts("\t-8 = emulate Intel 8080");
				puts("\t-s = save core and CPU");
				puts("\t-l = load core and CPU");
				puts("\t-i = trap on I/O to unused ports");
				puts("\t-u = trap on undocumented instructions");
#ifdef BOOTROM
				puts("\t-r = load and execute default ROM");
				printf("\t     %s\n", BOOTROM);
#endif
				puts("\t-m = init memory with val (00-FF)");
				puts("\t-f = CPU clock frequency freq in MHz");
				puts("\t-x = load and execute filename");
#ifdef HAS_DISKS
				puts("\t-d = use disks images at diskpath");
				puts("\t     default path for disk images:");
				puts("\t     ./disks");
				printf("\t     %s\n", DISKSDIR);
#endif
				exit(1);
			}

	putchar('\n');

	if (cpu == Z80) {
puts("#######  #####    ###            #####    ###   #     #");
puts("     #  #     #  #   #          #     #    #    ##   ##");
puts("    #   #     # #     #         #          #    # # # #");
puts("   #     #####  #     #  #####   #####     #    #  #  #");
puts("  #     #     # #     #               #    #    #     #");
puts(" #      #     #  #   #          #     #    #    #     #");
puts("#######  #####    ###            #####    ###   #     #");

	} else {

puts(" #####    ###     #####    ###            #####    ###   #     #");
puts("#     #  #   #   #     #  #   #          #     #    #    ##   ##");
puts("#     # #     #  #     # #     #         #          #    # # # #");
puts(" #####  #     #   #####  #     #  #####   #####     #    #  #  #");
puts("#     # #     #  #     # #     #               #    #    #     #");
puts("#     #  #   #   #     #  #   #          #     #    #    #     #");
puts(" #####    ###     #####    ###            #####    ###   #     #");
	}

	printf("\nRelease %s, %s\n", RELEASE, COPYR);

#ifdef	USR_COM
	printf("%s Release %s, %s\n\n", USR_COM, USR_REL, USR_CPR);
#else
	putchar('\n');
#endif
	if (f_flag > 0)
		printf("CPU speed is %d MHz\n", f_flag);
	else
		printf("CPU speed is unlimited\n");

	fflush(stdout);

	/* if the machine has configuration files try to find them */
#ifdef HAS_CONFIG
	/* first try ./conf */
	if ((stat("./conf", &sbuf) == 0) && S_ISDIR(sbuf.st_mode)) {
		strcpy(&confdir[0], "./conf");
	/* then CONFDIR as set in Makefile */
	} else {
		strcpy(&confdir[0], CONFDIR);
	}

	//printf("config = %s\n", &confdir[0]);
#endif

	/* seed random generator */
	gettimeofday(&tv, NULL);
	srand(tv.tv_sec);

	config();		/* read system configuration */
	init_memory();		/* initialise memory configuration */
	init_cpu();		/* initialise CPU */
	wrk_ram	= mem_base();	/* set work pointer for memory */

	/* fill memory content with some initial value */
	if (m_flag >= 0) {
		memset((char *) wrk_ram, m_flag, 65536);
	} else {
		for (i = 0; i < 65536; i++)
			*(wrk_ram + i) = (BYTE) (rand() % 256);
	}

	init_rom();		/* initialise ROM's */

	if (l_flag)		/* load core */
		if (load_core())
			return(1);

	int_on();		/* initialize UNIX interrupts */
	init_io();		/* initialize I/O devices */

	mon();			/* run system */

	if (s_flag)		/* save core */
		save_core();

	exit_io();		/* stop I/O devices */
	int_off();		/* stop UNIX interrupts */

	return(0);
}
예제 #19
0
/*
 *	Call system function from simulator
 */
static void do_unix(char *s)
{
	int_off();
	system(s);
	int_on();
}
예제 #20
0
int main(int argc, char *argv[]) {
    register char *s, *p;
    register char *pn = argv[0];

    // configure the I/O ports
    AD1PCFG = 0xFFFF; // Default all pins to digital
    mJTAGPortEnable(0); // turn off jtag

    // setup the CPU
    SYSTEMConfigPerformance(CLOCKFREQ); // System config performance
    mOSCSetPBDIV(OSC_PB_DIV_1); // fix the peripheral bus to half main clock speed
    INTEnableSystemMultiVectoredInt();

    TRISBbits.TRISB15 = 0;
 //   TRISDbits.TRISD11 = 0;
 //   ODCDbits.ODCD11 = 1;
 //   LATDbits.LATD11=0;

    TRISBbits.TRISB13 = 0;
    ODCBbits.ODCB13 = 1;
    PORTBbits.RB13=0;
#ifdef UARTConsole
    UARTInit();
#endif
    initKeyboard();

#ifdef UseVideo
    initVideo();
#endif



#ifdef CPU_SPEED
    f_flag = CPU_SPEED;
    tmax = CPU_SPEED * 10000;
#endif
    argc = 0;
    while (--argc > 0 && (*++argv)[0] == '-')
        for (s = argv[0] + 1; *s != '\0'; s++)
            switch (*s) {
                case 's': /* save core and CPU on exit */
                    s_flag = 1;
                    break;
                case 'l': /* load core and CPU from file */
                    l_flag = 1;
                    break;
#ifdef Z80_UNDOC
                case 'z': /* trap undocumented Z80 ops */
                    z_flag = 1;
                    break;
#endif
                case 'i': /* trap I/O on unused ports */
                    i_flag = 1;
                    break;
                case 'm': /* initialize Z80 memory */
                    m_flag = exatoi(s + 1);
                    s += strlen(s + 1);
                    break;
                case 'f': /* set emulation speed */
                    f_flag = atoi(s + 1);
                    s += strlen(s + 1);
                    tmax = f_flag * 10000;
                    break;
                case 'x': /* get filename with Z80 executable */
                    x_flag = 1;
                    s++;
                    p = xfn;
                    while (*s)
                        *p++ = *s++;
                    *p = '\0';
                    s--;
                    break;
                case '?':
                    goto usage;
                default:
                    printf("illegal option %c\n", *s);
#ifndef Z80_UNDOC
usage:
                    printf("usage:\t%s -s -l -i -mn -fn -xfilename\n", pn);
#else
usage:
                    printf("usage:\t%s -s -l -i -z -mn -fn -xfilename\n", pn);
#endif
                    puts("\ts = save core and cpu");
                    puts("\tl = load core and cpu");
                    puts("\ti = trap on I/O to unused ports");
#ifdef Z80_UNDOC
                    puts("\tz = trap on undocumented Z80 ops");
#endif
                    puts("\tm = init memory with n");
                    puts("\tf = CPU frequenzy n in MHz");
                    puts("\tx = load and execute filename");
                    exit(1);
            }

    putchar('\n');
    puts("#######  #####    ###            #####    ###   #     #");
    puts("     #  #     #  #   #          #     #    #    ##   ##");
    puts("    #   #     # #     #         #          #    # # # #");
    puts("   #     #####  #     #  #####   #####     #    #  #  #");
    puts("  #     #     # #     #               #    #    #     #");
    puts(" #      #     #  #   #          #     #    #    #     #");
    puts("#######  #####    ###            #####    ###   #     #");
    printf("\nRelease %s, %s\n", RELEASE, COPYR);
    printf("\nPort to PIC32 By kenseglerdesigns.com\n");
    if (f_flag > 0)
        printf("\nCPU speed is %d MHz\n", f_flag);
    else
        printf("\nCPU speed is unlimited\n");
#ifdef	USR_COM
    printf("\n%s Release %s, %s\n", USR_COM, USR_REL, USR_CPR);
#endif
    fflush(stdout);

    wrk_ram = PC = ram;
    STACK = ram +0xffff;
    memset((char *) ram, m_flag, 65536);
    if (l_flag)
        if (load_core())
            return (1);
    int_on();
    init_io();
    mon();
    if (s_flag)
        save_core();
    exit_io();
    int_off();
    return (0);
}