コード例 #1
0
ファイル: miniwindow.c プロジェクト: dvincent/frontier
static boolean minikeystroke (void) {
	
	/*
	7/23/90 DW: improve demo-ability.  if the user is still holding down the
	enter key, we instruct miniiconhit not to use the delay he does to improve
	the animation of the run icon.  this allows us to show how fast the compiler
	and interpreter are by holding down the enter key.
	*/
	
	register char chkb = keyboardstatus.chkb;
	
	minicheckselectall (); /*if a selectall is pending, do it now*/
	
	if (chkb == chenter) { /*if enter key is down, don't delay*/
		
		miniiconhit (!keyboardstatus.flautokey);
		
		return (true);
		}
	
	if (chkb == chtab)
		miniselectnexttextitem ();
	else {
		
		if (minisetactivewpglobals ())
			wpkeystroke ();
		else
			sysbeep ();
		}
	
	return (true);
	} /*minikeystroke*/
コード例 #2
0
ファイル: vt_core.c プロジェクト: ChristosKa/freebsd
static void
vtterm_bell(struct terminal *tm)
{
	struct vt_window *vw = tm->tm_softc;
	struct vt_device *vd = vw->vw_device;

	if (vd->vd_flags & VDF_QUIET_BELL)
		return;

	sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION);
}
コード例 #3
0
ファイル: about.c プロジェクト: pombredanne/Frontier
static boolean aboutmousedown (Point pt, tyclickflags flags) {
#pragma unused (flags)

	/*
	1/24/91 dmb: to allow the home window to be dragged with a single click, 
	even when it's not already the front window, the dontconsumefrontclicks 
	flag is set in its config.  in order to avoid reacting to button clicks 
	or clicks in the close box or on the flag (which aren't even visiable when 
	the window is inactive), we test to make sure that the window has been 
	activated before considering taking any special actions.
	*/
	
	hdlaboutrecord hc = aboutdata;
	Rect r;
	
	ccunblockmsg (); /*any mouse click re-enables background messages*/
	
	if ((**hc).flbigwindow) {
		
		if (ccgettextitemrect (urlitem, &r) && pointinrect (pt, r)) {
			
			if (trackicon (r, &ccdrawurlitem))
				if (!ccrunurlscript ())
					sysbeep ();
			
			return (true);
			}
		}

	if (ccgetagentpopuprect (&r)) { /*see if click is in agents popup*/
		
		if (pointinrect (pt, r)) { /*click in agents popup*/
			
			--r.top;
			
			if (ccagentpopuphit (r, pt))
				ccdrawagentpopup ();
			
			return (true);
			}
		}
	
	return (true);
	} /*aboutmousedown*/
コード例 #4
0
ファイル: tablewindow.c プロジェクト: dvincent/frontier
static void tableedittabkey () {
	
	short col = (**tableformatsdata).editcol;
	
	if (keyboardstatus.flshiftkey)
		--col;
	else
		++col;
	
	if (tablecelliseditable ((**outlinedata).hbarcursor, col)) {
		
		(**tableformatsdata).focuscol = col;
		
		opunloadeditbuffer ();
		
		oploadeditbuffer ();
		
		opeditselectall ();
		}
	else
		sysbeep ();
	} /*tableedittabkey*/
