[kernel] Let endpoints get interrupt notifications

- Add a tag field to all endpoint messages, which doubles as a
  notification field
- Add a endpoint_bind_irq syscall to enable an endpoint to listen for
  interrupt notifications. This mechanism needs to change.
- Add a temporary copy of the serial port code to nulldrv, and let it
  take responsibility for COM2
This commit is contained in:
2020-10-05 01:06:49 -07:00
parent 4ccaa2dfea
commit 1904e240cf
22 changed files with 325 additions and 153 deletions

View File

@@ -2,6 +2,7 @@
#include "j6/types.h"
#include "log.h"
#include "device_manager.h"
#include "objects/endpoint.h"
#include "syscalls/helpers.h"
@@ -24,32 +25,55 @@ endpoint_close(j6_handle_t handle)
}
j6_status_t
endpoint_send(j6_handle_t handle, size_t len, void *data)
endpoint_send(j6_handle_t handle, j6_tag_t tag, size_t len, void *data)
{
if (tag & j6_tag_system_flag)
return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
return e->send(len, data);
return e->send(tag, len, data);
}
j6_status_t
endpoint_receive(j6_handle_t handle, size_t *len, void *data)
endpoint_receive(j6_handle_t handle, j6_tag_t *tag, size_t *len, void *data)
{
if (!tag || !len || (*len && !data))
return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
return e->receive(len, data);
return e->receive(tag, len, data);
}
j6_status_t
endpoint_sendrecv(j6_handle_t handle, size_t *len, void *data)
endpoint_sendrecv(j6_handle_t handle, j6_tag_t *tag, size_t *len, void *data)
{
if (!tag || (*tag & j6_tag_system_flag))
return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
j6_status_t status = e->send(*len, data);
j6_status_t status = e->send(*tag, *len, data);
if (status != j6_status_ok)
return status;
return e->receive(len, data);
return e->receive(tag, len, data);
}
j6_status_t
endpoint_bind_irq(j6_handle_t handle, unsigned irq)
{
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
if (device_manager::get().bind_irq(irq, e))
return j6_status_ok;
return j6_err_invalid_arg;
}
} // namespace syscalls