[eros-cvs] cvs commit: eros/src/base/tests/func/i486/pcconsole .cvsignore Makefile imgmap pcconsole.c
shap@eros.cs.jhu.edu
shap@eros.cs.jhu.edu
Wed, 25 Jul 2001 00:51:53 -0400
shap 01/07/25 00:51:53
Added: src/base/tests/func/i486/pcconsole .cvsignore Makefile
imgmap pcconsole.c
Log:
Here is a test case that demonstrates how to publish a device memory
range, map it into a process, and then use it.
Note that this test case will only work until we start using the
graphics version of the console!!!
Revision Changes Path
1.1 eros/src/base/tests/func/i486/pcconsole/.cvsignore
Index: .cvsignore
===================================================================
constituents.h
vmfloppy
test.sysimg
test.sysvol
pcconsole
ztest.sysvol
sysgen.map
.*.m
1.1 eros/src/base/tests/func/i486/pcconsole/Makefile
Index: Makefile
===================================================================
#
# Copyright (C) 2001, Jonathan S. Shapiro.
#
# This file is part of the EROS Operating System.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
default: install
CROSS_BUILD=yes
EROS_SRC=../../../../..
include $(EROS_SRC)/build/lib/make/makevars.mk
GENERATED=constituents.h
TARGETS=pcconsole
OBJECTS=pcconsole.o
CLEANLIST=test.sysimg test.sysvol
INC=-I$(EROS_ROOT)/include
BOOT=$(EROS_ROOT)/lib/$(EROS_TARGET)/image/boot
VOLMAP=../../test.volmap
include $(EROS_SRC)/build/lib/make/makerules.mk
include ../../test.mk
install all: $(TARGETS)
pcconsole.c: constituents.h
pcconsole: pcconsole.o $(DOMLIB) $(DOMCRT0)
$(DOMLINK) $(DOMLINKOPT) -o pcconsole $(DOMCRT0) pcconsole.o -lsmall $(DOMLIB)
-include .*.m
1.1 eros/src/base/tests/func/i486/pcconsole/imgmap
Index: imgmap
===================================================================
/* -*- Mode: c -*- */
/*
* Copyright (C) 2001, Jonathan S. Shapiro.
*
* This file is part of the EROS Operating System.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*********************************************
* PRIMORDIAL DOMAINS
*********************************************/
#include <primebank.map>
#include <ipltool.map>
pcconsole = new process;
pcconsole space = small program "pcconsole";
pcconsole pc = symbol "pcconsole" _start;
pcconsole schedule = sched(8);
CONSTIT(pcconsole, KC_OSTREAM, 3) = misc Console;
CONSTIT(pcconsole, KC_DEVPRIVS, 4) = misc DevicePrivs;
CONSTIT(pcconsole, KC_PHYSRANGE, 5) = physmem range;
pcconsole key reg 2 = pcconsole;
pcconsole key reg 4 = primebank;
run pcconsole;
print directory;
1.1 eros/src/base/tests/func/i486/pcconsole/pcconsole.c
Index: pcconsole.c
===================================================================
/* Sample small program: the obligatory ``hello world'' demo. */
#include <eros/target.h>
#include <domain/domdbg.h>
#include <domain/SpaceBankKey.h>
#include <eros/Invoke.h>
#include <eros/Key.h>
#include <eros/NodeKey.h>
#include <eros/ProcessKey.h>
#include <eros/DevicePrivs.h>
#include "constituents.h"
#define KR_CONSTIT 1
#define KR_SELF 2
#define KR_OSTREAM 3
#define KR_BANK 4
#define KR_DEVPRIVS 15
#define KR_PHYSRANGE 16
#define KR_SCRATCH 17
#define KR_MYSPACE 18
int
main(void)
{
node_copy(KR_CONSTIT, KC_OSTREAM, KR_OSTREAM);
node_copy(KR_CONSTIT, KC_DEVPRIVS, KR_DEVPRIVS);
node_copy(KR_CONSTIT, KC_PHYSRANGE, KR_PHYSRANGE);
kprintf(KR_OSTREAM, "hello from physpublish!\n");
spcbank_buy_nodes(KR_BANK, 1, KR_MYSPACE, KR_VOID, KR_VOID);
node_make_node_key(KR_MYSPACE, EROS_PAGE_BLSS + 2, KR_MYSPACE);
process_copy(KR_SELF, ProcAddrSpace, KR_SCRATCH);
node_swap(KR_MYSPACE, 0, KR_SCRATCH, KR_VOID);
process_swap(KR_SELF, ProcAddrSpace, KR_MYSPACE, KR_VOID);
kprintf(KR_OSTREAM, "Address space rebuilt....\n");
#ifdef i386
/* Try the VGA memory area: */
devprivs_publishMem(KR_DEVPRIVS, 0xa0000u, 0xc0000u);
#else
#error "Valid test region not known for this architecture!"
#endif
range_waitobjectkey(KR_PHYSRANGE, OT_DataPage,
(0xb8000u / EROS_PAGE_SIZE) * EROS_OBJECTS_PER_FRAME, KR_SCRATCH);
kprintf(KR_OSTREAM, "Physpage key now in KR_%d....\n", KR_SCRATCH);
node_swap(KR_MYSPACE, 1, KR_SCRATCH, KR_VOID);
kprintf(KR_OSTREAM, "Now in addr space....\n");
/* Okay, now we go to town. This is a really SLEAZY test case! */
{
int i;
uint16_t *screen = (uint16_t *) (EROS_PAGE_SIZE * EROS_NODE_SIZE);
uint16_t *pos = screen;
const char *str = "testme ";
const char *done =
"This concludes the PC ascii console test. "
"It was good for me. ";
for(i = 0; i < 80*25*20; i++) {
if (pos == (screen + 80 * 25))
pos = screen;
*pos++ = str[i%7] | 0x700u; /* character + white on black */
}
pos = screen + 80 * 15;
for (i = 0; i < 80 * 4; i++) {
*pos++ = ' ' | 0x700u; /* character + white on black */
}
for (pos = screen + 80 * 17; *done; done++, pos++)
*pos = (*done) | 0x700u;
}
return 0;
}