You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(35) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(37) |
Feb
(10) |
Mar
|
Apr
(2) |
May
(17) |
Jun
(1) |
Jul
(14) |
Aug
(14) |
Sep
(4) |
Oct
|
Nov
(14) |
Dec
(4) |
2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(92) |
Dec
(12) |
2006 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(5) |
May
(3) |
Jun
(15) |
Jul
(3) |
Aug
(1) |
Sep
(29) |
Oct
(1) |
Nov
(6) |
Dec
(5) |
2007 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
(3) |
May
(14) |
Jun
(2) |
Jul
(16) |
Aug
(73) |
Sep
(12) |
Oct
(9) |
Nov
(27) |
Dec
(3) |
2008 |
Jan
(4) |
Feb
(4) |
Mar
(3) |
Apr
(8) |
May
(23) |
Jun
(4) |
Jul
(1) |
Aug
(3) |
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
(1) |
2009 |
Jan
|
Feb
(10) |
Mar
|
Apr
(4) |
May
(4) |
Jun
(10) |
Jul
|
Aug
(1) |
Sep
|
Oct
(7) |
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(1) |
Sep
|
Oct
(15) |
Nov
(1) |
Dec
(5) |
2011 |
Jan
(4) |
Feb
(1) |
Mar
(6) |
Apr
|
May
(22) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2012 |
Jan
|
Feb
(10) |
Mar
(1) |
Apr
(6) |
May
(27) |
Jun
(48) |
Jul
(30) |
Aug
(4) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(11) |
2013 |
Jan
(4) |
Feb
(7) |
Mar
(6) |
Apr
(18) |
May
(28) |
Jun
(20) |
Jul
|
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(7) |
2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(9) |
May
(11) |
Jun
(10) |
Jul
|
Aug
(18) |
Sep
(12) |
Oct
(17) |
Nov
(10) |
Dec
(16) |
2015 |
Jan
(5) |
Feb
(1) |
Mar
(5) |
Apr
(4) |
May
(28) |
Jun
(2) |
Jul
|
Aug
|
Sep
(6) |
Oct
|
Nov
(2) |
Dec
(1) |
2016 |
Jan
(14) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(1) |
2017 |
Jan
(11) |
Feb
|
Mar
(21) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(13) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2020 |
Jan
(10) |
Feb
(9) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(18) |
Jul
(4) |
Aug
(2) |
Sep
(20) |
Oct
(2) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2022 |
Jan
(1) |
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2023 |
Jan
(10) |
Feb
(7) |
Mar
(29) |
Apr
(31) |
May
(29) |
Jun
(34) |
Jul
(3) |
Aug
(24) |
Sep
(22) |
Oct
(10) |
Nov
(38) |
Dec
(27) |
2024 |
Jan
(15) |
Feb
(8) |
Mar
(4) |
Apr
(20) |
May
(33) |
Jun
(18) |
Jul
(15) |
Aug
(23) |
Sep
(26) |
Oct
(32) |
Nov
(6) |
Dec
(4) |
2025 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
(4) |
May
(46) |
Jun
(19) |
Jul
(26) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Lawrence S. <ljs...@us...> - 2014-12-24 02:06:50
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via a1805afad1e8266f93797a9fd8353bfa1fa31501 (commit) from 65fe5ec8bde7fe4e0e568a41036bd233af2ad2fe (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a1805afad1e8266f93797a9fd8353bfa1fa31501 Author: Lawrence Sebald <ljs...@us...> Date: Tue Dec 23 21:06:21 2014 -0500 New version of make_banner.sh that doesn't require bash. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/make_banner.sh | 42 +++++++++++++++----------- 1 files changed, 24 insertions(+), 18 deletions(-) diff --git a/kernel/arch/dreamcast/kernel/make_banner.sh b/kernel/arch/dreamcast/kernel/make_banner.sh index f824e20..35dd72d 100755 --- a/kernel/arch/dreamcast/kernel/make_banner.sh +++ b/kernel/arch/dreamcast/kernel/make_banner.sh @@ -1,31 +1,37 @@ -#!/usr/bin/env bash +#!/bin/sh # Re-creates the banner.h file for each compilation run -echo 'static const char banner[] = ' > banner.h +printf 'static const char banner[] = \n' > banner.h -echo -n '"KallistiOS ' >> banner.h +printf '"KallistiOS ' >> banner.h if [ -d "$KOS_BASE/.git" ]; then - echo -n 'Git revision ' >> banner.h - echo -n `git rev-list --full-history --all --abbrev-commit | head -1` >> banner.h - echo -n ': ' >> banner.h + printf 'Git revision ' >> banner.h + printf `git rev-list --full-history --all --abbrev-commit | head -1` >> banner.h + printf ': ' >> banner.h else - echo -n '##version##: ' >> banner.h + printf '##version##: ' >> banner.h fi -echo -n `date` >> banner.h -echo '\n"' >> banner.h -echo -n '" ' >> banner.h -echo -n `whoami` >> banner.h -echo -n '@' >> banner.h +tmp=`date` +printf "$tmp" >> banner.h +printf '\\n"\n' >> banner.h + +printf '" ' >> banner.h +tmp=`whoami` +printf "$tmp" >> banner.h +printf '@' >> banner.h + if [ `uname` = Linux ]; then - echo -n `hostname -f` >> banner.h + tmp=`hostname -f` else - echo -n `hostname` >> banner.h + tmp=`hostname` fi -echo -n ':' >> banner.h -echo -n $KOS_BASE >> banner.h -echo '\n"' >> banner.h -echo ';' >> banner.h +printf "$tmp" >> banner.h + +printf ':' >> banner.h +printf "$KOS_BASE" >> banner.h +printf '\\n"\n' >> banner.h +printf ';\n' >> banner.h hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-12-21 21:13:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 65fe5ec8bde7fe4e0e568a41036bd233af2ad2fe (commit) from c0c664a9e0c99acf581dd25351e028e5273b8b9f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 65fe5ec8bde7fe4e0e568a41036bd233af2ad2fe Author: Lawrence Sebald <ljs...@us...> Date: Sun Dec 21 16:11:52 2014 -0500 make_banner.sh requires bash. /bin/sh does not support the -n flag to echo on some OSes. We need bash to ensure it works properly. Revert "Use /bin/sh instead of bash" This reverts commit 8910881aa1100fe022c3c5e25c10ec7a4344afee. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/make_banner.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/kernel/arch/dreamcast/kernel/make_banner.sh b/kernel/arch/dreamcast/kernel/make_banner.sh index 0baaeb7..f824e20 100755 --- a/kernel/arch/dreamcast/kernel/make_banner.sh +++ b/kernel/arch/dreamcast/kernel/make_banner.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # Re-creates the banner.h file for each compilation run hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: PH3NOM <ph...@us...> - 2014-12-21 00:51:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via fd78ac5f956321de5273d445bfe72cab6f5ae12a (commit) from 29ba7674b3120608e4bcd17043a53817df9e2502 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fd78ac5f956321de5273d445bfe72cab6f5ae12a Author: Josh Pearson <ph...@us...> Date: Sat Dec 20 16:51:14 2014 -0800 Update to libgl 12-20-2014 ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index 8b276ca..4af2c8a 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit 8b276ca731cf818fc97a47fc740d364ea646c9aa +Subproject commit 4af2c8aacc9d59b3314767f16acddf9cb25ee73a hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: PH3NOM <ph...@us...> - 2014-12-21 00:50:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 4af2c8aacc9d59b3314767f16acddf9cb25ee73a (commit) from 8b276ca731cf818fc97a47fc740d364ea646c9aa (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4af2c8aacc9d59b3314767f16acddf9cb25ee73a Author: Josh Pearson <ph...@us...> Date: Sat Dec 20 16:49:56 2014 -0800 Added support for 2D vertices using glDrawArrays. Fixed a small bug in matrix transform stack. ----------------------------------------------------------------------- Summary of changes: gl-api.c | 6 +-- gl-arrays.c | 161 ++++++++++++++++++++++++++++++++++++++++++----------------- gl-matrix.c | 8 ++- 3 files changed, 123 insertions(+), 52 deletions(-) diff --git a/gl-api.c b/gl-api.c index 183e48c..31ddbd7 100755 --- a/gl-api.c +++ b/gl-api.c @@ -603,8 +603,7 @@ GLvoid _glKosVertex3fpv(const GLfloat *xyz) { _glKosFinishRect(); } -static inline void _glKosFinishRect() -{ +static inline void _glKosFinishRect() { pvr_vertex_t * v = _glKosVertexBufPointer(); v[0].argb = v[1].argb = v[2].argb = v[3].argb = GL_KOS_VERTEX_COLOR; @@ -887,7 +886,6 @@ GLubyte _glKosDepthMask() { return !GL_KOS_DEPTH_WRITE; } -GLuint _glKosVertexColor() -{ +GLuint _glKosVertexColor() { return GL_KOS_VERTEX_COLOR; } \ No newline at end of file diff --git a/gl-arrays.c b/gl-arrays.c index 063847d..248fbde 100755 --- a/gl-arrays.c +++ b/gl-arrays.c @@ -33,6 +33,7 @@ static GLfloat GL_ARRAY_BUFW[GL_MAX_ARRAY_VERTICES]; static GLfloat GL_ARRAY_DSTW[GL_MAX_ARRAY_VERTICES]; static glVertex *GL_ARRAY_BUF_PTR; static GLuint GL_VERTEX_PTR_MODE = 0; +static GLubyte GL_KOS_VERTEX_SIZE = 0; //========================================================================================// //== Local Function Definitions ==// @@ -46,8 +47,9 @@ static inline void _glKosArraysTransformPositions(GLfloat *position, GLuint coun /* Submit a Vertex Position Pointer */ GLAPI void APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { - if(size != 3) /* Expect 3D X,Y,Z vertex... could do 2d X,Y later */ - _glKosThrowError(GL_INVALID_VALUE, "glVertexPointer"); + if(size != 2) /* Expect 2D X,Y or 3D X,Y,Z vertex... */ + if(size != 3) + _glKosThrowError(GL_INVALID_VALUE, "glVertexPointer"); if(type != GL_FLOAT) /* Expect Floating point vertices */ _glKosThrowError(GL_INVALID_ENUM, "glVertexPointer"); @@ -59,9 +61,11 @@ GLAPI void APIENTRY glVertexPointer(GLint size, GLenum type, _glKosPrintError(); return; } - + + GL_KOS_VERTEX_SIZE = size; + (stride) ? (GL_VERTEX_STRIDE = stride / 4) : (GL_VERTEX_STRIDE = 3); - + GL_VERTEX_POINTER = (float *)pointer; GL_VERTEX_PTR_MODE |= GL_USE_ARRAY; @@ -191,6 +195,30 @@ static inline void _glKosArraysTransformPositions(GLfloat *position, GLuint coun //========================================================================================// //== Arrays Vertex Transform ==/ +static void _glKosArraysTransform2D(GLuint count) { + GLfloat *src = GL_VERTEX_POINTER; + pvr_vertex_t *dst = _glKosVertexBufPointer(); + + register float __x __asm__("fr12"); + register float __y __asm__("fr13"); + register float __z __asm__("fr14"); + + while(count--) { + __x = src[0]; + __y = src[1]; + __z = 0; + + mat_trans_fv12() + + dst->x = __x; + dst->y = __y; + dst->z = __z; + + ++dst; + + src += GL_VERTEX_STRIDE; + } +} static void _glKosArraysTransform(GLuint count) { GLfloat *src = GL_VERTEX_POINTER; @@ -508,21 +536,19 @@ static inline void _glKosArrayFlagsSetTriangleStrip(pvr_vertex_t *dst, GLuint co //== OpenGL Error Code Genration ==// static GLuint _glKosArraysVerifyParameter(GLenum mode, GLsizei count, GLenum type, GLubyte element) { - GLuint GL_ERROR_CODE = 0; - if(mode != GL_QUADS) if(mode != GL_TRIANGLES) if(mode != GL_TRIANGLE_STRIP) - GL_ERROR_CODE |= GL_INVALID_ENUM; + _glKosThrowError(GL_INVALID_ENUM, "glDrawArrays"); if(count < 0) - GL_ERROR_CODE |= GL_INVALID_VALUE; + _glKosThrowError(GL_INVALID_VALUE, "glDrawArrays"); if(!(GL_VERTEX_PTR_MODE & GL_USE_ARRAY)) - GL_ERROR_CODE |= GL_INVALID_OPERATION; + _glKosThrowError(GL_INVALID_OPERATION, "glDrawArrays"); if(count > GL_MAX_ARRAY_VERTICES) - GL_ERROR_CODE |= GL_OUT_OF_MEMORY; + _glKosThrowError(GL_OUT_OF_MEMORY, "glDrawArrays"); if(element) { switch(type) { @@ -531,31 +557,19 @@ static GLuint _glKosArraysVerifyParameter(GLenum mode, GLsizei count, GLenum typ break; default: - GL_ERROR_CODE |= GL_INVALID_ENUM; + _glKosThrowError(GL_INVALID_ENUM, "glDrawArrays"); } } else if(type > count) - GL_ERROR_CODE |= GL_INVALID_VALUE; - - return GL_ERROR_CODE; -} - -void _glKosPrintErrorString(GLuint error) { - if(error) { - printf("GL_ERROR_CODE GENERATED:\n"); - - if(error & GL_INVALID_ENUM) - printf("\tGL_INVALID_ENUM\n"); - - if(error & GL_INVALID_VALUE) - printf("\tGL_INVALID_VALUE\n"); - - if(error & GL_INVALID_OPERATION) - printf("\tGL_INVALID__OPERATION\n"); - - if(error & GL_OUT_OF_MEMORY) - printf("\tGL_OUT_OF_MEMORY\n"); + _glKosThrowError(GL_INVALID_VALUE, "glDrawArrays"); + + if(_glKosGetError()) + { + _glKosPrintError(); + return 0; } + + return 1; } //========================================================================================// @@ -563,15 +577,8 @@ void _glKosPrintErrorString(GLuint error) { GLAPI void APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { /* Before we process the vertex data, ensure all parameters are valid */ - GLuint error = _glKosArraysVerifyParameter(mode, count, type, 1); - - if(error) { - _glKosPrintErrorString(error); - - _glKosArraysResetState(); - + if(!_glKosArraysVerifyParameter(mode, count, type, 1)) return; - } switch(type) { case GL_UNSIGNED_BYTE: @@ -823,26 +830,88 @@ static inline void _glKosArrayTexCoord2f(pvr_vertex_t *dst, GLuint count) { //========================================================================================// //== Open GL Draw Arrays ==// -GLAPI void APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count) { - /* Before we process the vertex data, ensure all parameters are valid */ - GLuint error = _glKosArraysVerifyParameter(mode, count, first, 0); +static void _glKosDrawArrays2D(GLenum mode, GLint first, GLsizei count) { + pvr_vertex_t *dst = _glKosVertexBufPointer(); - if(error) { - _glKosPrintErrorString(error); + /* Check for Color Submission */ + if(GL_VERTEX_PTR_MODE & GL_USE_COLOR) { + switch(GL_COLOR_TYPE) { + case GL_FLOAT: + switch(GL_COLOR_COMPONENTS) { + case 3: + _glKosArrayColor3f(dst, count); + break; + + case 4: + _glKosArrayColor4f(dst, count); + break; + } + + break; + + case GL_UNSIGNED_INT: + if(GL_COLOR_COMPONENTS == 1) + _glKosArrayColor1ui(dst, count); + + break; + + case GL_UNSIGNED_BYTE: + if(GL_COLOR_COMPONENTS == 4) + _glKosArrayColor4ub(dst, count); + + break; + } + } + else + _glKosArrayColor0(dst, count); /* No colors bound */ - return _glKosArraysResetState(); + /* Check if Texture Coordinates are enabled */ + if((GL_VERTEX_PTR_MODE & GL_USE_TEXTURE) && (_glKosEnabledTexture2D() >= 0)) + _glKosArrayTexCoord2f(dst, count); + + _glKosMatrixApplyRender(); /* Apply the Render Matrix Stack */ + + /* Transform Vertex Positions */ + _glKosArraysTransform2D(count); + + /* Set the vertex flags for use with the PVR */ + switch(mode) { + case GL_QUADS: + _glKosArrayFlagsSetQuad(dst, count); + break; + + case GL_TRIANGLES: + _glKosArrayFlagsSetTriangle(dst, count); + break; + + case GL_TRIANGLE_STRIP: + _glKosArrayFlagsSetTriangleStrip(dst, count); + break; } + _glKosVertexBufAdd(count); + + _glKosArraysResetState(); +} + +GLAPI void APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count) { + /* Before we process the vertex data, ensure all parameters are valid */ + if(!_glKosArraysVerifyParameter(mode, count, first, 0)) + return; + GL_VERTEX_POINTER += first; /* Add Pointer Offset */ GL_TEXCOORD_POINTER += first; GL_COLOR_POINTER += first; GL_NORMAL_POINTER += first; - + /* Compile the PVR polygon context with the currently enabled flags */ if((GL_VERTEX_PTR_MODE & GL_USE_TEXTURE) && _glKosBoundTexID() > 0) _glKosCompileHdrTx(); else _glKosCompileHdr(); + + if(GL_KOS_VERTEX_SIZE == 2) + return _glKosDrawArrays2D(mode, first, count); pvr_vertex_t *dst; /* Destination of Output Vertex Array */ diff --git a/gl-matrix.c b/gl-matrix.c index d21d1b2..1ee931f 100755 --- a/gl-matrix.c +++ b/gl-matrix.c @@ -106,7 +106,10 @@ void glLoadIdentity() { mat_store(Matrix + MatrixMode); if(MatrixMode == GL_MODELVIEW) + { mat_store(&MatrixMdlRot); + mat_store(&MatrixLookAt); + } } void glTranslatef(GLfloat x, GLfloat y, GLfloat z) { @@ -339,7 +342,9 @@ void glhLookAtf2(vector3f eyePosition3D, // Does not modify internal Modelview matrix mat_load(&MatrixLookAt); mat_translate(-eyePosition3D[0], -eyePosition3D[1], -eyePosition3D[2]); - mat_store(&MatrixLookAt); + + mat_apply(Matrix + GL_MODELVIEW); + mat_store(Matrix + GL_MODELVIEW); } void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, @@ -354,7 +359,6 @@ void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, void _glKosMatrixApplyRender() { mat_load(Matrix + GL_SCREENVIEW); mat_apply(Matrix + GL_PROJECTION); - mat_apply(&MatrixLookAt); mat_apply(Matrix + GL_MODELVIEW); mat_store(Matrix + GL_RENDER); } hooks/post-receive -- The KallistiOS port of OpenGL. |
From: PH3NOM <ph...@us...> - 2014-12-20 03:33:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via c0c664a9e0c99acf581dd25351e028e5273b8b9f (commit) from 8910881aa1100fe022c3c5e25c10ec7a4344afee (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c0c664a9e0c99acf581dd25351e028e5273b8b9f Author: Josh Pearson <ph...@us...> Date: Fri Dec 19 19:32:58 2014 -0800 Fixed Open GL examples ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/kgl/basic/zclip_arrays/main.c | 72 +++++++++++++--------- examples/dreamcast/kgl/demos/Makefile | 2 +- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/examples/dreamcast/kgl/basic/zclip_arrays/main.c b/examples/dreamcast/kgl/basic/zclip_arrays/main.c index 966af33..0597ab3 100755 --- a/examples/dreamcast/kgl/basic/zclip_arrays/main.c +++ b/examples/dreamcast/kgl/basic/zclip_arrays/main.c @@ -18,51 +18,61 @@ /* Load a PVR texture - located in pvr-texture.c */ extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap); -GLfloat VERTEX_ARRAY[4 * 3 * 2] = { -100.0f, -10.0f, -100.0f, - 100.0f, -10.0f, -100.0f, - -100.0f, -10.0f, 100.0f, - 100.0f, -10.0f, 100.0f, - -100.0f, -10.0f, 300.0f, - 100.0f, -10.0f, 300.0f, - }; - -GLfloat TEXCOORD_ARRAY[4 * 2 * 2] = { 0, 0, - 1, 0, - 0, 1, - 1, 1, - 0, 0, - 1, 0, - 0, 1, - 1, 1 - }; - -GLuint ARGB_ARRAY[4 * 2] = { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFF00, - 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFF00 - }; +typedef struct +{ + GLfloat position[3]; + GLfloat texCoord[2]; + GLuint color; +} Vertex3tc; // 3 float vertex, textured, colored + +static Vertex3tc * vertex; + +static void SetVertex3tc(Vertex3tc * vertex, GLfloat x, GLfloat y, GLfloat z, + GLfloat u, GLfloat v, GLuint color) +{ + vertex->position[0] = x; + vertex->position[1] = y; + vertex->position[2] = z; + vertex->texCoord[0] = u; + vertex->texCoord[1] = v; + vertex->color = color; +} +static void buildDemoArray() +{ + vertex = malloc( sizeof( Vertex3tc ) * 6 ); + + SetVertex3tc(&vertex[0], -100.0f, -10.0f, -100.0f, 0, 0, 0xFFFF0000); + SetVertex3tc(&vertex[1], 100.0f, -10.0f, -100.0f, 1, 0, 0xFF00FF00); + SetVertex3tc(&vertex[2], -100.0f, -10.0f, 100.0f, 0, 1, 0xFF0000FF); + SetVertex3tc(&vertex[3], 100.0f, -10.0f, 100.0f, 1, 1, 0xFFFFFF00); + SetVertex3tc(&vertex[4], -100.0f, -10.0f, 300.0f, 0, 0, 0xFFFF0000); + SetVertex3tc(&vertex[5], 100.0f, -10.0f, 300.0f, 1, 0, 0xFF00FF00); +} static GLfloat rx = 1.0f; /* Example using Open GL Vertex Array Submission. */ void RenderCallback(GLuint texID) { glEnable(GL_KOS_NEARZ_CLIPPING); - + + /* Rotate the matrix to make sure transforms and clipping are working */ glLoadIdentity(); glRotatef(rx++, 0, 1, 0); /* Enable 2D Texturing and bind the Texture */ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texID); - + /* Enable Vertex, Color and Texture Coord Arrays */ glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); - - /* Bind Array Data */ - glColorPointer(1, GL_UNSIGNED_INT, 0, ARGB_ARRAY); - glTexCoordPointer(2, GL_FLOAT, 0, TEXCOORD_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, VERTEX_ARRAY); - + + /* Bind Vertex Array Data, Using Strided Vertices */ + glColorPointer(1, GL_UNSIGNED_INT, sizeof(Vertex3tc), &vertex[0].color); + glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex3tc), vertex[0].texCoord); + glVertexPointer(3, GL_FLOAT, sizeof(Vertex3tc), vertex[0].position); + /* Render the Submitted Vertex Data */ glDrawArrays(GL_TRIANGLE_STRIP, 0, 6); @@ -89,7 +99,9 @@ int main(int argc, char **argv) { /* Load a PVR texture to OpenGL */ GLuint texID = glTextureLoadPVR("/rd/wp001vq.pvr", 0, 0); - + + buildDemoArray(); + while(1) { /* Draw the "scene" */ RenderCallback(texID); diff --git a/examples/dreamcast/kgl/demos/Makefile b/examples/dreamcast/kgl/demos/Makefile index 6a41d32..8586379 100755 --- a/examples/dreamcast/kgl/demos/Makefile +++ b/examples/dreamcast/kgl/demos/Makefile @@ -9,7 +9,7 @@ # This will make all the examples, leaving only the elf files. # If you want to clean everything, use 'clean'. -SUBDIRS = blur mipmap multitexture multitexture-arrays specular +SUBDIRS = blur mipmap specular all: $(patsubst %, _dir_%, $(SUBDIRS)) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: PH3NOM <ph...@us...> - 2014-12-20 03:08:56
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via 29ba7674b3120608e4bcd17043a53817df9e2502 (commit) from d6f62c8ddc0220a8825c6a69645d92bb1f92a2cb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 29ba7674b3120608e4bcd17043a53817df9e2502 Author: Josh Pearson <ph...@us...> Date: Fri Dec 19 19:08:38 2014 -0800 Open GL Fixed const pointer function definitions ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index 2b37d7b..8b276ca 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit 2b37d7ba613c8d9b262de38594bb9d6745e4ed1a +Subproject commit 8b276ca731cf818fc97a47fc740d364ea646c9aa hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: PH3NOM <ph...@us...> - 2014-12-20 03:07:30
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 8b276ca731cf818fc97a47fc740d364ea646c9aa (commit) from 2b37d7ba613c8d9b262de38594bb9d6745e4ed1a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8b276ca731cf818fc97a47fc740d364ea646c9aa Author: Josh Pearson <ph...@us...> Date: Fri Dec 19 19:07:11 2014 -0800 Fixed const pointer function definitions ----------------------------------------------------------------------- Summary of changes: gl-api.c | 209 +++++++++++++++++++++++++++------------------------------- gl-api.h | 17 ++--- gl-arrays.c | 10 +-- gl-cap.c | 10 ++- gl-light.c | 28 ++++++-- include/gl.h | 40 ++++++++---- 6 files changed, 162 insertions(+), 152 deletions(-) diff --git a/gl-api.c b/gl-api.c index 4a679fd..183e48c 100755 --- a/gl-api.c +++ b/gl-api.c @@ -43,14 +43,15 @@ static GLfloat GL_KOS_POINT_SIZE = 0.02; static pvr_poly_cxt_t GL_KOS_POLY_CXT; -static inline GLvoid _glKosFlagsSetTriangleStrip(); -static inline GLvoid _glKosFlagsSetTriangle(); -static inline GLvoid _glKosFlagsSetQuad(); +static inline void _glKosFlagsSetTriangleStrip(); +static inline void _glKosFlagsSetTriangle(); +static inline void _glKosFlagsSetQuad(); +static inline void _glKosFinishRect(); //====================================================================================================// //== API Initialization ==// -GLvoid APIENTRY glKosInit() { +void APIENTRY glKosInit() { _glKosInitPVR(); _glKosInitTextures(); @@ -65,7 +66,7 @@ GLvoid APIENTRY glKosInit() { //====================================================================================================// //== Blending / Shading functions ==// -GLvoid APIENTRY glShadeModel(GLenum mode) { +void APIENTRY glShadeModel(GLenum mode) { switch(mode) { case GL_FLAT: GL_KOS_SHADE_FUNC = PVR_SHADE_FLAT; @@ -77,7 +78,7 @@ GLvoid APIENTRY glShadeModel(GLenum mode) { } } -GLvoid APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) { +void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) { GL_KOS_BLEND_FUNC = 0; switch(sfactor) { @@ -160,12 +161,12 @@ GLvoid APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) { //====================================================================================================// //== Depth / Clear functions ==// -GLvoid APIENTRY glClear(GLuint mode) { +void APIENTRY glClear(GLuint mode) { if(mode & GL_COLOR_BUFFER_BIT) pvr_set_bg_color(GL_KOS_COLOR_CLEAR[0], GL_KOS_COLOR_CLEAR[1], GL_KOS_COLOR_CLEAR[2]); } -GLvoid APIENTRY glClearColor(float r, float g, float b, float a) { +void APIENTRY glClearColor(float r, float g, float b, float a) { if(r > 1) r = 1; if(g > 1) g = 1; @@ -180,11 +181,11 @@ GLvoid APIENTRY glClearColor(float r, float g, float b, float a) { } //== NoOp ==// -GLvoid APIENTRY glClearDepthf(GLfloat depth) { +void APIENTRY glClearDepthf(GLfloat depth) { ; } -GLvoid APIENTRY glDepthFunc(GLenum func) { +void APIENTRY glDepthFunc(GLenum func) { switch(func) { case GL_LESS: GL_KOS_DEPTH_FUNC = PVR_DEPTHCMP_GEQUAL; @@ -207,14 +208,14 @@ GLvoid APIENTRY glDepthFunc(GLenum func) { } } -GLvoid APIENTRY glDepthMask(GLboolean flag) { +void APIENTRY glDepthMask(GLboolean flag) { GL_KOS_DEPTH_WRITE = !flag; } //====================================================================================================// //== Culling functions ==// -GLvoid APIENTRY glFrontFace(GLenum mode) { +void APIENTRY glFrontFace(GLenum mode) { switch(mode) { case GL_CW: case GL_CCW: @@ -223,7 +224,7 @@ GLvoid APIENTRY glFrontFace(GLenum mode) { } } -GLvoid APIENTRY glCullFace(GLenum mode) { +void APIENTRY glCullFace(GLenum mode) { switch(mode) { case GL_FRONT: case GL_BACK: @@ -238,57 +239,57 @@ GLvoid APIENTRY glCullFace(GLenum mode) { //== Vertex Color Submission ==// -GLvoid APIENTRY glColor1ui(GLuint argb) { +void APIENTRY glColor1ui(GLuint argb) { GL_KOS_VERTEX_COLOR = argb; } -GLvoid APIENTRY glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) { +void APIENTRY glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) { GL_KOS_VERTEX_COLOR = a << 24 | r << 16 | g << 8 | b; } -GLvoid APIENTRY glColor3f(GLfloat r, GLfloat g, GLfloat b) { +void APIENTRY glColor3f(GLfloat r, GLfloat g, GLfloat b) { GL_KOS_VERTEX_COLOR = PVR_PACK_COLOR(1.0f, r, g, b); } -GLvoid APIENTRY glColor3fv(const GLfloat *rgb) { +void APIENTRY glColor3fv(const GLfloat *rgb) { GL_KOS_VERTEX_COLOR = PVR_PACK_COLOR(1.0f, rgb[0], rgb[1], rgb[2]); } -GLvoid APIENTRY glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { +void APIENTRY glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { GL_KOS_VERTEX_COLOR = PVR_PACK_COLOR(a, r, g, b); } -GLvoid APIENTRY glColor4fv(const GLfloat *rgba) { +void APIENTRY glColor4fv(const GLfloat *rgba) { GL_KOS_VERTEX_COLOR = PVR_PACK_COLOR(rgba[3], rgba[0], rgba[1], rgba[2]); } //== Texture Coordinate Submission ==// -GLvoid APIENTRY glTexCoord2f(GLfloat u, GLfloat v) { +void APIENTRY glTexCoord2f(GLfloat u, GLfloat v) { GL_KOS_VERTEX_UV[0] = u; GL_KOS_VERTEX_UV[1] = v; } -GLvoid APIENTRY glTexCoord2fv(const GLfloat *uv) { +void APIENTRY glTexCoord2fv(const GLfloat *uv) { GL_KOS_VERTEX_UV[0] = uv[0]; GL_KOS_VERTEX_UV[1] = uv[1]; } //== Vertex Position Submission Functions ==// -GLvoid APIENTRY(*glVertex3f)(GLfloat, GLfloat, GLfloat); +void APIENTRY(*glVertex3f)(GLfloat, GLfloat, GLfloat); -GLvoid APIENTRY(*glVertex3fv)(GLfloat *); +void APIENTRY(*glVertex3fv)(const GLfloat *); -GLvoid APIENTRY glVertex2f(GLfloat x, GLfloat y) { +void APIENTRY glVertex2f(GLfloat x, GLfloat y) { return _glKosVertex3ft(x, y, 0.0f); } -GLvoid APIENTRY glVertex2fv(const GLfloat *xy) { +void APIENTRY glVertex2fv(const GLfloat *xy) { return _glKosVertex3ft(xy[0], xy[1], 0.0f); } -GLAPI void APIENTRY glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { +void APIENTRY glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { pvr_vertex_t * v = _glKosVertexBufPointer(); v[0].z = v[3].z = 0; @@ -296,24 +297,10 @@ GLAPI void APIENTRY glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { mat_trans_single3_nomod(x1, y1, v[0].z, v[0].x, v[0].y, v[0].z); mat_trans_single3_nomod(x2, y2, v[3].z, v[3].x, v[3].y, v[3].z); - v[0].argb = v[1].argb = v[2].argb = v[3].argb = GL_KOS_VERTEX_COLOR; - v[0].flags = v[1].flags = v[2].flags = PVR_CMD_VERTEX; - v[3].flags = PVR_CMD_VERTEX_EOL; - - v[1].x = v[0].x; - v[1].y = v[3].y; - v[1].z = v[3].z; - - v[2].x = v[3].x; - v[2].y = v[0].y; - v[2].z = v[0].z; - - _glKosVertexBufAdd(4); - - GL_KOS_VERTEX_COUNT += 4; + _glKosFinishRect(); } -GLAPI void APIENTRY glRectfv(const GLfloat *v1, const GLfloat *v2) { +void APIENTRY glRectfv(const GLfloat *v1, const GLfloat *v2) { pvr_vertex_t * v = _glKosVertexBufPointer(); v[0].z = v[3].z = 0; @@ -321,32 +308,18 @@ GLAPI void APIENTRY glRectfv(const GLfloat *v1, const GLfloat *v2) { mat_trans_single3_nomod(v1[0], v1[1], v[0].z, v[0].x, v[0].y, v[0].z); mat_trans_single3_nomod(v2[0], v2[1], v[3].z, v[3].x, v[3].y, v[3].z); - v[0].argb = v[1].argb = v[2].argb = v[3].argb = GL_KOS_VERTEX_COLOR; - v[0].flags = v[1].flags = v[2].flags = PVR_CMD_VERTEX; - v[3].flags = PVR_CMD_VERTEX_EOL; - - v[1].x = v[0].x; - v[1].y = v[3].y; - v[1].z = v[3].z; - - v[2].x = v[3].x; - v[2].y = v[0].y; - v[2].z = v[0].z; - - _glKosVertexBufAdd(4); - - GL_KOS_VERTEX_COUNT += 4; + _glKosFinishRect(); } -GLAPI void APIENTRY glRecti(GLint x1, GLint y1, GLint x2, GLint y2) { +void APIENTRY glRecti(GLint x1, GLint y1, GLint x2, GLint y2) { return glRectf((GLfloat)x1, (GLfloat)y1, (GLfloat)x2, (GLfloat)y2); } -GLAPI void APIENTRY glRectiv(const GLint *v1, const GLint *v2) { - return glRectfv((GLfloat *)v1, (GLfloat *)v2); +void APIENTRY glRectiv(const GLint *v1, const GLint *v2) { + return glRectfv((const GLfloat *)v1, (const GLfloat *)v2); } -GLvoid APIENTRY glKosVertex2f(GLfloat x, GLfloat y) { +void APIENTRY glKosVertex2f(GLfloat x, GLfloat y) { pvr_vertex_t *v = _glKosVertexBufPointer(); v->x = x; @@ -361,7 +334,7 @@ GLvoid APIENTRY glKosVertex2f(GLfloat x, GLfloat y) { ++GL_KOS_VERTEX_COUNT; } -GLvoid APIENTRY glKosVertex2fv(const GLfloat *xy) { +void APIENTRY glKosVertex2fv(const GLfloat *xy) { pvr_vertex_t *v = _glKosVertexBufPointer(); v->x = xy[0]; @@ -379,7 +352,7 @@ GLvoid APIENTRY glKosVertex2fv(const GLfloat *xy) { //====================================================================================================// //== GL Begin / End ==// -GLvoid APIENTRY glBegin(GLenum mode) { +void APIENTRY glBegin(GLenum mode) { _glKosMatrixApplyRender(); _glKosArrayBufReset(); @@ -412,7 +385,7 @@ GLvoid APIENTRY glBegin(GLenum mode) { } } -GLvoid APIENTRY glEnd() { +void APIENTRY glEnd() { if(_glKosEnabledNearZClip()) { /* Z-Clipping Enabled */ if(_glKosEnabledLighting()) { _glKosVertexComputeLighting(_glKosClipBufAddress(), GL_KOS_VERTEX_COUNT); @@ -484,7 +457,7 @@ GLvoid APIENTRY glEnd() { hand corner of the screen to be modified and glScissor(0, 0, 0, 0) disallows modification to all 'tiles' on the screen. */ -GLvoid APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { +void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { pvr_cmd_tclip_t *c = _glKosVertexBufPointer(); GLint miny, maxx, maxy; @@ -507,7 +480,7 @@ GLvoid APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { _glKosVertexBufIncrement(); } -GLvoid APIENTRY glHint(GLenum target, GLenum mode) { +void APIENTRY glHint(GLenum target, GLenum mode) { switch(target) { case GL_PERSPECTIVE_CORRECTION_HINT: if(mode == GL_NICEST) @@ -523,7 +496,7 @@ GLvoid APIENTRY glHint(GLenum target, GLenum mode) { //====================================================================================================// //== Internal API Vertex Submission functions ==// -GLvoid _glKosVertex3fs(GLfloat x, GLfloat y, GLfloat z) { +void _glKosVertex3fs(GLfloat x, GLfloat y, GLfloat z) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(x, y, z, v->x, v->y, v->z); @@ -536,7 +509,7 @@ GLvoid _glKosVertex3fs(GLfloat x, GLfloat y, GLfloat z) { ++GL_KOS_VERTEX_COUNT; } -GLvoid _glKosVertex3fsv(GLfloat *xyz) { +void _glKosVertex3fsv(const GLfloat *xyz) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(xyz[0], xyz[1], xyz[2], v->x, v->y, v->z); @@ -549,7 +522,7 @@ GLvoid _glKosVertex3fsv(GLfloat *xyz) { ++GL_KOS_VERTEX_COUNT; } -GLvoid _glKosVertex3ft(GLfloat x, GLfloat y, GLfloat z) { +void _glKosVertex3ft(GLfloat x, GLfloat y, GLfloat z) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(x, y, z, v->x, v->y, v->z); @@ -563,7 +536,7 @@ GLvoid _glKosVertex3ft(GLfloat x, GLfloat y, GLfloat z) { ++GL_KOS_VERTEX_COUNT; } -GLvoid _glKosVertex3ftv(GLfloat *xyz) { +void _glKosVertex3ftv(const GLfloat *xyz) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(xyz[0], xyz[1], xyz[2], v->x, v->y, v->z); @@ -577,7 +550,7 @@ GLvoid _glKosVertex3ftv(GLfloat *xyz) { ++GL_KOS_VERTEX_COUNT; } -GLvoid _glKosVertex3fc(GLfloat x, GLfloat y, GLfloat z) { +void _glKosVertex3fc(GLfloat x, GLfloat y, GLfloat z) { pvr_vertex_t *v = _glKosClipBufPointer(); v->x = x; @@ -592,7 +565,7 @@ GLvoid _glKosVertex3fc(GLfloat x, GLfloat y, GLfloat z) { ++GL_KOS_VERTEX_COUNT; } -GLvoid _glKosVertex3fcv(GLfloat *xyz) { +void _glKosVertex3fcv(const GLfloat *xyz) { pvr_vertex_t *v = _glKosClipBufPointer(); v->x = xyz[0]; @@ -608,44 +581,51 @@ GLvoid _glKosVertex3fcv(GLfloat *xyz) { } /* GL_POINTS */ +GLvoid _glKosVertex3fp(GLfloat x, GLfloat y, GLfloat z) { + pvr_vertex_t * v = _glKosVertexBufPointer(); -inline GLvoid _glKosVertex3fpa(GLfloat x, GLfloat y, GLfloat z) { - pvr_vertex_t *v = _glKosVertexBufPointer(); - - mat_trans_single3_nomod(x, y, z, v->x, v->y, v->z); - - v->argb = GL_KOS_VERTEX_COLOR; - v->flags = PVR_CMD_VERTEX; - - _glKosVertexBufIncrement(); + mat_trans_single3_nomod(x - GL_KOS_POINT_SIZE, y + GL_KOS_POINT_SIZE, z, + v[0].x, v[0].y, v[0].z); + mat_trans_single3_nomod(x + GL_KOS_POINT_SIZE, y - GL_KOS_POINT_SIZE, z, + v[3].x, v[3].y, v[3].z); + + _glKosFinishRect(); } -inline GLvoid _glKosVertex3fpb(GLfloat x, GLfloat y, GLfloat z) { - pvr_vertex_t *v = _glKosVertexBufPointer(); - - mat_trans_single3_nomod(x, y, z, v->x, v->y, v->z); - - v->argb = GL_KOS_VERTEX_COLOR; - v->flags = PVR_CMD_VERTEX_EOL; +GLvoid _glKosVertex3fpv(const GLfloat *xyz) { + pvr_vertex_t * v = _glKosVertexBufPointer(); - _glKosVertexBufIncrement(); + mat_trans_single3_nomod(xyz[0] - GL_KOS_POINT_SIZE, xyz[1] + GL_KOS_POINT_SIZE, xyz[2], + v[0].x, v[0].y, v[0].z); + mat_trans_single3_nomod(xyz[0] + GL_KOS_POINT_SIZE, xyz[1] - GL_KOS_POINT_SIZE, xyz[2], + v[3].x, v[3].y, v[3].z); + + _glKosFinishRect(); } -GLvoid _glKosVertex3fp(GLfloat x, GLfloat y, GLfloat z) { - _glKosVertex3fpa(x - GL_KOS_POINT_SIZE, y - GL_KOS_POINT_SIZE, z); - _glKosVertex3fpa(x + GL_KOS_POINT_SIZE, y - GL_KOS_POINT_SIZE, z); - _glKosVertex3fpa(x - GL_KOS_POINT_SIZE, y + GL_KOS_POINT_SIZE, z); - _glKosVertex3fpb(x + GL_KOS_POINT_SIZE, y + GL_KOS_POINT_SIZE, z); -} +static inline void _glKosFinishRect() +{ + pvr_vertex_t * v = _glKosVertexBufPointer(); + + v[0].argb = v[1].argb = v[2].argb = v[3].argb = GL_KOS_VERTEX_COLOR; + + v[0].flags = v[1].flags = v[2].flags = PVR_CMD_VERTEX; + v[3].flags = PVR_CMD_VERTEX_EOL; -GLvoid _glKosVertex3fpv(GLfloat *xyz) { - _glKosVertex3fpa(xyz[0] - GL_KOS_POINT_SIZE, xyz[1] - GL_KOS_POINT_SIZE, xyz[2]); - _glKosVertex3fpa(xyz[0] + GL_KOS_POINT_SIZE, xyz[1] - GL_KOS_POINT_SIZE, xyz[2]); - _glKosVertex3fpa(xyz[0] - GL_KOS_POINT_SIZE, xyz[1] + GL_KOS_POINT_SIZE, xyz[2]); - _glKosVertex3fpb(xyz[0] + GL_KOS_POINT_SIZE, xyz[1] + GL_KOS_POINT_SIZE, xyz[2]); + v[1].x = v[0].x; + v[1].y = v[3].y; + v[1].z = v[3].z; + + v[2].x = v[3].x; + v[2].y = v[0].y; + v[2].z = v[0].z; + + _glKosVertexBufAdd( 4 ); + + GL_KOS_VERTEX_COUNT += 4; } -GLvoid _glKosTransformClipBuf(pvr_vertex_t *v, GLuint verts) { +void _glKosTransformClipBuf(pvr_vertex_t *v, GLuint verts) { register float __x __asm__("fr12"); register float __y __asm__("fr13"); register float __z __asm__("fr14"); @@ -664,13 +644,13 @@ GLvoid _glKosTransformClipBuf(pvr_vertex_t *v, GLuint verts) { } } -static inline GLvoid _glKosVertexSwap(pvr_vertex_t *v1, pvr_vertex_t *v2) { +static inline void _glKosVertexSwap(pvr_vertex_t *v1, pvr_vertex_t *v2) { pvr_vertex_t tmp = *v1; *v1 = *v2; *v2 = * &tmp; } -static inline GLvoid _glKosFlagsSetQuad() { +static inline void _glKosFlagsSetQuad() { pvr_vertex_t *v = (pvr_vertex_t *)_glKosVertexBufPointer() - GL_KOS_VERTEX_COUNT; GLuint i; @@ -682,7 +662,7 @@ static inline GLvoid _glKosFlagsSetQuad() { } } -static inline GLvoid _glKosFlagsSetTriangle() { +static inline void _glKosFlagsSetTriangle() { pvr_vertex_t *v = (pvr_vertex_t *)_glKosVertexBufPointer() - GL_KOS_VERTEX_COUNT; GLuint i; @@ -693,7 +673,7 @@ static inline GLvoid _glKosFlagsSetTriangle() { } } -static inline GLvoid _glKosFlagsSetTriangleStrip() { +static inline void _glKosFlagsSetTriangleStrip() { pvr_vertex_t *v = (pvr_vertex_t *)_glKosVertexBufPointer() - GL_KOS_VERTEX_COUNT; GLuint i; @@ -708,7 +688,7 @@ static inline GLvoid _glKosFlagsSetTriangleStrip() { //====================================================================================================// //== GL KOS PVR Header Parameter Compilation Functions ==// -static inline GLvoid _glKosApplyDepthFunc() { +static inline void _glKosApplyDepthFunc() { if(_glKosEnabledDepthTest()) GL_KOS_POLY_CXT.depth.comparison = GL_KOS_DEPTH_FUNC; else @@ -717,17 +697,17 @@ static inline GLvoid _glKosApplyDepthFunc() { GL_KOS_POLY_CXT.depth.write = GL_KOS_DEPTH_WRITE; } -static inline GLvoid _glKosApplyScissorFunc() { +static inline void _glKosApplyScissorFunc() { if(_glKosEnabledScissorTest()) GL_KOS_POLY_CXT.gen.clip_mode = PVR_USERCLIP_INSIDE; } -static inline GLvoid _glKosApplyFogFunc() { +static inline void _glKosApplyFogFunc() { if(_glKosEnabledFog()) GL_KOS_POLY_CXT.gen.fog_type = PVR_FOG_TABLE; } -static inline GLvoid _glKosApplyCullingFunc() { +static inline void _glKosApplyCullingFunc() { if(_glKosEnabledCulling()) { if(GL_KOS_CULL_FUNC == GL_BACK) { if(GL_KOS_FACE_FRONT == GL_CW) @@ -746,14 +726,14 @@ static inline GLvoid _glKosApplyCullingFunc() { GL_KOS_POLY_CXT.gen.culling = PVR_CULLING_NONE; } -static inline GLvoid _glKosApplyBlendFunc() { +static inline void _glKosApplyBlendFunc() { if(_glKosEnabledBlend()) { GL_KOS_POLY_CXT.blend.src = (GL_KOS_BLEND_FUNC & 0xF0) >> 4; GL_KOS_POLY_CXT.blend.dst = (GL_KOS_BLEND_FUNC & 0x0F); } } -GLvoid _glKosCompileHdr() { +void _glKosCompileHdr() { pvr_poly_hdr_t *hdr = _glKosVertexBufPointer(); pvr_poly_cxt_col(&GL_KOS_POLY_CXT, _glKosList() * 2); @@ -775,7 +755,7 @@ GLvoid _glKosCompileHdr() { _glKosVertexBufIncrement(); } -GLvoid _glKosCompileHdrT(GL_TEXTURE_OBJECT *tex) { +void _glKosCompileHdrT(GL_TEXTURE_OBJECT *tex) { pvr_poly_hdr_t *hdr = _glKosVertexBufPointer(); pvr_poly_cxt_txr(&GL_KOS_POLY_CXT, @@ -905,4 +885,9 @@ GLuint _glKosDepthFunc() { ...<truncated>... hooks/post-receive -- The KallistiOS port of OpenGL. |
From: PH3NOM <ph...@us...> - 2014-12-13 23:55:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via d6f62c8ddc0220a8825c6a69645d92bb1f92a2cb (commit) from 508c81403fa3b4f483bb82894fdfe44574df994a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d6f62c8ddc0220a8825c6a69645d92bb1f92a2cb Author: Josh Pearson <ph...@us...> Date: Sat Dec 13 15:55:16 2014 -0800 Minor update to libgl ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index 704a46e..2b37d7b 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit 704a46e8dc9a4b0015c3949fa6123a1295f7506d +Subproject commit 2b37d7ba613c8d9b262de38594bb9d6745e4ed1a hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: PH3NOM <ph...@us...> - 2014-12-13 23:51:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 2b37d7ba613c8d9b262de38594bb9d6745e4ed1a (commit) from 704a46e8dc9a4b0015c3949fa6123a1295f7506d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2b37d7ba613c8d9b262de38594bb9d6745e4ed1a Author: Josh Pearson <ph...@us...> Date: Sat Dec 13 15:50:47 2014 -0800 Fixed change that removed allignment on L vector on gl-light.c ----------------------------------------------------------------------- Summary of changes: gl-light.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gl-light.c b/gl-light.c index ad68a8f..a4c3ddd 100755 --- a/gl-light.c +++ b/gl-light.c @@ -408,7 +408,7 @@ void _glKosVertexLights(glVertex *P, pvr_vertex_t *v, GLuint count) { float S; #endif unsigned char i; - float L[4]; + float L[4] __attribute__((aligned(8))); float C[3] = { 0, 0, 0 }; colorui *color = (colorui *)&v->argb; @@ -458,7 +458,7 @@ void _glKosVertexLight(glVertex *P, pvr_vertex_t *v) { float S; #endif unsigned char i; - float L[4]; + float L[4] __attribute__((aligned(8))); /* Compute Ambient */ float C[3] = { GL_MATERIAL.Ke[0] + GL_MATERIAL.Ka[0] *GL_GLOBAL_AMBIENT[0], @@ -503,7 +503,7 @@ GLuint _glKosVertexLightColor(glVertex *P) { #endif GLuint color; GLubyte i; - float L[4]; + float L[4] __attribute__((aligned(8))); /* Compute Ambient */ float C[3] = { GL_MATERIAL.Ke[0] + GL_MATERIAL.Ka[0] *GL_GLOBAL_AMBIENT[0], hooks/post-receive -- The KallistiOS port of OpenGL. |
From: PH3NOM <ph...@us...> - 2014-12-13 23:19:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via 508c81403fa3b4f483bb82894fdfe44574df994a (commit) from 9769a05de2c7c6e34f32191ac355e1ae3fd5e030 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 508c81403fa3b4f483bb82894fdfe44574df994a Author: Josh Pearson <ph...@us...> Date: Sat Dec 13 15:18:59 2014 -0800 Small update to libgl 12-13-2014 ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index 8c34258..704a46e 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit 8c34258eb439eed86efa79c403c6ebd07d833894 +Subproject commit 704a46e8dc9a4b0015c3949fa6123a1295f7506d hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: PH3NOM <ph...@us...> - 2014-12-13 23:18:16
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 704a46e8dc9a4b0015c3949fa6123a1295f7506d (commit) from 8c34258eb439eed86efa79c403c6ebd07d833894 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 704a46e8dc9a4b0015c3949fa6123a1295f7506d Author: Josh Pearson <ph...@us...> Date: Sat Dec 13 15:17:57 2014 -0800 Fixed stride on glDrawArrays, clean up on lighting code, added glRect function ----------------------------------------------------------------------- Summary of changes: gl-api.c | 164 ++++++++++++++++++++++++++++++++++++++------------------ gl-arrays.c | 23 +++++--- gl-light.c | 32 +++++------ gl-sh4-light.S | 131 ++++++++++++++++++-------------------------- 4 files changed, 193 insertions(+), 157 deletions(-) diff --git a/gl-api.c b/gl-api.c index bc417bf..4a679fd 100755 --- a/gl-api.c +++ b/gl-api.c @@ -43,14 +43,14 @@ static GLfloat GL_KOS_POINT_SIZE = 0.02; static pvr_poly_cxt_t GL_KOS_POLY_CXT; -static inline void _glKosFlagsSetTriangleStrip(); -static inline void _glKosFlagsSetTriangle(); -static inline void _glKosFlagsSetQuad(); +static inline GLvoid _glKosFlagsSetTriangleStrip(); +static inline GLvoid _glKosFlagsSetTriangle(); +static inline GLvoid _glKosFlagsSetQuad(); //====================================================================================================// //== API Initialization ==// -void APIENTRY glKosInit() { +GLvoid APIENTRY glKosInit() { _glKosInitPVR(); _glKosInitTextures(); @@ -65,7 +65,7 @@ void APIENTRY glKosInit() { //====================================================================================================// //== Blending / Shading functions ==// -void APIENTRY glShadeModel(GLenum mode) { +GLvoid APIENTRY glShadeModel(GLenum mode) { switch(mode) { case GL_FLAT: GL_KOS_SHADE_FUNC = PVR_SHADE_FLAT; @@ -77,7 +77,7 @@ void APIENTRY glShadeModel(GLenum mode) { } } -void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) { +GLvoid APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) { GL_KOS_BLEND_FUNC = 0; switch(sfactor) { @@ -160,12 +160,12 @@ void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) { //====================================================================================================// //== Depth / Clear functions ==// -void APIENTRY glClear(GLuint mode) { +GLvoid APIENTRY glClear(GLuint mode) { if(mode & GL_COLOR_BUFFER_BIT) pvr_set_bg_color(GL_KOS_COLOR_CLEAR[0], GL_KOS_COLOR_CLEAR[1], GL_KOS_COLOR_CLEAR[2]); } -void APIENTRY glClearColor(float r, float g, float b, float a) { +GLvoid APIENTRY glClearColor(float r, float g, float b, float a) { if(r > 1) r = 1; if(g > 1) g = 1; @@ -180,11 +180,11 @@ void APIENTRY glClearColor(float r, float g, float b, float a) { } //== NoOp ==// -void APIENTRY glClearDepthf(GLfloat depth) { +GLvoid APIENTRY glClearDepthf(GLfloat depth) { ; } -void APIENTRY glDepthFunc(GLenum func) { +GLvoid APIENTRY glDepthFunc(GLenum func) { switch(func) { case GL_LESS: GL_KOS_DEPTH_FUNC = PVR_DEPTHCMP_GEQUAL; @@ -207,14 +207,14 @@ void APIENTRY glDepthFunc(GLenum func) { } } -void APIENTRY glDepthMask(GLboolean flag) { +GLvoid APIENTRY glDepthMask(GLboolean flag) { GL_KOS_DEPTH_WRITE = !flag; } //====================================================================================================// //== Culling functions ==// -void APIENTRY glFrontFace(GLenum mode) { +GLvoid APIENTRY glFrontFace(GLenum mode) { switch(mode) { case GL_CW: case GL_CCW: @@ -223,7 +223,7 @@ void APIENTRY glFrontFace(GLenum mode) { } } -void APIENTRY glCullFace(GLenum mode) { +GLvoid APIENTRY glCullFace(GLenum mode) { switch(mode) { case GL_FRONT: case GL_BACK: @@ -238,57 +238,115 @@ void APIENTRY glCullFace(GLenum mode) { //== Vertex Color Submission ==// -void APIENTRY glColor1ui(GLuint argb) { +GLvoid APIENTRY glColor1ui(GLuint argb) { GL_KOS_VERTEX_COLOR = argb; } -void APIENTRY glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) { +GLvoid APIENTRY glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) { GL_KOS_VERTEX_COLOR = a << 24 | r << 16 | g << 8 | b; } -void APIENTRY glColor3f(GLfloat r, GLfloat g, GLfloat b) { +GLvoid APIENTRY glColor3f(GLfloat r, GLfloat g, GLfloat b) { GL_KOS_VERTEX_COLOR = PVR_PACK_COLOR(1.0f, r, g, b); } -void APIENTRY glColor3fv(GLfloat *rgb) { +GLvoid APIENTRY glColor3fv(const GLfloat *rgb) { GL_KOS_VERTEX_COLOR = PVR_PACK_COLOR(1.0f, rgb[0], rgb[1], rgb[2]); } -void APIENTRY glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { +GLvoid APIENTRY glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { GL_KOS_VERTEX_COLOR = PVR_PACK_COLOR(a, r, g, b); } -void APIENTRY glColor4fv(GLfloat *rgba) { +GLvoid APIENTRY glColor4fv(const GLfloat *rgba) { GL_KOS_VERTEX_COLOR = PVR_PACK_COLOR(rgba[3], rgba[0], rgba[1], rgba[2]); } //== Texture Coordinate Submission ==// -void APIENTRY glTexCoord2f(GLfloat u, GLfloat v) { +GLvoid APIENTRY glTexCoord2f(GLfloat u, GLfloat v) { GL_KOS_VERTEX_UV[0] = u; GL_KOS_VERTEX_UV[1] = v; } -void APIENTRY glTexCoord2fv(GLfloat *uv) { +GLvoid APIENTRY glTexCoord2fv(const GLfloat *uv) { GL_KOS_VERTEX_UV[0] = uv[0]; GL_KOS_VERTEX_UV[1] = uv[1]; } //== Vertex Position Submission Functions ==// -void APIENTRY(*glVertex3f)(GLfloat, GLfloat, GLfloat); +GLvoid APIENTRY(*glVertex3f)(GLfloat, GLfloat, GLfloat); -void APIENTRY(*glVertex3fv)(GLfloat *); +GLvoid APIENTRY(*glVertex3fv)(GLfloat *); -void APIENTRY glVertex2f(GLfloat x, GLfloat y) { +GLvoid APIENTRY glVertex2f(GLfloat x, GLfloat y) { return _glKosVertex3ft(x, y, 0.0f); } -void APIENTRY glVertex2fv(GLfloat *xy) { +GLvoid APIENTRY glVertex2fv(const GLfloat *xy) { return _glKosVertex3ft(xy[0], xy[1], 0.0f); } -void APIENTRY glKosVertex2f(GLfloat x, GLfloat y) { +GLAPI void APIENTRY glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { + pvr_vertex_t * v = _glKosVertexBufPointer(); + + v[0].z = v[3].z = 0; + + mat_trans_single3_nomod(x1, y1, v[0].z, v[0].x, v[0].y, v[0].z); + mat_trans_single3_nomod(x2, y2, v[3].z, v[3].x, v[3].y, v[3].z); + + v[0].argb = v[1].argb = v[2].argb = v[3].argb = GL_KOS_VERTEX_COLOR; + v[0].flags = v[1].flags = v[2].flags = PVR_CMD_VERTEX; + v[3].flags = PVR_CMD_VERTEX_EOL; + + v[1].x = v[0].x; + v[1].y = v[3].y; + v[1].z = v[3].z; + + v[2].x = v[3].x; + v[2].y = v[0].y; + v[2].z = v[0].z; + + _glKosVertexBufAdd(4); + + GL_KOS_VERTEX_COUNT += 4; +} + +GLAPI void APIENTRY glRectfv(const GLfloat *v1, const GLfloat *v2) { + pvr_vertex_t * v = _glKosVertexBufPointer(); + + v[0].z = v[3].z = 0; + + mat_trans_single3_nomod(v1[0], v1[1], v[0].z, v[0].x, v[0].y, v[0].z); + mat_trans_single3_nomod(v2[0], v2[1], v[3].z, v[3].x, v[3].y, v[3].z); + + v[0].argb = v[1].argb = v[2].argb = v[3].argb = GL_KOS_VERTEX_COLOR; + v[0].flags = v[1].flags = v[2].flags = PVR_CMD_VERTEX; + v[3].flags = PVR_CMD_VERTEX_EOL; + + v[1].x = v[0].x; + v[1].y = v[3].y; + v[1].z = v[3].z; + + v[2].x = v[3].x; + v[2].y = v[0].y; + v[2].z = v[0].z; + + _glKosVertexBufAdd(4); + + GL_KOS_VERTEX_COUNT += 4; +} + +GLAPI void APIENTRY glRecti(GLint x1, GLint y1, GLint x2, GLint y2) { + return glRectf((GLfloat)x1, (GLfloat)y1, (GLfloat)x2, (GLfloat)y2); +} + +GLAPI void APIENTRY glRectiv(const GLint *v1, const GLint *v2) { + return glRectfv((GLfloat *)v1, (GLfloat *)v2); +} + +GLvoid APIENTRY glKosVertex2f(GLfloat x, GLfloat y) { pvr_vertex_t *v = _glKosVertexBufPointer(); v->x = x; @@ -303,7 +361,7 @@ void APIENTRY glKosVertex2f(GLfloat x, GLfloat y) { ++GL_KOS_VERTEX_COUNT; } -void APIENTRY glKosVertex2fv(GLfloat *xy) { +GLvoid APIENTRY glKosVertex2fv(const GLfloat *xy) { pvr_vertex_t *v = _glKosVertexBufPointer(); v->x = xy[0]; @@ -321,7 +379,7 @@ void APIENTRY glKosVertex2fv(GLfloat *xy) { //====================================================================================================// //== GL Begin / End ==// -void APIENTRY glBegin(GLenum mode) { +GLvoid APIENTRY glBegin(GLenum mode) { _glKosMatrixApplyRender(); _glKosArrayBufReset(); @@ -354,7 +412,7 @@ void APIENTRY glBegin(GLenum mode) { } } -void APIENTRY glEnd() { +GLvoid APIENTRY glEnd() { if(_glKosEnabledNearZClip()) { /* Z-Clipping Enabled */ if(_glKosEnabledLighting()) { _glKosVertexComputeLighting(_glKosClipBufAddress(), GL_KOS_VERTEX_COUNT); @@ -426,7 +484,7 @@ void APIENTRY glEnd() { hand corner of the screen to be modified and glScissor(0, 0, 0, 0) disallows modification to all 'tiles' on the screen. */ -void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { +GLvoid APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { pvr_cmd_tclip_t *c = _glKosVertexBufPointer(); GLint miny, maxx, maxy; @@ -449,7 +507,7 @@ void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { _glKosVertexBufIncrement(); } -void APIENTRY glHint(GLenum target, GLenum mode) { +GLvoid APIENTRY glHint(GLenum target, GLenum mode) { switch(target) { case GL_PERSPECTIVE_CORRECTION_HINT: if(mode == GL_NICEST) @@ -465,7 +523,7 @@ void APIENTRY glHint(GLenum target, GLenum mode) { //====================================================================================================// //== Internal API Vertex Submission functions ==// -void _glKosVertex3fs(GLfloat x, GLfloat y, GLfloat z) { +GLvoid _glKosVertex3fs(GLfloat x, GLfloat y, GLfloat z) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(x, y, z, v->x, v->y, v->z); @@ -478,7 +536,7 @@ void _glKosVertex3fs(GLfloat x, GLfloat y, GLfloat z) { ++GL_KOS_VERTEX_COUNT; } -void _glKosVertex3fsv(GLfloat *xyz) { +GLvoid _glKosVertex3fsv(GLfloat *xyz) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(xyz[0], xyz[1], xyz[2], v->x, v->y, v->z); @@ -491,7 +549,7 @@ void _glKosVertex3fsv(GLfloat *xyz) { ++GL_KOS_VERTEX_COUNT; } -void _glKosVertex3ft(GLfloat x, GLfloat y, GLfloat z) { +GLvoid _glKosVertex3ft(GLfloat x, GLfloat y, GLfloat z) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(x, y, z, v->x, v->y, v->z); @@ -505,7 +563,7 @@ void _glKosVertex3ft(GLfloat x, GLfloat y, GLfloat z) { ++GL_KOS_VERTEX_COUNT; } -void _glKosVertex3ftv(GLfloat *xyz) { +GLvoid _glKosVertex3ftv(GLfloat *xyz) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(xyz[0], xyz[1], xyz[2], v->x, v->y, v->z); @@ -519,7 +577,7 @@ void _glKosVertex3ftv(GLfloat *xyz) { ++GL_KOS_VERTEX_COUNT; } -void _glKosVertex3fc(GLfloat x, GLfloat y, GLfloat z) { +GLvoid _glKosVertex3fc(GLfloat x, GLfloat y, GLfloat z) { pvr_vertex_t *v = _glKosClipBufPointer(); v->x = x; @@ -534,7 +592,7 @@ void _glKosVertex3fc(GLfloat x, GLfloat y, GLfloat z) { ++GL_KOS_VERTEX_COUNT; } -void _glKosVertex3fcv(GLfloat *xyz) { +GLvoid _glKosVertex3fcv(GLfloat *xyz) { pvr_vertex_t *v = _glKosClipBufPointer(); v->x = xyz[0]; @@ -551,7 +609,7 @@ void _glKosVertex3fcv(GLfloat *xyz) { /* GL_POINTS */ -inline void _glKosVertex3fpa(GLfloat x, GLfloat y, GLfloat z) { +inline GLvoid _glKosVertex3fpa(GLfloat x, GLfloat y, GLfloat z) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(x, y, z, v->x, v->y, v->z); @@ -562,7 +620,7 @@ inline void _glKosVertex3fpa(GLfloat x, GLfloat y, GLfloat z) { _glKosVertexBufIncrement(); } -inline void _glKosVertex3fpb(GLfloat x, GLfloat y, GLfloat z) { +inline GLvoid _glKosVertex3fpb(GLfloat x, GLfloat y, GLfloat z) { pvr_vertex_t *v = _glKosVertexBufPointer(); mat_trans_single3_nomod(x, y, z, v->x, v->y, v->z); @@ -573,21 +631,21 @@ inline void _glKosVertex3fpb(GLfloat x, GLfloat y, GLfloat z) { _glKosVertexBufIncrement(); } -void _glKosVertex3fp(GLfloat x, GLfloat y, GLfloat z) { +GLvoid _glKosVertex3fp(GLfloat x, GLfloat y, GLfloat z) { _glKosVertex3fpa(x - GL_KOS_POINT_SIZE, y - GL_KOS_POINT_SIZE, z); _glKosVertex3fpa(x + GL_KOS_POINT_SIZE, y - GL_KOS_POINT_SIZE, z); _glKosVertex3fpa(x - GL_KOS_POINT_SIZE, y + GL_KOS_POINT_SIZE, z); _glKosVertex3fpb(x + GL_KOS_POINT_SIZE, y + GL_KOS_POINT_SIZE, z); } -void _glKosVertex3fpv(GLfloat *xyz) { +GLvoid _glKosVertex3fpv(GLfloat *xyz) { _glKosVertex3fpa(xyz[0] - GL_KOS_POINT_SIZE, xyz[1] - GL_KOS_POINT_SIZE, xyz[2]); _glKosVertex3fpa(xyz[0] + GL_KOS_POINT_SIZE, xyz[1] - GL_KOS_POINT_SIZE, xyz[2]); _glKosVertex3fpa(xyz[0] - GL_KOS_POINT_SIZE, xyz[1] + GL_KOS_POINT_SIZE, xyz[2]); _glKosVertex3fpb(xyz[0] + GL_KOS_POINT_SIZE, xyz[1] + GL_KOS_POINT_SIZE, xyz[2]); } -void _glKosTransformClipBuf(pvr_vertex_t *v, GLuint verts) { +GLvoid _glKosTransformClipBuf(pvr_vertex_t *v, GLuint verts) { register float __x __asm__("fr12"); register float __y __asm__("fr13"); register float __z __asm__("fr14"); @@ -606,13 +664,13 @@ void _glKosTransformClipBuf(pvr_vertex_t *v, GLuint verts) { } } -static inline void _glKosVertexSwap(pvr_vertex_t *v1, pvr_vertex_t *v2) { +static inline GLvoid _glKosVertexSwap(pvr_vertex_t *v1, pvr_vertex_t *v2) { pvr_vertex_t tmp = *v1; *v1 = *v2; *v2 = * &tmp; } -static inline void _glKosFlagsSetQuad() { +static inline GLvoid _glKosFlagsSetQuad() { pvr_vertex_t *v = (pvr_vertex_t *)_glKosVertexBufPointer() - GL_KOS_VERTEX_COUNT; GLuint i; @@ -624,7 +682,7 @@ static inline void _glKosFlagsSetQuad() { } } -static inline void _glKosFlagsSetTriangle() { +static inline GLvoid _glKosFlagsSetTriangle() { pvr_vertex_t *v = (pvr_vertex_t *)_glKosVertexBufPointer() - GL_KOS_VERTEX_COUNT; GLuint i; @@ -635,7 +693,7 @@ static inline void _glKosFlagsSetTriangle() { } } -static inline void _glKosFlagsSetTriangleStrip() { +static inline GLvoid _glKosFlagsSetTriangleStrip() { pvr_vertex_t *v = (pvr_vertex_t *)_glKosVertexBufPointer() - GL_KOS_VERTEX_COUNT; GLuint i; @@ -650,7 +708,7 @@ static inline void _glKosFlagsSetTriangleStrip() { //====================================================================================================// //== GL KOS PVR Header Parameter Compilation Functions ==// -static inline void _glKosApplyDepthFunc() { +static inline GLvoid _glKosApplyDepthFunc() { if(_glKosEnabledDepthTest()) GL_KOS_POLY_CXT.depth.comparison = GL_KOS_DEPTH_FUNC; else @@ -659,17 +717,17 @@ static inline void _glKosApplyDepthFunc() { GL_KOS_POLY_CXT.depth.write = GL_KOS_DEPTH_WRITE; } -static inline void _glKosApplyScissorFunc() { +static inline GLvoid _glKosApplyScissorFunc() { if(_glKosEnabledScissorTest()) GL_KOS_POLY_CXT.gen.clip_mode = PVR_USERCLIP_INSIDE; } -static inline void _glKosApplyFogFunc() { +static inline GLvoid _glKosApplyFogFunc() { if(_glKosEnabledFog()) GL_KOS_POLY_CXT.gen.fog_type = PVR_FOG_TABLE; } -static inline void _glKosApplyCullingFunc() { +static inline GLvoid _glKosApplyCullingFunc() { if(_glKosEnabledCulling()) { if(GL_KOS_CULL_FUNC == GL_BACK) { if(GL_KOS_FACE_FRONT == GL_CW) @@ -688,14 +746,14 @@ static inline void _glKosApplyCullingFunc() { GL_KOS_POLY_CXT.gen.culling = PVR_CULLING_NONE; } -static inline void _glKosApplyBlendFunc() { +static inline GLvoid _glKosApplyBlendFunc() { if(_glKosEnabledBlend()) { GL_KOS_POLY_CXT.blend.src = (GL_KOS_BLEND_FUNC & 0xF0) >> 4; GL_KOS_POLY_CXT.blend.dst = (GL_KOS_BLEND_FUNC & 0x0F); } } -void _glKosCompileHdr() { +GLvoid _glKosCompileHdr() { pvr_poly_hdr_t *hdr = _glKosVertexBufPointer(); pvr_poly_cxt_col(&GL_KOS_POLY_CXT, _glKosList() * 2); @@ -717,7 +775,7 @@ void _glKosCompileHdr() { _glKosVertexBufIncrement(); } -void _glKosCompileHdrT(GL_TEXTURE_OBJECT *tex) { +GLvoid _glKosCompileHdrT(GL_TEXTURE_OBJECT *tex) { pvr_poly_hdr_t *hdr = _glKosVertexBufPointer(); pvr_poly_cxt_txr(&GL_KOS_POLY_CXT, diff --git a/gl-arrays.c b/gl-arrays.c index 315761f..32d4f0d 100755 --- a/gl-arrays.c +++ b/gl-arrays.c @@ -61,7 +61,7 @@ GLAPI void APIENTRY glVertexPointer(GLint size, GLenum type, } (stride) ? (GL_VERTEX_STRIDE = stride / 4) : (GL_VERTEX_STRIDE = 3); - + GL_VERTEX_POINTER = (float *)pointer; GL_VERTEX_PTR_MODE |= GL_USE_ARRAY; @@ -199,11 +199,11 @@ static void _glKosArraysTransform(GLuint count) { register float __x __asm__("fr12"); register float __y __asm__("fr13"); register float __z __asm__("fr14"); - + while(count--) { - __x = *src++; - __y = *src++; - __z = *src++; + __x = src[0]; + __y = src[1]; + __z = src[2]; mat_trans_fv12() @@ -212,6 +212,8 @@ static void _glKosArraysTransform(GLuint count) { dst->z = __z; ++dst; + + src += GL_VERTEX_STRIDE; } } @@ -226,9 +228,9 @@ static void _glKosArraysTransformClip(GLuint count) { register float __w __asm__("fr15"); while(count--) { - __x = *src++; - __y = *src++; - __z = *src++; + __x = src[0]; + __y = src[1]; + __z = src[2]; ...<truncated>... hooks/post-receive -- The KallistiOS port of OpenGL. |
From: Harley L. <los...@us...> - 2014-12-10 16:20:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 8910881aa1100fe022c3c5e25c10ec7a4344afee (commit) from 611aad0d8731ff188f6b6a771ec0fa3f045946c6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8910881aa1100fe022c3c5e25c10ec7a4344afee Author: Harley Laue <los...@gm...> Date: Wed Dec 10 10:18:26 2014 -0600 Use /bin/sh instead of bash ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/make_banner.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/kernel/arch/dreamcast/kernel/make_banner.sh b/kernel/arch/dreamcast/kernel/make_banner.sh index f824e20..0baaeb7 100755 --- a/kernel/arch/dreamcast/kernel/make_banner.sh +++ b/kernel/arch/dreamcast/kernel/make_banner.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # Re-creates the banner.h file for each compilation run hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Christian G. <sa...@us...> - 2014-12-05 11:40:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 611aad0d8731ff188f6b6a771ec0fa3f045946c6 (commit) from 1e2d9b894971dc3cbf129683cc378dcc460b32da (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 611aad0d8731ff188f6b6a771ec0fa3f045946c6 Author: Christian Groessler <ch...@gr...> Date: Fri Dec 5 12:39:59 2014 +0100 Don't hardcode bash location. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/make_banner.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/kernel/arch/dreamcast/kernel/make_banner.sh b/kernel/arch/dreamcast/kernel/make_banner.sh index 78416d7..f824e20 100755 --- a/kernel/arch/dreamcast/kernel/make_banner.sh +++ b/kernel/arch/dreamcast/kernel/make_banner.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Re-creates the banner.h file for each compilation run hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Christian G. <sa...@us...> - 2014-12-05 10:51:04
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 1e2d9b894971dc3cbf129683cc378dcc460b32da (commit) from 1cd1995d9108f4913323cac74b8efc9688c8135e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1e2d9b894971dc3cbf129683cc378dcc460b32da Author: Christian Groessler <ch...@gr...> Date: Fri Dec 5 11:48:57 2014 +0100 dc-chain: Adapt to system where the GNU make executable isn't called 'make' (but 'gmake' for example). Add '--disable-werror' to gdb and insight configure arguments. ----------------------------------------------------------------------- Summary of changes: utils/dc-chain/Makefile | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/utils/dc-chain/Makefile b/utils/dc-chain/Makefile index 6cec899..3e5a8a1 100644 --- a/utils/dc-chain/Makefile +++ b/utils/dc-chain/Makefile @@ -153,8 +153,8 @@ $(build_binutils): logdir -mkdir -p $(build) > $(log) cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --disable-werror CXX=$(CXX) $(to_log) - make $(makejobs) -C $(build) DESTDIR=$(DESTDIR) $(to_log) - make -C $(build) install DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) $(makejobs) -C $(build) DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) -C $(build) install DESTDIR=$(DESTDIR) $(to_log) $(clean_up) $(build_gcc_pass1) $(build_gcc_pass2): build = build-gcc-$(target)-$(gcc_ver) @@ -165,8 +165,8 @@ $(build_gcc_pass1): logdir -mkdir -p $(build) > $(log) cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --without-headers --with-newlib --enable-languages=c --disable-libssp --disable-tls $(extra_configure_args) CXX=$(CXX) $(to_log) - make $(makejobs) -C $(build) DESTDIR=$(DESTDIR) $(to_log) - make -C $(build) install DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) $(makejobs) -C $(build) DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) -C $(build) install DESTDIR=$(DESTDIR) $(to_log) $(build_newlib): build = build-newlib-$(target)-$(newlib_ver) $(build_newlib): src_dir = newlib-$(newlib_ver) @@ -176,8 +176,8 @@ $(build_newlib): logdir -mkdir -p $(build) > $(log) cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) $(extra_configure_args) $(to_log) - make $(makejobs) -C $(build) DESTDIR=$(DESTDIR) $(to_log) - make -C $(build) install DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) $(makejobs) -C $(build) DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) -C $(build) install DESTDIR=$(DESTDIR) $(to_log) $(clean_up) fixup-sh4-newlib: newlib_inc=$(DESTDIR)$(sh_prefix)/$(sh_target)/include @@ -203,8 +203,8 @@ $(build_gcc_pass2): logdir > $(log) cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --with-newlib --disable-libssp --disable-tls \ --enable-threads=$(thread_model) --enable-languages=$(pass2_languages) $(extra_configure_args) CXX=$(CXX) $(to_log) - make $(makejobs) -C $(build) DESTDIR=$(DESTDIR) $(to_log) - make -C $(build) install DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) $(makejobs) -C $(build) DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) -C $(build) install DESTDIR=$(DESTDIR) $(to_log) $(clean_up) # ---- }}}} @@ -236,9 +236,10 @@ build_gdb_stamp: rm -rf build-gdb-$(gdb_ver) mkdir build-gdb-$(gdb_ver) cd build-gdb-$(gdb_ver); ../gdb-$(gdb_ver)/configure \ + --disable-werror \ --prefix=$(sh_prefix) \ --target=$(sh_target) $(to_log) - make $(makejobs) -C build-gdb-$(gdb_ver) $(to_log) + $(MAKE) $(makejobs) -C build-gdb-$(gdb_ver) $(to_log) touch $@ install_gdb: log = $(logdir)/gdb-$(gdb_ver).log @@ -248,7 +249,7 @@ install_gdb: build_gdb install_gdb_stamp install_gdb_stamp: @echo "+++ Installing GDB..." rm -f $@ - make -C build-gdb-$(gdb_ver) install DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) -C build-gdb-$(gdb_ver) install DESTDIR=$(DESTDIR) $(to_log) touch $@ gdb: install_gdb @@ -280,9 +281,10 @@ build_insight_stamp: rm -rf build-insight-$(insight_ver) mkdir build-insight-$(insight_ver) cd build-insight-$(insight_ver); ../insight-$(insight_ver)/configure \ + --disable-werror \ --prefix=$(sh_prefix) \ --target=$(sh_target) $(to_log) - make $(makejobs) -C build-insight-$(insight_ver) $(to_log) + $(MAKE) $(makejobs) -C build-insight-$(insight_ver) $(to_log) touch $@ install_insight: log = $(logdir)/insight-$(insight_ver).log @@ -292,7 +294,7 @@ install_insight: build_insight install_insight_stamp install_insight_stamp: @echo "+++ Installing INSIGHT..." rm -f $@ - make -C build-insight-$(insight_ver) install DESTDIR=$(DESTDIR) $(to_log) + $(MAKE) -C build-insight-$(insight_ver) install DESTDIR=$(DESTDIR) $(to_log) touch $@ insight: install_insight hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-12-01 05:14:54
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 1cd1995d9108f4913323cac74b8efc9688c8135e (commit) via 024d59caa4bdaafacacdb8a0294af7cc6629bd11 (commit) from 8c4f8f6325c130788547e3f89980cf5df67773eb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1cd1995d9108f4913323cac74b8efc9688c8135e Author: Lawrence Sebald <ljs...@us...> Date: Mon Dec 1 00:14:22 2014 -0500 Add support for UDP Lite to the network stack. commit 024d59caa4bdaafacacdb8a0294af7cc6629bd11 Author: Lawrence Sebald <ljs...@us...> Date: Sun Nov 30 20:23:58 2014 -0500 Fix ugly indentation... ----------------------------------------------------------------------- Summary of changes: include/netinet/in.h | 24 ++++- kernel/net/net_input.c | 6 +- kernel/net/net_udp.c | 290 ++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 267 insertions(+), 53 deletions(-) diff --git a/include/netinet/in.h b/include/netinet/in.h index 4437200..f7d12e4 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -182,6 +182,9 @@ extern const struct in6_addr in6addr_loopback; /** \brief Internet Protocol Version 6. */ #define IPPROTO_IPV6 41 +/** \brief Lightweight User Datagram Protocol. */ +#define IPPROTO_UDPLITE 136 + /** \defgroup ipv4_opts IPv4 protocol level options These are the various socket-level optoins that can be accessed with the @@ -193,6 +196,7 @@ extern const struct in6_addr in6addr_loopback; \see so_opts \see ipv6_opts \see udp_opts + \see udplite_opts @{ */ @@ -210,6 +214,7 @@ extern const struct in6_addr in6addr_loopback; \see so_opts \see ipv4_opts \see udp_opts + \see udplite_opts @{ */ @@ -230,12 +235,29 @@ extern const struct in6_addr in6addr_loopback; \see so_opts \see ipv4_opts \see ipv6_opts + \see udplite_opts -@{ + @{ */ #define UDP_NOCHECKSUM 25 /**< \brief Don't calculate UDP checksums */ /** @} */ +/** \defgroup udplite_opts UDP-Lite protocol level options + + These are the various socket-level options that can be accessed with the + setsockopt() and getsockopt() functions for the IPPROTO_UDPLITE level value. + + \see so_opts + \see ipv4_opts + \see ipv6_opts + \see udp_opts + + @{ +*/ +#define UDPLITE_SEND_CSCOV 26 /**< \brief Sending checksum coverage. */ +#define UDPLITE_RECV_CSCOV 27 /**< \brief Receiving checksum coverage. */ +/** @} */ + /** \brief Test if an IPv6 Address is unspecified. This macro tests whether an IPv6 address (struct in6_addr *) is an diff --git a/kernel/net/net_input.c b/kernel/net/net_input.c index 961d6a4..90851ad 100644 --- a/kernel/net/net_input.c +++ b/kernel/net/net_input.c @@ -22,9 +22,9 @@ static int net_default_input(netif_t *nif, const uint8 *data, int len) { /* If this is bound for a multicast address, make sure we actually care about the one that it gets sent to. */ if((data[0] & 0x01) && - (data[0] != 0xFF || data[1] != 0xFF || data[2] != 0xFF || - data[3] != 0xFF || data[4] != 0xFF || data[5] != 0xFF) && - !net_multicast_check(data)) { + (data[0] != 0xFF || data[1] != 0xFF || data[2] != 0xFF || + data[3] != 0xFF || data[4] != 0xFF || data[5] != 0xFF) && + !net_multicast_check(data)) { return 0; } diff --git a/kernel/net/net_udp.c b/kernel/net/net_udp.c index ae89225..d806e20 100644 --- a/kernel/net/net_udp.c +++ b/kernel/net/net_udp.c @@ -10,6 +10,7 @@ #include <stdlib.h> #include <errno.h> #include <poll.h> +#include <stdint.h> #include <arpa/inet.h> #include <kos/net.h> #include <kos/mutex.h> @@ -44,6 +45,7 @@ struct udp_pkt { TAILQ_HEAD(udp_pkt_queue, udp_pkt); #define UDPSOCK_NO_CHECKSUM 0x00000001 +#define UDPSOCK_LITE_RCVCOV 0x00000002 struct udp_sock { LIST_ENTRY(udp_sock) sock_list; @@ -57,6 +59,11 @@ struct udp_sock { int hop_limit; file_t sock; + struct { + uint16_t send_cscov; + uint16_t recv_cscov; + } udp_lite; + struct udp_pkt_queue packets; }; @@ -69,7 +76,7 @@ static net_udp_stats_t udp_stats = { 0 }; static int net_udp_send_raw(netif_t *net, const struct sockaddr_in6 *src, const struct sockaddr_in6 *dst, const uint8 *data, size_t size, uint32_t flags, int hops, - uint32_t iflags); + uint32_t iflags, int proto, uint16_t cscov); static int net_udp_accept(net_socket_t *hnd, struct sockaddr *addr, socklen_t *addr_len) { @@ -421,7 +428,8 @@ static ssize_t net_udp_sendto(net_socket_t *hnd, const void *message, struct sockaddr_in *realaddr; struct sockaddr_in6 realaddr6; uint32_t sflags, iflags; - int hops; + int hops, proto; + uint16_t cscov; struct sockaddr_in6 local_addr; (void)flags; @@ -449,7 +457,7 @@ static ssize_t net_udp_sendto(net_socket_t *hnd, const void *message, } if(!IN6_IS_ADDR_UNSPECIFIED(&udpsock->remote_addr.sin6_addr) && - udpsock->remote_addr.sin6_port != 0) { + udpsock->remote_addr.sin6_port != 0) { if(addr) { errno = EISCONN; goto err; @@ -521,11 +529,13 @@ static ssize_t net_udp_sendto(net_socket_t *hnd, const void *message, sflags = udpsock->flags; iflags = udpsock->int_flags; hops = udpsock->hop_limit; + proto = udpsock->proto; + cscov = udpsock->udp_lite.send_cscov; mutex_unlock(&udp_mutex); return net_udp_send_raw(NULL, &local_addr, &realaddr6, (const uint8 *)message, length, sflags, hops, - iflags); + iflags, proto, cscov); err: mutex_unlock(&udp_mutex); return -1; @@ -578,7 +588,10 @@ static int net_udp_socket(net_socket_t *hnd, int domain, int type, int proto) { return -1; } - if(proto && proto != IPPROTO_UDP) { + if(!proto) { + proto = IPPROTO_UDP; + } + else if(proto != IPPROTO_UDP && proto != IPPROTO_UDPLITE) { errno = EPROTONOSUPPORT; return -1; } @@ -586,7 +599,7 @@ static int net_udp_socket(net_socket_t *hnd, int domain, int type, int proto) { memset(udpsock, 0, sizeof(struct udp_sock)); TAILQ_INIT(&udpsock->packets); udpsock->domain = domain; - udpsock->proto = IPPROTO_UDP; + udpsock->proto = proto; udpsock->hop_limit = UDP_DEFAULT_HOPS; if(irq_inside_int()) { @@ -705,11 +718,11 @@ static int net_udp_getsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_UDP: + if(sock->proto != IPPROTO_UDP) + goto ret_inval; + switch(option_name) { case UDP_NOCHECKSUM: - if(sock->proto != IPPROTO_UDP) - goto ret_inval; - /* UDP/IPv6 packets must always have a checksum. */ if(sock->domain == AF_INET6) { tmp = 0; @@ -721,6 +734,22 @@ static int net_udp_getsockopt(net_socket_t *hnd, int level, int option_name, } break; + + case IPPROTO_UDPLITE: + if(sock->proto != IPPROTO_UDPLITE) + goto ret_inval; + + switch(option_name) { + case UDPLITE_SEND_CSCOV: + tmp = sock->udp_lite.send_cscov; + goto copy_int; + + case UDPLITE_RECV_CSCOV: + tmp = sock->udp_lite.recv_cscov; + goto copy_int; + } + + break; } /* If it wasn't handled, return that error. */ @@ -734,7 +763,6 @@ ret_inval: return -1; copy_int: - if(*option_len >= sizeof(int)) { memcpy(option_value, &tmp, sizeof(int)); *option_len = sizeof(int); @@ -839,15 +867,15 @@ static int net_udp_setsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_UDP: + if(sock->proto != IPPROTO_UDP) + goto ret_inval; + switch(option_name) { case UDP_NOCHECKSUM: /* UDP/IPv6 packets must always have a checksum. */ if(sock->domain == AF_INET6) goto ret_inval; - if(sock->proto != IPPROTO_UDP) - goto ret_inval; - if(option_len != sizeof(int)) goto ret_inval; @@ -862,6 +890,43 @@ static int net_udp_setsockopt(net_socket_t *hnd, int level, int option_name, } break; + + case IPPROTO_UDPLITE: + if(sock->proto != IPPROTO_UDPLITE) + goto ret_inval; + + switch(option_name) { + case UDPLITE_SEND_CSCOV: + if(option_len != sizeof(int)) + goto ret_inval; + + tmp = *((int *)option_value); + + if(tmp && tmp < 8) + goto ret_inval; + else if(tmp > 0xFFFF) + tmp = 0xFFFF; + + sock->udp_lite.send_cscov = (uint16_t)tmp; + goto ret_success; + + case UDPLITE_RECV_CSCOV: + if(option_len != sizeof(int)) + goto ret_inval; + + tmp = *((int *)option_value); + + if(tmp && tmp < 8) + goto ret_inval; + else if(tmp > 0xFFFF) + tmp = 0xFFFF; + + sock->udp_lite.recv_cscov = (uint16_t)tmp; + sock->int_flags |= UDPSOCK_LITE_RCVCOV; + goto ret_success; + } + + break; } /* If it wasn't handled, return that error. */ @@ -963,7 +1028,8 @@ extern void __poll_event_trigger(int fd, short event); static int net_udp_input4(netif_t *src, const ip_hdr_t *ip, const uint8 *data, size_t size) { udp_hdr_t *hdr = (udp_hdr_t *)data; - uint16 cs; + uint16 cs, cscov = 0; + int partial = 1; struct udp_sock *sock; struct udp_pkt *pkt; @@ -975,17 +1041,44 @@ static int net_udp_input4(netif_t *src, const ip_hdr_t *ip, const uint8 *data, return -1; } - /* Calculate the checksum if one was computed by the sender. Unfortunately, - with IPv4, we don't know if a zero checksum means that the sender didn't - calculate the checksum or if it actually came out as 0xFFFF. We pretty - much have to assume the former option though. */ - if(hdr->checksum != 0) { - cs = net_ipv4_checksum_pseudo(ip->src, ip->dest, ip->protocol, size); + if(ip->protocol == IPPROTO_UDP) { + /* Calculate the checksum if one was computed by the sender. + Unfortunately, with IPv4, we don't know if a zero checksum means that + the sender didn't calculate the checksum or if it actually came out + as 0xFFFF. We pretty much have to assume the former option though. */ + if(hdr->checksum != 0) { + cs = net_ipv4_checksum_pseudo(ip->src, ip->dest, IPPROTO_UDP, size); + + /* If the checksum is right, we'll get zero back from the checksum + function */ + if(net_ipv4_checksum(data, size, cs)) { + /* The checksum was wrong, bail out */ + ++udp_stats.pkt_recv_bad_chksum; + return -1; + } + } + } + else { + cscov = ntohs(hdr->length); + + /* Make sure the checksum coverage is sane. */ + if(cscov && (cscov < 8 || cscov > size)) { + ++udp_stats.pkt_recv_bad_chksum; + return -1; + } + else if(!cscov) { + cscov = size; + partial = 0; + } + else if(cscov == size) { + partial = 0; + } + + cs = net_ipv4_checksum_pseudo(ip->src, ip->dest, IPPROTO_UDPLITE, size); /* If the checksum is right, we'll get zero back from the checksum - function */ - if(net_ipv4_checksum(data, size, cs)) { - /* The checksum was wrong, bail out */ + function. */ + if(net_ipv4_checksum(data, cscov, cs)) { ++udp_stats.pkt_recv_bad_chksum; return -1; } @@ -1008,16 +1101,32 @@ static int net_udp_input4(netif_t *src, const ip_hdr_t *ip, const uint8 *data, /* If the socket has a remote port set and it isn't the one that this packet came from, bail */ if(sock->remote_addr.sin6_port != 0 && - sock->remote_addr.sin6_port != hdr->src_port) + sock->remote_addr.sin6_port != hdr->src_port) continue; /* If we have a address specified, and its not v4-mapped or its not the address this packet came from, bail out */ if(!IN6_IS_ADDR_UNSPECIFIED(&sock->remote_addr.sin6_addr) && - (!IN6_IS_ADDR_V4MAPPED(&sock->remote_addr.sin6_addr) || - sock->remote_addr.sin6_addr.__s6_addr.__s6_addr32[3] != ip->src)) + (!IN6_IS_ADDR_V4MAPPED(&sock->remote_addr.sin6_addr) || + sock->remote_addr.sin6_addr.__s6_addr.__s6_addr32[3] != ip->src)) continue; + /* Make sure we have the right protocol */ + if(sock->proto != ip->protocol) + continue; + + /* If this packet is UDP-Lite, make sure the checksum coverage is valid + for the socket. We have to be careful here not to reject packets with + full coverage that just happen to be smaller than the coverage set by + the userspace program. Note that failing this check DOES NOT change + any of the statistics counters at all, by design. */ + if((sock->int_flags & UDPSOCK_LITE_RCVCOV) && partial && + cscov < sock->udp_lite.recv_cscov) { + /* Silently drop packets that fail the partial coverage check. */ + mutex_unlock(&udp_mutex); + return 0; + } + if(!(pkt = (struct udp_pkt *)malloc(sizeof(struct udp_pkt)))) { mutex_unlock(&udp_mutex); return -1; @@ -1059,7 +1168,8 @@ static int net_udp_input4(netif_t *src, const ip_hdr_t *ip, const uint8 *data, static int net_udp_input6(netif_t *src, const ipv6_hdr_t *ip, const uint8 *data, size_t size) { udp_hdr_t *hdr = (udp_hdr_t *)data; - uint16 cs; + uint16 cs, cscov = 0; + int partial = 1; struct udp_sock *sock; struct udp_pkt *pkt; @@ -1071,20 +1181,45 @@ static int net_udp_input6(netif_t *src, const ipv6_hdr_t *ip, const uint8 *data, return -1; } - /* Calculate the checksum of the packet. Note that this is optional for IPv4 - but required for IPv6. Thus, for IPv6, a zero checksum in the packet - implies that the value was actually calculated as 0xFFFF (whereas with - IPv4, that means that either the value was calculated as 0xFFFF or no - checksum was calculated). */ - cs = net_ipv6_checksum_pseudo(&ip->src_addr, &ip->dst_addr, size, - IPPROTO_UDP); + if(ip->next_header == IPPROTO_UDP) { + /* Calculate the checksum of the packet. Note that this is optional for + IPv4 but required for IPv6. */ + cs = net_ipv6_checksum_pseudo(&ip->src_addr, &ip->dst_addr, size, + IPPROTO_UDP); - /* If the checksum is right, we'll get zero back from the checksum - function */ - if(net_ipv4_checksum(data, size, cs)) { - /* The checksum was wrong, bail out */ - ++udp_stats.pkt_recv_bad_chksum; - return -1; + /* If the checksum is right, we'll get zero back from the checksum + function. */ + if(net_ipv4_checksum(data, size, cs)) { + /* The checksum was wrong, bail out */ + ++udp_stats.pkt_recv_bad_chksum; + return -1; + } + } + else { + cscov = ntohs(hdr->length); + + /* Make sure the checksum coverage is sane. */ + if(cscov && (cscov < 8 || cscov > size)) { + ++udp_stats.pkt_recv_bad_chksum; + return -1; + } + else if(!cscov) { + cscov = size; + partial = 0; + } + else if(cscov == size) { + partial = 0; + } + + cs = net_ipv6_checksum_pseudo(&ip->src_addr, &ip->dst_addr, size, + IPPROTO_UDPLITE); + + /* If the checksum is right, we'll get zero back from the checksum + function. */ + if(net_ipv4_checksum(data, cscov, cs)) { + ++udp_stats.pkt_recv_bad_chksum; + return -1; + } } if(mutex_trylock(&udp_mutex)) @@ -1104,16 +1239,32 @@ static int net_udp_input6(netif_t *src, const ipv6_hdr_t *ip, const uint8 *data, /* If the socket has a remote port set and it isn't the one that this packet came from, bail */ if(sock->remote_addr.sin6_port != 0 && - sock->remote_addr.sin6_port != hdr->src_port) + sock->remote_addr.sin6_port != hdr->src_port) continue; /* If we have a address specified and it is not the address this packet came from, bail out */ if(!IN6_IS_ADDR_UNSPECIFIED(&sock->remote_addr.sin6_addr) && - memcmp(&sock->remote_addr.sin6_addr, &ip->src_addr, - sizeof(struct in6_addr))) + memcmp(&sock->remote_addr.sin6_addr, &ip->src_addr, + sizeof(struct in6_addr))) continue; + /* Make sure we have the right protocol */ + if(sock->proto != ip->next_header) + continue; + + /* If this packet is UDP-Lite, make sure the checksum coverage is valid + for the socket. We have to be careful here not to reject packets with + full coverage that just happen to be smaller than the coverage set by + the userspace program. Note that failing this check DOES NOT change + any of the statistics counters at all, by design. */ + if((sock->int_flags & UDPSOCK_LITE_RCVCOV) && partial && + cscov < sock->udp_lite.recv_cscov) { + /* Silently drop packets that fail the partial coverage check. */ + mutex_unlock(&udp_mutex); + return 0; + } + if(!(pkt = (struct udp_pkt *)malloc(sizeof(struct udp_pkt)))) { mutex_unlock(&udp_mutex); return -1; @@ -1164,10 +1315,11 @@ static int net_udp_input(netif_t *src, int domain, const void *hdr, return -1; } +/* XXX */ static int net_udp_send_raw(netif_t *net, const struct sockaddr_in6 *src, const struct sockaddr_in6 *dst, const uint8 *data, size_t size, uint32_t flags, int hops, - uint32_t iflags) { + uint32_t iflags, int proto, uint16_t cscov) { uint8 buf[size + sizeof(udp_hdr_t)]; udp_hdr_t *hdr = (udp_hdr_t *)buf; uint16 cs; @@ -1220,18 +1372,36 @@ static int net_udp_send_raw(netif_t *net, const struct sockaddr_in6 *src, memcpy(buf + sizeof(udp_hdr_t), data, size); size += sizeof(udp_hdr_t); - cs = net_ipv6_checksum_pseudo(&srcaddr, &dst->sin6_addr, size, IPPROTO_UDP); ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-12-01 01:18:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 8c4f8f6325c130788547e3f89980cf5df67773eb (commit) from a2d40127976dbaba58b30794104460e70f3223ff (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8c4f8f6325c130788547e3f89980cf5df67773eb Author: Lawrence Sebald <ljs...@us...> Date: Sun Nov 30 20:16:10 2014 -0500 Make net_arp_gc() a static function, not a public one, also change the way it works a little bit. There's really no reason to have this function exposed to user programs... As for the changes to the way it works, now it will re-query for any incomplete entries every 5 seconds. Also, the timeout for expired entries is changed from 10 minutes to 2 minutes. ----------------------------------------------------------------------- Summary of changes: include/kos/net.h | 8 -------- kernel/net/net_arp.c | 34 +++++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/include/kos/net.h b/include/kos/net.h index 8924671..cfb7428 100644 --- a/include/kos/net.h +++ b/include/kos/net.h @@ -250,14 +250,6 @@ int net_arp_init(void); /** \brief Shutdown ARP. */ void net_arp_shutdown(void); -/** \brief Garbage collect timed out ARP entries. - - This will be done periodically as ARP lookups are requested. - - \retval 0 On success (no error conditions defined). -*/ -int net_arp_gc(void); - /** \brief Add an entry to the ARP cache manually. \param nif The network device in use. diff --git a/kernel/net/net_arp.c b/kernel/net/net_arp.c index 22a432c..c616d7e 100644 --- a/kernel/net/net_arp.c +++ b/kernel/net/net_arp.c @@ -74,7 +74,7 @@ struct netarp_list net_arp_cache = LIST_HEAD_INITIALIZER(0); /* Cache management */ /* Garbage collect timed out entries */ -int net_arp_gc(void) { +static int net_arp_gc(netif_t *nif) { netarp_t *a1, *a2; a1 = LIST_FIRST(&net_arp_cache); @@ -82,15 +82,27 @@ int net_arp_gc(void) { while(a1 != NULL) { a2 = LIST_NEXT(a1, ac_list); - if(a1->timestamp && jiffies >= (a1->timestamp + 600 * HZ)) { - LIST_REMOVE(a1, ac_list); + if(a1->timestamp) { + if(jiffies >= (a1->timestamp + 120 * HZ)) { + LIST_REMOVE(a1, ac_list); - if(a1->pkt) { - free(a1->pkt); - free(a1->data); + if(a1->pkt) { + free(a1->pkt); + free(a1->data); + } + + free(a1); + a1 = a2; + continue; } - free(a1); + /* If the entry is incomplete and it's been more than 5 seconds + since we queried it, try again. */ + if(a1->mac[0] == 0 && a1->mac[1] == 0 && a1->mac[2] == 0 && + a1->mac[3] == 0 && a1->mac[4] == 0 && a1->mac[5] == 0 && + jiffies > (a1->timestamp + 5 * HZ)) { + net_arp_query(nif, a1->ip); + } } a1 = a2; @@ -136,7 +148,7 @@ int net_arp_insert(netif_t *nif, const uint8 mac[6], const uint8 ip[4], LIST_INSERT_HEAD(&net_arp_cache, cur, ac_list); /* Garbage collect expired entries */ - net_arp_gc(); + net_arp_gc(nif); return 0; } @@ -150,14 +162,14 @@ int net_arp_lookup(netif_t *nif, const uint8 ip_in[4], uint8 mac_out[6], netarp_t *cur; /* Garbage collect expired entries */ - net_arp_gc(); + net_arp_gc(nif); /* Look for the entry */ LIST_FOREACH(cur, &net_arp_cache, ac_list) { if(!memcmp(ip_in, cur->ip, 4)) { if(cur->mac[0] == 0 && cur->mac[1] == 0 && - cur->mac[2] == 0 && cur->mac[3] == 0 && - cur->mac[4] == 0 && cur->mac[5] == 0) { + cur->mac[2] == 0 && cur->mac[3] == 0 && + cur->mac[4] == 0 && cur->mac[5] == 0) { return -1; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-29 15:42:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via a2d40127976dbaba58b30794104460e70f3223ff (commit) from 914169408261ebf4d5fbed9c61bf03725678bc3a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a2d40127976dbaba58b30794104460e70f3223ff Author: Lawrence Sebald <ljs...@us...> Date: Sat Nov 29 10:41:33 2014 -0500 Add an option to not compute UDP checksums on packets sent with a socket. ----------------------------------------------------------------------- Summary of changes: include/netinet/in.h | 16 ++++++++++ include/sys/socket.h | 8 +++++ kernel/net/net_udp.c | 81 ++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 90 insertions(+), 15 deletions(-) diff --git a/include/netinet/in.h b/include/netinet/in.h index ade851e..4437200 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -192,6 +192,7 @@ extern const struct in6_addr in6addr_loopback; \see so_opts \see ipv6_opts + \see udp_opts @{ */ @@ -208,6 +209,7 @@ extern const struct in6_addr in6addr_loopback; \see so_opts \see ipv4_opts + \see udp_opts @{ */ @@ -220,6 +222,20 @@ extern const struct in6_addr in6addr_loopback; #define IPV6_V6ONLY 23 /**< \brief IPv6 only -- no IPv4 (get/set) */ /** @} */ +/** \defgroup udp_opts UDP protocol level options + + These are the various socket-level options that can be accessed with the + setsockopt() and getsockopt() functions for the IPPROTO_UDP level value. + + \see so_opts + \see ipv4_opts + \see ipv6_opts + +@{ +*/ +#define UDP_NOCHECKSUM 25 /**< \brief Don't calculate UDP checksums */ +/** @} */ + /** \brief Test if an IPv6 Address is unspecified. This macro tests whether an IPv6 address (struct in6_addr *) is an diff --git a/include/sys/socket.h b/include/sys/socket.h index 4b395d7..04fdfa7 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -113,6 +113,8 @@ struct sockaddr_storage { completeness. \see ipv6_opts + \see ipv4_opts + \see udp_opts @{ */ @@ -355,6 +357,9 @@ int socket(int domain, int type, int protocol); appropriate. \see so_opts + \see ipv4_opts + \see ipv6_opts + \see udp_opts */ int getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len); @@ -374,6 +379,9 @@ int getsockopt(int socket, int level, int option_name, void *option_value, appropriate. \see so_opts + \see ipv4_opts + \see ipv6_opts + \see udp_opts */ int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len); diff --git a/kernel/net/net_udp.c b/kernel/net/net_udp.c index 6fb1b82..ae89225 100644 --- a/kernel/net/net_udp.c +++ b/kernel/net/net_udp.c @@ -43,13 +43,17 @@ struct udp_pkt { TAILQ_HEAD(udp_pkt_queue, udp_pkt); +#define UDPSOCK_NO_CHECKSUM 0x00000001 + struct udp_sock { LIST_ENTRY(udp_sock) sock_list; struct sockaddr_in6 local_addr; struct sockaddr_in6 remote_addr; uint32 flags; + uint32 int_flags; int domain; + int proto; int hop_limit; file_t sock; @@ -64,7 +68,8 @@ static net_udp_stats_t udp_stats = { 0 }; static int net_udp_send_raw(netif_t *net, const struct sockaddr_in6 *src, const struct sockaddr_in6 *dst, const uint8 *data, - size_t size, int flags, int hops); + size_t size, uint32_t flags, int hops, + uint32_t iflags); static int net_udp_accept(net_socket_t *hnd, struct sockaddr *addr, socklen_t *addr_len) { @@ -415,7 +420,8 @@ static ssize_t net_udp_sendto(net_socket_t *hnd, const void *message, struct udp_sock *udpsock; struct sockaddr_in *realaddr; struct sockaddr_in6 realaddr6; - uint32_t sflags; + uint32_t sflags, iflags; + int hops; struct sockaddr_in6 local_addr; (void)flags; @@ -513,11 +519,13 @@ static ssize_t net_udp_sendto(net_socket_t *hnd, const void *message, local_addr = udpsock->local_addr; sflags = udpsock->flags; + iflags = udpsock->int_flags; + hops = udpsock->hop_limit; mutex_unlock(&udp_mutex); return net_udp_send_raw(NULL, &local_addr, &realaddr6, - (const uint8 *)message, length, sflags, - udpsock->hop_limit); + (const uint8 *)message, length, sflags, hops, + iflags); err: mutex_unlock(&udp_mutex); return -1; @@ -570,9 +578,15 @@ static int net_udp_socket(net_socket_t *hnd, int domain, int type, int proto) { return -1; } + if(proto && proto != IPPROTO_UDP) { + errno = EPROTONOSUPPORT; + return -1; + } + memset(udpsock, 0, sizeof(struct udp_sock)); TAILQ_INIT(&udpsock->packets); udpsock->domain = domain; + udpsock->proto = IPPROTO_UDP; udpsock->hop_limit = UDP_DEFAULT_HOPS; if(irq_inside_int()) { @@ -650,7 +664,6 @@ static int net_udp_getsockopt(net_socket_t *hnd, int level, int option_name, switch(level) { case SOL_SOCKET: - switch(option_name) { case SO_ACCEPTCONN: tmp = 0; @@ -664,7 +677,6 @@ static int net_udp_getsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_IP: - if(sock->domain != AF_INET) goto ret_inval; @@ -677,7 +689,6 @@ static int net_udp_getsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_IPV6: - if(sock->domain != AF_INET6) goto ret_inval; @@ -692,6 +703,24 @@ static int net_udp_getsockopt(net_socket_t *hnd, int level, int option_name, } break; + + case IPPROTO_UDP: + switch(option_name) { + case UDP_NOCHECKSUM: + if(sock->proto != IPPROTO_UDP) + goto ret_inval; + + /* UDP/IPv6 packets must always have a checksum. */ + if(sock->domain == AF_INET6) { + tmp = 0; + goto copy_int; + } + + tmp = !!(sock->int_flags & UDPSOCK_NO_CHECKSUM); + goto copy_int; + } + + break; } /* If it wasn't handled, return that error. */ @@ -741,7 +770,6 @@ static int net_udp_setsockopt(net_socket_t *hnd, int level, int option_name, switch(level) { case SOL_SOCKET: - switch(option_name) { case SO_ACCEPTCONN: case SO_ERROR: @@ -752,13 +780,11 @@ static int net_udp_setsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_IP: - if(sock->domain != AF_INET) goto ret_inval; switch(option_name) { case IP_TTL: - if(option_len != sizeof(int)) goto ret_inval; @@ -777,13 +803,11 @@ static int net_udp_setsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_IPV6: - if(sock->domain != AF_INET6) goto ret_inval; switch(option_name) { case IPV6_UNICAST_HOPS: - if(option_len != sizeof(int)) goto ret_inval; @@ -799,7 +823,6 @@ static int net_udp_setsockopt(net_socket_t *hnd, int level, int option_name, goto ret_success; case IPV6_V6ONLY: - if(option_len != sizeof(int)) goto ret_inval; @@ -814,6 +837,31 @@ static int net_udp_setsockopt(net_socket_t *hnd, int level, int option_name, } break; + + case IPPROTO_UDP: + switch(option_name) { + case UDP_NOCHECKSUM: + /* UDP/IPv6 packets must always have a checksum. */ + if(sock->domain == AF_INET6) + goto ret_inval; + + if(sock->proto != IPPROTO_UDP) + goto ret_inval; + + if(option_len != sizeof(int)) + goto ret_inval; + + tmp = *((int *)option_value); + + if(tmp) + sock->int_flags |= UDPSOCK_NO_CHECKSUM; + else + sock->int_flags &= ~(UDPSOCK_NO_CHECKSUM); + + goto ret_success; + } + + break; } /* If it wasn't handled, return that error. */ @@ -1118,7 +1166,8 @@ static int net_udp_input(netif_t *src, int domain, const void *hdr, static int net_udp_send_raw(netif_t *net, const struct sockaddr_in6 *src, const struct sockaddr_in6 *dst, const uint8 *data, - size_t size, int flags, int hops) { + size_t size, uint32_t flags, int hops, + uint32_t iflags) { uint8 buf[size + sizeof(udp_hdr_t)]; udp_hdr_t *hdr = (udp_hdr_t *)buf; uint16 cs; @@ -1177,7 +1226,9 @@ static int net_udp_send_raw(netif_t *net, const struct sockaddr_in6 *src, hdr->dst_port = dst->sin6_port; hdr->length = htons(size); hdr->checksum = 0; - hdr->checksum = net_ipv4_checksum(buf, size, cs); + + if(!(iflags & UDPSOCK_NO_CHECKSUM)) + hdr->checksum = net_ipv4_checksum(buf, size, cs); /* Pass everything off to the network layer to do the rest. */ err = net_ipv6_send(net, buf, size, hops, IPPROTO_UDP, &srcaddr, hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-28 19:04:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 914169408261ebf4d5fbed9c61bf03725678bc3a (commit) from f46cbad0d6ca9c2ef781dd608b079ac74d25384c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 914169408261ebf4d5fbed9c61bf03725678bc3a Author: Lawrence Sebald <ljs...@us...> Date: Fri Nov 28 14:04:05 2014 -0500 The UDP checksum is required for IPv6 and optional for IPv4. ----------------------------------------------------------------------- Summary of changes: kernel/net/net_udp.c | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/kernel/net/net_udp.c b/kernel/net/net_udp.c index 28ea4b3..6fb1b82 100644 --- a/kernel/net/net_udp.c +++ b/kernel/net/net_udp.c @@ -1,7 +1,7 @@ /* KallistiOS ##version## kernel/net/net_udp.c - Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012, 2013 Lawrence Sebald + Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012, 2013, 2014 Lawrence Sebald */ @@ -927,6 +927,10 @@ static int net_udp_input4(netif_t *src, const ip_hdr_t *ip, const uint8 *data, return -1; } + /* Calculate the checksum if one was computed by the sender. Unfortunately, + with IPv4, we don't know if a zero checksum means that the sender didn't + calculate the checksum or if it actually came out as 0xFFFF. We pretty + much have to assume the former option though. */ if(hdr->checksum != 0) { cs = net_ipv4_checksum_pseudo(ip->src, ip->dest, ip->protocol, size); @@ -1019,17 +1023,20 @@ static int net_udp_input6(netif_t *src, const ipv6_hdr_t *ip, const uint8 *data, return -1; } - if(hdr->checksum != 0) { - cs = net_ipv6_checksum_pseudo(&ip->src_addr, &ip->dst_addr, - size, IPPROTO_UDP); + /* Calculate the checksum of the packet. Note that this is optional for IPv4 + but required for IPv6. Thus, for IPv6, a zero checksum in the packet + implies that the value was actually calculated as 0xFFFF (whereas with + IPv4, that means that either the value was calculated as 0xFFFF or no + checksum was calculated). */ + cs = net_ipv6_checksum_pseudo(&ip->src_addr, &ip->dst_addr, size, + IPPROTO_UDP); - /* If the checksum is right, we'll get zero back from the checksum - function */ - if(net_ipv4_checksum(data, size, cs)) { - /* The checksum was wrong, bail out */ - ++udp_stats.pkt_recv_bad_chksum; - return -1; - } + /* If the checksum is right, we'll get zero back from the checksum + function */ + if(net_ipv4_checksum(data, size, cs)) { + /* The checksum was wrong, bail out */ + ++udp_stats.pkt_recv_bad_chksum; + return -1; } if(mutex_trylock(&udp_mutex)) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-06 17:26:16
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via f46cbad0d6ca9c2ef781dd608b079ac74d25384c (commit) via 9d17e214c8c57c4ba1aba3ac262f8cf103e483a9 (commit) from 86f1d85f492f7981c5ac443b368689f20be0f451 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f46cbad0d6ca9c2ef781dd608b079ac74d25384c Author: Lawrence Sebald <ljs...@us...> Date: Thu Nov 6 12:25:55 2014 -0500 Update a bit of stuff in the documentation directory. commit 9d17e214c8c57c4ba1aba3ac262f8cf103e483a9 Author: Lawrence Sebald <ljs...@us...> Date: Wed Nov 5 13:05:26 2014 -0500 Add doxygen comment for rewinddir(). ----------------------------------------------------------------------- Summary of changes: doc/FAQ | 36 +++++++++++++++++++----------------- doc/LICENSE | 36 ++++++++++++++++++------------------ doc/README | 14 ++++++++++---- doc/README.GPL | 2 +- doc/goals.txt | 37 +++++++++++++++++++------------------ include/sys/dirent.h | 15 ++++++++++++++- 6 files changed, 81 insertions(+), 59 deletions(-) diff --git a/doc/FAQ b/doc/FAQ index 4d6402d..6cf0bef 100644 --- a/doc/FAQ +++ b/doc/FAQ @@ -223,7 +223,8 @@ support), and is slowly being worked out. Q) What VFS modules are available? -A) Presently there are six (and one in an addon library): +A) Presently there are six that you might interact with on a semi- +regular basis (and one in an addon library): - ISO9660 -- mounts on /cd, and is a decent implementation of the ISO9660 file system standard used on CDs. Note that because of the @@ -308,11 +309,13 @@ support. I recommend old school debugging (calling malloc_stats() every so often to see when it bombs and narrowing it down, or perhaps commenting out blocks until it works again). -You can also edit kernel/mm/malloc.c and enable the memory debugging -defines at the top. These will track all memory usage and look for buffer -overruns/underruns, reporting any issues as they happen. It will also -show leaked buffers remaining at the end of the program. There is a -similar facility for the PVR on the DC port. +You can also edit include/kos/opts.h and enable the memory debugging +defines (anything that starts with KM_ as well as MALLOC_DEBUG). These +will track all memory usage and look for buffer overruns/underruns, +reporting any issues as they happen. It will also show leaked buffers +remaining at the end of the program. There is a similar facility for the +PVR on the DC port (the PVR_KM_* and PVR_MALLOC_DEBUG macros in the same +file). 3 --- Networking --------------------------------------------------- @@ -329,9 +332,8 @@ tree. Note that lwIP is pretty much considered deprecated now, and isn't actively tested anymore. You should use the internal network stack for all new code. -There is also a driver for the Dreamcast modem, however there is no PPP -stack, which would be needed to connect to the internet and the rest of -the TCP/IP stack with it. +There is also a driver for the Dreamcast modem and a PPP stack that links +it into the rest of the TCP/IP stack. 3.2 @@ -355,10 +357,11 @@ thread primitives now in KOS this might not be as hard. Q) I'm having an issue building KOS; it gives me errors about not finding Makefiles or not finding include files. -A) Make sure you check the paths in environ.sh and/or environ.tcsh, and -make sure you are running one of those with the 'source' command (see the -README). If in doubt, use 'set' or 'setenv' to find the environment -variables. You should have a KOS_BASE variable. +A) Make sure you check the paths in environ.sh, and make sure you are +running the script with the 'source' command (see the README). If in +doubt, use 'set' or 'setenv' to find the environment variables. You +should have a KOS_BASE variable. If you don't, then you haven't set up +the and/or sourced environment script correctly in your shell. 4.2 @@ -380,7 +383,7 @@ debug output? A) Use dc-load-ip with your broadband adapter or lan adapter on the Dreamcast. If you don't have one of those, you might look into fb_console, -which you can redirect to either the whole framebuffer or a texture +which you can redirect to either the whole frame buffer or a texture somewhere in VRAM. @@ -389,9 +392,8 @@ somewhere in VRAM. Q) I want to use the serial line but the pesky kernel debug output is getting in my way. -A) You'll want to either disable all debug output (using dbglog_set_level) -or redirect it elsewhere using dbgio_set_printk(). You can also add -INIT_QUIET to your init flags. +A) Use INIT_QUIET in your init flags or make sure the debugging output +is not sent to the serial port by using dbgio_dev_select(). 5.3 diff --git a/doc/LICENSE b/doc/LICENSE index e684539..169c516 100644 --- a/doc/LICENSE +++ b/doc/LICENSE @@ -20,18 +20,18 @@ package like newlib), you can assume that this text is attached to them: KOS License (README.KOS) for more details. You should have received a copy of the KOS License along with this - program; if not, please visit Cryptic Allusion DCDev at: + program; if not, please visit Cryptic Allusion Game Dev at: - http://dcdev.allusion.net/ + http://gamedev.allusion.net/ Please read "README.KOS" for the full details. If there is ever a question or you want to ask permission to do something -else with it, please contact the authors and we'll see how we can accomidate +else with it, please contact the authors and we'll see how we can accomodate you. The Free Software Foundation has a very good source of information on -the various licenses. Please see this page if you have license compatability +the various licenses. Please see this page if you have license compatabality questions: http://www.gnu.org/philosophy/license-list.html @@ -42,10 +42,10 @@ on the BSD code, please reference README.BSD. Be aware, though, that the BSD license is basically identical, but ours has been cleaned up (the "advertising clause" is gone completely). -KOS also contains code from the "lwIP" TCP/IP stack, copyright 2001 -Swedish Institute of Computer Science. This code is licensed under a -license basically identical to the KOS license, but with their name. -You can find the license in any of their files. +KOS also optionally contains code from the "lwIP" TCP/IP stack, +copyright 2001 Swedish Institute of Computer Science. This code is +licensed under a license basically identical to the KOS license, but +with their name. You can find the license in any of their files. One final note: some of the software included with the KOS distribution is not copyrighted by us, nor is it part of the codebase of KOS. Pretty @@ -53,9 +53,9 @@ much all of that code is contained in the "utils" directory, and will shortly be contained as well (or perhaps only) in the "addons" directory. Licenses on these pieces vary; please see the source of the program in question to be sure. In particular, genromfs, dialog, and the -XingMP3 library (in addons/libmp3/xingmp3) are covered under the GPL, and -MPGLIB (in addons/libmp3/mpglib) is covered under the LGPL. I don't yell -lightly, so pay attention to this: +XingMP3 library (in kos-ports/libmp3/xingmp3) are covered under the GPL, +and MPGLIB (in kos-ports/libmp3/mpglib) is covered under the LGPL. I don't +yell lightly, so pay attention to this: IF YOU USE THE XINGMP3 LIBRARY IN YOUR PROGRAM, YOUR PROGRAM AUTOMATICALLY BECOMES RESTRICTED BY THE GPL LICENSE. IF YOU USE THE @@ -64,7 +64,7 @@ SOURCE CODE. END. Just in case you missed that or don't like caps, you may not include the Xing MP3 library in your program (this currently means linking -lmp3 -from the KOS addons tree) without making your program GPL'd, or +from the KOS kos-ports tree) without making your program GPL'd, or something less restrictive (e.g., BSD license) but distributing it by the terms of the GPL. If you replace the MP3 engine, however, you _can_ do this, as all of our libmp3 code is covered under the BSD license. @@ -72,12 +72,12 @@ do this, as all of our libmp3 code is covered under the BSD license. There. I've said my piece =). Now if you break the license, it's your fault. -I am currently working on porting the MPGLIB library from the unix -player 'mpg123', but this isn't complete yet. I included the code so far -but it doesn't work properly. If you want to play with it then email me -for the changes to libmp3 that are required to hook into it. +There was previously work on porting the MPGLIB library from mpg123, but +this work was never completed. The code is included in the libmp3/mpglib +directory. You're on your own if you want to try to get it to work, but +please let us know if you do (patches would be really nice). Also: -This software is based in part on the work of the Independent JPEG -Group (see addons/libjpeg/README). +This software optionally is based in part on the work of the Independent +JPEG Group (see kos-ports/libjpeg/README). diff --git a/doc/README b/doc/README index b8c79f8..b058da5 100644 --- a/doc/README +++ b/doc/README @@ -53,7 +53,7 @@ What KallistiOS provides optionally: What KallistiOS is NOT: - UNIX (or even compatible) - Linux/BSD (those are their own ports! =) -- Memory protection; programs can overwrite eachother at will# +- Memory protection; programs can overwrite each other at will# - Pretty much anything else you can think of that's not in the above list (# There is an MMU module for the DC port, but nothing really uses it at @@ -79,7 +79,7 @@ of the software distributed with KOS (newlib math routines, Xing MP3 engine, modplug, etc) are under different licenses. Please read "LICENSE" if in doubt! -This software is based in part on the work of the Independent JPEG +This software is optinoally based in part on the work of the Independent JPEG Group (see addons/libjpeg/README). I have also added a somewhat informative "licensing" section to the FAQ. @@ -107,7 +107,7 @@ for some more instructions (and perhaps a build script that may help you): On the Dreamcast, the 4.x series of GCC works pretty well. Look at the patches provided in utils/dc-chain/patches to see what versions have been tested and -are known to work. In addition, many people still use earlier versions of GCC, +are known to work. In addition, some people still use earlier versions of GCC, such as 3.4.6 and 3.0.4. There are often strange bugs with GCC for SuperH, so if you deviate from these suggested versions, you're on your own (for instance, pretty much the entire 3.1.x, 3.2.x, and 3.3.x branches of GCC were broken for @@ -183,6 +183,12 @@ properly, or I will probably reject your patches. You should also provide useful commit messages, with a summary on the first line to make it easier on me later. +In addition, for those used to working with pull requests on GitHub, I accept +those as well. I assume you know how to make things work that way if you wish +to go that route. The mirror of the repository at GitHub is currently at the +following url: + https://github.com/ljsebald/KallistiOS + I don't guarantee that any patch will get included (especially if your patch contains a lot of reformatting, sloppy coding, things at cross-purposes with the primary thrust of KOS, etc), but I will make an effort to at least @@ -208,7 +214,7 @@ OS MODE IS GONE FOR GOOD ------------------------ All the interesting and maintainable pieces of the KOS 1.0.x "os mode" have -been fully integrated back into the mainline KOS 2.0.x tree. It is now used +been fully integrated back into the mainline KOS 2.0.0 tree. It is now used for dynamic module loading and does not include process support, etc. This is unlikely to be revived again in the future. diff --git a/doc/README.GPL b/doc/README.GPL index 6af5b2d..b5ca86c 100644 --- a/doc/README.GPL +++ b/doc/README.GPL @@ -2,7 +2,7 @@ Some packages in the util directory are covered under the GNU Public License, version 2 or later. This includes genromfs and dialog. Some pieces of code that are aggregated with the KOS distribution (and have been ported to work with it) but are not part of the main distribution -(such as the Xing MP3 player library) can be found in the "addons" +(such as the Xing MP3 player library) can be found in the "kos-ports" directory. PLEASE realize that if you modify or extend these programs, unlike the diff --git a/doc/goals.txt b/doc/goals.txt index cd3ac55..789f081 100644 --- a/doc/goals.txt +++ b/doc/goals.txt @@ -2,23 +2,22 @@ Goals for KallistiOS (Dreamcast light-weight OS) - Thread support (within a single "process") - Synchronization support -- Dreamcast hardware control with some (compile time?) configuration, +- Dreamcast hardware control with some (compile and runtime?) configuration, e.g., printf() goes to the video screen or to the serial port, etc. More on this below. -- Simple libc that interfaces to the hardware layer so that things - like printf() work as expected. The libc would include file functions - (that access the GD-ROM) in both open() and fopen() forms, malloc() and - free() with a basic bucket algorithm, and other standard ANSI C functions - such as the ones in string.h, stdarg.h, etc. +- Low-level interfaces to work with the Newlib C library so that things + like printf() work as expected. These interfaces include file functions + (that access the GD-ROM or other filesystems), malloc() and free() with + a basic bucket algorithm, and other standard functions that are not + provided with Newlib or where we provide more optimized/useful versions. - Compile-time controls for many of the above, so that you can turn off - what you don't need. This would especially apply to the threading, as - we'd need synchronization in the access of things like sound and video. + what you don't need. This is one area where we are currently severely + lacking. - Support for loading elf binaries from a file system, relocating them, and running them in "immidate mode" or in a new thread. - Realtime features (thread priorities, event-based rescheduling, etc) -- Process support. This has moved from the "non-goal" list onto the goal - list due to a number of considerations (mainly centering around memory - allocation). +- Lightweight Process support. This does not imply full memory protection + or anything else of the sort. - Maybe eventually, MMU support. As a general rule we don't care much about address relocation and protection, but during debugging this could be a big life saver. @@ -28,14 +27,14 @@ Non-goals for KallistiOS - A lot of things that UNIX would provide -- like pipes, real tty's, etc. +- Full memory protection support through the MMU. Hardware Control Layer -- Provides synchronization for high-level primitives if thread support is - compiled into KallistiOS. +- Provides synchronization for high-level primitives. - Basic initialization -- initializes all known system components for you - to reasonable defaults. Some init parameters can be determined at + to reasonable defaults. Some init parameters can be determined at compile time (like default video mode), and potentially init can be disabled if you want to do it manually for some reason. * G2 bus module @@ -55,7 +54,7 @@ Hardware Control Layer - Page flipping / 3D pipeline assistance if you want it. - G2 interrupt and DMA support to TA and/or VRAM * Sound - - Init the sound chip with a sound control program that implements a + - Init the sound chip with a sound control program that implements a basic MIDI-style system. In reality, this is a MikMod-type abstracted Protracker player. (MAYBE, on this one and the next few) - Provide wavetable primitives -- loading patches, play, stop, vol/freq/pan @@ -76,6 +75,7 @@ Hardware Control Layer - Unified enumeration system to let you figure out what's on the bus and potentially use it. - G2 interrupt support for device activity and addition/removal. + - Modules for using each of the available device types. * VMU - Functions to load/save VMU files - Display VMU graphics (on the VMU display) @@ -88,20 +88,21 @@ Hardware Control Layer * Virtualized file system - Like Neutrino -- delegated path spaces - Default drivers will include: - + Built-ins (linked into the program) + ROMFS (linked into the program or perhaps tacked onto the end of the BIN) + CDFS (reads from a CDR) + PC Debug (reads over a debug cable [ethernet, etc]) + + RAM Disk (for temporary files) * GD-ROM - Hardware driver that accesses the GD-ROM directly, uses G2 interrupts, etc. - Access to the ISO file system on a CDR/CDROM - Playing audio tracks on music CDs * Debug support (optional) - - Interfaces to GDB over the serial port + - Interfaces to GDB over the serial port or ethernet - stdout gets redirected to debug stub output functions * Expansion port - Ethernet - - Bitmaster bus device? + - Modem * TCP/IP stack + - PPP support for the modem diff --git a/include/sys/dirent.h b/include/sys/dirent.h index 8733dd1..5006dae 100644 --- a/include/sys/dirent.h +++ b/include/sys/dirent.h @@ -111,8 +111,21 @@ struct dirent *readdir(DIR *dir); */ int dirfd(DIR *dirp); -/** \brief Not implemented */ +/** \brief Rewind a directory stream to the start of the directory. + + This function rewinds the directory stream so that the next call to the + readdir() function will return the first entry in the directory. + + \param dir The directory stream to rewind. + + \note Some filesystems do not support this call. Notably, none + of the dcload filesystems support it. Error values will + be returned in errno (so set errno to 0, then check + after calling the function to see if there was a problem + anywhere). +*/ void rewinddir(DIR *dir); + /** \brief Not implemented */ int scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-05 17:49:04
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 86f1d85f492f7981c5ac443b368689f20be0f451 (commit) from 47829c785b649b987a4f6eadedfd9e2500a50fb3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 86f1d85f492f7981c5ac443b368689f20be0f451 Author: Lawrence Sebald <ljs...@us...> Date: Wed Nov 5 12:48:20 2014 -0500 Dern typo. ----------------------------------------------------------------------- Summary of changes: include/threads.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/threads.h b/include/threads.h index d9669c7..51105fd 100644 --- a/include/threads.h +++ b/include/threads.h @@ -171,7 +171,7 @@ extern int mtx_timedlock(mtx_t *restrict mtx, \note This function is safe to call in an interrupt. \note Always check the return value to ensure that the lock was obtained. -*// +*/ extern int mtx_trylock(mtx_t *mtx); /** \brief Unlock a previously acquired lock. hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-05 17:46:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 47829c785b649b987a4f6eadedfd9e2500a50fb3 (commit) via e457937b8111cdc6a33cf1d6780d76601b0add59 (commit) via 6cdc70924ff0b9e5dd74611bf92595351ad521ab (commit) from 41725dd391b0625b72b19e57a4edef3e33457b62 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 47829c785b649b987a4f6eadedfd9e2500a50fb3 Author: Lawrence Sebald <ljs...@us...> Date: Wed Nov 5 12:44:35 2014 -0500 Add in C11 threading support. commit e457937b8111cdc6a33cf1d6780d76601b0add59 Author: Lawrence Sebald <ljs...@us...> Date: Wed Nov 5 12:42:49 2014 -0500 Fix a small typo in a doxygen comment. commit 6cdc70924ff0b9e5dd74611bf92595351ad521ab Author: Lawrence Sebald <ljs...@us...> Date: Mon Nov 3 16:02:17 2014 -0500 Fix stupid spacing in tls.c. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + include/sys/dirent.h | 2 +- include/threads.h | 504 ++++++++++++++++++++ kernel/libc/Makefile | 5 +- kernel/libc/c11/Makefile | 15 + kernel/libc/c11/call_once.c | 11 + kernel/libc/c11/cnd_broadcast.c | 11 + kernel/libc/c11/cnd_destroy.c | 11 + kernel/libc/c11/cnd_init.c | 11 + kernel/libc/c11/cnd_signal.c | 11 + kernel/libc/c11/cnd_timedwait.c | 31 ++ kernel/libc/c11/cnd_wait.c | 11 + kernel/libc/c11/mtx_destroy.c | 11 + kernel/libc/c11/mtx_init.c | 14 + kernel/libc/c11/mtx_lock.c | 11 + kernel/libc/c11/mtx_timedlock.c | 30 ++ kernel/libc/c11/mtx_trylock.c | 19 + kernel/libc/c11/mtx_unlock.c | 11 + kernel/libc/c11/thrd_create.c | 19 + kernel/libc/c11/thrd_current.c | 11 + kernel/libc/c11/thrd_detach.c | 14 + kernel/libc/c11/thrd_equal.c | 11 + kernel/libc/c11/thrd_exit.c | 11 + kernel/libc/c11/thrd_join.c | 17 + .../libc/{koslib/nanosleep.c => c11/thrd_sleep.c} | 27 +- kernel/libc/c11/thrd_yield.c | 11 + kernel/libc/c11/tss_create.c | 11 + kernel/libc/c11/tss_delete.c | 11 + kernel/libc/c11/tss_get.c | 11 + kernel/libc/c11/tss_set.c | 11 + kernel/thread/tls.c | 20 +- 31 files changed, 876 insertions(+), 29 deletions(-) create mode 100644 include/threads.h create mode 100644 kernel/libc/c11/Makefile create mode 100644 kernel/libc/c11/call_once.c create mode 100644 kernel/libc/c11/cnd_broadcast.c create mode 100644 kernel/libc/c11/cnd_destroy.c create mode 100644 kernel/libc/c11/cnd_init.c create mode 100644 kernel/libc/c11/cnd_signal.c create mode 100644 kernel/libc/c11/cnd_timedwait.c create mode 100644 kernel/libc/c11/cnd_wait.c create mode 100644 kernel/libc/c11/mtx_destroy.c create mode 100644 kernel/libc/c11/mtx_init.c create mode 100644 kernel/libc/c11/mtx_lock.c create mode 100644 kernel/libc/c11/mtx_timedlock.c create mode 100644 kernel/libc/c11/mtx_trylock.c create mode 100644 kernel/libc/c11/mtx_unlock.c create mode 100644 kernel/libc/c11/thrd_create.c create mode 100644 kernel/libc/c11/thrd_current.c create mode 100644 kernel/libc/c11/thrd_detach.c create mode 100644 kernel/libc/c11/thrd_equal.c create mode 100644 kernel/libc/c11/thrd_exit.c create mode 100644 kernel/libc/c11/thrd_join.c copy kernel/libc/{koslib/nanosleep.c => c11/thrd_sleep.c} (64%) create mode 100644 kernel/libc/c11/thrd_yield.c create mode 100644 kernel/libc/c11/tss_create.c create mode 100644 kernel/libc/c11/tss_delete.c create mode 100644 kernel/libc/c11/tss_get.c create mode 100644 kernel/libc/c11/tss_set.c diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 176f26f..6ac3262 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -52,6 +52,7 @@ KallistiOS version 2.0.1 ----------------------------------------------- - DC Added an example of the PVR's cheap shadow functionality [LS] - DC Added a tool for generation of bumpmaps that was sent to the mailing list all the way back in 2005 [Fredrik Ehnbom = FE] +- *** Added in C11 threading support [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Dan Potter == DP] diff --git a/include/sys/dirent.h b/include/sys/dirent.h index eb30e79..8733dd1 100644 --- a/include/sys/dirent.h +++ b/include/sys/dirent.h @@ -101,7 +101,7 @@ struct dirent *readdir(DIR *dir); This function retrieves the file descriptor of a directory stream that was previously opened with opendir(). - \param dir The directory stream to retrieve the descriptor of. + \param dirp The directory stream to retrieve the descriptor of. \return The file descriptor from the directory stream on success or -1 on failure (sets errno as appropriate). diff --git a/include/threads.h b/include/threads.h new file mode 100644 index 0000000..d9669c7 --- /dev/null +++ b/include/threads.h @@ -0,0 +1,504 @@ +/* KallistiOS ##version## + + threads.h + Copyright (C) 2014 Lawrence Sebald +*/ + +/** \file threads.h + \brief C11 threading functionality. + + This file contains the definitions needed for using C11 threads. The C11 + standard defines a number of threading-related primitives, which we wrap + neatly around KOS' built-in threading support here. + + If you compile your code with a strict standard set (you use a -std= flag + with GCC that doesn't start with gnu), you must use -std=c11 to use this + functionality. If you don't pass a -std= flag to GCC, then you're probably + fine. + + \author Lawrence Sebald +*/ + +#ifndef __THREADS_H +#define __THREADS_H + +#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) + +#include <sys/cdefs.h> +#include <time.h> + +/* Bring in all the threading-related stuff we'll need. */ +#include <kos/thread.h> +#include <kos/once.h> +#include <kos/mutex.h> +#include <kos/cond.h> +#include <kos/tls.h> + +__BEGIN_DECLS + +/** \defgroup c11_thd_rvs C11 Thread function return values + + Most of the C11 thread-related functions that return a result code return + one of these. + + @{ +*/ +#define thrd_success 0 /**< \brief Success */ +#define thrd_error -1 /**< \brief Uncategorized error */ +#define thrd_timedout -2 /**< \brief Time out error */ +#define thrd_busy -3 /**< \brief Resource busy */ +#define thrd_nomem -4 /**< \brief Out of memory */ +/** @} */ + +/** \brief Object type backing call_once. + + This object type holds a flag that is used by the call_once function to call + a function one time. It should always be initialized with the ONCE_FLAG_INIT + macro. + + \headerfile threads.h +*/ +typedef kthread_once_t once_flag; + +/** \brief Macro to initiallize a once_flag object. */ +#define ONCE_FLAG_INIT KTHREAD_ONCE_INIT + +/** \brief Call a function one time, no matter how many threads try. + + This function uses the once_flag object passed in to ensure that a given + function is called exactly once, regardless of how many threads attempt to + call through the once_flag. + + \param flag The once_flag to run against. + \param func The function to call. +*/ +extern void call_once(once_flag *flag, void (*func)(void)); + +/** \brief C11 mutual exclusion lock type. + + This type holds an identifier for a mutual exclusion (mutex) lock to be used + with C11 threading support. + + \headerfile threads.h +*/ +typedef mutex_t mtx_t; + +/** \defgroup c11_mutex_types C11 mutual exclusion lock types + + These are the possible types of mutex locks that C11 allows for. Note that + mtx_plain or mtx_recursive can be ORed with mtx_timed as well. + + @{ +*/ +#define mtx_plain (1 << 0) /**< \brief Plain mutex */ +#define mtx_recursive (1 << 1) /**< \brief Recursive mutex */ +#define mtx_timed (1 << 2) /**< \brief Mutex supporting the + mtx_timedlock function. */ +/** @} */ + +/** \brief Deinitialize a mutex lock. + + This function deinitializes a mutex lock that was previously created with + mtx_init(). + + \param mtx The mutex to deinitialize. +*/ +extern void mtx_destroy(mtx_t *mtx); + +/** \brief Initialize a mutex lock. + + This function initializes a mutex lock of the given type for later use to + protect critical sections of code. + + \param mtx The mutex to initialize. + \param type The type of mutex desired (see + \ref c11_mutex_types). + \retval thrd_success On success. + \retval thrd_error If the request could not be honored. +*/ +extern int mtx_init(mtx_t *mtx, int type); + +/** \brief Lock a mutex lock. + + This function locks the specified mutex, preventing any other threads from + obtaining the same lock. + + This function will block until the lock can be obtained. + + \param mtx The mutex to lock. + \retval thrd_success On success. + \retval thrd_error If the request could not be honored. + + \note Calling this function in an interrupt will result in an error being + returned. +*/ +extern int mtx_lock(mtx_t *mtx); + +/** \brief Lock a mutex lock with a timeout. + + This function locks the specified mutex, assuming that the lock can be + obtained in the time period specified. + + This function will block until the lock can be obtained or the timeout + expires. + + \param mtx The mutex to lock. + \param ts The amount of time to wait before timing out. + \retval thrd_success On success. + \retval thrd_error If the request could not be honored for some other + reason than a timeout. + \retval thrd_timedout If the timeout specified passes without obtaining + the lock. + + \note Calling this function in an interrupt will result in an error being + returned. + \note Although timeouts are specified in seconds and nanoseconds, the + timeout will be rounded up to the nearest millisecond. +*/ +extern int mtx_timedlock(mtx_t *restrict mtx, + const struct timespec *restrict ts); + +/** \brief Attempt to acquire a mutex lock. + + This function attempts to acquire the specififed mutex and will not block if + it cannot be obtained. + + \param mtx The mutex to lock. + \retval thrd_success On success. + \retval thrd_busy If the lock is already locked by a thread. + \retval thrd_error If the request could not be honored for some other + reason. + + \note This function is safe to call in an interrupt. + \note Always check the return value to ensure that the lock was obtained. +*// +extern int mtx_trylock(mtx_t *mtx); + +/** \brief Unlock a previously acquired lock. + + This function releases the specified mutex lock, allowing other threads to + acquire it. + + \param mtx The mutex to unlock. + \retval thrd_success On success. + \retval thrd_error If the request cannot be honored. + + \note Unlocking a mutex that was not previously locked by the calling + thread results in undefined behavior. +*/ +extern int mtx_unlock(mtx_t *mtx); + +/** \brief C11 condition variable type. + + This type holds an identifier for a condition variable object that is to be + used with C11 threading support. + + \headerfile threads.h +*/ +typedef condvar_t cnd_t; + +/** \brief Broadcast to all threads locked on a condition variable. + + This function wakes all threads that are blocked on the condition variable + cond at the time of the call. If no threads are currently blocked on cond, + this call does nothing. + + \param cond The condition variable to signal. + \retval thrd_success On success. + \retval thrd_error If the request cannot be honored. +*/ +extern int cnd_broadcast(cnd_t *cond); + +/** \brief Deinitialize a condition variable. + + This function cleans up all resources associated with the given condition + variable. You must ensure that no threads are currently blocked on the + condition variable before calling this function. + + \param cond The condition variable to deinitialize. + + \note Deinitializing a condition variable that is currently being waited + on by threads results in undefined behavior. +*/ +extern void cnd_destroy(cnd_t *cond); + +/** \brief Initialize a condition variable. + + This function initializes the specified condition variable for use. + + \param cond The condition variable to signal. + \retval thrd_success On success. + \retval thrd_nomem If memory cannot be allocated for the new condition + variable. + \retval thrd_error If the request cannot be honored for some other + reason. +*/ +extern int cnd_init(cnd_t *cond); + +/** \brief Signal one thread locked on a condition variable. + + This function wakes one thread that is blocked on the condition variable + cond at the time of the call. If no threads are currently blocked on cond, + this call does nothing. + + \param cond The condition variable to signal. + \retval thrd_success On success. + \retval thrd_error If the request cannot be honored. +*/ +extern int cnd_signal(cnd_t *cond); + +/** \brief Wait on a condition variable (with a timeout). + + This function puts the calling thread to sleep until either the condition + variable is signaled or the timeout specified expires, whichever happens + first. The specified mutex must be held by the calling thread when calling + this function and will be held by the thread again when it is unblocked. + + \param cond The condition variable to wait on. + \param mtx The mutex associated with the condition variable. + \param ts The time to wait before timing out. + \retval thrd_success On success. + \retval thrd_timedout If the timeout was reached before the condition + variable was signaled. + \retval thrd_error If the request cannot be honored for some other + reason. + + \note Calling this function in an interrupt will result in an error being + returned. + \note Although timeouts are specified in seconds and nanoseconds, the + timeout will be rounded up to the nearest millisecond. +*/ +extern int cnd_timedwait(cnd_t *restrict cond, mtx_t *restrict mtx, + const struct timespec *restrict ts); + +/** \brief Wait on a condition variable. + + This function puts the calling thread to sleep until the condition variable + is signaled. The specified mutex must be held by the calling thread when + calling this function and will be held by the thread again when it is + unblocked. + + \param cond The condition variable to wait on. + \param mtx The mutex associated with the condition variable. + \retval thrd_success On success. + \retval thrd_error If the request cannot be honored. + + \note Calling this function in an interrupt will result in an error being + returned. +*/ +extern int cnd_wait(cnd_t *cond, mtx_t *mtx); + +/** \brief C11 thread identifier type. + + This type holds an identifier for a C11 thread. + + \headerfile threads.h +*/ +typedef kthread_t *thrd_t; + +/** \brief C11 thread start function type. + + This is a function pointer type representing a function used to begin a + thread. The thread exits when the function returns or calls thrd_exit(). + + \headerfile threads.h +*/ +typedef int (*thrd_start_t)(void *); + +/** \brief Create and start a new thread. + + This function creates a new thread, calling the function specified. The + thread is immediately added to the runnable queue of the scheduler and can + start at any moment after that. The thread ends when either the function + specified returns or when the thread calls thrd_exit(). + + \param thr Storage for the thread identifier. + \param func The function to call in the new thread. + \param arg Argument to pass to the function called. + \retval thrd_success On success. + \retval thrd_nomem If memory cannot be allocated to satisfy the + request. + \retval thrd_error If the request cannot be honored for some other + reason. + + \note All threads created are joinable threads by default. That means that + in order to free all resources at thread termination, the thread + must be joined with the thrd_join() function or detached at some + point with thrd_detach(). +*/ +extern int thrd_create(thrd_t *thr, thrd_start_t func, void *arg); + +/** \brief Return the identifier of the currently running thread. + + \return The current thread's ID. +*/ +extern thrd_t thrd_current(void); + +/** \brief Detach a running thread. + + This function detaches a thread, which informs the kernel that any resources + associated with the thread should be freed immediately when it terminates. + + \param thr The thread to detach. + \retval thrd_success On success. + \retval thrd_error If the request cannot be honored. + + \note Detaching an already detached thread has no effect. + \note Detaching a thread that has been joined with another thread results + in undefined behavior. +*/ +extern int thrd_detach(thrd_t thr); + +/** \brief Compare two threads for equality. + + This function checks the two two thread identifiers passed in to see if they + refer to the same thread. + + \param thr0 The first thread to compare. + \param thr1 The second thread to compare. + \return 0 if the threads are not equal, nonzero if the + threads are equal. +*/ +extern int thrd_equal(thrd_t thr0, thrd_t thr1); + +/** \brief Terminate the current thread immediately. + + This function terminates the calling thread immediately, setting the return + value of the thread to the value specified. + + \param res The return value of the thread. + \note This function will not return. +*/ +extern _Noreturn void thrd_exit(int res); + +/** \brief Join a running thread. + + This function joins the current thread with the specified thread, blocking + until that thread has terminated. + + \param thr The thread to join with. + \param res Pointer to storage for the result code of the other + thread. Set to NULL if you don't care about the + result value. + \retval thrd_success On success. + \retval thrd_error If the request cannot be honored. + + \note Joining with a previously detached thread results in undefined + behavior. + \note Joining with a thread that has already been joined to another thread + results in undefined behavior. + \note Calling this function in an interrupt will result in an error being + returned. +*/ +extern int thrd_join(thrd_t thr, int *res); + +/** \brief Put the currently running thread to sleep. + + This function puts the currently running thread to sleep for the specified + duration of time, returning any left over time (if interrupted by a signal, + for instance) in the second parameter. + + \param duration The amount of time to sleep. + \param remaining Any remaining time from the duration that the thread + did not sleep for. + \return 0 if the requested time elapsed, a negative value + otherwise. + + \note Although the duration is expressed in seconds and nanoseconds, all + sleeping is done in millisecond increments. The value specified will + be rounded up if it is not an even number of milliseconds. + \note KOS does not support signals, so remaining will only ever have a + value after the function if there is some sort of error. + \note Calling this function in an interrupt will result in an error being + returned. +*/ +extern int thrd_sleep(const struct timespec *duration, + struct timespec *remaining); + +/** \brief Yield the current thread's timeslice. + + This function immediately pauses the current thread's execution and switches + to another thread in the ready queue (if there are any threads ready to ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-03 19:42:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 41725dd391b0625b72b19e57a4edef3e33457b62 (commit) from eea75bfaa47996beccc876322697a73c6b86772a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 41725dd391b0625b72b19e57a4edef3e33457b62 Author: Lawrence Sebald <ljs...@us...> Date: Mon Nov 3 14:41:45 2014 -0500 Add an initializer for rewinddir for fs_socket. ----------------------------------------------------------------------- Summary of changes: kernel/fs/fs_socket.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/kernel/fs/fs_socket.c b/kernel/fs/fs_socket.c index ab6929d..5cd254e 100644 --- a/kernel/fs/fs_socket.c +++ b/kernel/fs/fs_socket.c @@ -126,7 +126,8 @@ static vfs_handler_t vh = { NULL, /* seek64 */ NULL, /* tell64 */ NULL, /* total64 */ - NULL /* readlink */ + NULL, /* readlink */ + NULL /* rewinddir */ }; /* Have we been initialized? */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-03 14:49:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via eea75bfaa47996beccc876322697a73c6b86772a (commit) from 96a6132ad5b34d153d537b728869590e26f0a46c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit eea75bfaa47996beccc876322697a73c6b86772a Author: Lawrence Sebald <ljs...@us...> Date: Mon Nov 3 09:48:28 2014 -0500 Add rewinddir(). ----------------------------------------------------------------------- Summary of changes: addons/libkosext2fs/fs_ext2.c | 32 +++++++++++++++++++++++----- include/kos/fs.h | 17 +++++++++++++++ kernel/arch/dreamcast/fs/fs_dcload.c | 3 +- kernel/arch/dreamcast/fs/fs_dclsocket.c | 3 +- kernel/arch/dreamcast/fs/fs_iso9660.c | 19 +++++++++++++++- kernel/arch/dreamcast/fs/fs_vmu.c | 22 +++++++++++++++++++- kernel/fs/fs.c | 24 ++++++++++++++++++++- kernel/fs/fs_pty.c | 21 +++++++++++++++++- kernel/fs/fs_ramdisk.c | 25 +++++++++++++++++++++- kernel/fs/fs_romdisk.c | 34 +++++++++++++++++++++++------- kernel/libc/koslib/rewinddir.c | 17 +++++++++++---- 11 files changed, 187 insertions(+), 30 deletions(-) diff --git a/addons/libkosext2fs/fs_ext2.c b/addons/libkosext2fs/fs_ext2.c index 4c14c72..30733a5 100644 --- a/addons/libkosext2fs/fs_ext2.c +++ b/addons/libkosext2fs/fs_ext2.c @@ -1,7 +1,7 @@ /* KallistiOS ##version## fs_ext2.c - Copyright (C) 2012, 2013 Lawrence Sebald + Copyright (C) 2012, 2013, 2014 Lawrence Sebald */ #include <time.h> @@ -293,7 +293,7 @@ static ssize_t fs_ext2_read(void *h, void *buf, size_t cnt) { mutex_unlock(&ext2_mutex); return -1; } - + if(cnt > bs - bo) { memcpy(bbuf, block + bo, bs - bo); fh[fd].ptr += bs - bo; @@ -614,7 +614,7 @@ retry: errno = EIO; return NULL; } - + /* Fill in the static directory entry. */ fh[fd].dent.size = inode->i_size; memcpy(fh[fd].dent.name, dent->name, dent->name_len); @@ -1071,7 +1071,7 @@ static int fs_ext2_unlink(vfs_handler_t *vfs, const char *fn) { /* And, we're done. Unlock the mutex. */ mutex_unlock(&ext2_mutex); - return 0; + return 0; } static int fs_ext2_mkdir(vfs_handler_t *vfs, const char *fn) { @@ -1430,7 +1430,7 @@ static int fs_ext2_link(vfs_handler_t *vfs, const char *path1, errno = -rv; return -1; } - + /* If the entry we get back is not a directory, then we've got problems. */ if((pinode->i_mode & 0xF000) != EXT2_S_IFDIR) { ext2_inode_put(pinode); @@ -1764,6 +1764,25 @@ int fs_ext2_stat(vfs_handler_t *vfs, const char *path, struct stat *buf, return irv; } +static int fs_ext2_rewinddir(void *h) { + file_t fd = ((file_t)h) - 1; + + mutex_lock(&ext2_mutex); + + /* Check that the fd is valid */ + if(fd >= MAX_EXT2_FILES || !fh[fd].inode_num || !(fh[fd].mode & O_DIR)) { + mutex_unlock(&ext2_mutex); + errno = EBADF; + return -1; + } + + /* Rewind to the beginning of the directory. */ + fh[fd].ptr = 0; + + mutex_unlock(&ext2_mutex); + return 0; +} + /* This is a template that will be used for each mount */ static vfs_handler_t vh = { /* Name Handler */ @@ -1801,7 +1820,8 @@ static vfs_handler_t vh = { fs_ext2_seek64, /* seek64 */ fs_ext2_tell64, /* tell64 */ fs_ext2_total64, /* total64 */ - fs_ext2_readlink /* readlink */ + fs_ext2_readlink, /* readlink */ + fs_ext2_rewinddir /* rewinddir */ }; static int initted = 0; diff --git a/include/kos/fs.h b/include/kos/fs.h index 96129cd..ea9dacf 100644 --- a/include/kos/fs.h +++ b/include/kos/fs.h @@ -190,6 +190,9 @@ typedef struct vfs_handler { possible that realpath() will call this function. */ ssize_t (*readlink)(struct vfs_handler *vfs, const char *path, char *buf, size_t bufsize); + + /** \brief Rewind a directory stream to the start */ + int (*rewinddir)(void *hnd); } vfs_handler_t; /** \brief The number of distinct file descriptors that can be in use at a @@ -543,6 +546,20 @@ ssize_t fs_readlink(const char *path, char *buf, size_t bufsize); */ int fs_stat(const char *path, struct stat *buf, int flag); +/** \brief Rewind a directory to the start. + + This function rewinds the position of a directory stream to the beginning of + the directory. + + \param hnd The opened directory's file descriptor. + \return 0 on success, -1 on failure. + + \note Some filesystems may not support this function. If a + filesystem doesn't support it, errno will be set to + ENOSYS and -1 will be returned. +*/ +int fs_rewinddir(file_t hnd); + /** \brief Duplicate a file descriptor. This function duplicates the specified file descriptor, returning a new file diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c index c7afd94..48cc20a 100644 --- a/kernel/arch/dreamcast/fs/fs_dcload.c +++ b/kernel/arch/dreamcast/fs/fs_dcload.c @@ -460,7 +460,8 @@ static vfs_handler_t vh = { NULL, /* seek64 */ NULL, /* tell64 */ NULL, /* total64 */ - NULL /* readlink */ + NULL, /* readlink */ + NULL /* rewinddir */ }; // We have to provide a minimal interface in case dcload usage is diff --git a/kernel/arch/dreamcast/fs/fs_dclsocket.c b/kernel/arch/dreamcast/fs/fs_dclsocket.c index 28948d1..70d9bb1 100644 --- a/kernel/arch/dreamcast/fs/fs_dclsocket.c +++ b/kernel/arch/dreamcast/fs/fs_dclsocket.c @@ -726,7 +726,8 @@ static vfs_handler_t vh = { NULL, /* seek64 */ NULL, /* tell64 */ NULL, /* total64 */ - NULL /* readlink */ + NULL, /* readlink */ + NULL /* rewinddir */ }; /* dbgio handler */ diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c index cf8b5cd..b8f1de6 100644 --- a/kernel/arch/dreamcast/fs/fs_iso9660.c +++ b/kernel/arch/dreamcast/fs/fs_iso9660.c @@ -4,7 +4,7 @@ Copyright (C) 2000, 2001, 2003 Dan Potter Copyright (C) 2001 Andrew Kieschnick Copyright (C) 2002 Bero - Copyright (C) 2012, 2013 Lawrence Sebald + Copyright (C) 2012, 2013, 2014 Lawrence Sebald */ @@ -900,6 +900,20 @@ static dirent_t *iso_readdir(void * h) { return &fh[fd].dirent; } +static int iso_rewinddir(void * h) { + file_t fd = (file_t)h; + + if(fd >= MAX_ISO_FILES || fh[fd].first_extent == 0 || !fh[fd].dir || + fh[fd].broken) { + errno = EBADF; + return -1; + } + + /* Rewind to the beginning of the directory. */ + fh[fd].ptr = 0; + return 0; +} + int iso_reset() { iso_break_all(); bclear(); @@ -1013,7 +1027,8 @@ static vfs_handler_t vh = { NULL, /* seek64 */ NULL, /* tell64 */ NULL, /* total64 */ - NULL /* readlink */ + NULL, /* readlink */ + iso_rewinddir }; /* Initialize the file system */ diff --git a/kernel/arch/dreamcast/fs/fs_vmu.c b/kernel/arch/dreamcast/fs/fs_vmu.c index 7bd69ff..e49ca9d 100644 --- a/kernel/arch/dreamcast/fs/fs_vmu.c +++ b/kernel/arch/dreamcast/fs/fs_vmu.c @@ -633,6 +633,25 @@ static int vmu_fcntl(void *fd, int cmd, va_list ap) { return rv; } +static int vmu_rewinddir(void * fd) { + vmu_dh_t *dh; + + /* Check the handle */ + if(!vmu_verify_hnd(fd, VMU_DIR)) { + errno = EBADF; + return -1; + } + + /* Rewind to the beginning of the directory. */ + dh = (vmu_dh_t*)fd; + dh->entry = 0; + + /* TODO: Technically, we need to re-scan the directory here, but for now we + will punt on that requirement. */ + + return 0; +} + /* handler interface */ static vfs_handler_t vh = { /* Name handler */ @@ -669,7 +688,8 @@ static vfs_handler_t vh = { NULL, /* seek64 */ NULL, /* tell64 */ NULL, /* total64 */ - NULL /* readlink */ + NULL, /* readlink */ + vmu_rewinddir }; int fs_vmu_init() { diff --git a/kernel/fs/fs.c b/kernel/fs/fs.c index f9216ed..caa3886 100644 --- a/kernel/fs/fs.c +++ b/kernel/fs/fs.c @@ -2,7 +2,7 @@ fs.c Copyright (C) 2000, 2001, 2002, 2003 Dan Potter - Copyright (C) 2012, 2013 Lawrence Sebald + Copyright (C) 2012, 2013, 2014 Lawrence Sebald */ @@ -523,7 +523,6 @@ dirent_t *fs_readdir(file_t fd) { return NULL; } - errno = 0; return h->handler->readdir(h->hnd); } @@ -851,6 +850,27 @@ int fs_stat(const char *path, struct stat *buf, int flag) { } } +int fs_rewinddir(file_t fd) { + fs_hnd_t *h = fs_map_hnd(fd); + + if(!h) { + errno = EBADF; + return -1; + } + + if(h->handler == NULL) { + h->hnd = (void *)0; + return 0; + } + + if(h->handler->rewinddir == NULL) { + errno = ENOSYS; + return -1; + } + + return h->handler->rewinddir(h->hnd); +} + /* Initialize FS structures */ int fs_init() { return 0; diff --git a/kernel/fs/fs_pty.c b/kernel/fs/fs_pty.c index 33d8387..8239d41 100644 --- a/kernel/fs/fs_pty.c +++ b/kernel/fs/fs_pty.c @@ -2,7 +2,7 @@ fs_pty.c Copyright (C) 2003 Dan Potter - Copyright (C) 2012 Lawrence Sebald + Copyright (C) 2012, 2014 Lawrence Sebald */ @@ -639,6 +639,22 @@ static dirent_t * pty_readdir(void * h) { return &dl->dirent; } +static int pty_rewinddir(void *h) { + pipefd_t *fdobj = (pipefd_t *)h; + dirlist_t *dl; + + assert(h); + + if(fdobj->type != PF_DIR) { + errno = EBADF; + return -1; + } + + dl = fdobj->d.d; + dl->ptr = 0; + return 0; +} + static int pty_fcntl(void *h, int cmd, va_list ap) { pipefd_t *fd = (pipefd_t *)h; int rv = -1; @@ -713,7 +729,8 @@ static vfs_handler_t vh = { NULL, NULL, NULL, - NULL + NULL, + pty_rewinddir }; /* Are we initialized? */ diff --git a/kernel/fs/fs_ramdisk.c b/kernel/fs/fs_ramdisk.c index b661c4a..af67bfc 100644 --- a/kernel/fs/fs_ramdisk.c +++ b/kernel/fs/fs_ramdisk.c @@ -2,7 +2,7 @@ fs_ramdisk.c Copyright (C) 2002, 2003 Dan Potter - Copyright (C) 2012, 2013 Lawrence Sebald + Copyright (C) 2012, 2013, 2014 Lawrence Sebald */ @@ -676,6 +676,26 @@ static int ramdisk_fcntl(void *h, int cmd, va_list ap) { return rv; } +static int ramdisk_rewinddir(void * h) { + int rv = 0; + file_t fd = (file_t)h; + + mutex_lock(&rd_mutex); + + if(fd >= MAX_RAM_FILES || !fh[fd].file || !fh[fd].dir) { + errno = EBADF; + rv = -1; + } + else { + /* Rewind to the first file. */ + fh[fd].ptr = (uint32)LIST_FIRST((rd_dir_t *)fh[fd].file->data); + } + + mutex_unlock(&rd_mutex); + + return rv; +} + /* Put everything together */ static vfs_handler_t vh = { /* Name handler */ @@ -713,7 +733,8 @@ static vfs_handler_t vh = { NULL, /* seek64 XXX */ NULL, /* tell64 XXX */ NULL, /* total64 XXX */ - NULL /* readlink XXX */ + NULL, /* readlink XXX */ + ramdisk_rewinddir }; /* Attach a piece of memory to a file. This works somewhat like open for diff --git a/kernel/fs/fs_romdisk.c b/kernel/fs/fs_romdisk.c index 7acbc4b..5eeaed8 100644 --- a/kernel/fs/fs_romdisk.c +++ b/kernel/fs/fs_romdisk.c @@ -2,7 +2,7 @@ fs_romdisk.c Copyright (C) 2001, 2002, 2003 Dan Potter - Copyright (C) 2012, 2013 Lawrence Sebald + Copyright (C) 2012, 2013, 2014 Lawrence Sebald */ @@ -349,15 +349,20 @@ static size_t romdisk_total(void * h) { /* Read a directory entry */ static dirent_t *romdisk_readdir(void * h) { - romdisk_file_t *fhdr; - int type; - file_t fd = (file_t)h; + romdisk_file_t *fhdr; + int type; + file_t fd = (file_t)h; if(fd >= MAX_RD_FILES || fh[fd].index == 0 || !fh[fd].dir) { errno = EBADF; return NULL; } + /* This happens if we hit the end of the directory on advancing the pointer + last time through. */ + if(fh[fd].ptr == (uint32)-1) + return NULL; + /* Get the current file header */ fhdr = (romdisk_file_t *)(fh[fd].mnt->image + fh[fd].index + fh[fd].ptr); @@ -366,10 +371,10 @@ static dirent_t *romdisk_readdir(void * h) { type = fh[fd].ptr & 0x0f; fh[fd].ptr = fh[fd].ptr & 0xfffffff0; - if(fh[fd].ptr == 0) - fh[fd].index = 0; - else + if(fh[fd].ptr != 0) fh[fd].ptr = fh[fd].ptr - fh[fd].index; + else + fh[fd].ptr = (uint32)-1; /* Copy out the requested data */ strcpy(fh[fd].dirent.name, fhdr->filename); @@ -432,6 +437,18 @@ static int romdisk_fcntl(void *h, int cmd, va_list ap) { return rv; } +static int romdisk_rewinddir(void *h) { + file_t fd = (file_t)h; + + if(fd >= MAX_RD_FILES || fh[fd].index == 0 || !fh[fd].dir) { + errno = EBADF; + return -1; + } + + fh[fd].ptr = 0; + return 0; +} + /* This is a template that will be used for each mount */ static vfs_handler_t vh = { /* Name Handler */ @@ -469,7 +486,8 @@ static vfs_handler_t vh = { NULL, /* seek64 */ NULL, /* tell64 */ NULL, /* total64 */ - NULL /* readlink */ + NULL, /* readlink */ + romdisk_rewinddir }; /* Are we initialized? */ diff --git a/kernel/libc/koslib/rewinddir.c b/kernel/libc/koslib/rewinddir.c index f30a5fa..3fa37c9 100644 --- a/kernel/libc/koslib/rewinddir.c +++ b/kernel/libc/koslib/rewinddir.c @@ -1,13 +1,20 @@ /* KallistiOS ##version## rewinddir.c - Copyright (C)2004 Dan Potter + Copyright (C) 2004 Dan Potter + Copyright (C) 2014 Lawrence Sebald */ -#include <kos/dbglog.h> +#include <dirent.h> +#include <errno.h> +#include <kos/fs.h> -// This isn't properly prototyped... sosume :) -void rewinddir() { - dbglog(DBG_WARNING, "rewinddir: call ignored\n"); +void rewinddir(DIR *dirp) { + if(!dirp) { + errno = EBADF; + return; + } + + (void)fs_rewinddir(dirp->fd); } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-02 22:39:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 96a6132ad5b34d153d537b728869590e26f0a46c (commit) from 01673bc1b128f488c270634fba840bf374c509ff (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 96a6132ad5b34d153d537b728869590e26f0a46c Author: Lawrence Sebald <ljs...@us...> Date: Sun Nov 2 17:39:04 2014 -0500 We need to define _POSIX_TIMERS to get the prototype for nanosleep in <time.h>. ----------------------------------------------------------------------- Summary of changes: include/sys/_pthread.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/include/sys/_pthread.h b/include/sys/_pthread.h index a53bdd2..aa9ae36 100644 --- a/include/sys/_pthread.h +++ b/include/sys/_pthread.h @@ -14,4 +14,7 @@ /** \brief POSIX timeouts supported (sorta) */ #define _POSIX_TIMEOUTS +/** \brief POSIX timers supported (not really) */ +#define _POSIX_TIMERS + #endif /* __SYS__PTHREAD_H */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-11-02 22:04:36
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 01673bc1b128f488c270634fba840bf374c509ff (commit) from c76fe23bde52c921874079ec06bb12ea862806d7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 01673bc1b128f488c270634fba840bf374c509ff Author: Lawrence Sebald <ljs...@us...> Date: Sun Nov 2 17:04:03 2014 -0500 Add nanosleep. ----------------------------------------------------------------------- Summary of changes: kernel/libc/koslib/Makefile | 4 +- kernel/libc/koslib/nanosleep.c | 53 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 kernel/libc/koslib/nanosleep.c diff --git a/kernel/libc/koslib/Makefile b/kernel/libc/koslib/Makefile index edb1aa1..d7c9878 100644 --- a/kernel/libc/koslib/Makefile +++ b/kernel/libc/koslib/Makefile @@ -1,7 +1,7 @@ # KallistiOS ##version## # # kernel/libc/koslib/Makefile -# Copyright (C)2004 Dan Potter +# Copyright (C) 2004 Dan Potter # # In here we have pieces of the KOS libc that are either too custom or too @@ -13,6 +13,6 @@ OBJS = abort.o byteorder.o memset2.o memset4.o memcpy2.o memcpy4.o \ telldir.o usleep.o inet_addr.o realpath.o getcwd.o chdir.o mkdir.o \ creat.o sleep.o rmdir.o rename.o inet_pton.o inet_ntop.o \ inet_ntoa.o inet_aton.o poll.o select.o symlink.o readlink.o \ - gethostbyname.o getaddrinfo.o dirfd.o + gethostbyname.o getaddrinfo.o dirfd.o nanosleep.o include $(KOS_BASE)/Makefile.prefab diff --git a/kernel/libc/koslib/nanosleep.c b/kernel/libc/koslib/nanosleep.c new file mode 100644 index 0000000..969ac96 --- /dev/null +++ b/kernel/libc/koslib/nanosleep.c @@ -0,0 +1,53 @@ +/* KallistiOS ##version## + + nanosleep.c + Copyright (C) 2014 Lawrence Sebald + +*/ + +#include <time.h> +#include <errno.h> +#include <kos/thread.h> + +int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) { + int ms; + + /* Make sure we aren't inside an interrupt first... */ + if(irq_inside_int()) { + if(rmtp) + *rmtp = *rqtp; + + errno = EINTR; /* XXXX: Sorta. */ + return -1; + } + + /* Calculate the number of milliseconds to sleep for. No, you don't get + anywhere near nanosecond precision here. */ + ms = rqtp->tv_sec * 1000 + rqtp->tv_nsec / 1000000; + + /* We need to sleep for *at least* how long is specified, so if they've + given us a non-whole number of milliseconds, then add one to the time. */ + if(rqtp->tv_nsec % 1000000) + ++ms; + + /* Make sure they gave us something valid. */ + if(ms < 0) { + if(rmtp) + *rmtp = *rqtp; + + errno = EINVAL; + return -1; + } + + /* Sleep! */ + thd_sleep(ms); + + /* thd_sleep will always sleep for at least the specified time, so clear out + the remaining time, if it was given to us. */ + if(rmtp) { + rmtp->tv_sec = 0; + rmtp->tv_nsec = 0; + } + + return 0; +} hooks/post-receive -- A pseudo Operating System for the Dreamcast. |