Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Adding vsprintf to kernel source

jerrinsg edited this page Apr 18, 2012 · 3 revisions
  1. Obtain Linux Kernel 0.10 source from link
  2. Extract source and find vsprintf source at linux-0.10/kernel/vsprintf.c
  3. Requires header file stdarg.h. Find header file at linux-0.10/include/stdarg.h. Create a copy in the source directory of our 32 bit kernel.
  4. vsprintf requires implementation of string manipulative functions. Find strlen() function implementation at link under the section 'Improving pipeline effect'
  5. Add implementation of strlen() to file common.c . Add prototype to common.h
  6. Copy necessary function implementations [int vsprintf(char *buf, const char *fmt, va_list args)] [static char * number(char * str, int num, int base, int size, int precision ,int type)] [static int skip_atoi(const char **s)] and #define tags from vsprintf.c into the source file monitor.c. Remember to include "stdarg.h" in monitor.c
  7. Function prototype for vsprintf and other functions need not be added in monitor.h. Do not include "stdarg.h" in any other header/source files.
  8. To test vsprintf, refer source at link
  9. Source help :
    • Add "stdarg.h" to main.c
    • Give defintion for vout function exactly as given (including third argument ... ! )
    • vout copies the string with the given format into the argument 'string'
    • use monitor_write to print string.
    • supported formats are %s %d , rest to be explored!
Clone this wiki locally