コード例 #5
0
void
trap(struct trapframe *frame)
{
	struct thread *td = curthread;
	struct proc *p = td->td_proc;
	int i = 0, ucode = 0, code;
	u_int type;
	register_t addr = 0;
	vm_offset_t eva;
	ksiginfo_t ksi;
#ifdef POWERFAIL_NMI
	static int lastalert = 0;
#endif

	PCPU_INC(cnt.v_trap);
	type = frame->tf_trapno;

#ifdef SMP
	/* Handler for NMI IPIs used for stopping CPUs. */
	if (type == T_NMI) {
	         if (ipi_nmi_handler() == 0)
	                   goto out;
	}
#endif /* SMP */

#ifdef KDB
	if (kdb_active) {
		kdb_reenter();
		goto out;
	}
#endif

	if (type == T_RESERVED) {
		trap_fatal(frame, 0);
		goto out;
	}

#ifdef	HWPMC_HOOKS
	/*
	 * CPU PMCs interrupt using an NMI so we check for that first.
	 * If the HWPMC module is active, 'pmc_hook' will point to
	 * the function to be called.  A return value of '1' from the
	 * hook means that the NMI was handled by it and that we can
	 * return immediately.
	 */
	if (type == T_NMI && pmc_intr &&
	    (*pmc_intr)(PCPU_GET(cpuid), frame))
	    goto out;
#endif

	if (type == T_MCHK) {
		if (!mca_intr())
			trap_fatal(frame, 0);
		goto out;
	}

#ifdef KDTRACE_HOOKS
	/*
	 * A trap can occur while DTrace executes a probe. Before
	 * executing the probe, DTrace blocks re-scheduling and sets
	 * a flag in it's per-cpu flags to indicate that it doesn't
	 * want to fault. On returning from the probe, the no-fault
	 * flag is cleared and finally re-scheduling is enabled.
	 *
	 * If the DTrace kernel module has registered a trap handler,
	 * call it and if it returns non-zero, assume that it has
	 * handled the trap and modified the trap frame so that this
	 * function can return normally.
	 */
	if ((type == T_PROTFLT || type == T_PAGEFLT) &&
	    dtrace_trap_func != NULL)
		if ((*dtrace_trap_func)(frame, type))
			goto out;
	if (type == T_DTRACE_PROBE || type == T_DTRACE_RET ||
	    type == T_BPTFLT) {
		struct reg regs;

		fill_frame_regs(frame, &regs);
		if (type == T_DTRACE_PROBE &&
		    dtrace_fasttrap_probe_ptr != NULL &&
		    dtrace_fasttrap_probe_ptr(&regs) == 0)
			goto out;
		if (type == T_BPTFLT &&
		    dtrace_pid_probe_ptr != NULL &&
		    dtrace_pid_probe_ptr(&regs) == 0)
			goto out;
		if (type == T_DTRACE_RET &&
		    dtrace_return_probe_ptr != NULL &&
		    dtrace_return_probe_ptr(&regs) == 0)
			goto out;
	}
#endif

	if ((frame->tf_eflags & PSL_I) == 0) {
		/*
		 * Buggy application or kernel code has disabled
		 * interrupts and then trapped.  Enabling interrupts
		 * now is wrong, but it is better than running with
		 * interrupts disabled until they are accidentally
		 * enabled later.
		 */
		if (ISPL(frame->tf_cs) == SEL_UPL || (frame->tf_eflags & PSL_VM))
			uprintf(
			    "pid %ld (%s): trap %d with interrupts disabled\n",
			    (long)curproc->p_pid, curthread->td_name, type);
		else if (type != T_BPTFLT && type != T_TRCTRAP &&
			 frame->tf_eip != (int)cpu_switch_load_gs) {
			/*
			 * XXX not quite right, since this may be for a
			 * multiple fault in user mode.
			 */
			printf("kernel trap %d with interrupts disabled\n",
			    type);
			/*
			 * Page faults need interrupts disabled until later,
			 * and we shouldn't enable interrupts while holding
			 * a spin lock or if servicing an NMI.
			 */
			if (type != T_NMI && type != T_PAGEFLT &&
			    td->td_md.md_spinlock_count == 0)
				enable_intr();
		}
	}
	eva = 0;
	code = frame->tf_err;
	if (type == T_PAGEFLT) {
		/*
		 * For some Cyrix CPUs, %cr2 is clobbered by
		 * interrupts.  This problem is worked around by using
		 * an interrupt gate for the pagefault handler.  We
		 * are finally ready to read %cr2 and then must
		 * reenable interrupts.
		 *
		 * If we get a page fault while in a critical section, then
		 * it is most likely a fatal kernel page fault.  The kernel
		 * is already going to panic trying to get a sleep lock to
		 * do the VM lookup, so just consider it a fatal trap so the
		 * kernel can print out a useful trap message and even get
		 * to the debugger.
		 *
		 * If we get a page fault while holding a non-sleepable
		 * lock, then it is most likely a fatal kernel page fault.
		 * If WITNESS is enabled, then it's going to whine about
		 * bogus LORs with various VM locks, so just skip to the
		 * fatal trap handling directly.
		 */
		eva = rcr2();
		if (td->td_critnest != 0 ||
		    WITNESS_CHECK(WARN_SLEEPOK | WARN_GIANTOK, NULL,
		    "Kernel page fault") != 0)
			trap_fatal(frame, eva);
		else
			enable_intr();
	}

        if ((ISPL(frame->tf_cs) == SEL_UPL) ||
	    ((frame->tf_eflags & PSL_VM) && 
		!(PCPU_GET(curpcb)->pcb_flags & PCB_VM86CALL))) {
		/* user trap */

		td->td_pticks = 0;
		td->td_frame = frame;
		addr = frame->tf_eip;
		if (td->td_ucred != p->p_ucred) 
			cred_update_thread(td);

		switch (type) {
		case T_PRIVINFLT:	/* privileged instruction fault */
			i = SIGILL;
			ucode = ILL_PRVOPC;
			break;

		case T_BPTFLT:		/* bpt instruction fault */
		case T_TRCTRAP:		/* trace trap */
			enable_intr();
			frame->tf_eflags &= ~PSL_T;
			i = SIGTRAP;
			ucode = (type == T_TRCTRAP ? TRAP_TRACE : TRAP_BRKPT);
			break;

		case T_ARITHTRAP:	/* arithmetic trap */
#ifdef DEV_NPX
			ucode = npxtrap();
			if (ucode == -1)
				goto userout;
#else
			ucode = 0;
#endif
			i = SIGFPE;
			break;

			/*
			 * The following two traps can happen in
			 * vm86 mode, and, if so, we want to handle
			 * them specially.
			 */
		case T_PROTFLT:		/* general protection fault */
		case T_STKFLT:		/* stack fault */
			if (frame->tf_eflags & PSL_VM) {
				i = vm86_emulate((struct vm86frame *)frame);
				if (i == 0)
					goto user;
				break;
			}
			i = SIGBUS;
			ucode = (type == T_PROTFLT) ? BUS_OBJERR : BUS_ADRERR;
			break;
		case T_SEGNPFLT:	/* segment not present fault */
			i = SIGBUS;
			ucode = BUS_ADRERR;
			break;
		case T_TSSFLT:		/* invalid TSS fault */
			i = SIGBUS;
			ucode = BUS_OBJERR;
			break;
		case T_DOUBLEFLT:	/* double fault */
		default:
			i = SIGBUS;
			ucode = BUS_OBJERR;
			break;

		case T_PAGEFLT:		/* page fault */

			i = trap_pfault(frame, TRUE, eva);
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
			if (i == -2) {
				/*
				 * The f00f hack workaround has triggered, so
				 * treat the fault as an illegal instruction 
				 * (T_PRIVINFLT) instead of a page fault.
				 */
				type = frame->tf_trapno = T_PRIVINFLT;

				/* Proceed as in that case. */
				ucode = ILL_PRVOPC;
				i = SIGILL;
				break;
			}
#endif
			if (i == -1)
				goto userout;
			if (i == 0)
				goto user;

			if (i == SIGSEGV)
				ucode = SEGV_MAPERR;
			else {
				if (prot_fault_translation == 0) {
					/*
					 * Autodetect.
					 * This check also covers the images
					 * without the ABI-tag ELF note.
					 */
					if (SV_CURPROC_ABI() == SV_ABI_FREEBSD
					    && p->p_osrel >= P_OSREL_SIGSEGV) {
						i = SIGSEGV;
						ucode = SEGV_ACCERR;
					} else {
						i = SIGBUS;
						ucode = BUS_PAGE_FAULT;
					}
				} else if (prot_fault_translation == 1) {
					/*
					 * Always compat mode.
					 */
					i = SIGBUS;
					ucode = BUS_PAGE_FAULT;
				} else {
					/*
					 * Always SIGSEGV mode.
					 */
					i = SIGSEGV;
					ucode = SEGV_ACCERR;
				}
			}
			addr = eva;
			break;

		case T_DIVIDE:		/* integer divide fault */
			ucode = FPE_INTDIV;
			i = SIGFPE;
			break;

#ifdef DEV_ISA
		case T_NMI:
#ifdef POWERFAIL_NMI
#ifndef TIMER_FREQ
#  define TIMER_FREQ 1193182
#endif
			if (time_second - lastalert > 10) {
				log(LOG_WARNING, "NMI: power fail\n");
				sysbeep(880, hz);
				lastalert = time_second;
			}
			goto userout;
#else /* !POWERFAIL_NMI */
			/* machine/parity/power fail/"kitchen sink" faults */
			if (isa_nmi(code) == 0) {
#ifdef KDB
				/*
				 * NMI can be hooked up to a pushbutton
				 * for debugging.
				 */
				if (kdb_on_nmi) {
					printf ("NMI ... going to debugger\n");
					kdb_trap(type, 0, frame);
				}
#endif /* KDB */
				goto userout;
			} else if (panic_on_nmi)
				panic("NMI indicates hardware failure");
			break;
#endif /* POWERFAIL_NMI */
#endif /* DEV_ISA */

		case T_OFLOW:		/* integer overflow fault */
			ucode = FPE_INTOVF;
			i = SIGFPE;
			break;

		case T_BOUND:		/* bounds check fault */
			ucode = FPE_FLTSUB;
			i = SIGFPE;
			break;

		case T_DNA:
#ifdef DEV_NPX
			KASSERT(PCB_USER_FPU(td->td_pcb),
			    ("kernel FPU ctx has leaked"));
			/* transparent fault (due to context switch "late") */
			if (npxdna())
				goto userout;
#endif
			uprintf("pid %d killed due to lack of floating point\n",
				p->p_pid);
			i = SIGKILL;
			ucode = 0;
			break;

		case T_FPOPFLT:		/* FPU operand fetch fault */
			ucode = ILL_COPROC;
			i = SIGILL;
			break;

		case T_XMMFLT:		/* SIMD floating-point exception */
			ucode = 0; /* XXX */
			i = SIGFPE;
			break;
		}
	} else {
		/* kernel trap */

		KASSERT(cold || td->td_ucred != NULL,
		    ("kernel trap doesn't have ucred"));
		switch (type) {
		case T_PAGEFLT:			/* page fault */
			(void) trap_pfault(frame, FALSE, eva);
			goto out;

		case T_DNA:
#ifdef DEV_NPX
			KASSERT(!PCB_USER_FPU(td->td_pcb),
			    ("Unregistered use of FPU in kernel"));
			if (npxdna())
				goto out;
#endif
			break;

		case T_ARITHTRAP:	/* arithmetic trap */
		case T_XMMFLT:		/* SIMD floating-point exception */
		case T_FPOPFLT:		/* FPU operand fetch fault */
			/*
			 * XXXKIB for now disable any FPU traps in kernel
			 * handler registration seems to be overkill
			 */
			trap_fatal(frame, 0);
			goto out;

			/*
			 * The following two traps can happen in
			 * vm86 mode, and, if so, we want to handle
			 * them specially.
			 */
		case T_PROTFLT:		/* general protection fault */
		case T_STKFLT:		/* stack fault */
			if (frame->tf_eflags & PSL_VM) {
				i = vm86_emulate((struct vm86frame *)frame);
				if (i != 0)
					/*
					 * returns to original process
					 */
					vm86_trap((struct vm86frame *)frame);
				goto out;
			}
			if (type == T_STKFLT)
				break;

			/* FALL THROUGH */

		case T_SEGNPFLT:	/* segment not present fault */
			if (PCPU_GET(curpcb)->pcb_flags & PCB_VM86CALL)
				break;

			/*
			 * Invalid %fs's and %gs's can be created using
			 * procfs or PT_SETREGS or by invalidating the
			 * underlying LDT entry.  This causes a fault
			 * in kernel mode when the kernel attempts to
			 * switch contexts.  Lose the bad context
			 * (XXX) so that we can continue, and generate
			 * a signal.
			 */
			if (frame->tf_eip == (int)cpu_switch_load_gs) {
				PCPU_GET(curpcb)->pcb_gs = 0;
#if 0				
				PROC_LOCK(p);
				kern_psignal(p, SIGBUS);
				PROC_UNLOCK(p);
#endif				
				goto out;
			}

			if (td->td_intr_nesting_level != 0)
				break;

			/*
			 * Invalid segment selectors and out of bounds
			 * %eip's and %esp's can be set up in user mode.
			 * This causes a fault in kernel mode when the
			 * kernel tries to return to user mode.  We want
			 * to get this fault so that we can fix the
			 * problem here and not have to check all the
			 * selectors and pointers when the user changes
			 * them.
			 */
			if (frame->tf_eip == (int)doreti_iret) {
				frame->tf_eip = (int)doreti_iret_fault;
				goto out;
			}
			if (frame->tf_eip == (int)doreti_popl_ds) {
				frame->tf_eip = (int)doreti_popl_ds_fault;
				goto out;
			}
			if (frame->tf_eip == (int)doreti_popl_es) {
				frame->tf_eip = (int)doreti_popl_es_fault;
				goto out;
			}
			if (frame->tf_eip == (int)doreti_popl_fs) {
				frame->tf_eip = (int)doreti_popl_fs_fault;
				goto out;
			}
			if (PCPU_GET(curpcb)->pcb_onfault != NULL) {
				frame->tf_eip =
				    (int)PCPU_GET(curpcb)->pcb_onfault;
				goto out;
			}
			break;

		case T_TSSFLT:
			/*
			 * PSL_NT can be set in user mode and isn't cleared
			 * automatically when the kernel is entered.  This
			 * causes a TSS fault when the kernel attempts to
			 * `iret' because the TSS link is uninitialized.  We
			 * want to get this fault so that we can fix the
			 * problem here and not every time the kernel is
			 * entered.
			 */
			if (frame->tf_eflags & PSL_NT) {
				frame->tf_eflags &= ~PSL_NT;
				goto out;
			}
			break;

		case T_TRCTRAP:	 /* trace trap */
			if (frame->tf_eip == (int)IDTVEC(lcall_syscall)) {
				/*
				 * We've just entered system mode via the
				 * syscall lcall.  Continue single stepping
				 * silently until the syscall handler has
				 * saved the flags.
				 */
				goto out;
			}
			if (frame->tf_eip == (int)IDTVEC(lcall_syscall) + 1) {
				/*
				 * The syscall handler has now saved the
				 * flags.  Stop single stepping it.
				 */
				frame->tf_eflags &= ~PSL_T;
				goto out;
			}
			/*
			 * Ignore debug register trace traps due to
			 * accesses in the user's address space, which
			 * can happen under several conditions such as
			 * if a user sets a watchpoint on a buffer and
			 * then passes that buffer to a system call.
			 * We still want to get TRCTRAPS for addresses
			 * in kernel space because that is useful when
			 * debugging the kernel.
			 */
			if (user_dbreg_trap() && 
			   !(PCPU_GET(curpcb)->pcb_flags & PCB_VM86CALL)) {
				/*
				 * Reset breakpoint bits because the
				 * processor doesn't
				 */
				load_dr6(rdr6() & 0xfffffff0);
				goto out;
			}
			/*
			 * FALLTHROUGH (TRCTRAP kernel mode, kernel address)
			 */
		case T_BPTFLT:
			/*
			 * If KDB is enabled, let it handle the debugger trap.
			 * Otherwise, debugger traps "can't happen".
			 */
#ifdef KDB
			if (kdb_trap(type, 0, frame))
				goto out;
#endif
			break;

#ifdef DEV_ISA
		case T_NMI:
#ifdef POWERFAIL_NMI
			if (time_second - lastalert > 10) {
				log(LOG_WARNING, "NMI: power fail\n");
				sysbeep(880, hz);
				lastalert = time_second;
			}
			goto out;
#else /* !POWERFAIL_NMI */
			/* machine/parity/power fail/"kitchen sink" faults */
			if (isa_nmi(code) == 0) {
#ifdef KDB
				/*
				 * NMI can be hooked up to a pushbutton
				 * for debugging.
				 */
				if (kdb_on_nmi) {
					printf ("NMI ... going to debugger\n");
					kdb_trap(type, 0, frame);
				}
#endif /* KDB */
				goto out;
			} else if (panic_on_nmi == 0)
				goto out;
			/* FALLTHROUGH */
#endif /* POWERFAIL_NMI */
#endif /* DEV_ISA */
		}

		trap_fatal(frame, eva);
		goto out;
	}

	/* Translate fault for emulators (e.g. Linux) */
	if (*p->p_sysent->sv_transtrap)
		i = (*p->p_sysent->sv_transtrap)(i, type);

	ksiginfo_init_trap(&ksi);
	ksi.ksi_signo = i;
	ksi.ksi_code = ucode;
	ksi.ksi_addr = (void *)addr;
	ksi.ksi_trapno = type;
	trapsignal(td, &ksi);

#ifdef DEBUG
	if (type <= MAX_TRAP_MSG) {
		uprintf("fatal process exception: %s",
			trap_msg[type]);
		if ((type == T_PAGEFLT) || (type == T_PROTFLT))
			uprintf(", fault VA = 0x%lx", (u_long)eva);
		uprintf("\n");
	}
#endif

user:
	userret(td, frame);
	mtx_assert(&Giant, MA_NOTOWNED);
	KASSERT(PCB_USER_FPU(td->td_pcb),
	    ("Return from trap with kernel FPU ctx leaked"));
userout:
out:
	return;
}
コード例 #6
0
ファイル: tableedit.c プロジェクト: pombredanne/Frontier
boolean tablegetwpedittext (hdlheadrecord hnode, boolean flunload) {
	
	/*
	2/7/97 dmb: adapted from tableeditleavecell
	
	called when some action implies that the user is finished editing the cell.
	
	we attempt to save off the new value, or new name, potentially causing an 
	error if there was a duplicate name, or something bad about the value.
	*/
	
	hdltableformats hc = tableformatsdata;
	short col = (**hc).editcol;
	tybrowserspec fs;
	tyvaluerecord val;
	bigstring bstext;
	boolean fl = false;
	Handle htext;
	tyvaluerecord newval;
	Handle x;
	hdlhashtable ht;
	boolean flmustexit;
	hdlhashnode hhashnode;
	
	//assert (hnode == (**hc).editnode);
	
	flmustexit = false; // ***flmustexiteditmode;
	
	if (!wpgettexthandle (&htext))
		return (false);
	
	texthandletostring (htext, bstext);
	
	if (!claygetfilespec (hnode, &fs)) { // a new node
		
		assert (col == namecolumn);
		}
	else {

		ht = fs.parID;
		
		if (!hashtablesymbolexists (ht, fs.name)) { /*node is gone!*/
			
			fl = true;
			
			goto exit;
			}
		}
	
	if (col == namecolumn) {
		
		if (isemptystring (bstext)) /*name wasn't changed; undo will be bogus*/
			killundo ();
		else
			fl = opsetheadstring (hnode, bstext); // must do first so we can 
		
		goto exit;
		}
	
	/*we were editing a value - run a script to do the assignment*/
	
	assert (col == valuecolumn);
	
	flmustexit = true; /*don't want to stick in edit mode w/out error dialogs*/
	
	if (equalhandles (htext, (**hc).editval)) { /*no change*/
	
		fl = true;
		
		goto exit;
		}
	
	if (!claylookupvalue (&fs, &val, &hhashnode))
		goto exit;
	
	if (isemptystring (bstext) && (val.valuetype != novaluetype) && (val.valuetype != stringvaluetype)) {
		
		fl = true;
		
		goto exit;
		}
	
	if (val.valuetype == binaryvaluetype) {
	
		OSType binarytype = getbinarytypeid (val.data.binaryvalue);
		Handle hbytes;
		
		if (!hextobytes (htext, &hbytes))
			goto exit;
		
		if (!setbinaryvalue (hbytes, binarytype, &newval))
			goto exit;
		
		if (hashtableassign (ht, fs.name, newval)) {
			
			exemptfromtmpstack (&newval);
			
			fl = true;
			}
		
		goto exit;
		}
	
	if (!copyhandle (htext, &x))
		goto exit;
	
	tablepushcontext (ht, val.valuetype);
	
	disablelangerror ();
	
	shellblockevents (); /*don't want backgrounding during assignment*/
	
	#ifdef version5orgreater
	
		if (langrun (x, &newval) && (newval.valuetype != externalvaluetype) && !isemptystring (bstext))
			disposehandle (htext);
		
		else {
			if (val.valuetype != stringvaluetype && !isemptystring (bstext)) {
			
				byte ch = chdoublequote;
				
				if (copyhandle (htext, &x)) { /*2.1b2: try again, with quotes*/
					
					insertinhandle (x, 0, &ch, 1);
					
					enlargehandle (x, 1, &ch);
					
					if (langrun (x, &newval) && (newval.valuetype != externalvaluetype)) {
						
						disposehandle (htext);
						
						htext = nil;
						}
					}
				}
			
			if (htext != nil)
				setheapvalue (htext, stringvaluetype, &newval);
			}
	#else
	
		if (langrun (x, &newval) && (newval.valuetype != externalvaluetype) && !isemptystring (bstext))
			disposehandle (htext);
		
		else {
			byte ch = chdoublequote;
			
			if (copyhandle (htext, &x)) { /*2.1b2: try again, with quotes*/
				
				insertinhandle (x, 0, &ch, 1);
				
				enlargehandle (x, 1, &ch);
				
				if (langrun (x, &newval) && (newval.valuetype != externalvaluetype) && !isemptystring (bstext)) {
					
					disposehandle (htext);
					
					htext = nil;
					}
				}
			
			if (htext != nil)
				setheapvalue (htext, stringvaluetype, &newval);
			}
	#endif
	
	htext = nil; /*it's been consumed, one way or another*/
	
	shellpopevents ();
	
	if ((val.valuetype == novaluetype) || coercevalue (&newval, val.valuetype)) {
		
		if (hashtableassign (ht, fs.name, newval)) {
			
			exemptfromtmpstack (&newval);
			
			fl = true;
			}
		}
	
	enablelangerror ();
	
	if (!fl) {
		
		sysbeep ();
		
		/*disposevaluerecord (newval, false);*/
		
		cleartmpstack ();
		}
	
	tablepopcontext (ht, val.valuetype);
	
	exit:
	
	disposehandle (htext);
	
	if (flunload) { /*exiting edit mode*/
		
		disposehandle ((**hc).editval);
		
		(**hc).editval = nil;
		
		(**hc).editnode = nil;
		}
	
	return (fl);
	} /*tablegetwpedittext*/
