Skip to content

Commit

Permalink
Merge pull request #20 from kendryte/develop
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
sunnycase authored Oct 12, 2018
2 parents b071dc0 + d108a18 commit 9c7b0e0
Show file tree
Hide file tree
Showing 82 changed files with 4,936 additions and 4,469 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cmake_minimum_required(VERSION 3.0)
include(./cmake/common.cmake)
project(${PROJ})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/lib/arch/include ${CMAKE_CURRENT_LIST_DIR}/lib/utils/include)
# config self use headers
header_directories(${SDK_ROOT}/lib)
# build library first
Expand Down
4 changes: 2 additions & 2 deletions cmake/executable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (NOT BUILDING_SDK)
set_property(TARGET kendryte PROPERTY IMPORTED_LOCATION ${SDK_ROOT}/libkendryte.a)
else()
### source code sdk
header_directories(${SDK_ROOT}/lib)
include_directories(${SDK_ROOT}/lib/arch/include ${SDK_ROOT}/lib/utils/include)
add_subdirectory(${SDK_ROOT}/lib SDK)
endif()
endif ()
Expand All @@ -23,7 +23,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE C)

target_link_libraries(${PROJECT_NAME}
-Wl,--start-group
m kendryte
m freertos bsp
-Wl,--end-group
)

Expand Down
10 changes: 1 addition & 9 deletions cmake/macros.internal.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# Add lib headers
macro(header_directories parent)
file(GLOB_RECURSE newList ${parent}/*.h)
set(dir_list "")
foreach (file_path ${newList})
get_filename_component(dir_path ${file_path} DIRECTORY)
set(dir_list ${dir_list} ${dir_path})
endforeach ()
list(REMOVE_DUPLICATES dir_list)

include_directories(${dir_list})
include_directories(${parent})
endmacro()
10 changes: 9 additions & 1 deletion lds/kendryte.ld
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ SECTIONS
KEEP (*(.dtors))
} > ram : DATA

. = ALIGN(64);
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
Expand All @@ -149,6 +150,7 @@ SECTIONS
} > ram : DATA
_edata = .; PROVIDE (edata = .);

. = .;
__bss_start = .;
.sbss :
{
Expand All @@ -161,6 +163,12 @@ SECTIONS
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 64 / 8 : 1);
} > ram : DYN_DATA
__bss_end = .;

Expand Down Expand Up @@ -198,7 +206,7 @@ SECTIONS
* Align _heap_start to cache line size
*/
. = ALIGN(64);
PROVIDE( _end = ABSOLUTE(.) );
_end = .; PROVIDE( _end = ABSOLUTE(.) );
/* Leave 2 holes for stack & TLS, the size can set in kconfig */
PROVIDE( _heap_start = ABSOLUTE(.) + _stack_size * 5 );
PROVIDE( _tp0 = (_end + 63) & (-64) );
Expand Down
48 changes: 4 additions & 44 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
#project(kendryte_drivers)
#project(kendryte)

# create driver library
FILE(GLOB_RECURSE LIB_SRC_NOASM
"${CMAKE_CURRENT_LIST_DIR}/*.h"
"${CMAKE_CURRENT_LIST_DIR}/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/*.c"
)

FILE(GLOB_RECURSE ASSEMBLY_FILES
"${CMAKE_CURRENT_LIST_DIR}/*.s"
"${CMAKE_CURRENT_LIST_DIR}/*.S"
)
SET(LIB_SRC ${LIB_SRC_NOASM} ${ASSEMBLY_FILES})

include_directories(${CMAKE_CURRENT_LIST_DIR}/drivers/include ${CMAKE_CURRENT_LIST_DIR}/bsp/include)
#
#HEADER_DIRECTORIES(LIB_HEADERS)
#
#INCLUDE_DIRECTORIES(${LIB_HEADERS})

SET_PROPERTY(SOURCE ${ASSEMBLY_FILES} PROPERTY LANGUAGE C)
SET_SOURCE_FILES_PROPERTIES(${ASSEMBLY_FILES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp -D __riscv64")

#MESSAGE("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")

ADD_LIBRARY(kendryte STATIC ${LIB_SRC})
SET_TARGET_PROPERTIES(kendryte PROPERTIES LINKER_LANGUAGE C)

# find headers files to INSTALL
file(GLOB_RECURSE LIB_HEADERS
"../lib/*.h"
"../lib/*.hpp"
)

set_target_properties(kendryte PROPERTIES PUBLIC_HEADER "${LIB_HEADERS}")

# copy .a file and headers
install(TARGETS kendryte
EXPORT kendryte
ARCHIVE
DESTINATION ${CMAKE_BINARY_DIR}/archive
PUBLIC_HEADER DESTINATION ${CMAKE_BINARY_DIR}/archive/include
)
ADD_SUBDIRECTORY(drivers)
ADD_SUBDIRECTORY(freertos)
ADD_SUBDIRECTORY(bsp)
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/bsp/include/encoding.h → lib/arch/include/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RISCV_CSR_ENCODING_H
#define RISCV_CSR_ENCODING_H
#ifndef _RISCV_CSR_ENCODING_H
#define _RISCV_CSR_ENCODING_H

#define MSTATUS_UIE 0x00000001
#define MSTATUS_SIE 0x00000002
Expand Down
60 changes: 60 additions & 0 deletions lib/arch/include/pin_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* Copyright 2018 Canaan Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _PIN_CFG_H
#define _PIN_CFG_H

#include <platform.h>
#include <stdbool.h>
#include <stdint.h>

#define PIN_CFG_VERSION 1

typedef struct _fpioa_cfg_item
{
int number;
fpioa_function_t function;
} fpioa_cfg_item_t;

typedef struct _fpioa_cfg
{
uint32_t version;
uint32_t functions_count;
fpioa_cfg_item_t functions[];
} fpioa_cfg_t;

typedef struct _power_bank_item
{
sysctl_power_bank_t power_bank;
sysctl_io_power_mode_t io_power_mode;
} power_bank_item_t;

typedef struct _power_bank_cfg
{
uint32_t version;
uint32_t power_banks_count;
power_bank_item_t power_banks[];
} power_bank_cfg_t;

typedef struct _pin_cfg
{
uint32_t version;
bool set_spi0_dvp_data;
} pin_cfg_t;

extern const fpioa_cfg_t g_fpioa_cfg;
extern const power_bank_cfg_t g_power_bank_cfg;
extern const pin_cfg_t g_pin_cfg;

#endif
Loading

0 comments on commit 9c7b0e0

Please sign in to comment.