Example #1
0
static RETSIGTYPE serv_sighup(int sig)
{
    cleanconfig();
    rdconfig(CONFIGFILE);

    if(conf.debug>0) {
	puts("Server reconfiguring...\n");
	showconfig();
    }
    resetservtraps();
}
Example #2
0
/*********************************************************
*           M A I N
*********************************************************/
int main()
	{
	FILE *fp;
	char msg[80], num[10], *fmt1, *fmt2;
	int i;

  printf(TITLE);

	initvars();           /* initialize config variables */
	if (loadvars())       /* load config variables       */
		{
		printf("\nLast MCX11 configuration:\n\n");
    showconfig();
		do {
			printf("Do you wish to change the configuration? ");
			gets(msg);
			*msg = tolower(*msg);
			} while (*msg!='y' && *msg!='n');
		if (*msg=='n')
			return 0;
		}


	do {
		enterconfig();
		printf("\nNew MCX11 configuration:\n\n");
    showconfig();
		do {
			printf("Are the configuration parameters correct? ");
			gets(msg);
			*msg = tolower(*msg);
			} while (*msg!='y' && *msg!='n');
		} while (*msg=='n');


	do {
		printf("Save configuration? ");
		gets(msg);
		*msg = tolower(*msg);
		} while (*msg!='y' && *msg!='n');

	if (*msg=='n')
		{
		printf("Not saved.\n");
		return 0;
		}
	savevars();
  configdoc();


	/***************************
	 * Write the MCXDEF.S file *
	 ***************************/
	fp = fopen("mcxdef.s", "w");
	fprintf(fp,"; mcxdef.s\n\n");
	fmt1 = "        .DEFINE   %-10s = %3d      ; %s\n";
	fprintf(fp,fmt1, "NTASKS",  gNTASKS,  "Number of tasks (counting timer)");
	fprintf(fp,fmt1, "NQUEUES", gNQUEUES, "Number of queues");
	fprintf(fp,fmt1, "NNAMSEM", gNNAMSEM, "Number of named semaphores");
	fprintf(fp,fmt1, "NTIMERS", gNTIMERS, "Number of timers");
	fclose(fp);


	/***************************
	 * Write the MCXDEF.H file *
	 ***************************/
	fp = fopen("mcxdef.h", "w");
	fprintf(fp,"/************\n * mcxdef.h *\n ************/\n\n");
	fprintf(fp,"#define NTASKS  %d\n", gNTASKS);
	fprintf(fp,"#define NQUEUES %d\n", gNQUEUES);
	fprintf(fp,"#define NNAMSEM %d\n", gNNAMSEM);
	fprintf(fp,"#define NTIMERS %d\n", gNTIMERS);
	fprintf(fp,"\n");
	for (i=0; i<gNTASKS; i++)
		fprintf(fp,"#define TASK_%-12s  %d\n", task[i].name, i+1);
	fprintf(fp,"\n");
	for (i=0; i<gNTASKS; i++)
		fprintf(fp,"#define STACKSIZE_%-12s  %d\n", task[i].name, task[i].stacksize);
	fprintf(fp,"\n");
	for (i=0; i<gNQUEUES; i++)
		fprintf(fp,"#define QUEUE_%-12s %d\n", queue[i].name, i+1);
	fprintf(fp,"\n");
	for (i=0; i<gNNAMSEM; i++)
		fprintf(fp,"#define SEMA_%-12s  %d\n", sema_name[i], i+1);
	fprintf(fp,"\n");
	for (i=1; i<gNTASKS; i++)
		fprintf(fp,"extern void task_%s (void);\n", task[i].name);
	fclose(fp);


	/****************************
	 * Write the MCXDBUG.H file *
	 ****************************/
	fp = fopen("mcxdbug.h", "w");
	fprintf(fp,"/*************\n * mcxdbug.h *\n *************/\n\n");
	fprintf(fp,"\n");
	fprintf(fp,"typedef struct {\n");
	fprintf(fp,"    char *name;\n");
	fprintf(fp,"    int  stacksize;\n");
	fprintf(fp,"} MCXTASK;\n");
	fprintf(fp,"#ifdef _DBUG_\n");
  fprintf(fp,"const MCXTASK mcxtask[%d]={\n", gNTASKS);
	for (i=0; i<gNTASKS; i++)
		fprintf(fp,"    \"%s\", %d%s\n", task[i].name, task[i].stacksize, (i==gNTASKS-1)? "};": ",");
	fprintf(fp,"#else\n");
	fprintf(fp,"extern MCXTASK mcxtask[];\n");
	fprintf(fp,"#endif\n");
	fclose(fp);


	/****************************
	 * Write the MCXDATA.S file *
	 ****************************/
	fp = fopen("mcxdata.s", "w");
	fprintf(fp,"; mcxdata.s\n\n");
	fprintf(fp,"        .INCLUDE \"DEFINE.S\"\n");
	fprintf(fp,"        .INCLUDE \"MCXDEF.S\"\n\n");
	fprintf(fp,"        .PUBLIC   FLGTBL, QHDRTBL, STATLS, TIMERS\n");
	fprintf(fp,"        .PUBLIC   tickcnt, FREE, ACTIVE, curtsk, curtcb, hipri\n");
	fprintf(fp,"        .PUBLIC   pritcb, intlvl, temp, _width, _depth, notmt\n");
	fprintf(fp,"        .PUBLIC   SYSTACK, TCBDATA, QUEDATA, STKBASE\n");
	fprintf(fp,"        .PUBLIC   _TCBDATA\n\n");
	for (i=0; i<gNTASKS; i++)
		fprintf(fp,"        .EXTERNAL %s%s\n", i?"_task_":"", task[i].name);
	fprintf(fp,"\n\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  Stack Areas\n");
	fprintf(fp,";************************\n");
   fprintf(fp,"        .PSECT _%s\n", task[0].memtype ? "bss" : "data");
	fprintf(fp,"        .BYTE [64]\n");
	fprintf(fp,"SYSTACK: .BYTE [19]\n");
	for (i=0; i<gNTASKS; i++)
		{
      fprintf(fp,"        .PSECT _%s\n", task[i].memtype ? "bss" : "data");
		sprintf(msg,"STAK%d:", i+1);
		fprintf(fp,"        .BYTE [%d]\n", task[i].stacksize);
		fprintf(fp,"%-7s\n", msg);
		}
	fprintf(fp,"STKBASE:\n");
   fprintf(fp,"\n        .PSECT _%s\n", task[0].memtype ? "bss" : "data");
	fprintf(fp,"\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  Queue Headers\n");
	fprintf(fp,";************************\n");
	fprintf(fp,"QHDRTBL:\n");
	for (i=0; i<gNQUEUES; i++)
		{
		sprintf(msg,"Q%dHDR:",i+1);
		fprintf(fp,"%-7s .BYTE [QHDRLEN]\n", msg);
		}
	fprintf(fp,"\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  Timers\n");
	fprintf(fp,";************************\n");
	fprintf(fp,"TIMERS: .BYTE [NTIMERS*TIMRLEN]\n\n");
	fprintf(fp,"\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  System Variables\n");
	fprintf(fp,";************************\n");
	fmt1 = "%-7s .BYTE [1]       ; %s\n";
	fmt2 = "%-7s .WORD [1]       ; %s\n";
	fprintf(fp,"MCXVAR:\n");
	fprintf(fp,"tickcnt: .BYTE [1]      ; Tick counter\n");
	fprintf(fp,fmt2,"FREE:","Address of first free timer block");
	fprintf(fp,fmt2,"ACTIVE:","Address of first active timer in list");
	fprintf(fp,fmt1,"curtsk:","Current task (i.e. the active task)");
	fprintf(fp,fmt2,"curtcb:","Address of current task's TCB");
	fprintf(fp,fmt1,"hipri:","Highest priority task ready to run");
	fprintf(fp,fmt2,"pritcb:","Address of TCB of highest priority task");
	fprintf(fp,fmt1,"intlvl:","Depth of nested interrupts");
	fprintf(fp,fmt2,"temp:","Temporary area");
	fprintf(fp,fmt1,"_width:","Work area for queue width");
	fprintf(fp,fmt1,"_depth:","Work area for queue depth");
	fprintf(fp,fmt1,"notmt:","Work area for queue not empty semaphore");
	fprintf(fp,"\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  Semaphore table\n");
	fprintf(fp,";************************\n");
	fprintf(fp,"FLGTBL: .BYTE [NQUEUES*2 + NTASKS + NNAMSEM]\n\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  Task Control Block\n");
	fprintf(fp,";************************\n");
	fprintf(fp,"STATLS:\n");
	for (i=0; i<gNTASKS; i++)
		{
		sprintf(msg,"TASK%d:",i+1);
		fprintf(fp,"%-7s .BYTE [TCBLEN]\n", msg);
		}
	fprintf(fp,"\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  Queue Bodies\n");
	fprintf(fp,";************************\n");
	for (i=0; i<gNQUEUES; i++)
		{
		sprintf(msg,"Q%dBODY:",i+1);
		fprintf(fp,"%-7s .BYTE [%d*%d]\n", msg, queue[i].width, queue[i].depth);
		}
	fprintf(fp,"\n");
	fprintf(fp,"\n");
	fprintf(fp,"        .PSECT _text\n");
	fprintf(fp,"\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  Queue data in ROM\n");
	fprintf(fp,";************************\n");
	fprintf(fp,"QUEDATA:\n");
	for (i=0; i<gNQUEUES; i++)
		{
		fprintf(fp,"        .BYTE   %d,%d\n", queue[i].width, queue[i].depth);
		fprintf(fp,"        .WORD   Q%dHDR,Q%dBODY\n", i+1, i+1);
		}
	fprintf(fp,"\n");
	fprintf(fp,"\n");
	fprintf(fp,";************************\n");
	fprintf(fp,";  TCB data in ROM\n");
	fprintf(fp,";************************\n");
	fprintf(fp,"TCBDATA:\n");
	fprintf(fp,"_TCBDATA:\n");
	i = 0;
	for (i=0; i<gNTASKS; i++)
		{
		fprintf(fp,"        .BYTE   %s\n", task[i].initial ? "_IDLE":"_RUN");
		fprintf(fp,"        .WORD   %s%s, STAK%d-1, TASK%d\n\n",
			i?"_task_":"", task[i].name, i+1, i+1);
		}
	fprintf(fp,"\n");
	fprintf(fp,"        .END\n");
	fclose(fp);

	printf("Saved.\n");
	return 0;
	}