Commit Graph

215 Commits

Author SHA1 Message Date
manu 95cc30edca Correctly implement task_suspend and task_resume: the struct proc is
taked from mp->mp_data.
2003-11-11 17:26:32 +00:00
manu 6961fe8c08 Fix an unitialized variable bug that caused a crash in mach_task_suspend().
While we are there, resolved another mystery: the unallocated port described
in the comment removed by this commit was in fact allocated by mach_task_pid().
2003-11-11 15:00:09 +00:00
manu 7c1e8e9716 There is some padding on the reply packet of vm_make_memory_entry too. 2003-11-09 23:17:15 +00:00
manu ffe118644c Added missing padding fields in vm_make_memory_entry request packet. 2003-11-09 23:07:05 +00:00
manu d7d1474c7a Typo 2003-11-09 23:05:29 +00:00
manu 70a91d4b66 Better warnings on not fully implemented mach traps. 2003-11-09 11:10:11 +00:00
christos e348b1067c Catch up with struct proc lock changes. 2003-11-07 17:17:00 +00:00
christos 69ae0c6ad2 Fix unitialized variable use. mmm gcc. 2003-11-07 17:16:39 +00:00
manu 10d03389ac mach_port_get_attributes (incomplete and untested) 2003-11-03 22:17:42 +00:00
manu 90b3ec4640 First attempt at mach_make_memory_entry. Untested 2003-11-03 20:58:18 +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 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
mycroft a65f74a513 Previous changes were not correct. 2003-10-25 20:15:13 +00:00
christos 4bec333ae4 Fix uninitialized variable warnings 2003-10-25 18:37:49 +00:00
manu 3b556e0bb2 Fix error in struct definition 2003-10-18 13:25:27 +00:00
manu f816300903 (file missing from the previous commit, I copy/past the commit log)
Some initial support for IOHIDSystem. This gives us some pointer moves in X11
(not really related the the actual mouse movement, but this will come).

The darwin_iohidsystem_thread reads events from wscons, translates them
into IOHIDSystem events and wakes up the userland client with a notification.
To do this, I had to improve the void implementation of
io_connect_set_notification_port() to actually register something (I assumed
a single notification port, which makes some sense since only one process
seems to be able to open the driver)

Missing bits:
- we do not take event masks given by the process into account.
- the notification message has not been checked against Darwin
- events are badly translated
2003-09-11 23:18:10 +00:00
manu f9c483a301 Some initial support for IOHIDSystem. This gives us some pointer moves in X11
(not really related the the actual mouse movement, but this will come).

The darwin_iohidsystem_thread reads events from wscons, translates them
into IOHIDSystem events and wakes up the userland client with a notification.
To do this, I had to improve the void implementation of
io_connect_set_notification_port() to actually register something (I assumed
a single notification port, which makes some sense since only one process
seems to be able to open the driver)

Missing bits:
- we do not take event masks given by the process into account.
- the notification message has not been checked against Darwin
- events are badly translated
2003-09-11 23:16:18 +00:00
christos e09c2a122c don't abuse the native sigcode. 2003-09-10 16:44:56 +00:00
manu 4de9ba3f19 Added vm_region_64 and thread_info 2003-09-06 23:52:25 +00:00
manu f600082353 Added vm_region_64 and thread_info 2003-09-06 23:52:24 +00:00
manu 41a89bc98d Fix a buffer overflow that was leading to various kernel crashes 2003-08-26 21:52:18 +00:00
chs 939df36e55 add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default.  the changes
fall into two basic catagories:

 - pmap and trap-handler changes.  these are all MD:
   = alpha: we already track per-page execute permission with the (software)
	PG_EXEC bit, so just have the trap handler pay attention to it.
   = i386: use a new GDT segment for %cs for processes that have no
	executable mappings above a certain threshold (currently the
	bottom of the stack).  track per-page execute permission with
	the last unused PTE bit.
   = powerpc/ibm4xx: just use the hardware exec bit.
   = powerpc/oea: we already track per-page exec bits, but the hardware only
	implements non-exec mappings at the segment level.  so track the
	number of executable mappings in each segment and turn on the no-exec
	segment bit iff the count is 0.  adjust the trap handler to deal.
   = sparc (sun4m): fix our use of the hardware protection bits.
	fix the trap handler to recognize text faults.
   = sparc64: split the existing unified TSB into data and instruction TSBs,
	and only load TTEs into the appropriate TSB(s) for the permissions.
	fix the trap handler to check for execute permission.
   = not yet implemented: amd64, hppa, sh5

 - changes in all the emulations that put a signal trampoline on the stack.
   instead, we now put the trampoline into a uvm_aobj and map that into
   the process separately.

