sys/boot/arm/at91/boot2/boot2.c
/*
 * fixup_boot_drv() will try to find the ROOTDEVNAME spec in the kernel
 * and change it to what was specified on the comandline or /boot.conf
 * file or to what was encountered on the disk. It will try to handle 3
 * different disk layouts, raw (dangerously dedicated), slice only and
 * slice + partition. It will look for the following strings in the
 * kernel, but if it is one of the first three, the string in the kernel
 * must use the correct form to match the actual disk layout:
 * - ufs:ad0a
 * - ufs:ad0s1
 * - ufs:ad0s1a
 * - ufs:ROOTDEVNAME
 * In the case of the first three strings, only the "a" at the end and
 * the "1" after the "s" will be modified, if they exist. The string
 * length will not be changed. In the case of the last string, the
 * whole string will be built up and nul, '\0' terminated.
 */
fixup_boot_drv() will try to find the ROOTDEVNAME spec in the kernel
and change it to what was specified on the comandline or /boot.conf
file or to what was encountered on the disk. It will try to handle 3
different disk layouts, raw (dangerously dedicated), slice only and
slice + partition.
fixup_boot_drv () will try to find the ROOTDEVNAME spec in the kernel and change it to what was specified on the comandline or / boot . conf file or to what was encountered on the disk . It will try to handle 3 different disk layouts raw ( dangerously dedicated ) slice only and slice + partition .
static void
fixup_boot_drv(caddr_t addr, int klen, int bs, int bp)
{
	const u_int8_t op[] = "ufs:ROOTDEVNAME";
	const u_int8_t op2[] = "ufs:ad0";
	u_int8_t *p, *ps;
	DPRINTF("fixup_boot_drv: 0x%x, %d, slice %d, partition %d\n",
	    (int)addr, klen, bs, bp);
	if (bs > 4)
		return;
	if (bp > 7)
		return;
	ps = memmem(addr, klen, op, sizeof(op));
	if (ps != NULL) {
		p = ps + 4;	
		DPRINTF("Found it at 0x%x\n", (int)ps);
		p[0] = 'a'; p[1] = 'd'; p[2] = '0';	
		p += 3;
		if (bs > 0) {
			*p++ = 's';
			*p++ = bs + '0';
		}
		if (disk_layout != DL_SLICE) {
			*p++ = bp + 'a';
		}
		*p = '\0';
	} else {
		ps = memmem(addr, klen, op2, sizeof(op2) - 1);
		if (ps != NULL) {
			p = ps + sizeof(op2) - 1;
			DPRINTF("Found it at 0x%x\n", (int)ps);
			if (*p == 's') {
				p++;
				*p++ = bs + '0';
			}
			if (*p == 'a')
				*p = bp + 'a';
		}
	}
	if (ps == NULL) {
		printf("Could not locate \"%s\" to fix kernel boot device, "
		     "check ROOTDEVNAME is set\n", op);
		return;
	}
	DPRINTF("Changed boot device to %s\n", ps);
}
static void fixup_boot_drv ( caddr_t addr , int klen , int bs , int bp ) { const u_int8_t op [ ] = " " ; const u_int8_t op2 [ ] = " " ; u_int8_t * p , * ps ; DPRINTF ( " \n " , ( int ) addr , klen , bs , bp ) ; if ( bs > 4 ) return ; if ( bp > 7 ) return ; ps = memmem ( addr , klen , op , sizeof ( op ) ) ; if ( ps != NULL ) { p = ps + 4 ; DPRINTF ( " \n " , ( int ) ps ) ; p [ 0 ] = ' ' ; p [ 1 ] = ' ' ; p [ 2 ] = ' ' ; p += 3 ; if ( bs > 0 ) { * p ++ = ' ' ; * p ++ = bs + ' ' ; } if ( disk_layout != DL_SLICE ) { * p ++ = bp + ' ' ; } * p = ' \0 ' ; } else { ps = memmem ( addr , klen , op2 , sizeof ( op2 ) - 1 ) ; if ( ps != NULL ) { p = ps + sizeof ( op2 ) - 1 ; DPRINTF ( " \n " , ( int ) ps ) ; if ( * p == ' ' ) { p ++ ; * p ++ = bs + ' ' ; } if ( * p == ' ' ) * p = bp + ' ' ; } } if ( ps == NULL ) { printf ( " \" \" " " \n " , op ) ; return ; } DPRINTF ( " \n " , ps ) ; }
fixup_boot_drv() will try to find the ROOTDEVNAME spec in the kernel
 and change it to what was specified on the comandline or /boot.conf
 file or to what was encountered on the disk.
fixup_boot_drv () will try to find the ROOTDEVNAME spec in the kernel and change it to what was specified on the comandline or / boot . conf file or to what was encountered on the disk .
/* past ufs: */ /* ad0 */ /* append slice */ /* append partition */ /* fix slice */