mlibc: Add ioctl.
* stage0/x86.M1 (SYS_ioctl): New define. * lib/linux-mes.c (ioctl): New syscall. * lib/linux-gcc.c (ioctl): New syscall. * include/sys/ioctl.h: New file.
This commit is contained in:
parent
75444afc21
commit
979406f3a6
36
include/sys/ioctl.h
Normal file
36
include/sys/ioctl.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes 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 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes 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 Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __MES_SYS_IOCTL_H
|
||||
#define __MES_SYS_IOCTL_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#undef __MES_SYS_IOCTL_H
|
||||
#include_next <sys/ioctl.h>
|
||||
|
||||
#else // !(__GNUC__ && POSIX)
|
||||
|
||||
#define TCGETS 0x5401
|
||||
#define TCGETA 0x5405
|
||||
int ioctl (int fd, unsigned long request, ...);
|
||||
|
||||
#endif // !(__GNUC__ && POSIX)
|
||||
|
||||
#endif // __MES_SYS_IOCTL_H
|
||||
|
|
@ -137,6 +137,37 @@ brk (void *p)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
ioctl (int fd, unsigned long request, ...)
|
||||
{
|
||||
#if !__TINYC__
|
||||
int p;
|
||||
asm (
|
||||
"mov %%ebp,%%eax\n\t"
|
||||
"add $0x10,%%eax\n\t"
|
||||
"mov (%%eax),%%eax\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=p" (p)
|
||||
: //no inputs ""
|
||||
);
|
||||
int r;
|
||||
//syscall (SYS_ioctl, fd));
|
||||
asm (
|
||||
"mov %1,%%ebx\n\t"
|
||||
"mov %2,%%ecx\n\t"
|
||||
"mov %3,%%edx\n\t"
|
||||
|
||||
"mov $0x36, %%eax\n\t"
|
||||
"int $0x80\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "" (fd), "" (request), "" (p)
|
||||
: "eax", "ebx", "ecx", "edx"
|
||||
);
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
fsync (int fd)
|
||||
{
|
||||
|
|
|
@ -69,6 +69,17 @@ brk ()
|
|||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
void
|
||||
ioctl ()
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%ebx !8");
|
||||
asm ("mov____0x8(%ebp),%ecx !12");
|
||||
asm ("mov____0x8(%ebp),%edx !16");
|
||||
|
||||
asm ("mov____$i32,%eax SYS_ioctl");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
void
|
||||
fsync ()
|
||||
{
|
||||
|
|
|
@ -205,5 +205,6 @@ DEFINE SYS_chmod 0f000000
|
|||
DEFINE SYS_lseek 13000000
|
||||
DEFINE SYS_access 21000000
|
||||
DEFINE SYS_brk 2d000000
|
||||
DEFINE SYS_ioctl 36000000
|
||||
DEFINE SYS_fsync 76000000
|
||||
DEFINE SYS_getcwd b7000000
|
||||
|
|
Loading…
Reference in a new issue