コード例 #7
0
ファイル: trap.c プロジェクト: mihaicarabas/dragonfly
void
trap(struct trapframe *frame)
{
	struct globaldata *gd = mycpu;
	struct thread *td = gd->gd_curthread;
	struct lwp *lp = td->td_lwp;
	struct proc *p;
	int sticks = 0;
	int i = 0, ucode = 0, type, code;
	int have_mplock = 0;
#ifdef INVARIANTS
	int crit_count = td->td_critcount;
	lwkt_tokref_t curstop = td->td_toks_stop;
#endif
	vm_offset_t eva;

	p = td->td_proc;
#ifdef DDB
	/*
	 * We need to allow T_DNA faults when the debugger is active since
	 * some dumping paths do large bcopy() which use the floating
	 * point registers for faster copying.
	 */
	if (db_active && frame->tf_trapno != T_DNA) {
		eva = (frame->tf_trapno == T_PAGEFLT ? rcr2() : 0);
		++gd->gd_trap_nesting_level;
		MAKEMPSAFE(have_mplock);
		trap_fatal(frame, eva);
		--gd->gd_trap_nesting_level;
		goto out2;
	}
#endif

	eva = 0;
	++gd->gd_trap_nesting_level;
	if (frame->tf_trapno == T_PAGEFLT) {
		/*
		 * For some Cyrix CPUs, %cr2 is clobbered by interrupts.
		 * This problem is worked around by using an interrupt
		 * gate for the pagefault handler.  We are finally ready
		 * to read %cr2 and then must reenable interrupts.
		 *
		 * XXX this should be in the switch statement, but the
		 * NO_FOOF_HACK and VM86 goto and ifdefs obfuscate the
		 * flow of control too much for this to be obviously
		 * correct.
		 */
		eva = rcr2();
		cpu_enable_intr();
	}

	--gd->gd_trap_nesting_level;

	if (!(frame->tf_eflags & PSL_I)) {
		/*
		 * Buggy application or kernel code has disabled interrupts
		 * and then trapped.  Enabling interrupts now is wrong, but
		 * it is better than running with interrupts disabled until
		 * they are accidentally enabled later.
		 */
		type = frame->tf_trapno;
		if (ISPL(frame->tf_cs)==SEL_UPL || (frame->tf_eflags & PSL_VM)) {
			MAKEMPSAFE(have_mplock);
			kprintf(
			    "pid %ld (%s): trap %d with interrupts disabled\n",
			    (long)curproc->p_pid, curproc->p_comm, type);
		} else if (type != T_BPTFLT && type != T_TRCTRAP) {
			/*
			 * XXX not quite right, since this may be for a
			 * multiple fault in user mode.
			 */
			MAKEMPSAFE(have_mplock);
			kprintf("kernel trap %d with interrupts disabled\n",
			    type);
		}
		cpu_enable_intr();
	}

#if defined(I586_CPU) && !defined(NO_F00F_HACK)
restart:
#endif
	type = frame->tf_trapno;
	code = frame->tf_err;

	if (in_vm86call) {
		if (frame->tf_eflags & PSL_VM &&
		    (type == T_PROTFLT || type == T_STKFLT)) {
			KKASSERT(get_mplock_count(curthread) > 0);
			i = vm86_emulate((struct vm86frame *)frame);
			KKASSERT(get_mplock_count(curthread) > 0);
			if (i != 0) {
				/*
				 * returns to original process
				 */
				vm86_trap((struct vm86frame *)frame,
					  have_mplock);
				KKASSERT(0); /* NOT REACHED */
			}
			goto out2;
		}
		switch (type) {
			/*
			 * these traps want either a process context, or
			 * assume a normal userspace trap.
			 */
		case T_PROTFLT:
		case T_SEGNPFLT:
			trap_fatal(frame, eva);
			goto out2;
		case T_TRCTRAP:
			type = T_BPTFLT;	/* kernel breakpoint */
			/* FALL THROUGH */
		}
		goto kernel_trap;	/* normal kernel trap handling */
	}

        if ((ISPL(frame->tf_cs) == SEL_UPL) || (frame->tf_eflags & PSL_VM)) {
		/* user trap */

		KTR_LOG(kernentry_trap, p->p_pid, lp->lwp_tid,
			frame->tf_trapno, eva);

		userenter(td, p);

		sticks = (int)td->td_sticks;
		lp->lwp_md.md_regs = frame;

		switch (type) {
		case T_PRIVINFLT:	/* privileged instruction fault */
			i = SIGILL;
			ucode = ILL_PRVOPC;
			break;

		case T_BPTFLT:		/* bpt instruction fault */
		case T_TRCTRAP:		/* trace trap */
			frame->tf_eflags &= ~PSL_T;
			i = SIGTRAP;
			ucode = (type == T_TRCTRAP ? TRAP_TRACE : TRAP_BRKPT);
			break;

		case T_ARITHTRAP:	/* arithmetic trap */
			ucode = code;
			i = SIGFPE;
			break;

		case T_ASTFLT:		/* Allow process switch */
			mycpu->gd_cnt.v_soft++;
			if (mycpu->gd_reqflags & RQF_AST_OWEUPC) {
				atomic_clear_int(&mycpu->gd_reqflags,
						 RQF_AST_OWEUPC);
				addupc_task(p, p->p_prof.pr_addr,
					    p->p_prof.pr_ticks);
			}
			goto out;

			/*
			 * The following two traps can happen in
			 * vm86 mode, and, if so, we want to handle
			 * them specially.
			 */
		case T_PROTFLT:		/* general protection fault */
		case T_STKFLT:		/* stack fault */
			if (frame->tf_eflags & PSL_VM) {
				i = vm86_emulate((struct vm86frame *)frame);
				if (i == 0)
					goto out;
				break;
			}
			i = SIGBUS;
			ucode = (type == T_PROTFLT) ? BUS_OBJERR : BUS_ADRERR;
			break;
		case T_SEGNPFLT:	/* segment not present fault */
			i = SIGBUS;
			ucode = BUS_ADRERR;
			break;
		case T_TSSFLT:		/* invalid TSS fault */
		case T_DOUBLEFLT:	/* double fault */
		default:
			i = SIGBUS;
			ucode = BUS_OBJERR;
			break;

		case T_PAGEFLT:		/* page fault */
			i = trap_pfault(frame, TRUE, eva);
			if (i == -1)
				goto out;
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
			if (i == -2)
				goto restart;
#endif
			if (i == 0)
				goto out;

			if (i == SIGSEGV)
				ucode = SEGV_MAPERR;
			else {
				i = SIGSEGV;
				ucode = SEGV_ACCERR;
			}
			break;

		case T_DIVIDE:		/* integer divide fault */
			ucode = FPE_INTDIV;
			i = SIGFPE;
			break;

#if NISA > 0
		case T_NMI:
			MAKEMPSAFE(have_mplock);
#ifdef POWERFAIL_NMI
			goto handle_powerfail;
#else /* !POWERFAIL_NMI */
			/* machine/parity/power fail/"kitchen sink" faults */
			if (isa_nmi(code) == 0) {
#ifdef DDB
				/*
				 * NMI can be hooked up to a pushbutton
				 * for debugging.
				 */
				if (ddb_on_nmi) {
					kprintf ("NMI ... going to debugger\n");
					kdb_trap (type, 0, frame);
				}
#endif /* DDB */
				goto out2;
			} else if (panic_on_nmi)
				panic("NMI indicates hardware failure");
			break;
#endif /* POWERFAIL_NMI */
#endif /* NISA > 0 */

		case T_OFLOW:		/* integer overflow fault */
			ucode = FPE_INTOVF;
			i = SIGFPE;
			break;

		case T_BOUND:		/* bounds check fault */
			ucode = FPE_FLTSUB;
			i = SIGFPE;
			break;

		case T_DNA:
			/*
			 * Virtual kernel intercept - pass the DNA exception
			 * to the virtual kernel if it asked to handle it.
			 * This occurs when the virtual kernel is holding
			 * onto the FP context for a different emulated
			 * process then the one currently running.
			 *
			 * We must still call npxdna() since we may have
			 * saved FP state that the virtual kernel needs
			 * to hand over to a different emulated process.
			 */
			if (lp->lwp_vkernel && lp->lwp_vkernel->ve &&
			    (td->td_pcb->pcb_flags & FP_VIRTFP)
			) {
				npxdna();
				break;
			}

#if NNPX > 0
			/* 
			 * The kernel may have switched out the FP unit's
			 * state, causing the user process to take a fault
			 * when it tries to use the FP unit.  Restore the
			 * state here
			 */
			if (npxdna())
				goto out;
#endif
			if (!pmath_emulate) {
				i = SIGFPE;
				ucode = FPE_FPU_NP_TRAP;
				break;
			}
			i = (*pmath_emulate)(frame);
			if (i == 0) {
				if (!(frame->tf_eflags & PSL_T))
					goto out2;
				frame->tf_eflags &= ~PSL_T;
				i = SIGTRAP;
			}
			/* else ucode = emulator_only_knows() XXX */
			break;

		case T_FPOPFLT:		/* FPU operand fetch fault */
			ucode = ILL_COPROC;
			i = SIGILL;
			break;

		case T_XMMFLT:		/* SIMD floating-point exception */
			ucode = 0; /* XXX */
			i = SIGFPE;
			break;
		}
	} else {
kernel_trap:
		/* kernel trap */

		switch (type) {
		case T_PAGEFLT:			/* page fault */
			trap_pfault(frame, FALSE, eva);
			goto out2;

		case T_DNA:
#if NNPX > 0
			/*
			 * The kernel may be using npx for copying or other
			 * purposes.
			 */
			if (npxdna())
				goto out2;
#endif
			break;

		case T_PROTFLT:		/* general protection fault */
		case T_SEGNPFLT:	/* segment not present fault */
			/*
			 * Invalid segment selectors and out of bounds
			 * %eip's and %esp's can be set up in user mode.
			 * This causes a fault in kernel mode when the
			 * kernel tries to return to user mode.  We want
			 * to get this fault so that we can fix the
			 * problem here and not have to check all the
			 * selectors and pointers when the user changes
			 * them.
			 */
#define	MAYBE_DORETI_FAULT(where, whereto)				\
	do {								\
		if (frame->tf_eip == (int)where) {			\
			frame->tf_eip = (int)whereto;			\
			goto out2;					\
		}							\
	} while (0)
			if (mycpu->gd_intr_nesting_level == 0) {
				/*
				 * Invalid %fs's and %gs's can be created using
				 * procfs or PT_SETREGS or by invalidating the
				 * underlying LDT entry.  This causes a fault
				 * in kernel mode when the kernel attempts to
				 * switch contexts.  Lose the bad context
				 * (XXX) so that we can continue, and generate
				 * a signal.
				 */
				MAYBE_DORETI_FAULT(doreti_iret,
						   doreti_iret_fault);
				MAYBE_DORETI_FAULT(doreti_popl_ds,
						   doreti_popl_ds_fault);
				MAYBE_DORETI_FAULT(doreti_popl_es,
						   doreti_popl_es_fault);
				MAYBE_DORETI_FAULT(doreti_popl_fs,
						   doreti_popl_fs_fault);
				MAYBE_DORETI_FAULT(doreti_popl_gs,
						   doreti_popl_gs_fault);

				/*
				 * NOTE: cpu doesn't push esp on kernel trap
				 */
				if (td->td_pcb->pcb_onfault &&
				    td->td_pcb->pcb_onfault_sp ==
				    (int)&frame->tf_esp) {
					frame->tf_eip = 
					    (register_t)td->td_pcb->pcb_onfault;
					goto out2;
				}
			}
			break;

		case T_TSSFLT:
			/*
			 * PSL_NT can be set in user mode and isn't cleared
			 * automatically when the kernel is entered.  This
			 * causes a TSS fault when the kernel attempts to
			 * `iret' because the TSS link is uninitialized.  We
			 * want to get this fault so that we can fix the
			 * problem here and not every time the kernel is
			 * entered.
			 */
			if (frame->tf_eflags & PSL_NT) {
				frame->tf_eflags &= ~PSL_NT;
				goto out2;
			}
			break;

		case T_TRCTRAP:	 /* trace trap */
			if (frame->tf_eip == (int)IDTVEC(syscall)) {
				/*
				 * We've just entered system mode via the
				 * syscall lcall.  Continue single stepping
				 * silently until the syscall handler has
				 * saved the flags.
				 */
				goto out2;
			}
			if (frame->tf_eip == (int)IDTVEC(syscall) + 1) {
				/*
				 * The syscall handler has now saved the
				 * flags.  Stop single stepping it.
				 */
				frame->tf_eflags &= ~PSL_T;
				goto out2;
			}
                        /*
                         * Ignore debug register trace traps due to
                         * accesses in the user's address space, which
                         * can happen under several conditions such as
                         * if a user sets a watchpoint on a buffer and
                         * then passes that buffer to a system call.
                         * We still want to get TRCTRAPS for addresses
                         * in kernel space because that is useful when
                         * debugging the kernel.
                         */
                        if (user_dbreg_trap()) {
                                /*
                                 * Reset breakpoint bits because the
                                 * processor doesn't
                                 */
                                load_dr6(rdr6() & 0xfffffff0);
                                goto out2;
                        }
			/*
			 * FALLTHROUGH (TRCTRAP kernel mode, kernel address)
			 */
		case T_BPTFLT:
			/*
			 * If DDB is enabled, let it handle the debugger trap.
			 * Otherwise, debugger traps "can't happen".
			 */
			ucode = TRAP_BRKPT;
#ifdef DDB
			MAKEMPSAFE(have_mplock);
			if (kdb_trap (type, 0, frame))
				goto out2;
#endif
			break;

#if NISA > 0
		case T_NMI:
			MAKEMPSAFE(have_mplock);
#ifdef POWERFAIL_NMI
#ifndef TIMER_FREQ
#  define TIMER_FREQ 1193182
#endif
	handle_powerfail:
		{
		  static unsigned lastalert = 0;

		  if (time_uptime - lastalert > 10) {
		      log(LOG_WARNING, "NMI: power fail\n");
		      sysbeep(TIMER_FREQ/880, hz);
		      lastalert = time_uptime;
		  }
		    /* YYY mp count */
		  goto out2;
		}
#else /* !POWERFAIL_NMI */
			/* machine/parity/power fail/"kitchen sink" faults */
			if (isa_nmi(code) == 0) {
#ifdef DDB
				/*
				 * NMI can be hooked up to a pushbutton
				 * for debugging.
				 */
				if (ddb_on_nmi) {
					kprintf ("NMI ... going to debugger\n");
					kdb_trap (type, 0, frame);
				}
#endif /* DDB */
				goto out2;
			} else if (panic_on_nmi == 0)
				goto out2;
			/* FALL THROUGH */
#endif /* POWERFAIL_NMI */
#endif /* NISA > 0 */
		}

		MAKEMPSAFE(have_mplock);
		trap_fatal(frame, eva);
		goto out2;
	}

	/*
	 * Virtual kernel intercept - if the fault is directly related to a
	 * VM context managed by a virtual kernel then let the virtual kernel
	 * handle it.
	 */
	if (lp->lwp_vkernel && lp->lwp_vkernel->ve) {
		vkernel_trap(lp, frame);
		goto out;
	}

	/* Translate fault for emulators (e.g. Linux) */
	if (*p->p_sysent->sv_transtrap)
		i = (*p->p_sysent->sv_transtrap)(i, type);

	MAKEMPSAFE(have_mplock);
	trapsignal(lp, i, ucode);

#ifdef DEBUG
	if (type <= MAX_TRAP_MSG) {
		uprintf("fatal process exception: %s",
			trap_msg[type]);
		if ((type == T_PAGEFLT) || (type == T_PROTFLT))
			uprintf(", fault VA = 0x%lx", (u_long)eva);
		uprintf("\n");
	}
#endif

out:
	userret(lp, frame, sticks);
	userexit(lp);
out2:	;
	if (have_mplock)
		rel_mplock();
	if (p != NULL && lp != NULL)
		KTR_LOG(kernentry_trap_ret, p->p_pid, lp->lwp_tid);
#ifdef INVARIANTS
	KASSERT(crit_count == td->td_critcount,
		("trap: critical section count mismatch! %d/%d",
		crit_count, td->td_pri));
	KASSERT(curstop == td->td_toks_stop,
		("trap: extra tokens held after trap! %zd/%zd",
		curstop - &td->td_toks_base,
		td->td_toks_stop - &td->td_toks_base));
#endif
}
コード例 #8
0
ファイル: vt_core.c プロジェクト: lutianba/freebsd
static void
vtterm_bell(struct terminal *tm)
{

	sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION);
}
コード例 #9
0
ファイル: command.c プロジェクト: pombredanne/Frontier
static boolean cmdiconhit (void) {
	
	/*
	5/21/91 dmb: run the string as a process so we can handle errors nicely.
	
	8/20/91 dmb: when the process completes, we're in another thread and can't 
	assume that the window is around anymore, let alone that its globals are 
	set.  to handle this (crashing) situation, use new minisetwindowmessage 
	to display the result.
	
	10/25/91 dmb: check new process's disposewhenidleflag before running it.
	
	10/27/91 dmb: don't dispose result value if processruncode returns false
	
	12/12/91 dmb: extract the text handle from the dialog record's TE record to 
	overcome the miniwindow's string-oriented architecture.  Unfortunately, the
	text also saved in the database as a string, to this is just a band-aid, not 
	a real fix.
	
	2.1a6 dmb: reworked threading for thread mgr 1.1
	
	2.1b2 dmb: pass -1 for errorrefcon instead of zero to prevent top level 
	lexical scope from being transparent (i.e. visible to subroutines)
	
	5.0d14 dmb: minidialog now uses full text handles, not bigstrings
	
	5.0b17 dmb: minigetstring result is ours to consume
	*/
	
	Handle hscript;
	hdltreenode hcode;
	boolean fl;
	hdlprocessrecord hprocess;
	register hdlprocessrecord hp;
	hdlprocessthread hthread;
	
	if (quickscriptprocess != nil) {
		
		sysbeep ();
		
		return (false);
		}
	
	if (!langpusherrorcallback (&cmderrorroutine, (long) -1))
		return (false);
	
	minigetstring (0, &hscript);
	
	fl = langbuildtree (hscript, false, &hcode); /*consumes htext*/
	
	langpoperrorcallback ();
	
	if (!fl) /*syntax error*/
		return (false);
	
	langerrorclear (); /*compilation produced no error, be sure error window is empty*/
	
	if (!newprocess (hcode, true, &cmderrorroutine, (long) -1, &hprocess)) {
		
		langdisposetree (hcode);
		
		return (false);
		}
	
	hp = hprocess; /*copy into register*/
	
	(**hp).processstartedroutine = &cmdprocesscallback;
	
	(**hp).processkilledroutine = &cmdprocesscallback;
	
	#ifndef oldthreads
	
	if (!newprocessthread (&cmdthreadmain, (tythreadmainparams) hp, &hthread)) {
		
		disposeprocess (hp);
		
		return (false);
		}
	
	quickscriptprocess = hp; /*can only run one of these at a time*/
	
	return (true);	
	
	#else
	
	quickscriptprocess = hp; /*can only run one of these at a time*/
	
	if (!innewprocessthread (&hthread)) /*not in new thread -- we're done with synchonous stuff*/
		return (true);
	
	if ((hthread == nil) || (**hp).fldisposewhenidle)
		fl = false;
	else
		fl = processruncode (hp, &val);
	
	disposeprocess (hp);
	
	if (!fl)
		setbooleanvalue (false, &val);
	
	hashgetvaluestring (val, bsresult);
	
	disposetmpvalue (val);
	
	minisetwindowmessage (idcommandconfig, bsresult); /*can't assume miniwindow is around anymore*/
	
	quickscriptprocess = nil; /*clear "semaphore"*/
	
	endprocessthread (hthread);
	
	return (false); /*if we got here, hthread was nil*/
	
	#endif
	} /*cmdiconhit*/