originally from openbsd, adapted for netbsd by me.
2003-08-24 17:52:28 +00:00
christos baccb9bad5 Another chicken sacrifice to the gcc3 warning gods. 2003-08-05 21:12:53 +00:00
manu 0229e10bf3 Added a IOFBSETCOLORCONVERTTABLE method in ioframebuffer driver.
Added sanity check for user provided offsets in messages.
2003-07-01 19:15:47 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
martin d505b18964 Make sure to include opt_foo.h if a defflag option FOO is used. 2003-06-23 11:00:59 +00:00
manu 9c3b5e7aec Replace strlcpy by strncpy so that it builds again 2003-06-04 19:51:03 +00:00
manu 899161bdbc Added vm_copy 2003-06-03 20:09:37 +00:00
manu faba943220 Added IOHIDSystem properties (this is about keyboard mapping)
Also added a ssize arg to mach trap args so that trap handler are aware
of the sent packet size.
2003-06-03 06:48:47 +00:00
manu 1ea26aeafe + In ioframebuffer driver:
We try to map the console framebuffer through wsdisplay. It seems to work,
 but we still need to _see_ something.
XXX Framebuffer size discovery is borken.

+ In ioframebuffer and iohidsystem:
More methods and more debug for io_connect_method_*

+ A few new IOKit mach traps.
2003-05-22 22:07:36 +00:00
manu 0d9cf0359a Added io_connect_add_client 2003-05-22 18:10:19 +00:00
itojun 51110d0c20 use strlcpy
[compat/svr4_32 should have bound check for SVR4_32_AUX_ARGSIZ]
2003-05-16 14:36:30 +00:00
manu da05e7b4d3 Added io_service_close and the io_connect_map_memory method for
ioframebuffer's shared meory (used to handle the cursor).

XDarwin and WindowServer now fail on framebuffer mapping.
2003-05-14 18:28:04 +00:00
manu 31b52bb7f2 More efforts on the XDarwin front. Introduce io_connect_method_scalari_structo
and io_connect_method_structi_structo. We don't know at all how this stuff
works, but at least we can imitate what Darwin does.
2003-05-14 14:41:04 +00:00
manu 962a6c7d59 Fix a bug in io_registry_entry_get_property: one of the field in the
return packet was wrong (port descriptor instead of VM area descriptor),
thus leading to SIGSEGV when calling IOKit's IOFBCreateSharedCursor().

Now this is fixed we can move forward again on graphic mode.
2003-05-13 20:48:16 +00:00
manu 4c94241d26 Make io_iterator_reset working for device class itaerators 2003-04-30 18:38:19 +00:00
manu f8c2ac11e9 typo 2003-04-30 18:05:47 +00:00
manu 9a5720f8f0 Added io_iterator_reset (there is a nundocumented flag argument, no idea
of its use yet)
2003-04-30 07:32:16 +00:00
manu d46d73437c Added the map_memory method for the IOKit, plus an implementation
for the IOHIDSystem driver in Darwin. IOHIDSystem provides access
to user interface devices.

Communication between userspace and kernel is done through a shared
memory page. Our plan is to have a kernel thread waiting on wscons
events (for now it just does nothing), and have it feeding the
shared page.
2003-04-29 22:16:38 +00:00
manu 30bb8c56a7 More debug 2003-04-29 22:12:51 +00:00
manu aa5f0948ad Improved bahvior for map_fd. When Darin uses findspace = 0, this seems to
request a mapping at fixed address, overlaying previously existing mappings.

The overlay is done by unmapping (sys_munmap) before mapping at fixed
location. This makes XDarwin able to link and run.
2003-04-19 21:41:15 +00:00
manu 0479104b05 First attempt with task_suspend/task_resume, but we hit some bugs somewhere
else in our code.
2003-04-06 17:58:49 +00:00
manu c74de80216 Implement task_info 2003-04-05 21:18:02 +00:00
manu acab734a9e Fix a few bugs and get a better notification support (A sample program
actually works)
2003-04-05 19:27:51 +00:00
manu fd94bf9486 First work on notifications. Not really working for now. 2003-03-29 11:04:08 +00:00
manu 523dbf2146 Quick and dirty version of io_registry_entry_get_properties. 2003-03-09 18:33:28 +00:00
manu a6757a0de1 Less accurate vm_region, but it sticks better to Darwin results. 2003-03-05 22:39:48 +00:00
manu 03dfd69a01 Added vm_region and vm_msync traps 2003-03-03 22:07:39 +00:00
manu edcf894563 Notification request packets format, nothing implemented yet. 2003-02-28 09:30:23 +00:00
manu c3be74fe41 Introduced IOKit driver methods. Moved back into Mach some IOKit driver
support that was in Darwin code. I get an empty darwin_iokit.c, which is
getting a good candidate for cvs delete.
2003-02-20 22:39:42 +00:00
manu 749de24f94 - Make sure darwin_iokit_ioframebuffer is invoked
- fix a mistake in mach_io_registry_entry_get_property message format
2003-02-16 18:33:35 +00:00
manu ca120fe1a2 Match IOHIDSystem and IOFramebuffer request in the IOKit and handle them in
Darwin specific files. The handler does nothing yet.

