Exemple #1
0
/* main()
 * ================================================================
 */
void
main( void )
{
	int 	i;

	appl_init();
	AES_Version = _AESglobal[0];	/* Get the AES version number */

	vhandle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );

	work_in[0] = Getrez()+2; /* let's not gag GDOS */
	for( i = 1; i < 10; work_in[i++] = 1 );
	work_in[10] = 2;
	v_opnvwk( work_in, &vhandle, work_out );
	xres = work_out[0];
	yres = work_out[1];
	num_pens = work_out[13];

	gl_screen.g_x = gl_screen.g_y = 0;
        gl_screen.g_w = xres + 1;
        gl_screen.g_h = yres + 1;

	/* We're too wide for ST LOW Rez */
        if(( work_in[0] == STLOW ) || ( work_in[0] == TTLOW ))
        {
	    form_alert( 1, alow );
	    v_clsvwk( vhandle );
	    appl_exit();
	    exit( 0 );
        }

	wind_get( 0, WF_WORKXYWH, &gl_full.g_x, &gl_full.g_y,
				  &gl_full.g_w, &gl_full.g_h );

	initialize();
	if( !rsrc_init())
        {
	   form_alert( 1, arsc );
	   Gem_Exit( -1 );
        }

	do_main();
	Gem_Exit( 0 );
}
Exemple #2
0
void init_kspace(int membottom)
{
	uint32 *raw;
	
    /* there's an existing aspace at vaddr 0x803FD000 that was initialized
       by the 2nd stage loader */
	raw = (uint32 *) 0x803FD000;
    flat = &_flat;
	flat->pdir = raw;
	flat->ptab = &raw[1024];
	flat->high = &raw[2048];
	memtotal = memsize;
	
    memsize -= 3; /* three pages already in use */
    
    memory_init(membottom, memsize);

	
    toppage = (char *) kgetpages(3); /* kernel startup stack */
    gdt = (char *) kgetpages(1);
    rsrc_init(kgetpages(6),4096*6);
    

	kernel = (task_t *) kmalloc(task_t);
	ktss = (TSS *) kgetpages(1);
    kernel->flags = tKERNEL;
	kernel->rsrc.id = 0;
	kernel->rsrc.owner = NULL;
	list_init(&kernel->rsrc.rights);
	list_init(&kernel->rsrc.queue);
    current = kernel;

    init_idt(idt = kgetpages(1));              /* init the new idt, save the old */
    gdt2 = (void *) i386sgdt(&gdt2len);        /* save the old gdt */

    i386SetSegment(gdt + SEL_KCODE,      /* #01 - 32bit DPL0 CODE */
                   0, 0xFFFFF,
                   i386rPRESENT | i386rDPL0 | i386rCODE,
                   i386g4K | i386g32BIT);

    i386SetSegment(gdt + SEL_KDATA,      /* #02 - 32bit DPL0 DATA */
                   0, 0xFFFFF,
                   i386rPRESENT | i386rDPL0 | i386rDATA,
                   i386g4K | i386g32BIT);

    i386SetSegment(gdt + SEL_KDATA2,        /* #02 - 32bit DPL0 DATA */
                   0, 0xFFFFF,
                   i386rPRESENT | i386rDPL0 | i386rDATA,
                   i386g4K | i386g32BIT);

    i386SetSegment(gdt + SEL_UCODE,        /* #03 - 32bit DPL3 CODE */
                   0, 0xFFFFF,
                   i386rPRESENT | i386rDPL3 | i386rCODE,
                   i386g4K | i386g32BIT);

    i386SetSegment(gdt + SEL_UDATA,        /* #04 - 32bit DPL3 DATA */
                   0, 0xFFFFF,
                   i386rPRESENT | i386rDPL3 | i386rDATA,
                   i386g4K | i386g32BIT);

    i386SetSegment(gdt + SEL_KTSS,        /* #05 - DPL0 TSS (Kernel) */
                   (uint32) ktss, 104,
                   i386rPRESENT | i386rDPL0 | i386rTSS,
                   0);
    
    i386lgdt((uint32) gdt, 1024/8);

    asm("mov %%cr3, %0":"=r" (_cr3));
    
        /* setup the kernel TSS to insure that it's happy */
    ktss->cs = SEL_KCODE;
    ktss->ds = ktss->es = ktss->ss = ktss->fs = ktss->gs = SEL_KDATA; 
    ktss->ldts = ktss->debugtrap = ktss->iomapbase = 0;
    ktss->cr3 = _cr3;
	ktss->ss0 = SEL_KDATA;
    ktss->esp1 = ktss->esp2 = ktss->ss1 = ktss->ss2 = 0;
    i386ltr(SEL_KTSS);
}
Exemple #3
0
void
main( int argc, char *argv[], char *envp[] )
{
	int 	i;
/* 	-----	evnt_multi return parameters */
	int		event, msg[8], key, nclicks;
	MRETS	mrets;
	int  	rez;
/*
 * Initialize global arguments
 */
	if( (nargs = argc) != 1)
		args = argv;
	env = envp;

/*
 * See if we were run from the AUTO folder...
 */
	if( (gl_apid = appl_init()) == -1 ) {
		Cconws("\r\nError initializing GEM, hit a key...");
		Cconin();
		exit( gl_apid );
	}
	rez = Getrez() + 2;
	if(( rez != 2 ) && ( rez != 6 ) )
	{
	   /* Ensure that we run ONLY in ST LOW or TT MED - 640x480 16 colors */
	   form_alert( 1, "[3][ | This program runs in| ST LOW or TT MED Only][ OK ]" );
	   appl_exit();
	   exit( -1 );
	}
/*
 * Set up work_in to initialize VDI functions to useful values,
 * Get the physical workstation handle from the AES, then
 * open a virtual workstation and get our AES work area's extent.
 */
	work_in[0] = Getrez()+2; /* let's not gag GDOS */
	for( i = 1; i < 10; work_in[i++] = 1 )
	;
	work_in[10] = 2; /* raster coordinates */
	vhandle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );
	v_opnvwk( work_in, &vhandle, work_out );
	xres = work_out[0];
	yres = work_out[1];

