📄 referencer.c
字号:
/* * Copyright (C) 1998, 1999, 2001, The EROS Group. * * 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. */#include <eros/target.h>#include <eros/Invoke.h>#include <domain/domdbg.h>#include "memmap.h"/* * In order to simplify the requirements for building this process's * address space, the code and the stack are in the same page, * which is mapped at address 0. * So this program is carefully constructed to fit in less than one page. */extern uint8_t _end;const uint32_t __rt_stack_pages = 0;const uint32_t __rt_stack_pointer = 0x1000;#define KR_VOID 0#define KR_OSTREAM 1#define KR_CALLER 15uint8_t b;intmain(){ Message msg; /* If this program doesn't fit in a page, with room for a stack, we are in trouble. */ if ((unsigned long)&_end + 100 > __rt_stack_pointer) return 8; msg.snd_invKey = KR_VOID; msg.snd_key0 = KR_VOID; msg.snd_key1 = KR_VOID; msg.snd_key2 = KR_VOID; msg.snd_key3 = KR_VOID; msg.snd_data = 0; msg.snd_len = 0; msg.snd_code = 0; msg.snd_w1 = 0; msg.snd_w2 = 0; msg.snd_w3 = 0; msg.rcv_key0 = KR_VOID; msg.rcv_key1 = KR_VOID; msg.rcv_key2 = KR_VOID; msg.rcv_key3 = KR_CALLER; msg.rcv_len = 0; msg.rcv_data = 0; for(;;) { uint8_t * ptr; RETURN(&msg); /* Process the request. The driver has set up our address space. msg.rcv_w1 has the address to read or write. If the reference is successful, we will return to the caller (the driver) with return code 0. If the reference is unsuccessful, we will invoke the driver via a segment keeper or process keeper. */ ptr = (uint8_t *)msg.rcv_w1; msg.snd_code = 0; /* default return code */ switch (msg.rcv_code) { case refReadDirect: b = *ptr; break; default: msg.snd_code = 1; } msg.snd_invKey = KR_CALLER; } return 0; /* never executed */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -