diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-05-18 06:11:17 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-05-18 06:11:17 +0000 |
commit | 55ee0b4b9f71cc4b59b74d2b005eaab5d9462e98 (patch) | |
tree | 6d3ee587d0a615b32d4722b2c700a55d1d293890 /sys | |
parent | 43eb8af22a2d2d59300559c9610a5a4faf274cdc (diff) |
Use standard swap16() and swap32() functions instead of abusing <db.h> to get
similar M_xx_SWAP().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/mvme88k/stand/prtvid/chklabel.c | 115 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/prtvid/prtvid.c | 124 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/wrtvid/wrtvid.c | 70 |
3 files changed, 104 insertions, 205 deletions
diff --git a/sys/arch/mvme88k/stand/prtvid/chklabel.c b/sys/arch/mvme88k/stand/prtvid/chklabel.c deleted file mode 100644 index d776270a26b..00000000000 --- a/sys/arch/mvme88k/stand/prtvid/chklabel.c +++ /dev/null @@ -1,115 +0,0 @@ -/* $OpenBSD: chklabel.c,v 1.3 2002/03/14 01:26:40 millert Exp $ */ -/* - * Copyright (c) 1993 Paul Kranenburg - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/param.h> -#include <sys/disklabel.h> -#include <stdio.h> - -void cputobsdlabel(struct disklabel *lp, struct cpu_disklabel *clp); - -main(int argc, char *argv[]) -{ - struct cpu_disklabel cpu_label; - struct disklabel sdlabel; - int i; - - fread((void *)&cpu_label, sizeof(struct cpu_disklabel), 1, stdin); - cputobsdlabel(&sdlabel, (struct cpu_disklabel *)&cpu_label); - - for (i = 0; i < MAXPARTITIONS; i++) { - printf("part %x off %x size %x\n", - i, sdlabel.d_partitions[i].p_offset, - sdlabel.d_partitions[i].p_size); - } -} - -void -cputobsdlabel(struct disklabel *lp, struct cpu_disklabel *clp) -{ - int i; - - lp->d_magic = clp->magic1; - lp->d_type = clp->type; - lp->d_subtype = clp->subtype; - bcopy(clp->vid_vd, lp->d_typename, 16); - bcopy(clp->packname, lp->d_packname, 16); - lp->d_secsize = clp->cfg_psm; - lp->d_nsectors = clp->cfg_spt; - lp->d_ncylinders = clp->cfg_trk; /* trk is really num of cyl! */ - lp->d_ntracks = clp->cfg_hds; - - lp->d_secpercyl = clp->secpercyl; - lp->d_secperunit = clp->secperunit; - lp->d_secpercyl = clp->secpercyl; - lp->d_secperunit = clp->secperunit; - lp->d_sparespertrack = clp->sparespertrack; - lp->d_sparespercyl = clp->sparespercyl; - lp->d_acylinders = clp->acylinders; - lp->d_rpm = clp->rpm; - lp->d_interleave = clp->cfg_ilv; - lp->d_trackskew = clp->cfg_sof; - lp->d_cylskew = clp->cylskew; - lp->d_headswitch = clp->headswitch; - - /* this silly table is for winchester drives */ - switch (clp->cfg_ssr) { - case 0: - lp->d_trkseek = 0; - break; - case 1: - lp->d_trkseek = 6; - break; - case 2: - lp->d_trkseek = 10; - break; - case 3: - lp->d_trkseek = 15; - break; - case 4: - lp->d_trkseek = 20; - break; - default: - lp->d_trkseek = 0; - break; - } - lp->d_flags = clp->flags; - for (i = 0; i < NDDATA; i++) - lp->d_drivedata[i] = clp->drivedata[i]; - for (i = 0; i < NSPARE; i++) - lp->d_spare[i] = clp->spare[i]; - lp->d_magic2 = clp->magic2; - lp->d_checksum = clp->checksum; - lp->d_npartitions = clp->partitions; - lp->d_bbsize = clp->bbsize; - lp->d_sbsize = clp->sbsize; - bcopy(clp->vid_4, &(lp->d_partitions[0]), sizeof (struct partition) * 4); - bcopy(clp->cfg_4, &(lp->d_partitions[4]), sizeof (struct partition) * 12); -} diff --git a/sys/arch/mvme88k/stand/prtvid/prtvid.c b/sys/arch/mvme88k/stand/prtvid/prtvid.c index 11c376e3fa1..065d278a411 100644 --- a/sys/arch/mvme88k/stand/prtvid/prtvid.c +++ b/sys/arch/mvme88k/stand/prtvid/prtvid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prtvid.c,v 1.4 2006/05/16 22:52:26 miod Exp $ */ +/* $OpenBSD: prtvid.c,v 1.5 2006/05/18 06:11:15 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn <drahn@openbsd.org> @@ -17,10 +17,14 @@ */ #include <stdio.h> -#define __DBINTERFACE_PRIVATE -#include <db.h> +#include <stdlib.h> + #include "vid.h" +void swabcfg(struct cfg *); +void swabvid(struct vid *); + +int main(argc, argv) int argc; char *argv[]; @@ -35,23 +39,23 @@ main(argc, argv) if (BYTE_ORDER != BIG_ENDIAN) swabvid(pvid); - printf("vid_id %s %x\n", pvid->vid_id, + printf("vid_id %s %lx\n", pvid->vid_id, (char *)&(pvid->vid_id[4]) - (char *)pvid); - printf("vid_oss %x %x\n", pvid->vid_oss, + printf("vid_oss %x %lx\n", pvid->vid_oss, (char *)&(pvid->vid_oss) - (char *)pvid); - printf("vid_osl %x %x\n", pvid->vid_osl, + printf("vid_osl %x %lx\n", pvid->vid_osl, (char *)&(pvid->vid_osl) - (char *)pvid); - printf("vid_osa_u %x %x\n", pvid->vid_osa_u, + printf("vid_osa_u %x %lx\n", pvid->vid_osa_u, (char *)&(pvid->vid_osa_u) - (char *)pvid); - printf("vid_osa_l %x %x\n", pvid->vid_osa_l, + printf("vid_osa_l %x %lx\n", pvid->vid_osa_l, (char *)&(pvid->vid_osa_l) - (char *)pvid); - printf("vid_vd %x %x\n", pvid->vid_vd, + printf("vid_vd %s %lx\n", pvid->vid_vd, (char *)&(pvid->vid_vd) - (char *)pvid); - printf("vid_cas %x %x\n", pvid->vid_cas, + printf("vid_cas %x %lx\n", pvid->vid_cas, (char *)&(pvid->vid_cas) - (char *)pvid); - printf("vid_cal %x %x\n", pvid->vid_cal, + printf("vid_cal %x %lx\n", pvid->vid_cal, (char *)&(pvid->vid_cal) - (char *)pvid); - printf("vid_moto %s %x\n", pvid->vid_mot, + printf("vid_moto %s %lx\n", pvid->vid_mot, (char *)&(pvid->vid_mot[0]) - (char *)pvid); free(pvid); @@ -63,88 +67,92 @@ main(argc, argv) if (BYTE_ORDER != BIG_ENDIAN) swabcfg(pcfg); - printf("cfg_atm %x %x\n", pcfg->cfg_atm, + printf("cfg_atm %x %lx\n", pcfg->cfg_atm, (char *)&(pcfg->cfg_atm) - (char *)(pcfg)); - printf("cfg_prm %x %x\n", pcfg->cfg_prm, + printf("cfg_prm %x %lx\n", pcfg->cfg_prm, (char *)&(pcfg->cfg_prm) - (char *)(pcfg)); - printf("cfg_atw %x %x\n", pcfg->cfg_atw, + printf("cfg_atw %x %lx\n", pcfg->cfg_atw, (char *)&(pcfg->cfg_atw) - (char *)(pcfg)); - printf("cfg_rec %x %x\n",(long)pcfg->cfg_rec, + printf("cfg_rec %x %lx\n",(int)pcfg->cfg_rec, (char *)&(pcfg->cfg_rec) - (char *)(pcfg)); - printf("cfg_spt %x %x\n", pcfg->cfg_spt, + printf("cfg_spt %x %lx\n", pcfg->cfg_spt, (char *)&(pcfg->cfg_spt) - (char *)(pcfg)); - printf("cfg_hds %x %x\n", pcfg->cfg_hds, + printf("cfg_hds %x %lx\n", pcfg->cfg_hds, (char *)&(pcfg->cfg_hds) - (char *)(pcfg)); - printf("cfg_trk %x %x\n", pcfg->cfg_trk, + printf("cfg_trk %x %lx\n", pcfg->cfg_trk, (char *)&(pcfg->cfg_trk) - (char *)(pcfg)); - printf("cfg_ilv %x %x\n", pcfg->cfg_ilv, + printf("cfg_ilv %x %lx\n", pcfg->cfg_ilv, (char *)&(pcfg->cfg_ilv) - (char *)(pcfg)); - printf("cfg_sof %x %x\n", pcfg->cfg_sof, + printf("cfg_sof %x %lx\n", pcfg->cfg_sof, (char *)&(pcfg->cfg_sof) - (char *)(pcfg)); - printf("cfg_psm %x %x\n", pcfg->cfg_psm, + printf("cfg_psm %x %lx\n", pcfg->cfg_psm, (char *)&(pcfg->cfg_psm) - (char *)(pcfg)); - printf("cfg_shd %x %x\n", pcfg->cfg_shd, + printf("cfg_shd %x %lx\n", pcfg->cfg_shd, (char *)&(pcfg->cfg_shd) - (char *)(pcfg)); - printf("cfg_pcom %x %x\n", pcfg->cfg_pcom, + printf("cfg_pcom %x %lx\n", pcfg->cfg_pcom, (char *)&(pcfg->cfg_pcom) - (char *)(pcfg)); - printf("cfg_ssr %x %x\n", pcfg->cfg_ssr, + printf("cfg_ssr %x %lx\n", pcfg->cfg_ssr, (char *)&(pcfg->cfg_ssr) - (char *)(pcfg)); - printf("cfg_rwcc %x %x\n", pcfg->cfg_rwcc, + printf("cfg_rwcc %x %lx\n", pcfg->cfg_rwcc, (char *)&(pcfg->cfg_rwcc) - (char *)(pcfg)); - printf("cfg_ecc %x %x\n", pcfg->cfg_ecc, + printf("cfg_ecc %x %lx\n", pcfg->cfg_ecc, (char *)&(pcfg->cfg_ecc) - (char *)(pcfg)); - printf("cfg_eatm %x %x\n", pcfg->cfg_eatm, + printf("cfg_eatm %x %lx\n", pcfg->cfg_eatm, (char *)&(pcfg->cfg_eatm) - (char *)(pcfg)); - printf("cfg_eprm %x %x\n", pcfg->cfg_eprm, + printf("cfg_eprm %x %lx\n", pcfg->cfg_eprm, (char *)&(pcfg->cfg_eprm) - (char *)(pcfg)); - printf("cfg_eatw %x %x\n", pcfg->cfg_eatw, + printf("cfg_eatw %x %lx\n", pcfg->cfg_eatw, (char *)&(pcfg->cfg_eatw) - (char *)(pcfg)); - printf("cfg_gpb1 %x %x\n", pcfg->cfg_gpb1, + printf("cfg_gpb1 %x %lx\n", pcfg->cfg_gpb1, (char *)&(pcfg->cfg_gpb1) - (char *)(pcfg)); - printf("cfg_gpb2 %x %x\n", pcfg->cfg_gpb2, + printf("cfg_gpb2 %x %lx\n", pcfg->cfg_gpb2, (char *)&(pcfg->cfg_gpb2) - (char *)(pcfg)); - printf("cfg_gpb3 %x %x\n", pcfg->cfg_gpb3, + printf("cfg_gpb3 %x %lx\n", pcfg->cfg_gpb3, (char *)&(pcfg->cfg_gpb3) - (char *)(pcfg)); - printf("cfg_gpb4 %x %x\n", pcfg->cfg_gpb4, + printf("cfg_gpb4 %x %lx\n", pcfg->cfg_gpb4, (char *)&(pcfg->cfg_gpb4) - (char *)(pcfg)); - printf("cfg_ssc %x %x\n", pcfg->cfg_ssc, + printf("cfg_ssc %x %lx\n", pcfg->cfg_ssc, (char *)&(pcfg->cfg_ssc) - (char *)(pcfg)); - printf("cfg_runit %x %x\n", pcfg->cfg_runit, + printf("cfg_runit %x %lx\n", pcfg->cfg_runit, (char *)&(pcfg->cfg_runit) - (char *)(pcfg)); - printf("cfg_rsvc1 %x %x\n", pcfg->cfg_rsvc1, + printf("cfg_rsvc1 %x %lx\n", pcfg->cfg_rsvc1, (char *)&(pcfg->cfg_rsvc1) - (char *)(pcfg)); - printf("cfg_rsvc2 %x %x\n", pcfg->cfg_rsvc2, + printf("cfg_rsvc2 %x %lx\n", pcfg->cfg_rsvc2, (char *)&(pcfg->cfg_rsvc2) - (char *)(pcfg)); + + return (0); } +void swabvid(pvid) struct vid *pvid; { - M_32_SWAP(pvid->vid_oss); - M_16_SWAP(pvid->vid_osl); - M_16_SWAP(pvid->vid_osa_u); - M_16_SWAP(pvid->vid_osa_l); - M_32_SWAP(pvid->vid_cas); + swap32(pvid->vid_oss); + swap16(pvid->vid_osl); + swap16(pvid->vid_osa_u); + swap16(pvid->vid_osa_l); + swap32(pvid->vid_cas); } +void swabcfg(pcfg) struct cfg *pcfg; { printf("swapping cfg\n"); - M_16_SWAP(pcfg->cfg_atm); - M_16_SWAP(pcfg->cfg_prm); - M_16_SWAP(pcfg->cfg_atm); - M_16_SWAP(pcfg->cfg_rec); - M_16_SWAP(pcfg->cfg_trk); - M_16_SWAP(pcfg->cfg_psm); - M_16_SWAP(pcfg->cfg_shd); - M_16_SWAP(pcfg->cfg_pcom); - M_16_SWAP(pcfg->cfg_rwcc); - M_16_SWAP(pcfg->cfg_ecc); - M_16_SWAP(pcfg->cfg_eatm); - M_16_SWAP(pcfg->cfg_eprm); - M_16_SWAP(pcfg->cfg_eatw); - M_16_SWAP(pcfg->cfg_rsvc1); - M_16_SWAP(pcfg->cfg_rsvc2); + swap16(pcfg->cfg_atm); + swap16(pcfg->cfg_prm); + swap16(pcfg->cfg_atm); + swap16(pcfg->cfg_rec); + swap16(pcfg->cfg_trk); + swap16(pcfg->cfg_psm); + swap16(pcfg->cfg_shd); + swap16(pcfg->cfg_pcom); + swap16(pcfg->cfg_rwcc); + swap16(pcfg->cfg_ecc); + swap16(pcfg->cfg_eatm); + swap16(pcfg->cfg_eprm); + swap16(pcfg->cfg_eatw); + swap16(pcfg->cfg_rsvc1); + swap16(pcfg->cfg_rsvc2); } diff --git a/sys/arch/mvme88k/stand/wrtvid/wrtvid.c b/sys/arch/mvme88k/stand/wrtvid/wrtvid.c index 159852be5b9..4a0fa2f12ef 100644 --- a/sys/arch/mvme88k/stand/wrtvid/wrtvid.c +++ b/sys/arch/mvme88k/stand/wrtvid/wrtvid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wrtvid.c,v 1.5 2004/12/27 15:23:46 drahn Exp $ */ +/* $OpenBSD: wrtvid.c,v 1.6 2006/05/18 06:11:16 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn <drahn@openbsd.org> @@ -16,19 +16,25 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> #include <unistd.h> +#include <fcntl.h> #include <stdio.h> -#define __DBINTERFACE_PRIVATE -#include <db.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> + #include "disklabel.h" -/* disklabel.h is in current dir because of my +/* disklabel.h is in current dir because of my cross-compile env. if <machine/disklabel.h> is newer, copy it here. */ +void copy_exe(int, int); +void swabcfg(struct cpu_disklabel *); +void swabvid(struct cpu_disklabel *); + +int main(argc, argv) int argc; char **argv; @@ -39,11 +45,8 @@ main(argc, argv) int tape_vid; int tape_exe; unsigned int exe_addr; - unsigned short exe_addr_u; - unsigned short exe_addr_l; char *filename; char fileext[256]; - char filebase[256]; if (argc == 1) filename = "a.out"; @@ -121,6 +124,7 @@ main(argc, argv) } #define BUF_SIZ 512 +void copy_exe(exe_file, tape_exe) int exe_file, tape_exe; { @@ -137,34 +141,36 @@ copy_exe(exe_file, tape_exe) write(tape_exe, buf, BUF_SIZ); } +void swabvid(pcpul) struct cpu_disklabel *pcpul; { - M_32_SWAP(pcpul->vid_oss); - M_16_SWAP(pcpul->vid_osl); - /* - M_16_SWAP(pcpul->vid_osa_u); - M_16_SWAP(pcpul->vid_osa_l); - */ - M_32_SWAP(pcpul->vid_cas); + swap32(pcpul->vid_oss); + swap16(pcpul->vid_osl); +#if 0 + swap16(pcpul->vid_osa_u); + swap16(pcpul->vid_osa_l); +#endif + swap32(pcpul->vid_cas); } +void swabcfg(pcpul) struct cpu_disklabel *pcpul; { - M_16_SWAP(pcpul->cfg_atm); - M_16_SWAP(pcpul->cfg_prm); - M_16_SWAP(pcpul->cfg_atm); - M_16_SWAP(pcpul->cfg_rec); - M_16_SWAP(pcpul->cfg_trk); - M_16_SWAP(pcpul->cfg_psm); - M_16_SWAP(pcpul->cfg_shd); - M_16_SWAP(pcpul->cfg_pcom); - M_16_SWAP(pcpul->cfg_rwcc); - M_16_SWAP(pcpul->cfg_ecc); - M_16_SWAP(pcpul->cfg_eatm); - M_16_SWAP(pcpul->cfg_eprm); - M_16_SWAP(pcpul->cfg_eatw); - M_16_SWAP(pcpul->cfg_rsvc1); - M_16_SWAP(pcpul->cfg_rsvc2); + swap16(pcpul->cfg_atm); + swap16(pcpul->cfg_prm); + swap16(pcpul->cfg_atm); + swap16(pcpul->cfg_rec); + swap16(pcpul->cfg_trk); + swap16(pcpul->cfg_psm); + swap16(pcpul->cfg_shd); + swap16(pcpul->cfg_pcom); + swap16(pcpul->cfg_rwcc); + swap16(pcpul->cfg_ecc); + swap16(pcpul->cfg_eatm); + swap16(pcpul->cfg_eprm); + swap16(pcpul->cfg_eatw); + swap16(pcpul->cfg_rsvc1); + swap16(pcpul->cfg_rsvc2); } |