Giter VIP home page Giter VIP logo

kcpp's Introduction

kcpp

version: 0.0.1

description: C++ framework for the linux kernel

website: https://veltzer.github.io/kcpp

Build

build

Contact

chat with me at gitter

POC for writing C++ modules for the Linux kernel

C++ has lots of issues which are not dealt with in the kernel.

  • Problems in linking.

  • Exception handling that needs to be turned off.

  • Memory management functions (like new and delete) which need to be implemented.

  • The kernel headers are not suitable for inclusion for a C++ compiler since they conflict with many C++ constructs ('class' for instance and more).

  • The kernel build system does not compile C++ correctly, or even at all.

  • separate the "top part" - the one that is getting called by Linux, like driver entry and exit points, interrupt functions, tasklets, whatever and handle them in a C layer. expose APIs for all of these facilities and other low level facilities (printk, hardware access and more) via C functions.

  • write a top part that only accesses these services by well controlled C functions which do not include the kernel headers and are C++ friendly. In the top part write a framework for device driver writing based on OO concepts (inherit from Device and implement the relevant methods).

  • Add ability to include header files directly in C++ code. Progress: have 'copy_headers' target in makefile which also applies patch but headers are still hard to work with... This is to be developed as a patch to the linux kernel (big project - watch out! may never happen...)

  • add a framework for writing char drivers

  • http://code.google.com/p/kernelcpp/ They do not have a buffer layer but instead do "extern C" before kernel headers. Try to see if this works for a big example. They have all kinds of other ideas about constructors for global object and so on.

  • http://www.drdobbs.com/cpp/c-exceptions-the-linux-kernel/229100146

Mark Veltzer, Copyright © 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024

kcpp's People

Contributors

veltzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kcpp's Issues

Kernel 6.6.14 - KBuild trying to access cpp module *.o.cmd file ?

Hi,

I wonder if you know how to work around the problem shown below. I've been compiling a module with .cpp source using your general system for a while now, The last time I did it was on the 5.15.x kernels. Along the way there had to be some fix ups for process_flags.py and a patch to Makedisk.build to link in .a modules (path won't apply to 6.6.x, I'm not sure if I'll have to find another one or it will work, they changed it quite a bit).

Anyway, with 6.6.x I had to update process_flags.py, so I just updated to your latest, but I had to modify it a bit because I couldn't get any of the uint32_t, uint64_t, etc.. types to work even though linux/types.h was included. I redid the way the -D was before, removing then adding one for LINUX_MODULE, and now it works okay, I presume that was the change needed. Anyway, now I'm at this point:

LD [M]  /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/mymodule.o
  ld -m elf_i386 -z noexecstack   -r -o /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/mymodule.o @/media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/mymodule.mod 
# cmd_modules_order /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/modules.order
  {   echo /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/mymodule.o; :; } > /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/modules.order
sh ./scripts/modules-check.sh /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/modules.order
make -f ./scripts/Makefile.modpost
# MODPOST /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/Module.symvers
   scripts/mod/modpost -M -m       -o /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/Module.symvers -T /media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/modules.order -i Module.symvers -e 
/media/sf_SRC_DRIVE/mymodule/linux/driver/6.6.14-686-mine/.mymodulelindrivercpp.o.cmd: No such file or directory

The .cpp source module is the one with cpp in the name. It's looking for .mymodulelindrivercpp.o.cmd which it never has in the past. It's never built one and still doesn't build one, but now it's looking for it.

Is there something that needs patched or changed for the 6.6.x kernels?

Thanks!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.