if ((int) pexec->a_entry != (int) addr + 0x22) { (int) addr + 0x22, pexec->a_entry); printf("kernel loaded at %x\n", addr); }
load_kern(pbugargs)	struct mvmeprom_args *pbugargs;{	int     ret;	char   *addr;	u_char flags;	short   status = 0;	int     blk_num;	struct exec *pexec;	int     magic;	int    *esym;	int    *symtab;	int     cnt, len;	char    buf[512];	blk_num = 2;	/* flags = IGNORE_FILENUM; */	flags = 0;	cnt = 512;	ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status,	    buf, &cnt, blk_num, &flags, verbose);	if (ret != 0) {		printf("unable to load kernel 1 status %x\n", status);		return (1);	}	pexec = (struct exec *) buf;	if (N_GETMID(*pexec) != MID_M68K &&	    N_GETMID(*pexec) != MID_M68K4K) {		printf("invalid mid on kernel\n");		return (1);	}	magic = N_GETMAGIC(*pexec);	switch (magic) {	case ZMAGIC:		break;	case NMAGIC:		printf("NMAGIC not yet supported");	case OMAGIC:	case QMAGIC:	default:		printf("Unknown or unsupported magic type <%x>\n", magic);		return (1);	}	if (magic == ZMAGIC) {		status = 0;		addr = (char *) (pexec->a_entry & ~0x0FFF);		if ((int) pexec->a_entry != (int) addr + 0x22) {			    (int) addr + 0x22, pexec->a_entry);			printf("kernel loaded at %x\n", addr);		}		bcopy(&buf, addr, 512);		/* 2nd block of exe */		addr += 512;		printf("text 0x%x data 0x%x bss 0x%x\n",		    pexec->a_text, pexec->a_data, pexec->a_bss);		len = (pexec->a_text - 512);	/* XXX */		len += (pexec->a_data);		printf("loading [ %x + %x ", pexec->a_text, pexec->a_data);		cnt = len;		flags = IGNORE_FILENUM;		ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun,		    &status, addr, &cnt, blk_num, &flags, verbose);		if (ret != 0 || cnt != len) {			printf("unable to load kernel 2 status %x\n", status);			return 1;		}		addr += len;		/* Skip over text and data and zero bss. */		len = pexec->a_bss;		printf("+ %x", len);#ifdef DEBUG		printf("bss %x - %x\n", addr, addr + pexec->a_bss);#endif		bzero(addr, pexec->a_bss);		addr += len;		if (pexec->a_syms != 0 && !(kernel.bflags & RB_NOSYM)) {			printf(" + [ %x", pexec->a_syms);			addr += 4;	/* skip over _end symbol */			symtab = (void *) pexec->a_syms;			len = pexec->a_syms;			cnt = ((len + (512 - 1)) / 512) * 512;			flags = IGNORE_FILENUM;			ret = read_tape_block(pbugargs->ctrl_lun,			    pbugargs->dev_lun, &status, addr,			    &cnt, blk_num, &flags, verbose);			if (ret != 0 || cnt != ((len + (512 - 1)) / 512) * 512) {				printf("unable to load kernel 3\n");				return 1;			}			/* this value should have already been loaded XXX */			esym = (void *) ((u_int) addr + pexec->a_syms);			if ((int) addr + cnt <= (int) esym) {				printf("missed loading count of symbols\n");				return 1;			}			addr += cnt;			len = *esym;#if 0			printf("start load %x end load %x %x\n", addr,			    len, addr + len);			printf("esym %x *esym %x\n", esym, len);#endif			/* dont load tail of already loaded */			len -= (u_int) addr - (u_int) esym;			if (len > 0) {				printf(" + %x", *esym);				esym = (void *) (addr + len);				cnt = ((len + (512 - 1)) / 512) * 512;				flags = IGNORE_FILENUM;				ret = read_tape_block(pbugargs->ctrl_lun,				    pbugargs->dev_lun, &status, addr,				    &cnt, blk_num, &flags, verbose);				if (ret != 0 || cnt != ((len + (512-1)) / 512)*512) {					printf("unable to load kernel 4\n");					return (1);				}				addr += len;				printf(" ]");			} else {				printf("+ %x ]", *esym);			}			esym = (int *) (((int) esym) + *esym);			kernel.symtab = symtab;			kernel.esym = esym;		} else {			kernel.symtab = 0;			kernel.esym = 0;		}		kernel.end_loaded = (int) addr;		flags = IGNORE_FILENUM | END_OF_FILE;		cnt = 8192;		printf("removing pad [");		ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun,		    &status, addr, &cnt, blk_num, &flags, verbose);		if (ret != 0) {			printf("unable to load kernel 5\n");			return (1);		}		printf(" %d ]", cnt);		printf("]\n");	}	kernel.entry = (void *) pexec->a_entry;	return (0);}