1# $NetBSD: x86.conf,v 1.11 2023/09/27 00:24:13 riastradh Exp $
2# x86 shared config
3#
4
5image=$HOME/${board}.img
6MACHINE=${board}
7kernel=$src/sys/arch/${board}/compile/GENERIC/netbsd
8bootfile=$release/usr/mdec/boot
9
10extra=8		# spare space
11size=0		# autocompute
12netbsdid=169
13init=63
14ffsoffset=${init}b
15
16make_label() {
17	# compute all sizes in terms of sectors
18	local totalsize=$(( ${size} / 512 ))
19
20	local aoffset=${init}
21	local asize=$(( ${totalsize} - ${aoffset} ))
22
23	local bps=512
24	local spt=32
25	local tpc=64
26	local spc=2048
27	local cylinders=$(( ${totalsize} / ${spc} ))
28
29	cat << EOF
30type: SCSI
31disk: STORAGE DEVICE
32label: fictitious
33flags: removable
34bytes/sector: ${bps}
35sectors/track: ${spt}
36tracks/cylinder: ${tpc}
37sectors/cylinder: ${spc}
38cylinders: ${cylinders}
39total sectors: ${totalsize}
40rpm: 3600
41interleave: 1
42trackskew: 0
43cylinderskew: 0
44headswitch: 0           # microseconds
45track-to-track seek: 0  # microseconds
46drivedata: 0 
47
488 partitions:
49#     size         offset        fstype [fsize bsize cpg/sgs]
50 a:   ${asize}     ${aoffset}    4.2BSD  ${fsize} ${bsize} 0  # 
51 c:   ${totalsize} 0             unused      0     0          #
52 d:   ${totalsize} 0             unused      0     0          #
53EOF
54}
55
56make_fstab_normal() {
57	cat > ${mnt}/etc/fstab << EOF
58# NetBSD /etc/fstab
59# See /usr/share/examples/fstab/ for more examples.
60/dev/${rootdev}0a	/		ffs	rw,log	1 1
61ptyfs		/dev/pts	ptyfs	rw
62procfs		/proc		procfs	rw
63EOF
64}
65
66# From Richard Neswold's:
67# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html
68# Also for the postfix stuff below
69make_fstab_minwrites() {
70	cat > ${mnt}/etc/fstab << EOF
71# NetBSD /etc/fstab
72# See /usr/share/examples/fstab/ for more examples.
73/dev/${rootdev}0a	/			ffs	rw,log,noatime,nodevmtime 1 1
74ptyfs		/dev/pts		ptyfs	rw
75procfs		/proc			procfs	rw
76tmpfs		/tmp			tmpfs	rw,-s32M
77tmpfs		/var/log		tmpfs	rw,union,-s32M
78tmpfs		/var/run		tmpfs	rw,union,-s1M
79tmpfs		/var/mail		tmpfs	rw,union,-s10M
80tmpfs		/var/spool/postfix	tmpfs	rw,union,-s20M
81tmpfs		/var/db/postfix		tmpfs	rw,union,-s1M
82tmpfs		/var/chroot		tmpfs	rw,union,-s10M
83EOF
84}
85
86make_fstab() {
87	if $minwrites; then
88		make_fstab_minwrites
89	else
90		make_fstab_normal
91	fi
92	echo "./etc/fstab type=file uname=root gname=wheel mode=0755" \
93	    >> "$tmp/selected_sets"
94
95	echo "./proc type=dir uname=root gname=wheel mode=0755" \
96	    >> "$tmp/selected_sets"
97}
98
99customize() {
100	cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf
101	if $minwrites; then
102		mkdir ${mnt}/etc/postfix
103		(umask 022
104		sed -e 's/fifo/unix/' < ${release}/etc/postfix/master.cf > \
105		    ${mnt}/etc/postfix/master.cf)
106	fi
107	cat >> ${mnt}/etc/rc.conf << EOF
108rc_configured=YES
109hostname=${board}
110sshd=YES
111dhcpcd=YES
112wscons=YES
113devpubd=YES
114certctl_init=YES
115EOF
116	echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \
117	    >> "$tmp/selected_sets"
118
119	if [ ! -f ${release}/dev/MAKEDEV ]; then
120		echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
121		exit 1
122	fi
123	echo "${bar} running MAKEDEV ${bar}"
124	${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \
125	    >> "$tmp/selected_sets"
126}
127
128populate() {
129	if [ ! -f ${kernel} ]; then
130		echo ${PROG}: Missing ${kernel} 1>&2
131		exit 1
132	fi
133
134	echo "${bar} installing kernel ${bar}"
135	cp ${kernel} ${mnt}/netbsd
136	if [ ! -f ${bootfile} ]; then
137		echo ${PROG}: Missing ${bootfile} 1>&2
138		exit 1
139	fi
140	cp ${bootfile} ${mnt}/boot ||
141	    fail "copy of ${bootfile} to ${mnt}/boot failed"
142
143	echo "./netbsd type=file uname=root gname=wheel mode=0755" \
144	    >> "$tmp/selected_sets"
145	echo "./boot type=file uname=root gname=wheel mode=0444" \
146	    >> "$tmp/selected_sets"
147}
148