Commit Graph

145 Commits

Author SHA1 Message Date
manu 0dc13ccc05 Added the getattrlist system call. That was annoying. 2003-12-31 02:55:04 +00:00
manu 5c83b03a81 Added DARWIN_IOFBSETGAMMATABLE
In DARWIN_IOFBSETCLUTWITHENTRIES, split big tables into 128 items chunks
so that they fit in the stackgap (currently 512 bytes)
2003-12-29 01:34:02 +00:00
manu 48d72491a9 The VRAM offset seems to be the offset of the framebuffer within the VRAM.
Until we really map the whole VRAM, this is 0.
Two missing files in the last commit
2003-12-27 22:06:19 +00:00
manu afc357e66b Correctly return the VRAM offset in IOFBGETVRAMMAPOFFSET connect method.
With this, WindowServer blanks hals of my screen before crashing the kernel.
That's sweet.
2003-12-26 20:34:34 +00:00
manu 219b24a068 Chand emul.darwin MIB to fit best current practice.
emul.darwin.init.pid instead of emul.darwin.init_pid, and so on.

This breaks backward compatibility with the pre-dynamic sysctl(8) for
emul.darwin, but it has never been available in a formal release, so
it should be alright.
2003-12-26 16:00:53 +00:00
manu 834aafd284 Rework Mach exception and Darwin's ptrace. gdb is now able to attach a
remote process. This new implementation also passes all the test programs
I've written so far.

- When exceptions come from traps, no UNIX signal should evet be sent.
- Add a lock to ensure a debugger handles only one exception at a time
- Use a structure to hold flavor and behavior in exception ports, instead
  of stuffing the two argument into an int.
- Implement new Mach services: thread_suspend, thread_resume and thread_abort
- Implement Darwin's ptrace PT_ATTACHEXC and PT_THUPDATE commands
- Handle NULL second argument correctly in sigprocmask.
- One mistake in the last commit (darwin_tracesig prototype)
2003-12-24 23:22:22 +00:00
manu 3bc6a59873 Small prototype mistake (I'm juggling with too much uncommitted files) 2003-12-24 22:57:22 +00:00
manu ffb3de5522 Move the sigfilter hook to a more adequate location, and rename it to better
fit what it does.

The softsignal feature is used in Darwin to trace processes. When the
traced process gets a signal, this raises an exception. The debugger will
receive the exception message, use ptrace with PT_THUPDATE to pass the
signal to the child or discard it, and then it will send a reply to the
exception message, to resume the child.

With the hook at the beginnng of kpsignal2, we are in the context of the
signal sender, which can be the kill(1) command, for instance. We cannot
afford to sleep until the debugger tells us if the signal should be
delivered or not.

Therefore, the hook to generate the Mach exception must be in the traced
process context. That was we can sleep awaiting for the debugger opinion
about the signal, this is not a problem. The hook is hence located into
issignal, at the place where normally SIGCHILD is sent to the debugger,
whereas the traced process is stopped. If the hook returns 0, we bypass
thoses operations, the Mach exception mecanism will take care of notifying
the debugger (through a Mach exception), and stop the faulting thread.
2003-12-24 22:53:59 +00:00
manu 066436a916 Provide a kernel port for each thread. This makes the emulation of
Mach threads much more accurate: we do not confuse threads and tasks
anymore.
2003-12-20 19:43:17 +00:00
fvdl d99705e941 Put back Emmanuel's sigfilter hooks, as decided by Core. 2003-12-20 19:01:29 +00:00
manu b23b73b953 Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.
2003-12-20 18:22:16 +00:00
manu 966a0ee30b Darwin's sigprocmask is an hybrid between or modern sigprocmak (old set
argument, large sigset), and the older sigprocset (no old set argument,
small sigset). It feature old set argument and small sigset.

