source: trunk/kernel/kern/sysconf.c @ 21

Last change on this file since 21 was 1, checked in by alain, 8 years ago

First import

File size: 2.0 KB
RevLine 
[1]1/*
2 * kern/sysconf.c - interface to access system exported configurations
3 *
4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
6 *
7 * This file is part of ALMOS-kernel.
8 *
9 * ALMOS-kernel is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2.0 of the License.
12 *
13 * ALMOS-kernel is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <types.h>
24#include <config.h>
25#include <libk.h>
26#include <system.h>
27#include <sysfs.h>
28#include <arch.h>
29#include <pmm.h>
30#include <thread.h>
31#include <sysconf.h>
32
33static sysfs_entry_t sysconf;
34static void sysconf_sysfs_op_init(sysfs_op_t *op);
35
36error_t sysconf_init(void)
37{
38        sysfs_op_t op;
39
40        sysconf_sysfs_op_init(&op);
41        sysfs_entry_init(&sysconf, &op, 
42#if CONFIG_ROOTFS_IS_VFAT
43                         "SYSCONF"
44#else
45                         "sysconf"
46#endif
47                );
48        sysfs_entry_register(&sysfs_root_entry, &sysconf);
49
50        return 0;
51}
52
53static error_t sysconf_sysfs_read_op(sysfs_entry_t *entry, sysfs_request_t *rq, uint_t *offset)
54{
55        struct thread_s *this;
56
57        if(*offset != 0)
58        {
59                *offset   = 0;
60                rq->count = 0;
61                return 0;
62        }
63 
64        this = current_thread;
65
66        sprintk((char*)rq->buffer, 
67                "CLUSTER_ONLN_NR %d\nCPU_ONLN_NR %d\nCPU_CACHE_LINE_SIZE %d\nPAGE_SIZE %d\nHEAP_MAX_SIZE %d\n",
68                arch_onln_cluster_nr(),
69                arch_onln_cpu_nr(), 
70                CACHE_LINE_SIZE, 
71                PMM_PAGE_SIZE,
72                CONFIG_TASK_HEAP_MAX_SIZE);
73 
74        rq->count = strlen((const char*)rq->buffer); 
75        *offset   = 0;
76        return 0;
77}
78
79static void sysconf_sysfs_op_init(sysfs_op_t *op)
80{
81        op->open  = NULL;
82        op->read  = sysconf_sysfs_read_op;
83        op->write = NULL;
84        op->close = NULL;
85}
Note: See TracBrowser for help on using the repository browser.