コード例 #10
0
ファイル: co_pc3.c プロジェクト: dank101/386BSD
/*
 *	this routine does all the ESC and character processing stuff
 */
void vtemul_exec(struct vty *vp, XCHAR ch)
{
	int inccol, par1, par2;
	int sc = 1;	/* do scroll check */
	u_short at,sat;
	struct outmode *sk = vp->op;

	/* which attributes do we use? */
	at = sk->fg_at|sk->bg_at;
	sat= vp->so_at;

	/* translate to proper font */
	ch = vga_xlatiso646(vp,&at,&sat,ch);

	switch(ch) {
	case 016:	/* SO, select font 2 */
		emul_selectfont(vp,2);
		break;
	case 017:	/* SI, select font 1 */
		emul_selectfont(vp,1);
		break;
	case 0x1B:
		if(sk->escstate != ESC_NONE)
			emul_wrtchar(vp,ch,sat);
		else	
			sk->escstate = ESC_WBRAC;
		break;

	case '\t':
		inccol = (8 - vp->col % 8);	/* non-destructive tab */
		emul_cursorrelative(vp,inccol,0);
		break;

	case '\010':
		emul_cursorleft(vp, 1); 
		break;

	case '\r':
		emul_cursorrelative(vp,-vp->col,0);
		break;

	case '\n':
		emul_cursorrelative(vp,0,1);
		break;

	case 0x07:
		/* different sounds for different vtys possible */
		sysbeep (vp->pitch, vp->duration);
		break;
	default:
		/* ESC Processing */
		switch (sk->escstate) {

		default:
		case ESC_NONE:	
			/* NO ESC, normal processing */
			emul_wrtchar(vp,ch,vp->so ? sat : at);
			if (vp->col >= vp->ncol) vp->col = 0;
			break;

		case ESC_WBRAC:	
			/* has seen ESC, wait for [ or 'c' */
			if (ch=='[') {
				sk->escstate = ESC_WPARAM;
				sk->parcnt = 0;
				sk->param[0] = 0;
				sk->param[1] = 0;
			} 
			else if (ch == 'c') { 
				/* Clear screen & home */
				emul_clearcursor(vp, 2);
				emul_cursormove(vp, 0, 0);
				sk->escstate = ESC_NONE;
			} 
			else {	
				/* error */
				sk->escstate = ESC_NONE;
				emul_wrtchar(vp, ch, sat); 
			}
			break;

		case ESC_WPARAM:	/* has seen ESC [ wait for digit, ';' or letter */
			if (ch>='0' && ch<='9') {
				sk->param[sk->parcnt] *= 10;
				sk->param[sk->parcnt] += ch-'0';
			} 
			else if (ch==';') {
				if (sk->parcnt>=2) {
					sk->escstate = ESC_NONE;	/* error */
					emul_wrtchar(vp,ch,sat); 
				}
				else {
					sk->parcnt++;
					sk->param[sk->parcnt] = 0;
				}
			} 
			else if (ch>=' ' && ch<='~') {
				par1 = sk->param[0];
				par2 = sk->param[1];
				sk->parcnt++;
				sk->param[sk->parcnt] = 0;
				switch (ch) {
				case 'A': /* back cx rows */
					emul_cursorup(vp, par1);
					sc = 0;
					break;
				case 'B': /* down cx rows */
					emul_cursordown(vp, par1);
					sc = 0;
					break;
				case 'C': /* right cursor */
					emul_cursorright(vp, par1, 1);
					sc = 0;
					break;
				case 'D': /* left cursor */
					emul_cursorleft(vp, par1);
					sc = 0;
					break;
				case 'f': /* in system V consoles */
				case 'H': /* Cursor move */
					emul_cursormove(vp, par1, par2);
					break;
				case 'J': /* Clear ... */
					emul_clearcursor(vp, par1);
					break;
				case 'K': /* Clear line ... */
					emul_clearline(vp, par1);
					break;
				case 'L':  /* Insert Line */
					emul_insertline(vp, par1);
					break;
				case 'M':  /* Delete Line */
					emul_deleteline(vp, par1);
					break;
				case 'P':  /* delete spaces */
					emul_deletechars(vp, par1);
					break;
				case 'S':  /* scroll up cx lines */
					emul_scrollup(vp, par1, 0);
					break;
				case 'T':  /* scroll down cx lines */
					emul_scrolldown(vp, par1);
					break;
				case 'm':	/* standout mode */
					if (par1) vp->so = 1;
					else vp->so = 0;
					break;
				case 'r':
					vp->so_at = (par1 & 0x0f) | ((par2 & 0x0f) << 4);
					break;
				case 'x': /* set attributes */
					emul_setattributes(vp, par1, par2);
					break;
				case '@':  /* insert spaces */
					emul_insertchars(vp, par1);
					break;
				case '!':  /* set beep pitch and duration */
					kbd_cvtsound(par1, &vp->pitch, 
						     par2, &vp->duration);
					break;
				default:
					emul_wrtchar(vp,ch,sat); 
				}
				sk->escstate = ESC_NONE;
			}
			break;
		}
	}
	
	if (sc && emul_checkcursor(vp) > 0) {
		if (consoftc.cs_flags&CO_OPEN) 
			do 
				(void)kbd_sgetc(1); 
			while (vp->scroll);

		emul_scrollup(vp, 1, 1);
	}
}
コード例 #11
0
ファイル: langerrorwindow.c プロジェクト: dvincent/frontier
static boolean langerrorset (bigstring bserror, bigstring bslocation) {
#pragma unused (bslocation)

	/*
	2.1b2 dmb: if the langerror window isn't already there, don't try to 
	create it now -- the heap or stack may be dangerously low.  instead, 
	just build the data structure and wait for langerrorflush to be called
	*/
	
	hdllangerrorrecord hle;
	boolean flalreadythere;
	hdlerrorstack herrorstack;
	register hdlerrorstack hs;
	register boolean flcallbackconsumed;
	WindowPtr w;
	
	flalreadythere = langerrorfindwindow (&w, &hle);
	
	if (flalreadythere) {
		
		++inhibiterrorclear; /*6.1b18 AR: make sure other threads don't clear the error window while
											we release the thread globals (only relevant for Win32)*/
	
		shellpushglobals (w);  /*dmb 9/20/90: set langerror.c globals*/
		
		shellbringtofront (langerrorwindowinfo);

		--inhibiterrorclear;
		}
	else {
		
		if (!newclearhandle (sizeof (tylangerrorrecord), (Handle *) &pendingerrordata)) {
			
			sysbeep (); // some kind of feedback
			
			return (false);
			}
		
		hle = pendingerrordata;
		
		shellforcebackgroundtask (); /*mimimize delay before window opens*/
		}
	
	copystring (bserror, (**hle).bserror);
	
	/*
	copystring (bslocation, (**hle).bslocation);
	*/
	
	copyhandle ((Handle) langcallbacks.scripterrorstack, (Handle *) &herrorstack);
	
	hs = herrorstack; /*copy into register*/
	
	disposehandle ((Handle) (**hle).herrorstack); /*toss old error info*/
	
	(**hle).herrorstack = hs;
	
	if ((hs == nil) || ((**hs).toperror == 0))
		flcallbackconsumed = true;
	else
		flcallbackconsumed = (**hs).stack [(**hs).toperror - 1].errorcallback == nil;
	
	(**hle).flcallbackconsumed = flcallbackconsumed;
	
	(**hle).lnum = ctscanlines;
	
	(**hle).cnum = ctscanchars;
	
	if (flalreadythere) {
		
		langerrorupdate ();
		
		shellpopglobals ();
		}

	return (true);
	} /*langerrorset*/