Evaluated license issues, made some other enhancements.

This commit is contained in:
Bahadir Balban
2009-06-08 17:00:21 +03:00
parent f285337bba
commit 49d47abe97
6 changed files with 77 additions and 123 deletions

View File

@@ -1,11 +1,6 @@
#ifndef __ERRNO_H__
#define __ERRNO_H__
/*
* LICENSE:
* Taken from linux errno.h
*/
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
@@ -140,34 +135,8 @@
#define EKEYREVOKED 128 /* Key has been revoked */
#define EKEYREJECTED 129 /* Key was rejected by service */
/* for robust mutexes */
#define EOWNERDEAD 130 /* Owner died */
#define ENOTRECOVERABLE 131 /* State not recoverable */
/* Codezero specific error codes */
#define EACTIVE 132 /* Task active */
#define ENOIPC 133 /* General IPC error */
#ifdef __KERNEL__
/* Should never be seen by user programs */
#define ERESTARTSYS 512
#define ERESTARTNOINTR 513
#define ERESTARTNOHAND 514 /* restart if no handler.. */
#define ENOIOCTLCMD 515 /* No ioctl command */
#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
/* Defined for the NFSv3 protocol */
#define EBADHANDLE 521 /* Illegal NFS file handle */
#define ENOTSYNC 522 /* Update synchronization mismatch */
#define EBADCOOKIE 523 /* Cookie is stale */
#define ENOTSUPP 524 /* Operation is not supported */
#define ETOOSMALL 525 /* Buffer or request is too small */
#define ESERVERFAULT 526 /* An untranslatable error occurred */
#define EBADTYPE 527 /* Type not supported by server */
#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */
#define EIOCBQUEUED 529 /* iocb queued, will get completion event */
#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */
#endif /* __KERNEL__ */
#endif /* __ERRNO_H__ */

View File

