9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] pxeload nvram
Date: Mon,  2 Nov 2009 16:45:07 -0500	[thread overview]
Message-ID: <1bdac4f0786944b8523779749145784a@ladd.quanstro.net> (raw)
In-Reply-To: <<F199679A-1998-4100-BA44-AE7DBA583730@lsub.org>>

On Mon Nov  2 15:34:25 EST 2009, nemo@lsub.org wrote:
> iirc you could put nvram=/dev/sdU...
> in plan9.ini.

this patch, mentioned at iwp9, will also solve the
problem without mangling plan9.ini:

/n/sources/plan9//sys/src/libauthsrv/readnvram.c:25,46 - readnvram.c:25,32
  	int len;
  } nvtab[] = {
  	"sparc", "#r/nvram", 1024+850, sizeof(Nvrsafe),
- 	"pc", "#S/sdC0/nvram", 0, sizeof(Nvrsafe),
- 	"pc", "#S/sdC0/9fat", -1, sizeof(Nvrsafe),
- 	"pc", "#S/sdC1/nvram", 0, sizeof(Nvrsafe),
- 	"pc", "#S/sdC1/9fat", -1, sizeof(Nvrsafe),
- 	"pc", "#S/sdD0/nvram", 0, sizeof(Nvrsafe),
- 	"pc", "#S/sdD0/9fat", -1, sizeof(Nvrsafe),
- 	"pc", "#S/sdE0/nvram", 0, sizeof(Nvrsafe),
- 	"pc", "#S/sdE0/9fat", -1, sizeof(Nvrsafe),
- 	"pc", "#S/sdF0/nvram", 0, sizeof(Nvrsafe),
- 	"pc", "#S/sdF0/9fat", -1, sizeof(Nvrsafe),
- 	"pc", "#S/sd00/nvram", 0, sizeof(Nvrsafe),
- 	"pc", "#S/sd00/9fat", -1, sizeof(Nvrsafe),
- 	"pc", "#S/sd01/nvram", 0, sizeof(Nvrsafe),
- 	"pc", "#S/sd01/9fat", -1, sizeof(Nvrsafe),
- 	"pc", "#S/sd10/nvram", 0, sizeof(Nvrsafe),
- 	"pc", "#S/sd10/9fat", -1, sizeof(Nvrsafe),
+ 	"pc", "#S/%s%x/9fat", -1, 512,
+ 	"pc", "#S/%s%x/nvram",	0, 512,
  	"pc", "#f/fd0disk", -1, 512,	/* 512: #f requires whole sector reads */
  	"pc", "#f/fd1disk", -1, 512,
  	"mips", "#r/nvram", 1024+900, sizeof(Nvrsafe),
/n/sources/plan9//sys/src/libauthsrv/readnvram.c:123,128 - readnvram.c:109,152
  	}
  }

+ static int
+ sdnvram0(char *s, int l, int tabi)
+ {
+ 	char *p, *f[3], buf[16];
+ 	int fd, i;
+
+ 	s[l] = 0;
+ 	for(; p = strchr(s, '\n'); s = p + 1){
+ 		if(tokenize(s, f, nelem(f)) < 1)
+ 			continue;
+ 		for(i = 0; i < 0x10; i++){
+ 			snprint(buf, sizeof buf, nvtab[tabi].file, f[0], i);
+ 			if((fd = open(buf, ORDWR)) >= 0)
+ 				return fd;
+ 		}
+ 	}
+ 	return -1;
+ }
+
+ static int
+ sdnvram(int tabi)
+ {
+ 	char *s;
+ 	int fd, l, r;
+
+ 	fd = open("#S/sdctl", OREAD);
+ 	if(fd == -1)
+ 		return -1;
+ 	r = -1;
+ 	l = 1024;	/* #S/sdctl has 0 size; guess */
+ 	if(s = malloc(l + 1))
+ 	if((l = read(fd, s, l)) > 0)
+ 		r = sdnvram0(s, l, tabi);
+ 	free(s);
+ 	close(fd);
+ 	return r;
+ }
+
  typedef struct {
  	int	fd;
  	int	safeoff;
/n/sources/plan9//sys/src/libauthsrv/readnvram.c:185,191 - readnvram.c:209,219
  		for(i=0; i<nelem(nvtab); i++){
  			if(strcmp(cputype, nvtab[i].cputype) != 0)
  				continue;
- 			if((fd = open(nvtab[i].file, ORDWR)) < 0)
+ 			if(nvtab[i].file[0] == '#' && nvtab[i].file[1] == 'S')
+ 				fd = sdnvram(i);
+ 			else
+ 				fd = open(nvtab[i].file, ORDWR);
+ 			if(fd < 0)
  				continue;
  			safeoff = nvtab[i].off;
  			safelen = nvtab[i].len;



       reply	other threads:[~2009-11-02 21:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<F199679A-1998-4100-BA44-AE7DBA583730@lsub.org>
2009-11-02 21:45 ` erik quanstrom [this message]
2009-11-02 20:32 Francisco J Ballesteros
  -- strict thread matches above, loose matches on Subject: below --
2009-11-02 18:29 Francisco J Ballesteros
2009-11-02 19:51 ` Skip Tavakkolian
2009-11-02 17:58 Skip Tavakkolian
2009-11-02 18:18 ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1bdac4f0786944b8523779749145784a@ladd.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).