This needs some improvement. Darwin attaches an IOHIDSystem device to
each human-interface device in the tree: mouse, keyboard, and a few others.
For now we only emulate one IOHIDSystem device.
2003-02-16 15:02:05 +00:00
manu 80a30f1a31 A first attempt at providing access to our device tree through the IOKit.
Darwin's ioreg is able to display the tree.
2003-02-09 22:13:46 +00:00
manu 44af8c7eb4 More IOKit shell. This makes ioreg looping on device discovery: foobar
has a child called foobar, and so on.
2003-02-07 20:40:37 +00:00
manu d0139ca922 More iokit shell: it does nothing, but WindowServer get a bit more far
away and ends with a SIGSEGV.
2003-02-07 16:56:19 +00:00
manu 2e73bb80fe More IOKit basics. Also introduced a mach_port flag to get a precise idea
of what port is sending a message to the kernel.
2003-02-05 23:58:09 +00:00
manu 357afc4e2f Some bits of the first iokit call 2003-02-04 22:47:41 +00:00
manu 2cd19ab0b2 - WindowServer wants io_master_port? Give it a port!
- introduce mach_port_destroy (badly emulated for now)
- on fork/exec, don't set l_private, as the process might be not mature
enough to survive a proc_representative_lwp call (-> kernel panic)

Once we give WindowServer the io_master_port, it sends a message to it:

   305 WindowServer MMSG  id 2804 [0x1310009 -> 0x131000e] -12016 bytes, flags 0
