static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { if (!mount_init ()) { /* we were not able to properly initialize ourselves, bail out */ g_main_loop_quit (loop); return; } }
void main_matthias(void) { printf("Setup kernel\n"); setup_kernel(); setup_device_manager(); mount_init(); __enable_interrupts(); __switch_to_user_mode(); init_mouse_handler(); //manuel_setup_device_manager(); play_game(); /*int m[] = {0, 1, 2, 1, 1, 0, 2, 2, 0}; draw_current_tictactoe(&m); int i; for(i = 5; i < 650; i+=4){ draw_curser(i, 30, &m); } */ // api_video_draw_raw_image( 0, 0, "/sd/Banner.raw", TRUE); /*draw_tictactoe(); int p1[] = {0, 0, 0, 1, 1, 1, 0, 0, 0}; int p2[] = {0, 0, 0, 1, 1, 1, 0, 0, 0}; game_won(&p1); draw_tictactoe_field(1, 1, TRUE); draw_tictactoe_field(0, 1, FALSE); draw_tictactoe_field(0, 0, TRUE); draw_tictactoe_field(2, 2, FALSE); draw_tictactoe_field(1, 0, TRUE); draw_tictactoe_field(1,2, FALSE); draw_tictactoe_field(0, 2, TRUE); draw_tictactoe_field(2, 0, FALSE);*/ //color_t c; //c.rgb = 0xFF0000FF; //api_video_fill_rect(c, 10, 10, 200, 200, TRUE); //printf("Test"); //mmuInit(); /* //Pagetables Pagetable masterPT = {0x00000000, 0x18000, 0x18000, MASTER, 3}; Pagetable systemPT = {0x00000000, 0x1c000, 0x18000, COARSE, 3}; Pagetable task1PT = {0x00400000, 0x1c400, 0x18000, COARSE, 3}; Pagetable task2PT = {0x00400000, 0x1c800, 0x18000, COARSE, 3}; Pagetable task3PT = {0x00400000, 0x1cc00, 0x18000, COARSE, 3}; //Region Tables Region kernelRegion = {0x00000000, 4, 16, RWNA, WT, 0x00000000, &systemPT}; Region sharedRegion = {0x00010000, 4, 8, RWRW, WT, 0x00010000, &systemPT}; Region pageTableRegion = {0x00018000, 4, 8, RWNA, WT, 0x00018000, &systemPT}; Region peripheralRegion = {0x10000000, 1024, 256, RWNA, cb, 0x10000000, &masterPT}; init_MMU(kernelRegion); init_MMU(sharedRegion); init_MMU(pageTableRegion); init_MMU(peripheralRegion); //Set TTB asm("MCR p15,0,ttb,c2,c0,0"); //Enabling MMU asm("MRC p15,0,r1,c1,c0,0"); asm("ORR r1,r1,#0x1"); asm("MCR p15,0,r1,c1,c0,0"); */ /*User Mode Cernel Mode unsigned int first_stack[256]; unsigned int *first_stack_start = first_stack + 256 - 16; first_stack_start[0] = 0x10; printf("Erste\n"); first_stack_start[1] = (unsigned int)&first; bwputs("Starting\n"); printf("Zweite\n"); activate(first_stack_start); printf("Dritte\n"); while(1){ printf("Das ist ein test2\n"); } */ }
/* * login() * Log in as given account */ static void login(struct uinfo *u) { int x; port_t port; struct perm perm; char *p, buf[128]; extern void zero_ids(); /* * Activate root abilities */ zero_ids(&perm, 1); perm.perm_len = 0; if (perm_ctl(1, &perm, (void *)0) < 0) { printf("login: can't enable root\n"); exit(1); } /* * Set our ID. We skip slot 1, which is our superuser slot * used to authorize the manipulation of all others. Finish * by setting 1--after this, we only hold the abilities of * the user logging on. */ for (x = 0; x < PROCPERMS; ++x) { if (x == 1) { continue; } perm_ctl(x, &u->u_perms[x], (void *)0); } /* * Initialize our environment. Slot 0, our default ownership, * is now set, so we will own the nodes which appear. */ setenv_init(u->u_env); /* * Give up our powers */ perm_ctl(1, &u->u_perms[1], (void *)0); /* * Re-initialize. The /env server otherwise still believes * we have vast privileges. */ setenv_init(u->u_env); /* * Mount system default stuff. Remove our root-capability * entry from the mount table. */ port = mount_port("/"); mount_init(_PATH_SYSMOUNT); umount("/", port); /* * Put some stuff into our environment. We place it in the * common part of our environment so all processes under this * login will share it. */ sprintf(buf, "/%s/USER", u->u_env); setenv(buf, u->u_acct); sprintf(buf, "/%s/HOME", u->u_env); setenv(buf, u->u_home); /* * If we can chdir to their home, set up their mount * environment as requested. */ if (chdir(u->u_home) >= 0) { mount_init(_PATH_MOUNTRC); } else { printf("Note: can not chdir to home: %s\n", u->u_home); } /* * Scrub TTY. Create our own signal group and tell our TTY. * We need to re-open the TTY if we have a path to it, so * our server can see our "real" ID's, not the login process's * version. */ if (tty_dev) { open_tty_dev(tty_dev); } (void)tcsetattr(1, TCSANOW, &torig); (void)setsid(); (void)sprintf(buf, "pgrp=%lu\n", getpid()); (void)wstat(__fd_port(1), buf); /* * Launch their shell with a leading '-' in argv[0] to flag * a login shell. */ p = strrchr(u->u_shell, '/'); if (p && (strlen(p)+4 < sizeof(buf))) { sprintf(buf, "-%s", p+1); p = buf; } else { p = u->u_shell; } execl(u->u_shell, p, (char *)0); perror(u->u_shell); exit(1); }
int vfs_mountroot_devfs(void) { struct vnode *vp; struct nchandle nch; struct nlookupdata nd; struct mount *mp; struct vfsconf *vfsp; int error; struct ucred *cred = proc0.p_ucred; const char *devfs_path, *init_chroot; char *dev_malloced = NULL; if ((init_chroot = kgetenv("init_chroot")) != NULL) { size_t l; l = strlen(init_chroot) + sizeof("/dev"); dev_malloced = kmalloc(l, M_MOUNT, M_WAITOK); ksnprintf(dev_malloced, l, "%s/dev", init_chroot); devfs_path = dev_malloced; } else { devfs_path = "/dev"; } /* * Lookup the requested path and extract the nch and vnode. */ error = nlookup_init_raw(&nd, devfs_path, UIO_SYSSPACE, NLC_FOLLOW, cred, &rootnch); if (error == 0) { devfs_debug(DEVFS_DEBUG_DEBUG, "vfs_mountroot_devfs: nlookup_init is ok...\n"); if ((error = nlookup(&nd)) == 0) { devfs_debug(DEVFS_DEBUG_DEBUG, "vfs_mountroot_devfs: nlookup is ok...\n"); if (nd.nl_nch.ncp->nc_vp == NULL) { devfs_debug(DEVFS_DEBUG_SHOW, "vfs_mountroot_devfs: nlookup: simply not found\n"); error = ENOENT; } } } if (dev_malloced != NULL) kfree(dev_malloced, M_MOUNT), dev_malloced = NULL; devfs_path = NULL; if (error) { nlookup_done(&nd); devfs_debug(DEVFS_DEBUG_SHOW, "vfs_mountroot_devfs: nlookup failed, error: %d\n", error); return (error); } /* * Extract the locked+refd ncp and cleanup the nd structure */ nch = nd.nl_nch; cache_zero(&nd.nl_nch); nlookup_done(&nd); /* * now we have the locked ref'd nch and unreferenced vnode. */ vp = nch.ncp->nc_vp; if ((error = vget(vp, LK_EXCLUSIVE)) != 0) { cache_put(&nch); devfs_debug(DEVFS_DEBUG_SHOW, "vfs_mountroot_devfs: vget failed\n"); return (error); } cache_unlock(&nch); if ((error = vinvalbuf(vp, V_SAVE, 0, 0)) != 0) { cache_drop(&nch); vput(vp); devfs_debug(DEVFS_DEBUG_SHOW, "vfs_mountroot_devfs: vinvalbuf failed\n"); return (error); } if (vp->v_type != VDIR) { cache_drop(&nch); vput(vp); devfs_debug(DEVFS_DEBUG_SHOW, "vfs_mountroot_devfs: vp is not VDIR\n"); return (ENOTDIR); } vfsp = vfsconf_find_by_name("devfs"); vsetflags(vp, VMOUNT); /* * Allocate and initialize the filesystem. */ mp = kmalloc(sizeof(struct mount), M_MOUNT, M_ZERO|M_WAITOK); mount_init(mp); vfs_busy(mp, LK_NOWAIT); mp->mnt_op = vfsp->vfc_vfsops; mp->mnt_vfc = vfsp; vfsp->vfc_refcount++; mp->mnt_stat.f_type = vfsp->vfc_typenum; mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK; strncpy(mp->mnt_stat.f_fstypename, vfsp->vfc_name, MFSNAMELEN); mp->mnt_stat.f_owner = cred->cr_uid; vn_unlock(vp); /* * Mount the filesystem. */ error = VFS_MOUNT(mp, "/dev", NULL, cred); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* * Put the new filesystem on the mount list after root. The mount * point gets its own mnt_ncmountpt (unless the VFS already set one * up) which represents the root of the mount. The lookup code * detects the mount point going forward and checks the root of * the mount going backwards. * * It is not necessary to invalidate or purge the vnode underneath * because elements under the mount will be given their own glue * namecache record. */ if (!error) { if (mp->mnt_ncmountpt.ncp == NULL) { /* * allocate, then unlock, but leave the ref intact */ cache_allocroot(&mp->mnt_ncmountpt, mp, NULL); cache_unlock(&mp->mnt_ncmountpt); } mp->mnt_ncmounton = nch; /* inherits ref */ nch.ncp->nc_flag |= NCF_ISMOUNTPT; /* XXX get the root of the fs and cache_setvp(mnt_ncmountpt...) */ vclrflags(vp, VMOUNT); mountlist_insert(mp, MNTINS_LAST); vn_unlock(vp); //checkdirs(&mp->mnt_ncmounton, &mp->mnt_ncmountpt); error = vfs_allocate_syncvnode(mp); if (error) { devfs_debug(DEVFS_DEBUG_SHOW, "vfs_mountroot_devfs: vfs_allocate_syncvnode failed\n"); } vfs_unbusy(mp); error = VFS_START(mp, 0); vrele(vp); } else { vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_coherency_ops); vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_journal_ops); vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_norm_ops); vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_spec_ops); vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_fifo_ops); vclrflags(vp, VMOUNT); mp->mnt_vfc->vfc_refcount--; vfs_unbusy(mp); kfree(mp, M_MOUNT); cache_drop(&nch); vput(vp); devfs_debug(DEVFS_DEBUG_SHOW, "vfs_mountroot_devfs: mount failed\n"); } devfs_debug(DEVFS_DEBUG_DEBUG, "rootmount_devfs done with error: %d\n", error); return (error); }