1*433d6423SLionel Sambuc /* The kernel call implemented in this file:
2*433d6423SLionel Sambuc * m_type: SYS_READBIOS
3*433d6423SLionel Sambuc *
4*433d6423SLionel Sambuc * The parameters for this kernel call are:
5*433d6423SLionel Sambuc * m_lsys_krn_readbios.size number of bytes to copy
6*433d6423SLionel Sambuc * m_lsys_krn_readbios.addr absolute address in BIOS area
7*433d6423SLionel Sambuc * m_lsys_krn_readbios.buf buffer address in requesting process
8*433d6423SLionel Sambuc */
9*433d6423SLionel Sambuc
10*433d6423SLionel Sambuc #include "kernel/system.h"
11*433d6423SLionel Sambuc
12*433d6423SLionel Sambuc /*===========================================================================*
13*433d6423SLionel Sambuc * do_readbios *
14*433d6423SLionel Sambuc *===========================================================================*/
do_readbios(struct proc * caller,message * m_ptr)15*433d6423SLionel Sambuc int do_readbios(struct proc * caller, message * m_ptr)
16*433d6423SLionel Sambuc {
17*433d6423SLionel Sambuc struct vir_addr src, dst;
18*433d6423SLionel Sambuc size_t len = m_ptr->m_lsys_krn_readbios.size;
19*433d6423SLionel Sambuc vir_bytes limit;
20*433d6423SLionel Sambuc
21*433d6423SLionel Sambuc src.offset = m_ptr->m_lsys_krn_readbios.addr;
22*433d6423SLionel Sambuc dst.offset = m_ptr->m_lsys_krn_readbios.buf;
23*433d6423SLionel Sambuc src.proc_nr_e = NONE;
24*433d6423SLionel Sambuc dst.proc_nr_e = m_ptr->m_source;
25*433d6423SLionel Sambuc
26*433d6423SLionel Sambuc limit = src.offset + len - 1;
27*433d6423SLionel Sambuc
28*433d6423SLionel Sambuc #define VINRANGE(v, a, b) ((a) <= (v) && (v) <= (b))
29*433d6423SLionel Sambuc #define SUBRANGE(a,b,c,d) (VINRANGE((a), (c), (d)) && VINRANGE((b),(c),(d)))
30*433d6423SLionel Sambuc #define USERRANGE(a, b) SUBRANGE(src.offset, limit, (a), (b))
31*433d6423SLionel Sambuc
32*433d6423SLionel Sambuc if(!USERRANGE(BIOS_MEM_BEGIN, BIOS_MEM_END) &&
33*433d6423SLionel Sambuc !USERRANGE(BASE_MEM_TOP, UPPER_MEM_END))
34*433d6423SLionel Sambuc return EPERM;
35*433d6423SLionel Sambuc
36*433d6423SLionel Sambuc return virtual_copy_vmcheck(caller, &src, &dst, m_ptr->m_lsys_krn_readbios.size);
37*433d6423SLionel Sambuc }
38