Exemplo n.º 1
0
void uevents_setup(void)
{
  OUTC(PRE "setting up uevent...");
  ep_fd=(k_i)sysc(epoll_create1,1,0);
  if(K_ISERR(ep_fd)){
    OUT("ERROR(%d):unable to create epoll fd\n",ep_fd);
    sysc(exit_group,1,-1);
  }

  //----------------------------------------------------------------------------

  //blocking socket
  s=(k_i)sysc(socket,3,K_PF_NETLINK,K_SOCK_RAW,
                       K_NETLINK_KOBJECT_UEVENT);
  if(K_ISERR(s)){
    OUT("ERROR(%d):unable to create uevent netlink socket\n",s);
    sysc(exit_group,1,-1);
  }

  //----------------------------------------------------------------------------

  k_i recv_buf_sz=128*1024;//128k for kernel buffering
  k_l r=sysc(setsockopt,5,s,K_SOL_SOCKET,K_SO_RCVBUFFORCE,&recv_buf_sz,
                          sizeof(recv_buf_sz));
  if(K_ISERR(r)){
    OUT("ERROR(%ld):unable to force the size of the socket buffer\n",r);
    sysc(exit_group,1,-1);
  }

  //----------------------------------------------------------------------------

  //uevent groups-->only one: 1
  struct k_sockaddr_nl addr={K_AF_NETLINK,0,0,1};
  r=sysc(bind,3,s,&addr,sizeof(addr));
  if(K_ISERR(r)){
    OUT("ERROR(%ld):unable to bind address to uevent netlink socket\n",r);
    sysc(exit_group,1,-1);
  }
  
  //----------------------------------------------------------------------------

  struct k_epoll_event ep_evt;
  u_memset(&ep_evt,0,sizeof(ep_evt));
  ep_evt.events=K_EPOLLIN;
  ep_evt.data.fd=s;
  r=sysc(epoll_ctl,4,ep_fd,K_EPOLL_CTL_ADD,s,&ep_evt);
  if(K_ISERR(r)){
    OUT("ERROR(%ld):unable to register uevent netlink socket to epoll\n",r);
    sysc(exit_group,1,-1);
  }
  OUTC("done\n");
}
Exemplo n.º 2
0
void
tenot(struct blk *p,int sc)
{
	register int c,f;
	char	b[3];

	fsfile(p);
	f=0;
	while((sfbeg(p) == 0) && ((p->rd-p->beg-1)*2 >= sc)){
		c = sbackc(p);
		if((c<10) && (f == 1))snprintf(b, sizeof b, "0%d",c);
		else snprintf(b, sizeof b, "%d",c);
		f=1;
		TEST2(b);
	}
	if(sc == 0){
		printf("\n");
		release(p);
		return;
	}
	if((p->rd-p->beg)*2 > sc){
		c = sbackc(p);
		snprintf(b, sizeof b, "%d.",c/10);
		TEST2(b);
		OUTC(c%10 +'0');
		sc--;
	}
	else {
		OUTC('.');
	}
	if(sc > (p->rd-p->beg)*2){
		while(sc>(p->rd-p->beg)*2){
			OUTC('0');
			sc--;
		}
	}
	while(sc > 1){
		c = sbackc(p);
		if(c<10)snprintf(b, sizeof b, "0%d",c);
		else snprintf(b, sizeof b, "%d",c);
		sc -= 2;
		TEST2(b);
	}
	if(sc == 1){
		OUTC(sbackc(p)/10 +'0');
	}
	printf("\n");
	release(p);
	return;
}
Exemplo n.º 3
0
void
tenot(Blk *p, int sc)
{
	int c, f;

	fsfile(p);
	f=0;
	while((sfbeg(p) == 0) && ((p->rd-p->beg-1)*2 >= sc)) {
		c = sbackc(p);
		if((c<10) && (f == 1))
			Bprint(&bout,"0%d",c);
		else
			Bprint(&bout,"%d",c);
		f=1;
		TEST2;
	}
	if(sc == 0) {
		Bprint(&bout,"\n");
		release(p);
		return;
	}
	if((p->rd-p->beg)*2 > sc) {
		c = sbackc(p);
		Bprint(&bout,"%d.",c/10);
		TEST2;
		OUTC(c%10 +'0');
		sc--;
	} else {
		OUTC('.');
	}
	while(sc>(p->rd-p->beg)*2) {
		OUTC('0');
		sc--;
	}
	while(sc > 1) {
		c = sbackc(p);
		if(c<10)
			Bprint(&bout,"0%d",c);
		else
			Bprint(&bout,"%d",c);
		sc -= 2;
		TEST2;
	}
	if(sc == 1) {
		OUTC(sbackc(p)/10 +'0');
	}
	Bprint(&bout,"\n");
	release(p);
}
Exemplo n.º 4
0
void uevents_process(void)
{
  OUTC(PRE "processing uevents...\n");
  while(1){
    k_l r;
    static struct k_epoll_event evts;//uevent netlink event
    do{
      u_memset(&evts,0,sizeof(evts));
      r=sysc(epoll_wait,4,ep_fd,&evts,1,UEVENTS_TIMEOUT);
    }while(r==-K_EINTR);
    if(K_ISERR(r)){
      OUT(PRE "ERROR(%ld):error epolling uevent netlink socket\n",r);
      sysc(exit_group,1,-1);
    }
	if(!r) break;//assume no more uevents
    if(evts.events&K_EPOLLIN) uevent_msg();
    else{
      OUT(PRE "ERROR:unmanaged epolling event on uevent netlink socket"
          "(events=%u)\n",evts.events);
      sysc(exit_group,1,-1);
    }
  }
  OUTC(PRE "uevents processed\n");
}
Exemplo n.º 5
0
void
oneot(Blk *p, int sc, char ch)
{
	Blk *q;

	q = removc(p,sc);
	create(strptr);
	sputc(strptr,-1);
	while(length(q)>0) {
		p = add(strptr,q);
		release(q);
		q = p;
		OUTC(ch);
	}
	release(q);
	Bprint(&bout,"\n");
}
Exemplo n.º 6
0
void
oneot(struct blk *p,int sc,char ch)
{
	register struct blk *q;

	q = removc(p,sc);
	create(strptr);
	sputc(strptr,-1);
	while(length(q)>0){
		p = add(strptr,q);
		release(q);
		q = p;
		OUTC(ch);
	}
	release(q);
	printf("\n");
	return;
}
Exemplo n.º 7
0
void setupsc520(void)
{
	volatile unsigned char *cp;
	volatile unsigned short *sp;
	volatile unsigned long *edi;

	/* do this to see if MMCR will start acting right. we suspect
	 * you have to do SOMETHING to get things going. I'm really
	 * starting to hate this processor.
	 */

	/* no, that did not help. I wonder what will?
	 * outl(0x800df0cb, 0xfffc);
	 */

	/* well, this is special! You have to do SHORT writes to the
	 * locations, even though they are CHAR in size and CHAR aligned
	 * and technically, a SHORT write will result in -- yoo ha! --
	 * over writing the next location! Thanks to the u-boot guys
	 * for a reference code I can use. with these short pointers,
	 * it now reliably comes up after power cycle with printk. Ah yi
	 * yi.
   	 */

	/* turn off the write buffer*/
	/* per the note above, make this a short? Let's try it. */
	sp = (unsigned short *)0xfffef040;
	*sp = 0;

	/* as per the book: */
	/* PAR register setup */
	/* set up the PAR registers as they are on the MSM586SEG */
	/*    moved to romstage.c by Stepan, Ron says: */
	/* NOTE: move this to mainboard.c ASAP */
	setup_pars();

	/* CPCSF register */
	sp =  (unsigned short *)0xfffefc24;
	*sp = 0xfe;

	/* ADDDECTL */
	sp =  (unsigned short *)0xfffefc80;
	*sp = 0x10;

	/* byte writes in AMD assembly */
	/* we do short anyway, since u-boot does ... */
	/*set the GP CS offset*/
	sp =  (unsigned short *)0xfffefc08;
	*sp = 0x00001;
	/*set the GP CS width*/
	sp =  (unsigned short *)0xfffefc09;
	*sp = 0x00003;

	/* short writes in AMD assembly */
	/*set the GP CS width*/
	sp =  (unsigned short *)0xfffefc0a;
	*sp = 0x00001;
	/*set the RD pulse width*/
	sp =  (unsigned short *)0xfffefc0b;
	*sp = 0x00003;
	/*set the GP RD offset */
	sp =  (unsigned short *)0xfffefc0c;
	*sp = 0x00001;
	/*set the GP WR pulse width*/
	sp =  (unsigned short *)0xfffefc0d;
	*sp = 0x00003;
	/*set the GP WR offset*/
	sp =  (unsigned short *)0xfffefc0e;
	*sp = 0x00001;


	/* set up the GP IO pins*/
	/*set the GPIO directionreg*/
	sp =  (unsigned short *)0xfffefc2c;
	*sp = 0x00000;
	/*set the GPIO directionreg*/
	sp =  (unsigned short *)0xfffefc2a;
	*sp = 0x00000;
	/*set the GPIO pin function 31-16 reg*/
	sp =  (unsigned short *)0xfffefc22;
	*sp = 0x0FFFF;
	/*set the GPIO pin function 15-0 reg*/
	sp =  (unsigned short *)0xfffefc20;
	*sp = 0x0FFFF;


	/* the 0x80 led should now be working*/
	post_code(0xaa);
#if 0
	/* wtf are 680 leds ... *//* <-- WTF is this comment? */
	par = (unsigned long *) 0xfffef0c4;
	*par = 0x28000680;
	/* well? */
	post_code(0x55);
#endif

	/* set the uart baud rate clocks to the normal 1.8432 MHz.*/
	/* enable interrupts here? Why not? */
	cp = (unsigned char *)0xfffefcc0;
	*cp = 4 | 3;			/* uart 1 clock source */
	cp = (unsigned char *)0xfffefcc4;
	*cp = 4;			/* uart 2 clock source */

#if 0
/*; set the interrupt mapping registers.*/
	cp = (unsigned char *)0x0fffefd20;
	*cp = 0x01;

	cp = (unsigned char *)0x0fffefd28;
	*cp = 0x0c;

	cp = (unsigned char *)0x0fffefd29;
	*cp = 0x0b;

	cp = (unsigned char *)0x0fffefd30;
	*cp = 0x07;

	cp = (unsigned char *)0x0fffefd43;
	*cp = 0x03;

	cp = (unsigned char *)0x0fffefd51;
	*cp = 0x02;
#endif

/* Stepan says: This needs to go to the msm586seg code */
/* "enumerate" the PCI. Mainly set the interrupt bits on the PCnetFast. */
	outl(0x08000683c, 0xcf8);
	outl(0xc, 0xcfc); /* set the interrupt line */


	/* Set the SC520 PCI host bridge to target mode to
	 * allow external bus mastering events
	 */
	/* index the status command register on device 0*/
	outl(0x080000004, 0x0cf8);
	outl(0x2, 0xcfc);		/*set the memory access enable bit*/
	OUTC(0x0fffef072, 1);		/* enable req bits in SYSARBMENB */
}
Exemplo n.º 8
0
void
dcprint(Blk *hptr)
{
	Blk *p, *q, *dec;
	int dig, dout, ct, sc;

	rewind(hptr);
	while(sfeof(hptr) == 0) {
		if(sgetc(hptr)>99) {
			rewind(hptr);
			while(sfeof(hptr) == 0) {
				Bprint(&bout,"%c",sgetc(hptr));
			}
			Bprint(&bout,"\n");
			return;
		}
	}
	fsfile(hptr);
	sc = sbackc(hptr);
	if(sfbeg(hptr) != 0) {
		Bprint(&bout,"0\n");
		return;
	}
	count = ll;
	p = copy(hptr,length(hptr));
	sclobber(p);
	fsfile(p);
	if(sbackc(p)<0) {
		chsign(p);
		OUTC('-');
	}
	if((obase == 0) || (obase == -1)) {
		oneot(p,sc,'d');
		return;
	}
	if(obase == 1) {
		oneot(p,sc,'1');
		return;
	}
	if(obase == 10) {
		tenot(p,sc);
		return;
	}
	/* sleazy hack to scale top of stack - divide by 1 */
	pushp(p);
	sputc(p, sc);
	p=salloc(0);
	create(p);
	sputc(p, 1);
	sputc(p, 0);
	pushp(p);
	if(dscale() != 0)
		return;
	p = div(arg1, arg2);
	release(arg1);
	release(arg2);
	sc = savk;

	create(strptr);
	dig = logten*sc;
	dout = ((dig/10) + dig) / logo;
	dec = getdec(p,sc);
	p = removc(p,sc);
	while(length(p) != 0) {
		q = div(p,basptr);
		release(p);
		p = q;
		(*outdit)(rem,0);
	}
	release(p);
	fsfile(strptr);
	while(sfbeg(strptr) == 0)
		OUTC(sbackc(strptr));
	if(sc == 0) {
		release(dec);
		Bprint(&bout,"\n");
		return;
	}
	create(strptr);
	OUTC('.');
	ct=0;
	do {
		q = mult(basptr,dec);
		release(dec);
		dec = getdec(q,sc);
		p = removc(q,sc);
		(*outdit)(p,1);
	} while(++ct < dout);
	release(dec);
	rewind(strptr);
	while(sfeof(strptr) == 0)
		OUTC(sgetc(strptr));
	Bprint(&bout,"\n");
}
Exemplo n.º 9
0
void
print(struct blk *hptr)
{
	int sc;
	register struct blk *p,*q,*dec;
	int dig,dout,ct;

	rewind(hptr);
	while(sfeof(hptr) == 0){
		if(sgetc(hptr)>99){
			rewind(hptr);
			while(sfeof(hptr) == 0){
				printf("%c",sgetc(hptr));
			}
			printf("\n");
			return;
		}
	}
	fsfile(hptr);
	sc = sbackc(hptr);
	if(sfbeg(hptr) != 0){
		printf("0\n");
		return;
	}
	count = ll;
	p = copy(hptr,length(hptr));
	sunputc(p);
	fsfile(p);
	if(sbackc(p)<0){
		chsign(p);
		OUTC('-');
	}
	if((obase == 0) || (obase == -1)){
		oneot(p,sc,'d');
		return;
	}
	if(obase == 1){
		oneot(p,sc,'1');
		return;
	}
	if(obase == 10){
		tenot(p,sc);
		return;
	}
	create(strptr);
	dig = log_10*sc;
	dout = ((dig/10) + dig) /logo;
	dec = getdec(p,sc);
	p = removc(p,sc);
	while(length(p) != 0){
		q = dcdiv(p,basptr);
		release(p);
		p = q;
		(*outdit)(rem,0,1);
	}
	release(p);
	fsfile(strptr);
	while(sfbeg(strptr) == 0)OUTC(sbackc(strptr));
	if(sc == 0){
		release(dec);
		printf("\n");
		return;
	}
	create(strptr);
	OUTC('.');
	ct=0;
	do{
		q = mult(basptr,dec);
		release(dec);
		dec = getdec(q,sc);
		p = removc(q,sc);
		(*outdit)(p,1,ct+1<dout);
	}while(++ct < dout);
	release(dec);
	rewind(strptr);
	while(sfeof(strptr) == 0)OUTC(sgetc(strptr));
	printf("\n");
	return;
}
Exemplo n.º 10
0
static int
action(jsminCtx *ctx, int d)
{
	int res = JSMIN_OK;
    switch (d) {
    case 1:
        OUTC(ctx, ctx->theA);
        if (
            (ctx->theY == '\n' || ctx->theY == ' ') &&
            (ctx->theA == '+' || ctx->theA == '-' || ctx->theA == '*' || ctx->theA == '/') &&
            (ctx->theB == '+' || ctx->theB == '-' || ctx->theB == '*' || ctx->theB == '/')
        ) {
            OUTC(ctx, ctx->theY);
        }
    case 2:
        ctx->theA = ctx->theB;
        if (ctx->theA == '\'' || ctx->theA == '"' || ctx->theA == '`') {
            for (;;) {
                OUTC(ctx, ctx->theA);
                ctx->theA = get(ctx);
                if (ctx->theA == ctx->theB) {
                    break;
                }
                if (ctx->theA == '\\') {
                    OUTC(ctx, ctx->theA);
                    ctx->theA = get(ctx);
                }
                if (ctx->theA == EOF) {
                    error(ctx,"Unterminated string literal.");
					return JSMIN_ERROR;
                }
            }
        }
    case 3:
        res = next(ctx, &ctx->theB);
		if (res != JSMIN_OK) return res;
        if (ctx->theB == '/' && (
            ctx->theA == '(' || ctx->theA == ',' || ctx->theA == '=' || ctx->theA == ':' ||
            ctx->theA == '[' || ctx->theA == '!' || ctx->theA == '&' || ctx->theA == '|' ||
            ctx->theA == '?' || ctx->theA == '+' || ctx->theA == '-' || ctx->theA == '~' ||
            ctx->theA == '*' || ctx->theA == '/' || ctx->theA == '{' || ctx->theA == '\n'
        )) {
            OUTC(ctx, ctx->theA);
            if (ctx->theA == '/' || ctx->theA == '*') {
                OUTC(ctx, ' ');
            }
            OUTC(ctx, ctx->theB);
            for (;;) {
                ctx->theA = get(ctx);
                if (ctx->theA == '[') {
                    for (;;) {
                        OUTC(ctx, ctx->theA);
                        ctx->theA = get(ctx);
                        if (ctx->theA == ']') {
                            break;
                        }
                        if (ctx->theA == '\\') {
                            OUTC(ctx, ctx->theA);
                            ctx->theA = get(ctx);
                        }
                        if (ctx->theA == EOF) {
                            error(ctx, "Unterminated set in Regular Expression literal.");
							return JSMIN_ERROR;
                        }
                    }
                } else if (ctx->theA == '/') {
                    switch (peek(ctx)) {
                    case '/':
                    case '*':
                        error(ctx, "Unterminated set in Regular Expression literal.");
						return JSMIN_ERROR;
                    }
                    break;
                } else if (ctx->theA =='\\') {
                    OUTC(ctx, ctx->theA);
                    ctx->theA = get(ctx);
                }
                if (ctx->theA == EOF) {
                    error(ctx, "Unterminated Regular Expression literal.");
					return JSMIN_ERROR;
                }
                OUTC(ctx, ctx->theA);
            }
            res = next(ctx, &ctx->theB);
			if (res != JSMIN_OK) return res;
        }
    }
	return JSMIN_OK;
}