#tyndur · 2009-11-23
303 Nachrichten · Seite 1 von 2 · Original-CSV herunterladen
- kwolfGood morning
- kwolfpcmattman: So you want to implement some generic IPC mechanism in CDI?
- pcmattmankwolf: I wouldn't label it "IPC", because it may not necessarily be inter-process, but yes, I do think there should be a method for device drivers to communicate with each other
- kwolfRight, not necessarily, but they need to be designed to allow implementing them by IPC
- pcmattmanAh, yes, I understand what you're saying
- kwolfI'm not sure what I should be thinking of it
- kwolfOn the one hand I have a feeling that it would be the clean solution for all future drivers
- kwolfOn the other hand, I'm scared ;-)
- pcmattmanHeh :)
- pcmattmanIt's not an easy thing to design, really
- kwolfGetting the one IPC method right in your OS is difficult enough. I'm not sure what getting it right for all sorts of IPC is like...
- kwolfFor example, if shared memory is available, you surely want to use it. But should we make it a requirement for CDI?
- kwolfCreating an interface that looks the same for both variants seems hard to me
- pcmattmanI think ideally the IPC method would merely expose an interface to send "messages" to a "destination"
- pcmattmanFor example, cdi_ipc_send(void *msg, size_t length, const char *dest);
- pcmattmanThe method through which said message is routed is then totally up to the OS
- pcmattmanAnd then drivers might have something like cdi_ipc_register_dest(const char *dest, func_ptr callback) which links the "destination" to a callback
- kwolfI'd like to avoid copying msg, so I'd prefer implementing this as SHM. Which in turn means for tyndur that the page for msg needs to be allocated as SHM in the first place.
- pcmattmanPerhaps a method for obtaining IPC-specific memory then?
- pcmattmancdi_ipc_malloc(size_t) ?
- pcmattmanThat would solve that problem, as tyndur could implement that as allocating shared memory, and other OS's as some other mechanism
- kwolfCould work
- kwolfAre you sure that const char* dest is really helpful? I feel that an OS specific struct cdi_ipc_endpoint could be more appropriate
- pcmattmanHmm, good point
- pcmattmanThat'd probably make it easier to integrate into an existing IPC system
- kwolf_[11:04] <kwolf> But maybe I just don't see what you want the strings to look like
- pcmattman(8:05:21 PM) pcmattman: Hmm, good point
- pcmattman(8:06:00 PM) pcmattman: That'd probably make it easier to integrate into an existing IPC system
- kwolfNo need to repost your lines, #tyndur is logged ;-)
- pcmattmanAnd I was thinking driver defined strings, but that wouldn't solve the mixer communication problem at all in hindsight
- pcmattmanAh, good to know :)
- kwolfhttp://irc.tyndur.org/index.php
- kwolfJust in case you need it some time
- pcmattmanThanks
- kwolfThe problem with a string is that needs to be unique. Which would probably mean things like encoding driver PIDs in the string.
- pcmattmanYup, and to be honest, I like the cdi_ipc_endpoint idea better
- pcmattmanIf it's OS-specific, you can store all kinds of useful information
- pcmattmanThere probably needs to be a way to enumerate all CDI IPC endpoints, and they probably need some form of well-defined control protocol
- kwolfI think (hope) there is no need for the drivers to look into the struct.
- pcmattmanThe control protocol would be something like "what type of device are you", if that makes sense
- pcmattmanWell, I imagine cdi_ipc_endpoint would be much like FILE in POSIX - don't depend on its layout
- kwolfRight. One of the existing constants?
- kwolfpcmattman: I agree
- pcmattmanYes, the control protocol can hook in to existing information
- pcmattmanThe control protocol might also add things such as "unload" in the future, but that's mere speculation
- kwolf"what type of device are you" would mean a cdi_device_type_t, right? CDI_NETWORK and so on.
- pcmattmanYup, that's what I was thinking
- kwolfOk. I think this mechanism is doable if someone volunteer to implement it. ;-) I guess it means no sound in 0.2.2, though...
- pcmattmanHmm, I'm going to be unable to code for most of December and part of January
- pcmattmanOtherwise I'd get in there and write it
- kwolfYeah, I read that in #pedigree. Lots of RL stuff to do?
- pcmattmanYup, and for part of that I won't even be internet connected
- kwolfEnjoy the time without internet. It's always amazing how much sleep one can get. ;-)
- pcmattmanHaha :)
- kwolfDo you think eddyb would be a help in this area, or would he rather be an impediment?
- pcmattmanI'm not sure
- pcmattmanIt would give him something to work on, while I'm away :)
- kwolfI wouldn't let him do the interface, but maybe porting the existing ac97 onto it or something like this
- pcmattmanRight, he'd probably be able to do that
- kwolfProbably he would also need to implement the IPC interface for Pedigree. But it will be mostly a nop, so he should manage to do it
- kwolfWe just need to agree on a concrete interface before, i.e. best a header file that contains all of the data structures and function prototypes
- pcmattmanRight, I can put together a proposal again in an email
- pcmattmanThe Pedigree CDI IPC interface will end up basically calling a callback function defined in cdi_ipc_endpoint, I imagine
- kwolfProbably with some pointer to a Device
- kwolfBut that should be really enough
- pcmattmanFor Pedigree, yes
- pcmattmanI don't know what tyndur would need
- kwolfI think it's going to be minimally more sophisticated ;-)
- kwolfEspecially for the enumeration we need to introduce something new. But we'd need this anyway.
- pcmattmanI think it will be highly beneficial in the future with other drivers which need to communicate with each other
- kwolfDefinitely. We have the very same problem with USB, for example. Currently all of the USB related drivers are in one monolithic CDI driver.
- kwolfAt the same time I'm concerned about how difficult/time-consuming it might become to get CDI running. Maybe we need to define several "levels" of CDI implementations
- pcmattmanHmm, perhaps
- pcmattmanMaybe something like a "config.h" but for the OS to specify what it supports?
- kwolfYou mean like #define CDI_HAVE_IPC?
- pcmattmanYup
- pcmattmanA header like that, provided by the OS, which would switch on and off different features
- kwolfI suggested adding such defines myself earlier, so I think that makes a lot of sense.
- kwolfBy the way, have you read that thread in the osdev.org forum? I kind of hate it when people dream of UDI... ;-)
- kwolfWe should get CDI in a shape that we could advertise it more loudly in the community
- pcmattmanI agree
- pcmattmanAt the moment the problem is that nobody knows what CDI is, so they look at UDI and think it's the answer to life :)
- kwolfProbably it's me who needs to do the next step. Finally implementing the changes we discussed a month ago and adding English comments.
- pcmattmanI'd be happy to contribute, it's just difficult to start anything right now as I'm not going to be coding for a couple of months
- kwolfSo when does it start? (whatever "it" may be)
- pcmattmanSaturday 28 November
- kwolfOk, that's really soon
- pcmattmanYup
- kwolfAnd you'll be back end of January?
- pcmattmanProbably about halfway through
- pcmattmanI will still have access to email every now and then, and possibly IRC on my phone, but not coding
- kwolfSomehow we'll get by without you for some weeks ;-)
- kwolfafk
- pcmattmanI don't worry about you, I worry about my own project ;)
- kwolfBack
- pcmattmanWelcome back
- kwolfpcmattman: You mean eddyb will destroy it while you're away? ;-)
- pcmattmanPerhaps, I'm more concerned about the fact that it's a long time to be away; code that you haven't seen in a long time always looks worse ;)
- kwolfBut that's great. You can improve it then. ;-)
- pcmattmanYep, it's just always a lot of effort to improve :)
- kwolfWell, if you don't want to invest effort, you can stop developing an OS.
- pcmattmanWell, there's effort, of course
- pcmattmanBut effort to improve is usually also quite depressing ;)
- kwolfBut if you find a way how to let an OS create itself while you merely think about its design, let me know I could use that, too, at times ;-)
- pcmattmanHeh, we'd all be out of a job if such a thing existed
- FreakyPenguinGood Morning
- kwolfpcmattman: I'm curious what CDI redesign you'll bring up when you look at it again in January ;-)
- kwolfMoin FreakyPenguin
- FreakyPenguinpcmattman: Do you have some other possible applications (besides sound) in mind for such an "ipc" mechanism?
- pcmattmanGraphics, perhaps?
- FreakyPenguinIf I look at usb i think it would be a good idea to "hide" the communication between the different drivers in cdi, seems somhow cleaner to me...
- pcmattmanDo you mean via IPC, or remove communication at all?
- FreakyPenguinWell I think the drivers have to communicate somehow
- pcmattmanRight
- pcmattmanI also think a better term might be "IDC" - "Inter-driver communication", as it may not necessarily be between two processes
- kwolfBascially, the two options are a generic IPC mechanism or specific cdi_audio_mixer_* and cdi_usb_* functions
- pcmattmanBut that's purely aesthetic :)
- FreakyPenguinkwolf: That's what I had in mind, yes
- kwolfpcmattman: You're complety right, but everyone knows what IPC is and noone knows IDC ;-)
- FreakyPenguinThe second way looks somehow more structured and cleaner to me
- kwolfFreakyPenguin: The latter means that for each new device class we need to add more and more functions to the framework
- kwolfInstead of solving the problem just once
- kwolfObviously, solving the problem just once means that you need to get a complex thing right
- FreakyPenguinWell of course. But doesn't this mean that we take code out of the cdi implementation and duplicate it in each driver?
- kwolfFor example, we haven't even discussed what messages would look like
- kwolfDoes it?
- FreakyPenguinWell at least the code for handling the messages and splitting it up, into the different handlers, and somehow do synchronisation when sending some data back
- kwolfpcmattman: You don't feel like discussing this? I wanted to leave the answer to you. ;-)
- pcmattmanWell, I think communication between drivers is something CDI will need, and it'll help avoid clogging up the CDI interfac with lots of functions
- pcmattmanOn the other hand, implementing a new way of talking between drivers may be a lot of hard work and involve a lot of rewriting
- kwolfPossibly. But I think what FreakyPenguin is worried about is that your simple cdi_send_message isn't enough
- pcmattmanbbs
- pcmattmanBack
- pcmattmanAnd the cdi_send_message idea centers around each message being a part of a "protocol" between drivers
- pcmattmanThe control protocol defines the generics (type, etc...) while you have a more specific protocol for the device type (eg, for the mixer, it'd be centered around functionality to do with the mixer's relationship to devices)
- pcmattmanBut it's your driver interface, it's just an idea :)
- kwolfSo if you needed a response from the other driver, you would need to implement this logic for each driver, right?
- kwolfpcmattman: No, it's your driver interface as well
- pcmattmanWell, you'd need to reimplement the logic for the current drivers
- pcmattmanBut future drivers, it'd be just a part of writing that driver
- kwolfThe point is if this means a lot of code duplication
- kwolfCurrent drivers don't communicate with other drivers, so they won't need reimplementation
- pcmattmanPerhaps the common code, such as the control protocol, can be hidden away in a CDI function?
- pcmattmanThe only thing that's really going to be duplicated is the control protocol code, the other code is driver-specific (ie, mixer -> device interface will have one device handle messages differently from another device)
- kwolfWe have only one mixer, but n different sound drivers
- pcmattmanYup
- pcmattmanThe mixer has code to communicate with the sound drivers
- pcmattmanThe sound drivers take those messages (whatever they may be) and performs the action it needs to (which is device-specific)
- pcmattmanAn alternative that can get around the need for any communication is to allow drivers to access a list of other devices/drivers in the system
- kwolfFreakyPenguin: Do you have some specific example in mind where we would actually need a response or other more complicated communication patterns?
- kwolfpcmattman: How that? The mixer would still need to send to audio data, wouldn't it?
- pcmattmanWell, it can do that via the sound device interface
- pcmattman(cdi_audio_driver)
- pcmattmanI'm merely looking at another alternative here, in order to find where the IPC-style interface works better
- kwolfThis would lead to the solution with many cdi_usb_* and cdi_audio_* functions, I think
- pcmattmanPerhaps, but realistically the mixer (as an example) takes streams, mixes them into one output stream, and sends that to the sound device
- pcmattmanI don't know enough about USB in CDI to comment intelligently there, it's probably very different
- kwolfIt's basically nonexistent as of today ;-)
- pcmattmanThe way I see it, the mixer is going one way - Application -> Mixer -> Sound device - so two-way communication isn't necessary
- FreakyPenguin*g*
- pcmattmanHowever, USB is Application <-> Controller <-> Device (I *think* so anyway) - there's two-way communication everywhere
- FreakyPenguinkwolf: Well I don't know about usb either, but I had somthing in mind like reading some memory/storage/whatever, you have to send offset and size and get some data back.
- kwolfpcmattman: Hm... We can make audio two-way very easily. What about recording?
- pcmattmanI was really hoping someone wouldn't bring up recording ;)
- pcmattmanI think IPC may be a bit over-the-top for audio, but it may be just the right thing for USB
- kwolfYou're trying to talk us into a bad design, so you take over world domination alone? ;-)
- pcmattmanI also think IPC should be done on a per-device-class basis, not necessarily across the entire interface, to keep things simple
- kwolfI'm not sure what to think about IPC and "keep it simple" in one sentence.
- pcmattmanHaha
- FreakyPenguin*g*
- kwolfI mean we could easily expose the whole tyndur RPC functions to CDI, but I'm unsure if other OSes would like it
- pcmattmanI feel that IPC should be used as little as possible, where communication is required
- kwolfI'm not even sure if we would like it, to be honest ;-)
- pcmattmanFor instance, there's no point having IPC in network drivers
- kwolfUnless someone has the idea of moving the TCP/IP stack into CDI
- FreakyPenguinWhell what about protocol-stacks in cdi?
- pcmattmanIf that were to happen, you would add IPC
- kwolfRight. It's going to happen always when you need to stack drivers.
- pcmattmanSo I guess it comes down to a) IPC as a necessity in drivers, or b) Add more and more functions to CDI to suit the needs of the communication between drivers
- kwolfRight, as I said above. FreakyPenguin, I think it's your turn. ;-)
- FreakyPenguinBut I'm just reviewing some nice well commented pascal code. *g*
- kwolfMoin XanClic
- XanClicGood afternoon
- kwolfYou might want to read up the log, we're discussing pretty fundamental questions ;-)
- XanClicFirst of all I wouldn't call it "IPC"
- XanClicIn a monolithic kernel that's no IPC
- kwolfMeh... s/IPC/IDC/g if you all insist on it...
- XanClicAnd why not using the cdi_device structure as the destination operand?
- XanClicThis structure also tells you what kind of device it is
- kwolfHm, it's not a perfect match
- kwolfIt contains pointer to the driver and so on which probably don't exist for the caller
- XanClicSo you could use an index in an array or something like that, just a handle that can be used to receive more information about the destination driver
- kwolfHm, how would receiving a message look like for a driver? A callback function called?
- XanClicI think so
- XanClicI gives a function pointer to the OS and that one is called upon receiving a message
- XanClic*it
- kwolfWell then, let's copy the tyndur RPC interface ;-)
- XanClicI think it's enough to tell the called driver what driver called it and a pointer to a message (driver-defined format)
- kwolfMessages need to consist of at least two different parts to avoid copying things around while constructing the message
- kwolfMetadata and payload.