@@ -7,7 +7,6 @@
#ifndef __KIP_H__
#define __KIP_H__
/* FIXME: LICENCE: Taken from a forum post. Must reimplement with GPL terms */
#define __YEAR__ ((((__DATE__ [7] - '0') * 10 + (__DATE__ [8] - '0')) * 10 \
+ (__DATE__ [9] - '0')) * 10 + (__DATE__ [10] - '0'))
@@ -24,19 +23,18 @@
#define __DAY__ ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10 \
+ (__DATE__ [5] - '0'))
//#define DATE_AS_INT (((YEAR - 2000) * 12 + MONTH) * 31 + DAY)
#define CODEZERO_VERSION 0
#define CODEZERO_SUBVERSION 1
#define KDESC_DATE_SIZE 12
#define KDESC_TIME_SIZE 9
struct kernel_desc {
u16 rsrv;
u8 subid;
u8 id;
u16 gendate;
u16 date_rsrv;
u16 subsubver;
u8 subver;
u8 ver;
u32 supplier;
struct kernel_descriptor {
u32 version;
u32 subversion;
u32 magic;
char date[KDESC_DATE_SIZE];
char time[KDESC_TIME_SIZE];
} __attribute__((__packed__));
/* Experimental KIP with non-standard offsets */
@@ -70,7 +68,7 @@ struct kip {
u32 utcb;
struct kernel_desc kdesc;
struct kernel_descriptor kdesc;
} __attribute__((__packed__));
/*

View File

@@ -1,47 +0,0 @@
#ifndef __DEBUG_MACRO_S__
#define __DEBUG_MACRO_S__
#include INC_PLAT(offsets.h)
#define UART01x_DR 0x00
/*
* linux/arch/arm/kernel/debug.S
*
* Copyright (C) 1994-1999 Russell King
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 32-bit debugging code
*/
.macro addruart,rx
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0x10000000
orreq \rx, \rx, #0x001F0000
orreq \rx, \rx, #0x00001000
/* FIXME: This offset is incorrect for now. Make sure you pass correct offset */
movne \rx, #0xf9000000 @#IO_AREA0_VADDR
@movne \rx, #IO_AREA0_VADDR
addne \rx, \rx, #PB926_UART0_VOFFSET @ UART0 page offset from
@ virtual io area base.
.endm
.macro senduart,rd,rx
strb \rd, [\rx, #UART01x_DR]
.endm
.macro waituart,rd,rx
1001: ldr \rd, [\rx, #0x18] @ UARTFLG
tst \rd, #1 << 5 @ UARTFLGUTXFF - 1 when full
bne 1001b
.endm
.macro busyuart,rd,rx
1001: ldr \rd, [\rx, #0x18] @ UARTFLG
tst \rd, #1 << 3 @ UARTFLGUBUSY - 1 when busy
bne 1001b
.endm
#endif /* __DEBUG_MACRO_S__ */

View File

@@ -181,12 +181,12 @@ void kip_init()
kip.api_version = 0xBB;
kip.api_subversion = 1;
kip.api_flags = 0; /* LE, 32-bit architecture */
kip.kdesc.subid = 0x1;
kip.kdesc.id = 0xBB;
kip.kdesc.gendate = (__YEAR__ << 9)|(__MONTH__ << 5)|(__DAY__);
kip.kdesc.subsubver = 0x00000001; /* Consider as .00000001 */
kip.kdesc.ver = 0;
memcpy(&kip.kdesc.supplier, "BBB", 3);
kip.kdesc.magic = 0xBBB;
kip.kdesc.version = CODEZERO_VERSION;
kip.kdesc.subversion = CODEZERO_SUBVERSION;
// kip.kdesc.gendate = (__YEAR__ << 9)|(__MONTH__ << 5)|(__DAY__);
strncpy(kip.kdesc.date, __DATE__, KDESC_DATE_SIZE);
strncpy(kip.kdesc.time, __TIME__, KDESC_TIME_SIZE);
kip_init_syscalls();
@@ -198,6 +198,8 @@ void kip_init()
add_mapping(virt_to_phys(&kip), USER_KIP_PAGE, PAGE_SIZE,
MAP_USR_RO_FLAGS);
printk("%s: Kernel built on %s, %s\n", __KERNELNAME__,
kip.kdesc.date, kip.kdesc.time);
}

View File

@@ -41,29 +41,27 @@ int strcmp(const char *s1, const char *s2)
}
}
/* LICENCE: Taken from linux for now BB.
* strncpy - Copy a length-limited, %NUL-terminated string
* @dest: Where to copy the string to
* @src: Where to copy the string from
* @count: The maximum number of bytes to copy
*
* The result is not %NUL-terminated if the source exceeds
* @count bytes.
*
* In the case where the length of @src is less than that of
* count, the remainder of @dest will be padded with %NUL.
/*
* Copies string pointed by @from to string pointed by @to.
*
* If count is greater than the length of string in @from,
* pads rest of the locations with null.
*/
char *strncpy(char *dest, const char *src, int count)
char *strncpy(char *to, const char *from, int count)
{
char *tmp = dest;
char *temp = to;
while (count) {
if ((*tmp = *src) != 0)
src++;
tmp++;
*temp = *from;
/*
* Stop updating from if null
* terminator is reached.
*/
if (*from)
from++;
temp++;
count--;
}
return dest;
return to;
}

View File

@@ -1,7 +1,41 @@
#include INC_PLAT(debug-macro.S)
/*
* Basic UART printing.
*/
#include INC_ARCH(asm.h)
#include INC_GLUE(memlayout.h)
#define UART_DATA_OFFSET 0x0
.macro uart_address rx
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0x10000000
orreq \rx, \rx, #0x001F0000
orreq \rx, \rx, #0x00001000
/* FIXME: This offset is incorrect */
movne \rx, #0xf9000000 @#IO_AREA0_VADDR
addne \rx, \rx, #PB926_UART0_VOFFSET @ UART0 page offset from
@ virtual io area base.
.endm
.macro uart_send, ry, rx
strb \ry, [\rx, #UART_DATA_OFFSET]
.endm
.macro uart_wait, ry, rx
501:
ldr \ry, [\rx, #0x18]
tst \ry, #1 << 5
bne 501b
.endm
.macro uart_busy, ry, rx
501:
ldr \ry, [\rx, #0x18]
tst \ry, #1 << 3
bne 501b
.endm
.text
/*
* Useful debugging routines
@@ -49,11 +83,11 @@ printhex: adr r2, hexbuf
BEGIN_PROC(printascii)
get_straddr r0, r1
addruart r3
uart_address r3
b 2f
1: waituart r2, r3
senduart r1, r3
busyuart r2, r3
1: uart_wait r2, r3
uart_send r1, r3
uart_busy r2, r3
teq r1, #'\n'
moveq r1, #'\r'
beq 1b
@@ -65,7 +99,7 @@ BEGIN_PROC(printascii)
END_PROC(printascii)
BEGIN_PROC(printch)
addruart r3
uart_address r3
mov r1, r0
mov r0, #0
b 1b