/*
 * Call initialization hooks
 */
	Wind_get( 0, WF_WORKXYWH, ( WARGS *)&desk );
	if( !rsrc_init() ) {
		form_alert( 1, "[3][ RSC ERROR ][ OK ]" );
		v_clsvwk( vhandle );
		appl_exit();
		exit( -1 );
	}

	wind_init();
	evnt_init();

/*
 * Main event loop
 */
	do {

		event = Evnt_multi( ev_mask, ev_clicks, ev_bmask, ev_bstate,
							&ev_m1, &ev_m2, ( WORD *)msg, ev_time,
							&mrets, ( WORD *)&key, ( WORD *)&nclicks );
		wind_update( BEG_UPDATE );
	/*
	 * call pre-event-processing hook
	 */
		if( evnt_hook( event, msg, &mrets, &key, &nclicks ) )
			continue;

	/* Dispatch events.
	 * It is possible to get more than one event at a time, so if the
	 * order of event handling is important to you, change the order
	 * in which they're handled here.
	 */
		if( event & MU_TIMER )
			do_timer( &event );

		if( event & MU_KEYBD )
			do_key( mrets.kstate, key, &event );

		if( event & MU_BUTTON )
			do_button( &mrets, nclicks, &event );

		if( event & MU_M1 )
			do_m1( &mrets, &event );

		if( event & MU_M2 )
			do_m2( &mrets, &event );

		if( event & MU_MESAG )
			switch( msg[0] ) {

				case MN_SELECTED:
					do_menu( msg, &event );
				break;

				case WM_REDRAW:
				case WM_TOPPED:
				case WM_CLOSED:
				case WM_FULLED:
				case WM_ARROWED:
				case WM_HSLID:
				case WM_VSLID:
				case WM_SIZED:
				case WM_MOVED:
				case WM_NEWTOP:
					do_windows( msg, &event );
				break;

				case AC_OPEN:
					acc_open( msg );
				break;

				case AC_CLOSE:
					acc_close( msg );
				break;

				default:
					msg_hook( msg, &event );
			} /* switch */
		/* MU_MESAG */

		wind_update( END_UPDATE );

	/*
	 * Event handling routines zero out the event variable
	 * to exit the application.
	 */
	} while( event );

	gem_exit( 0 );
}
Exemple #4
0
/*
 * main()
 * ================================================================
 */
void
main( void )
{
	int	event, msg[8], key, nclicks;
	MRETS	mrets;


/*
 * See if we were run from the AUTO folder...
 */
        gl_apid = appl_init();

	/* Get the AES version #.  TOS 3.0 is TT TOS */
	AES_Version = _GemParBlk.global[0];
/*
 * Set up work_in to initialize VDI functions to useful values,
 * Get the physical workstation handle from the AES, then
 * open a virtual workstation and get our AES work area's extent.
 */
	phys_handle = graf_handle(&gl_wchar,&gl_hchar,&gl_wbox,&gl_hbox );

	Wind_get( 0, WF_WORKXYWH, ( WARGS *)&desk );
	
	/* Call initialization hooks */
	rsrc_init();


	if( !open_vwork() )
        {
	   /* Unable to open workstation - exit application */
           form_alert( 1, alert18 );
	   gem_exit( 0 );
        }
	close_vwork();
	gl_ncolors = work_out[13];
	xres       = work_out[0];
	yres	   = work_out[1];
	vhandle = 0;

	
	wind_init();
	evnt_init();
	
	/* Main event loop */
	do
	{

		event = Evnt_multi( ev_mask, ev_clicks, ev_bmask, ev_bstate,
				    &ev_m1, &ev_m2, ( WORD *)msg, ev_time,
				    &mrets,(WORD *)&key,(WORD *)&nclicks );
		wind_update( BEG_UPDATE );
		

	/* Dispatch events.
	 * It is possible to get more than one event at a time, so if the
	 * order of event handling is important to you, change the order
	 * in which they're handled here.
	 */
		if( event & MU_MESAG )
			switch( msg[0] ) {

				case MN_SELECTED:
				break;

				case WM_REDRAW:
				case WM_TOPPED:
				case WM_CLOSED:
				case WM_FULLED:
				case WM_ARROWED:
				case WM_HSLID:
				case WM_VSLID:
				case WM_SIZED:
				case WM_MOVED:
				case WM_NEWTOP:
					do_windows( msg, &event );
				break;

				case AC_OPEN:
					acc_open( msg );
				break;
				
				case AP_TERM:
				case AC_CLOSE:
					acc_close( msg );
				break;

				default:
					break;
			} /* switch */
		/* MU_MESAG */

		wind_update( END_UPDATE );

	/*
	 * Event handling routines zero out the event variable
	 * to exit the application.
	 */
	} while( event );

	gem_exit( 0 );
}