1*ce099b40Smartin /* -*-C++-*- $NetBSD: platform.cpp,v 1.6 2008/04/28 20:23:20 martin Exp $ */
29173eae7Such
39173eae7Such /*-
49173eae7Such * Copyright (c) 2001 The NetBSD Foundation, Inc.
59173eae7Such * All rights reserved.
69173eae7Such *
79173eae7Such * This code is derived from software contributed to The NetBSD Foundation
89173eae7Such * by UCHIYAMA Yasushi.
99173eae7Such *
109173eae7Such * Redistribution and use in source and binary forms, with or without
119173eae7Such * modification, are permitted provided that the following conditions
129173eae7Such * are met:
139173eae7Such * 1. Redistributions of source code must retain the above copyright
149173eae7Such * notice, this list of conditions and the following disclaimer.
159173eae7Such * 2. Redistributions in binary form must reproduce the above copyright
169173eae7Such * notice, this list of conditions and the following disclaimer in the
179173eae7Such * documentation and/or other materials provided with the distribution.
189173eae7Such *
199173eae7Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
209173eae7Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
219173eae7Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
229173eae7Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
239173eae7Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
249173eae7Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
259173eae7Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
269173eae7Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
279173eae7Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
289173eae7Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
299173eae7Such * POSSIBILITY OF SUCH DAMAGE.
309173eae7Such */
319173eae7Such
329173eae7Such #include <hpcmenu.h>
339173eae7Such #include <machine/platid.h>
349173eae7Such #include <machine/platid_mask.h>
359173eae7Such
369173eae7Such void *
_platform(int n,enum _platform_op op)379173eae7Such HpcMenuInterface::_platform(int n, enum _platform_op op)
389173eae7Such {
399173eae7Such int i, cnt;
409173eae7Such struct platid_name *name;
419173eae7Such
429173eae7Such for (i = cnt = 0, name = platid_name_table;
439173eae7Such i < platid_name_table_size; i++, name++) {
449173eae7Such platid_t *mask = name->mask;
459173eae7Such if (mask->dw.dw0 == PLATID_WILD || mask->dw.dw1 == PLATID_WILD)
469173eae7Such continue;
479173eae7Such switch(op) {
489173eae7Such case _PLATFORM_OP_GET:
499173eae7Such if (n == cnt)
5075d8bdf0Suwe // XXX: constification fallout
5175d8bdf0Suwe return reinterpret_cast <void *>
5275d8bdf0Suwe (const_cast <tchar *>(name->name));
539173eae7Such break;
549173eae7Such case _PLATFORM_OP_SET:
559173eae7Such if (n == cnt) {
569173eae7Such _pref.platid_hi = mask->dw.dw0;
579173eae7Such _pref.platid_lo = mask->dw.dw1;
589173eae7Such return static_cast <void *>(0);
599173eae7Such }
609173eae7Such break;
619173eae7Such case _PLATFORM_OP_DEFAULT:
629173eae7Such if ((mask->dw.dw0 == _pref.platid_hi) &&
639173eae7Such (mask->dw.dw1 == _pref.platid_lo))
649173eae7Such return reinterpret_cast <void *>(cnt);
659173eae7Such break;
669173eae7Such }
679173eae7Such cnt++;
689173eae7Such }
699173eae7Such
709173eae7Such return 0;
719173eae7Such }
72