We now emulates this correctly.
2003-12-16 16:13:59 +00:00
manu d2b4a2c0fa Enable SA_SIGINFO for COMPAT_DARWIN 2003-12-16 13:38:25 +00:00
manu d34fcf6a3b One more property needed by WindowServer 2003-12-09 19:51:51 +00:00
manu 10f0bf745b Fix various broken sanity checks in iokit emulation.
Add some methods to IOFramebuffer (DARWIN_IOFBSETBOUNDS,
DARWIN_IOFBSETCURSORVISIBLE) and to IOHIDSystem (DARWIN_IOHIDPOSTEVENT),
all are unimplemented empty shells.
2003-12-09 17:13:18 +00:00
manu b50934fc19 Move exception related code to a dedicated file 2003-12-09 12:13:44 +00:00
manu 99ee466dbb Move most of the code involved into message header, trailer, and descriptor
construction to inline functions. This removes a lot of redundent code
from Mach services
2003-12-09 11:29:01 +00:00
christos 9c81f1b787 make this compile again. 2003-12-09 00:48:54 +00:00
manu bb9ea468f8 Remove useless and verbose debug message 2003-12-07 10:25:38 +00:00
manu 8019168c34 Remove a useless debug printf 2003-12-06 11:43:56 +00:00
christos 0cc29b2a89 darwin_sysctl is no more. 2003-12-05 22:17:47 +00:00
jdolecek 0e253cf5f5 back the sigfilter emulation hook change off 2003-12-05 21:12:42 +00:00
manu c79cdf6650 struct darwin_slock is not undefined, it's just machine dependent. 2003-12-05 19:57:44 +00:00
christos 91fec5ebba Make this compile.
- does darwin_sysctl() need to be gc'ed?
- does the darwin root node need to be in struct emul?
- does struct emul need a root sysctl node?
2003-12-05 17:34:56 +00:00
manu 6d6c56a0dc Add the kdebug_trace system call. It does nothing but dumping anything it
gets. dyd uses that feature when DYLD_TRACE is set.
2003-12-04 23:59:50 +00:00
manu 632ce64965 When wakeing up a process that was sleeping for a signal when we have a Mach
exception, don't temper with ps_sigwaited.
2003-12-04 22:00:03 +00:00
manu 8a670a0018 Fix newer compiler warning 2003-12-04 21:48:15 +00:00
atatat 13f8d2ce5f Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al.  Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded.  Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment.  I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 19:38:21 +00:00
manu 18e13eee35 Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

if sigfilter returns 0, then no signal is sent by kpsignal2().

There is another place where signals can be generated: trapsignal. Since this
function is already an emulation hook, no call to the sigfilter hook was
introduced in trapsignal.

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)
2003-12-03 20:24:51 +00:00
manu 7973f2217b Rework Mach exceptions and softignals
Exceptions coming from a trap are generated from darwin_trapsignal()
softsignals are from darwin_sigfilter(), a function that is called
from darwin_trapsignal() and from kpsignal2() [the latter from a
emulation specific hook which is not yet committed]

Make some sanity checks to avoid sending data to a port with no receiver.

See http://mail-index.netbsd.org/tech-kern/2003/12/01/0008.html and
follow-ups for details.
2003-12-03 18:40:07 +00:00
manu c36ad94b40 Add HW_PAGE_SIZE sysctl 2003-11-22 23:26:52 +00:00
manu 43b8c2c38e Avoid re-allocations of darwin_emuldata structures by COMPAT_MACH. This
caused a memory leak, and as mach_emuldata is shorter than darwin_emuldata,
it caused memory corruption.
2003-11-20 22:05:25 +00:00
manu 3c00d1aad5 Start to implement another strange feature: signals as Mach software
exceptions. This can be requested with ptrace, and cause signals to
be transformed into a particular kind of exception.
2003-11-20 07:12:34 +00:00
manu e04d06c9bb More work on exceptions. Once a task has raised an exception, it remains
blocked in the kernel. The task that catched the exception may unblock
it by sending a reply to the exception message (Of course it will have
to change something so that the exception is not immediatly raised again).

Handling of this reply is a bit complicated, as the kernel acts as the
client instead of the server. In this situation, we receive a message
but we will not send any reply (the message we receive is already a reply).
I have not found anything better than a special case in
mach_msg_overwrite_trap() to handle this.

A surprise: exceptions ports are preserved accross forks.

While we are there, use appropriate 64 bit types for make_memory_entry_64.
2003-11-18 01:40:18 +00:00
manu 144bfac97b First work on Mach exceptions. Things that can turn into signals on UNIX
may turn into exceptions on Mach: a small message sent by the kernel to
the task that requested the exception.
On Darwin, when an exception is sent, no signal can be delivered.

TODO: more exceptions: arithmetic, bad instructions, emulation, s
software, and syscalls (plain and Mach). There is also RPC alert, but
I have no idea about what it is.

While we are there, remove some user ktrace in notification code, and add
a NODEF qualifier in mach_services.master: it will be used for notifications
and exceptions, where the kernel is always client and never server: we
don't want the message to be displayed as "unimplemented xxx" in kdump (thus
UNIMPL is not good), but we don't want to generate the server prototype
(therefore, STD is not good either). NODEF will declare it normally in the
name tables without creating the prototype.
2003-11-17 01:52:14 +00:00
thorpej 052ba0ec50 We have CVS; there is no reason to make .bak files when generating the
syscall tables.
2003-11-15 20:30:59 +00:00
manu b5139de154 Enforce good santity checks with Mach messages sizes:
1) make sure Mach servers will not work on data beyond the end of the
   request message buffer.