x1513
   0x0000  0x00001513 0xffffd110 0x0131000e 0x01310009   .........1...1..
   0x0010  0xffffcfd0 0x00000af4 0x00000000 0x00000000   ................
   0x0020  0xffffcf60 0x00000052 0x3c646963 0x74204944   ...`...R<dict ID
   0x0030  0x3d223022 0x3e3c6b65 0x793e494f 0x50726f76   ="0"><key>IOProv
   0x0040  0x69646572 0x436c6173 0x733c2f6b 0x65793e3c   iderClass</key><
   0x0050  0x73747269 0x6e672049 0x443d2231 0x223e494f   string ID="1">IO
   0x0060  0x48494453 0x79737465 0x6d3c2f73 0x7472696e   HIDSystem</strin
   0x0070  0x673e3c2f 0x64696374 0x3e0047cc              g></dict>.G.

Did you ever dreamt about system call arguments in XML?
2003-02-02 19:06:31 +00:00
manu 34a458238c For cproc_t, use a per thread value instead of a per process value. ifdef
out l_emuldata in struct lwp until we actually use it.
2003-01-30 19:14:18 +00:00
manu 7e15e89c0a Fixed dumb bug 2003-01-26 19:32:04 +00:00
manu ce8bd172b2 For thread creation, make the newly created thread runnable. Mach threads
are now functionnal again.
2003-01-26 19:02:14 +00:00
manu 55215e5266 Remove right duplication on thread creation, which became useless now we
are using lwp.
Enable kill -9 to kill parent thread waiting for its child.
Use upcallret instead of child_return for the newly created lwp.
Add debug messages for thread creation.

Thread creation are still broken...
2003-01-26 12:39:32 +00:00
manu 82a9c6faf0 Use per process emuldata for the thread id for now, but this will change
shortly. This makes hello world working again.
2003-01-24 22:35:43 +00:00
manu cb771e3c64 Make the beast build again (but it is still probably broken) 2003-01-24 21:37:01 +00:00
matt b03d17694a Do a preliminary switchover of the mach code to lwp's. It compiles now
but probably doesn't work.   That's for someone who understand this code
better.
2003-01-21 04:06:06 +00:00
matt de92ce633f Regen. 2003-01-21 04:02:37 +00:00
matt d8ad92c6b6 Add <sys/sa.h> 2003-01-21 04:02:10 +00:00
matt 312dfd8487 Adapt to the LWP world. 2003-01-21 04:01:09 +00:00
matt e093b867e9 Regen. 2003-01-21 04:00:02 +00:00
matt 6d793da904 Add <sys/sa.h> 2003-01-21 03:59:27 +00:00
thorpej d88bc9c3a2 Regen for correct RCS ID. 2003-01-18 23:36:48 +00:00
thorpej 53e750d150 Regen: Merge the nathanw_sa branch. 2003-01-18 08:19:32 +00:00
thorpej 7024ec54cc Merge the nathanw_sa branch. 2003-01-18 08:18:50 +00:00
simonb 775343ebae Fix a tyop. 2003-01-08 00:39:44 +00:00
manu f656d621e7 Here we enter the land of IOKit where the shadows lie.
There are two new mach traps:
mach_vm_make_memory_entry, mach_host_get_io_master. Now we need to find
the documentation to understand what they are supposed to do.
2003-01-04 15:15:01 +00:00
manu 4b219b054a I don't know where I saw this 8 bit shift for the inherit argument of
vm_inherit, but it's not usefull (it's even harmful), so remove it.
WindowServer still crashes but later.
2003-01-04 13:17:07 +00:00
manu 80d406d8fe FIxed the way rights are recycled: the refcount makes only sense for
send, send once, and dead names, not for port sets and receive rights.
This make vi and telnet able to work again.

Also removed the all process right list and its lock, which got useless. The
all process lock is replaced by a per process lock, located in struct
mach_emuldata.

Also one bug fix: we did not correctly called Mach hooks for struct emuldata
initialization and release for Darwin processes.
2003-01-03 13:40:04 +00:00
manu 2c04ce0604 A better implementation of right carried by messages. We now correctly create
the right in the destination process.

This is a small step backward for functionnality: vi does not work anymore
because our right checks cause some spurious errors, but this will be fixed
later.
2003-01-02 12:46:06 +00:00
manu 0d5c4544d1 The first int on the stack is not the page size, it's the address of the
mach-O header. This is a guess based on what we have on Darwin, we need
to check other Mach systems to see if this value is Darwin specific or not.
Also updated copyright and removed useless debug
2003-01-01 15:18:25 +00:00
manu f3e11e72e9 Introduce port names, deallocate mach ressources at Darwin process exit 2002-12-31 15:47:37 +00:00
manu 6f978415df When the kernel transmits a message to a processs, remote and local port
are swapped. Also added some debug.
2002-12-31 13:09:38 +00:00
manu 48ad3f41b6 Remove some debug and make it build again wihout DEBUG_MACH 2002-12-31 09:32:03 +00:00
manu 1d1b901b90 bug fix: in debug functions, the port set right and the port set members
wer mixed up
2002-12-30 19:32:15 +00:00
manu d9f2a8dbcd - When mach_init saves the bootstrap port, make it the default bootstrap port
for any program we will launch later. This is a hack to avoid the need
of launching any Darwin binary as a child of mach_init
- More and more debug
2002-12-30 18:44:33 +00:00
manu f449715c66 When allocating a receive right on a port, don't forget to change
the reciever.
2002-12-30 12:46:19 +00:00
manu 27427542f4 When the right is not a port set, set the port set head to the right
itself. That way when we want to wakeup a receiver, we just have to
wakeup the port set head, it will work either for port set and for non
port sets.
2002-12-30 12:41:52 +00:00
manu 874517b438 - When MACH_MSG_RCV_LARGE is set, we must return a message with just a header
and a body.
- If mach_init is not availabkle for boostrap requests, try to handle them
in the kernel (we don't really handle them, we just try to avoid hanging there)
- minor tweaks.
2002-12-27 19:57:47 +00:00
manu f464631d66 Several things:
1) rights should be shared by the threads within a process. While it would
be easier to handle this with the struct proc/struct lwp split, we attempt to
do this now by sharing the right lists. Because each right holds a reference
to struct proc, this might cause some problems later.
2) in pthread_exit, really exit the thread. Also reintialize the righ tlist to
make sure we will not destroy the parent's right list
3) rights can hold multiple permissions on a port (ie: send and receive). Fix th
is.
4) first attempt on right carried by messages. We still have to do rights carrie
d in the message body (complex messages).
2002-12-27 09:59:24 +00:00
manu 2894c4a53f Handle the kernel clock service by the kernel. 2002-12-26 13:45:17 +00:00
manu f4d5ba5dbd Queue and dequeue message replies from kernel servers. This is less efficient,
but it sticks closer to the actual Mach semantics: the reply is queued at the
end of the queue. Also add more debug messages on port operations.
2002-12-26 11:41:46 +00:00
manu dc403d4519 Bootstrap messages are not for the kernel, they are for mach_init. 2002-12-24 16:40:46 +00:00
manu b2a7ace594 Better error reporting in mach_msg_trap: this system call does not use the
standard error codes.
2002-12-24 15:54:26 +00:00
manu 4d3d28af57 cosmetic 2002-12-24 15:53:46 +00:00
manu 93b65fbd1d regen 2002-12-24 12:29:28 +00:00
manu 185383e0a7 Typo 2002-12-24 12:29:06 +00:00
manu 360f1c3ebe Cosmetic changes, added a debug printf 2002-12-22 21:51:56 +00:00
gmcgarry c4b66baf3f We do want yield() for voluntary context switches. Update comment. 2002-12-21 23:57:57 +00:00
manu 8958b6f9ba Handle receive operations on port sets 2002-12-21 23:50:47 +00:00