Return to BSD News archive
Xref: sserve comp.os.386bsd.questions:6366 comp.os.386bsd.development:1350 Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!osuunx.ucc.okstate.edu!moe.ksu.ksu.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!pipex!uknet!mcsun!Germany.EU.net!sunmbx.netmbx.de!mailgzrz.TU-Berlin.DE!zib-berlin.de!gmdtub!g386bsd!ats From: ats@g386bsd.first.gmd.de (Andreas Schulz) Newsgroups: comp.os.386bsd.questions,comp.os.386bsd.development Subject: Re: [NetBSD] What is this in SYS.h? Message-ID: <4177@bigfoot.first.gmd.de> Date: 31 Oct 93 23:09:04 GMT References: <2avo6k$mlm@homer.cs.mcgill.ca> Sender: news@bigfoot.first.gmd.de Followup-To: comp.os.386bsd.questions Organization: GMD-FIRST, Berlin, Germany Lines: 38 In article <2avo6k$mlm@homer.cs.mcgill.ca>, Marc WANDSCHNEIDER <storm@cs.mcgill.ca> wrote: > >MooO! > > Could some kind soul explain to me what the LCALL and SYSCALL > macros in SYS.h in /usr/src/lib/libc/i386/sys are doing? > > THe macros look like: > >#define SYSCALL(x) 2: jmp cerror; ENTRY(x); lea SYS_/**/x,%eax; LCALL(7,0); jb 2b >/* gas fucks up offset -- although we don't currently need it, do for BCS */ >#define LCALL(x,y) .byte 0x9a ; .long y; .word x The SYSCALL macro is the assembler call for all the system calls, like open, read, write. These are all the calls that are documented under "/usr/share/man/man2". And the LCALL macro is the actual trap into the kernel. Don't ask me in the moment, what the "2: jmp cerror;" does. An expanded call for this would look: 2: jmp cerror; open: # Label for system call lea SYS_open,%eax # put the number for the system call # into the eax register .byte 0x9a # trap into the kernel .long 0 # these are arguments to the .word 7 # trap. I am not sure, if the 0x9a is a trap or a gate-call , for this you must look into a 386 CPU description. I don't know, where mine is, i try to prevent assembly programming on this type of CPU :-). -- ATS ( ats@first.gmd.de or ats@cs.tu-berlin.de ) Andreas Schulz GMD-FIRST 12489 Berlin-Adlershof Rudower Chaussee 5 Gebaeude 13.7 Tel: +49-30-6392-1856 Germany/Europe