2) make sure that on copying out the reply message buffer, we will not
   leak kernel data located after the buffer.
3) make sure that the server will not overwrite memory beyond the end
   of the reply message buffer. That check is the responsability of the
   server, there is just a DIAGNOSTIC test to check everything is in
   good shape. All currently implemented servers in NetBSD have been
   modified to check for this condition

While we are here, build the mach services table (formerly in mach_namemap.c)
and the services prototypes automatically from mach_services.master, just
as this is done for system calls.

The next step would be to fold the message formats in the mach_services.master
file, but this tends to be difficult, as some messages are quite long and
complex.
2003-11-13 13:40:39 +00:00
manu 60e46c0cc8 Finnally, the missing field in IOHIDSystem keyboard events was identified. The
keyboard now works in XDarwin. Hurrah!
2003-11-02 00:44:19 +00:00
manu bb7e6443cb Remove all our real devices from the IOKit registry, as they won't be
usefull. Emulate only IOHIDSystem, IOFramebuffer and friends in the
registry.

ioreg is able to display the tree and dump the properties.
2003-11-01 18:41:25 +00:00
manu 762ffea0a4 Build again whereas I removed adarwin_ioresource.c (removed before it
was committed...)
2003-11-01 00:42:04 +00:00
manu 53b35abfa2 Parent itarators in the IOKit emulation. A driver can only
have one parent yet (on Darwin, multiple parents are possible: the IOKit
seems to handle a graph more than a tree). Introfuction of a keyboard
driver parent for IOHIDSystem.

The kernel keymapping is still a big mystery.
2003-11-01 00:32:44 +00:00
lukem f85d2d1c14 Use ${HOST_SH} instead of `sh'.
If necessary, pull in <bsd.sys.mk> to get the definition of HOST_SH;
Makefiles that pull in one of (most of) <bsd.*.mk> will get this anyway.
2003-10-26 07:25:33 +00:00
christos 4bec333ae4 Fix uninitialized variable warnings 2003-10-25 18:37:49 +00:00
manu e7fc3d0217 Correctly terminate the iohidsystem thread (with appropriate cleanups of
the shared memory), when the display server quits. We are now able to
restart the X server without the need to reboot the machine. That's better.
2003-10-25 10:43:45 +00:00
manu 13b975e15d Typo 2003-10-25 10:41:53 +00:00
manu d77ec799a5 Support Darwin static binaries (I should say: support the only Darwin
static binary: otool). Dynamic binaires have a pointer to the Mach-O
header on the top of the stack, static binaries don't have this, and
having it produced a crash.

One bugfix: the EXEC_MACHO code assumes that entry = NULL means that
the entry point has not been found in the load commands seen so far.
Therefore we need to initialized entry to NULL if we want a static binary
to discover it. (dynamic binaries were forced to iscover it because when
the intepreter load command is found, entry is updated whatever its
value was before).

One hack: Both COMPAT_MACH and COMPAT_DARWIN are willing to run Mach-O
binaries. COMPAT_MACH fails for dynamic binaries because it cannot find
the interpreter in /emul/mach. For static binaires, it will accept them
(and for Darwin static binaries, this will cause a failure). Until we
rite a test for matchinf Darwin static binaries, just swap the order of
COMPAT_MACH and COMPAT_DARWIN in the exec switch so that COMPAT_DARWIN
is tried first (this will have the advantage of speeding up program
startup). EXECSW_PRIO_{FIRST_LAST} does not seem to work...
2003-10-19 07:52:22 +00:00
manu 8c5377c3b8 Remove references to wsmux_cdevsw and wsdisplay_cdevsw (how to remove
them completely?)

Add SETCURSORPOSITION operation
2003-10-18 13:27:17 +00:00
manu 2522a3f784 Build PowerPC again with _HAS_SIGINFO. Remove the ifdef on _HAS_SIGINFO
in the header file since all platforms supported by COMPAT_DARWIN now have it.
2003-09-30 21:04:54 +00:00
manu 45fa851e14 Report keyup and keydown events
Qhen the event queue is full, sleep so that the process will be able to
consume entries
2003-09-30 19:56:54 +00:00
manu a61584517b Attempt to restore colormap after a display server crashed 2003-09-30 19:49:00 +00:00