mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 21:58:20 +00:00
devfs: take cred struct in devfs_register
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#include <kernel/pci.h>
|
||||
#include <logging.h>
|
||||
#include <kernel/hda.h>
|
||||
|
||||
static void initcontroller(pcienum_t *e) {
|
||||
//pcibar_t bar0p = pci_getbar(e, 0);
|
||||
//volatile nvmebar0_t *bar0 = (volatile nvmebar0_t *)bar0p.address;
|
||||
//__assert(bar0);
|
||||
|
||||
pci_setcommand(e, PCI_COMMAND_MMIO, 1);
|
||||
pci_setcommand(e, PCI_COMMAND_IO, 0);
|
||||
pci_setcommand(e, PCI_COMMAND_IRQDISABLE, 1);
|
||||
pci_setcommand(e, PCI_COMMAND_BUSMASTER, 1);
|
||||
|
||||
printf("hda: found controller at %02x:%02x.%x\n", e->bus, e->device, e->function);
|
||||
|
||||
// enable interrupts
|
||||
|
||||
size_t intcount;
|
||||
if (e->msix.exists) {
|
||||
intcount = pci_initmsix(e);
|
||||
} else if (e->msi.exists) {
|
||||
// intcount = pci_initmsi(e);
|
||||
} else {
|
||||
printf("hda: controller doesn't support msi-x or msi\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void hda_init() {
|
||||
int i = 0;
|
||||
for (;;) {
|
||||
pcienum_t *e = pci_getenum(-1, -1, -1, 0x8086, 0x2668, -1, i++);
|
||||
if (e == NULL)
|
||||
break;
|
||||
initcontroller(e);
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ static int registerdesc(blockdesc_t *desc, char *name) {
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return devfs_register(&devops, name, V_TYPE_BLKDEV, DEV_MAJOR_BLOCK, id, 0644);
|
||||
return devfs_register(&devops, name, V_TYPE_BLKDEV, DEV_MAJOR_BLOCK, id, 0600, NULL);
|
||||
}
|
||||
|
||||
#define PART_NONE 0
|
||||
|
||||
+1
-1
@@ -244,7 +244,7 @@ void fb_init() {
|
||||
char name[6];
|
||||
snprintf(name, 6, "fb%d", i);
|
||||
|
||||
__assert(devfs_register(&ops, name, V_TYPE_CHDEV, DEV_MAJOR_FB, i, 0644) == 0);
|
||||
__assert(devfs_register(&ops, name, V_TYPE_CHDEV, DEV_MAJOR_FB, i, 0666, NULL) == 0);
|
||||
|
||||
printf("%s: %dx%d %d bpp\n", name, fb->width, fb->height, fb->bpp);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ keyboard_t *keyboard_new() {
|
||||
char name[12];
|
||||
snprintf(name, 12, "keyboard%d", currentkbnum);
|
||||
|
||||
__assert(devfs_register(&devops, name, V_TYPE_CHDEV, DEV_MAJOR_KEYBOARD, currentkbnum, 0644) == 0);
|
||||
__assert(devfs_register(&devops, name, V_TYPE_CHDEV, DEV_MAJOR_KEYBOARD, currentkbnum, 0666, NULL) == 0);
|
||||
|
||||
POLL_INITHEADER(&kb->pollheader);
|
||||
++currentkbnum;
|
||||
|
||||
@@ -171,7 +171,7 @@ mouse_t *mouse_new() {
|
||||
char name[12];
|
||||
|
||||
snprintf(name, 12, "mouse%d", currentnum);
|
||||
__assert(devfs_register(&devops, name, V_TYPE_CHDEV, DEV_MAJOR_MOUSE, currentnum, 0644) == 0);
|
||||
__assert(devfs_register(&devops, name, V_TYPE_CHDEV, DEV_MAJOR_MOUSE, currentnum, 0600, NULL) == 0);
|
||||
|
||||
++currentnum;
|
||||
return mouse;
|
||||
|
||||
@@ -17,7 +17,7 @@ int netdev_register(netdev_t *netdev, char *name) {
|
||||
goto leave;
|
||||
|
||||
|
||||
e = devfs_register(&devops, name, V_TYPE_CHDEV, DEV_MAJOR_NET, 0, 0644);
|
||||
e = devfs_register(&devops, name, V_TYPE_CHDEV, DEV_MAJOR_NET, 0, 0600, NULL);
|
||||
if (e)
|
||||
hashtable_remove(&nametable, name, strlen(name));
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ static devops_t urandomops = {
|
||||
};
|
||||
|
||||
void pseudodevices_init() {
|
||||
__assert(devfs_register(&nullops, "null", V_TYPE_CHDEV, DEV_MAJOR_NULL, 0, 0644) == 0);
|
||||
__assert(devfs_register(&fullops, "full", V_TYPE_CHDEV, DEV_MAJOR_FULL, 0, 0644) == 0);
|
||||
__assert(devfs_register(&zeroops, "zero", V_TYPE_CHDEV, DEV_MAJOR_ZERO, 0, 0644) == 0);
|
||||
__assert(devfs_register(&urandomops, "urandom", V_TYPE_CHDEV, DEV_MAJOR_URANDOM, 0, 0644) == 0);
|
||||
__assert(devfs_register(&nullops, "null", V_TYPE_CHDEV, DEV_MAJOR_NULL, 0, 0666, NULL) == 0);
|
||||
__assert(devfs_register(&fullops, "full", V_TYPE_CHDEV, DEV_MAJOR_FULL, 0, 0666, NULL) == 0);
|
||||
__assert(devfs_register(&zeroops, "zero", V_TYPE_CHDEV, DEV_MAJOR_ZERO, 0, 0666, NULL) == 0);
|
||||
__assert(devfs_register(&urandomops, "urandom", V_TYPE_CHDEV, DEV_MAJOR_URANDOM, 0, 0666, NULL) == 0);
|
||||
}
|
||||
|
||||
+2
-2
@@ -253,7 +253,7 @@ static int open(int oldminor, vnode_t **vnode, int flags) {
|
||||
|
||||
// register a master device and immediatelly remove it from the filesystem and tables
|
||||
// while holding the refcount
|
||||
int error = devfs_register(&devops, tmpname, V_TYPE_CHDEV, DEV_MAJOR_PTY, newminor, 0644);
|
||||
int error = devfs_register(&devops, tmpname, V_TYPE_CHDEV, DEV_MAJOR_PTY, newminor, 0, NULL);
|
||||
if (error) {
|
||||
freeptyminor(newminor);
|
||||
freepty(pty);
|
||||
@@ -284,7 +284,7 @@ static int open(int oldminor, vnode_t **vnode, int flags) {
|
||||
}
|
||||
|
||||
void pty_init() {
|
||||
__assert(devfs_register(&devops, "ptmx", V_TYPE_CHDEV, DEV_MAJOR_PTY, PTMX_MINOR, 0644) == 0);
|
||||
__assert(devfs_register(&devops, "ptmx", V_TYPE_CHDEV, DEV_MAJOR_PTY, PTMX_MINOR, 0666, NULL) == 0);
|
||||
__assert(devfs_createdir("pts") == 0);
|
||||
SPINLOCK_INIT(listlock);
|
||||
}
|
||||
|
||||
+2
-2
@@ -477,7 +477,7 @@ tty_t *tty_create(char *name, ttydevicewritefn_t writefn, ttyinactivefn_t inacti
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (devfs_register(&devops, name, V_TYPE_CHDEV, DEV_MAJOR_TTY, minor, 0644)) {
|
||||
if (devfs_register(&devops, name, V_TYPE_CHDEV, DEV_MAJOR_TTY, minor, 0600, _cpu()->thread->proc ? &_cpu()->thread->proc->cred : NULL)) {
|
||||
freeminor(minor);
|
||||
ringbuffer_destroy(&tty->readbuffer);
|
||||
goto error;
|
||||
@@ -541,6 +541,6 @@ void tty_unregister(tty_t *tty) {
|
||||
|
||||
|
||||
void tty_init() {
|
||||
__assert(devfs_register(&devops, "tty", V_TYPE_CHDEV, DEV_MAJOR_TTY, CONTROLLING_TTY_MINOR, 0644) == 0);
|
||||
__assert(devfs_register(&devops, "tty", V_TYPE_CHDEV, DEV_MAJOR_TTY, CONTROLLING_TTY_MINOR, 0666, NULL) == 0);
|
||||
MUTEX_INIT(&listmutex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user